documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589
  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. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  1871. /** viewport left coordinate */
  1872. x: number,
  1873. /** viewport top coordinate */
  1874. y: number,
  1875. /**viewport width */
  1876. width: number,
  1877. /** viewport height */
  1878. height: number);
  1879. /**
  1880. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Class representing a vector containing 2 coordinates
  1918. */
  1919. export class Vector2 {
  1920. /** defines the first coordinate */
  1921. x: number;
  1922. /** defines the second coordinate */
  1923. y: number;
  1924. /**
  1925. * Creates a new Vector2 from the given x and y coordinates
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. */
  1929. constructor(
  1930. /** defines the first coordinate */
  1931. x?: number,
  1932. /** defines the second coordinate */
  1933. y?: number);
  1934. /**
  1935. * Gets a string with the Vector2 coordinates
  1936. * @returns a string with the Vector2 coordinates
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Gets class name
  1941. * @returns the string "Vector2"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Gets current vector hash code
  1946. * @returns the Vector2 hash code as a number
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1951. * @param array defines the source array
  1952. * @param index defines the offset in source array
  1953. * @returns the current Vector2
  1954. */
  1955. toArray(array: FloatArray, index?: number): Vector2;
  1956. /**
  1957. * Copy the current vector to an array
  1958. * @returns a new array with 2 elements: the Vector2 coordinates.
  1959. */
  1960. asArray(): number[];
  1961. /**
  1962. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1963. * @param source defines the source Vector2
  1964. * @returns the current updated Vector2
  1965. */
  1966. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1967. /**
  1968. * Sets the Vector2 coordinates with the given floats
  1969. * @param x defines the first coordinate
  1970. * @param y defines the second coordinate
  1971. * @returns the current updated Vector2
  1972. */
  1973. copyFromFloats(x: number, y: number): Vector2;
  1974. /**
  1975. * Sets the Vector2 coordinates with the given floats
  1976. * @param x defines the first coordinate
  1977. * @param y defines the second coordinate
  1978. * @returns the current updated Vector2
  1979. */
  1980. set(x: number, y: number): Vector2;
  1981. /**
  1982. * Add another vector with the current one
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1985. */
  1986. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2
  2004. */
  2005. addVector3(otherVector: Vector3): Vector2;
  2006. /**
  2007. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. subtract(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Multiplies in place the current Vector2 coordinates by the given ones
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2033. * @param otherVector defines the other vector
  2034. * @returns a new Vector2
  2035. */
  2036. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @param result defines the target vector
  2041. * @returns the unmodified current Vector2
  2042. */
  2043. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2044. /**
  2045. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2046. * @param x defines the first coordinate
  2047. * @param y defines the second coordinate
  2048. * @returns a new Vector2
  2049. */
  2050. multiplyByFloats(x: number, y: number): Vector2;
  2051. /**
  2052. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2053. * @param otherVector defines the other vector
  2054. * @returns a new Vector2
  2055. */
  2056. divide(otherVector: Vector2): Vector2;
  2057. /**
  2058. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @param result defines the target vector
  2061. * @returns the unmodified current Vector2
  2062. */
  2063. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2064. /**
  2065. * Divides the current Vector2 coordinates by the given ones
  2066. * @param otherVector defines the other vector
  2067. * @returns the current updated Vector2
  2068. */
  2069. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2070. /**
  2071. * Gets a new Vector2 with current Vector2 negated coordinates
  2072. * @returns a new Vector2
  2073. */
  2074. negate(): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * 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".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Multiplies the Vector3 coordinates by the float "scale"
  2428. * @param scale defines the multiplier factor
  2429. * @returns the current updated Vector3
  2430. */
  2431. scaleInPlace(scale: number): Vector3;
  2432. /**
  2433. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2434. * @param scale defines the multiplier factor
  2435. * @returns a new Vector3
  2436. */
  2437. scale(scale: number): Vector3;
  2438. /**
  2439. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2440. * @param scale defines the multiplier factor
  2441. * @param result defines the Vector3 object where to store the result
  2442. * @returns the current Vector3
  2443. */
  2444. scaleToRef(scale: number, result: Vector3): Vector3;
  2445. /**
  2446. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2447. * @param scale defines the scale factor
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the unmodified current Vector3
  2450. */
  2451. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2452. /**
  2453. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2454. * @param otherVector defines the second operand
  2455. * @returns true if both vectors are equals
  2456. */
  2457. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2458. /**
  2459. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2460. * @param otherVector defines the second operand
  2461. * @param epsilon defines the minimal distance to define values as equals
  2462. * @returns true if both vectors are distant less than epsilon
  2463. */
  2464. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2465. /**
  2466. * Returns true if the current Vector3 coordinates equals the given floats
  2467. * @param x defines the x coordinate of the operand
  2468. * @param y defines the y coordinate of the operand
  2469. * @param z defines the z coordinate of the operand
  2470. * @returns true if both vectors are equals
  2471. */
  2472. equalsToFloats(x: number, y: number, z: number): boolean;
  2473. /**
  2474. * Multiplies the current Vector3 coordinates by the given ones
  2475. * @param otherVector defines the second operand
  2476. * @returns the current updated Vector3
  2477. */
  2478. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2479. /**
  2480. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2481. * @param otherVector defines the second operand
  2482. * @returns the new Vector3
  2483. */
  2484. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2485. /**
  2486. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2487. * @param otherVector defines the second operand
  2488. * @param result defines the Vector3 object where to store the result
  2489. * @returns the current Vector3
  2490. */
  2491. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2492. /**
  2493. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2494. * @param x defines the x coordinate of the operand
  2495. * @param y defines the y coordinate of the operand
  2496. * @param z defines the z coordinate of the operand
  2497. * @returns the new Vector3
  2498. */
  2499. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2500. /**
  2501. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2502. * @param otherVector defines the second operand
  2503. * @returns the new Vector3
  2504. */
  2505. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2508. * @param otherVector defines the second operand
  2509. * @param result defines the Vector3 object where to store the result
  2510. * @returns the current Vector3
  2511. */
  2512. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2513. /**
  2514. * Divides the current Vector3 coordinates by the given ones.
  2515. * @param otherVector defines the second operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. divideInPlace(otherVector: Vector3): Vector3;
  2519. /**
  2520. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2521. * @param other defines the second operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2527. * @param other defines the second operand
  2528. * @returns the current updated Vector3
  2529. */
  2530. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2531. /**
  2532. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2533. * @param x defines the x coordinate of the operand
  2534. * @param y defines the y coordinate of the operand
  2535. * @param z defines the z coordinate of the operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2539. /**
  2540. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2541. * @param x defines the x coordinate of the operand
  2542. * @param y defines the y coordinate of the operand
  2543. * @param z defines the z coordinate of the operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2547. /**
  2548. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2549. * Check if is non uniform within a certain amount of decimal places to account for this
  2550. * @param epsilon the amount the values can differ
  2551. * @returns if the the vector is non uniform to a certain number of decimal places
  2552. */
  2553. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2554. /**
  2555. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2556. */
  2557. get isNonUniform(): boolean;
  2558. /**
  2559. * Gets a new Vector3 from current Vector3 floored values
  2560. * @returns a new Vector3
  2561. */
  2562. floor(): Vector3;
  2563. /**
  2564. * Gets a new Vector3 from current Vector3 floored values
  2565. * @returns a new Vector3
  2566. */
  2567. fract(): Vector3;
  2568. /**
  2569. * Gets the length of the Vector3
  2570. * @returns the length of the Vector3
  2571. */
  2572. length(): number;
  2573. /**
  2574. * Gets the squared length of the Vector3
  2575. * @returns squared length of the Vector3
  2576. */
  2577. lengthSquared(): number;
  2578. /**
  2579. * Normalize the current Vector3.
  2580. * Please note that this is an in place operation.
  2581. * @returns the current updated Vector3
  2582. */
  2583. normalize(): Vector3;
  2584. /**
  2585. * Reorders the x y z properties of the vector in place
  2586. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2587. * @returns the current updated vector
  2588. */
  2589. reorderInPlace(order: string): this;
  2590. /**
  2591. * Rotates the vector around 0,0,0 by a quaternion
  2592. * @param quaternion the rotation quaternion
  2593. * @param result vector to store the result
  2594. * @returns the resulting vector
  2595. */
  2596. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2597. /**
  2598. * Rotates a vector around a given point
  2599. * @param quaternion the rotation quaternion
  2600. * @param point the point to rotate around
  2601. * @param result vector to store the result
  2602. * @returns the resulting vector
  2603. */
  2604. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2605. /**
  2606. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2607. * The cross product is then orthogonal to both current and "other"
  2608. * @param other defines the right operand
  2609. * @returns the cross product
  2610. */
  2611. cross(other: Vector3): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 with the given input length.
  2614. * Please note that this is an in place operation.
  2615. * @param len the length of the vector
  2616. * @returns the current updated Vector3
  2617. */
  2618. normalizeFromLength(len: number): Vector3;
  2619. /**
  2620. * Normalize the current Vector3 to a new vector
  2621. * @returns the new Vector3
  2622. */
  2623. normalizeToNew(): Vector3;
  2624. /**
  2625. * Normalize the current Vector3 to the reference
  2626. * @param reference define the Vector3 to update
  2627. * @returns the updated Vector3
  2628. */
  2629. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2630. /**
  2631. * Creates a new Vector3 copied from the current Vector3
  2632. * @returns the new Vector3
  2633. */
  2634. clone(): Vector3;
  2635. /**
  2636. * Copies the given vector coordinates to the current Vector3 ones
  2637. * @param source defines the source Vector3
  2638. * @returns the current updated Vector3
  2639. */
  2640. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Copies the given floats to the current Vector3 coordinates
  2643. * @param x defines the x coordinate of the operand
  2644. * @param y defines the y coordinate of the operand
  2645. * @param z defines the z coordinate of the operand
  2646. * @returns the current updated Vector3
  2647. */
  2648. copyFromFloats(x: number, y: number, z: number): Vector3;
  2649. /**
  2650. * Copies the given floats to the current Vector3 coordinates
  2651. * @param x defines the x coordinate of the operand
  2652. * @param y defines the y coordinate of the operand
  2653. * @param z defines the z coordinate of the operand
  2654. * @returns the current updated Vector3
  2655. */
  2656. set(x: number, y: number, z: number): Vector3;
  2657. /**
  2658. * Copies the given float to the current Vector3 coordinates
  2659. * @param v defines the x, y and z coordinates of the operand
  2660. * @returns the current updated Vector3
  2661. */
  2662. setAll(v: number): Vector3;
  2663. /**
  2664. * Get the clip factor between two vectors
  2665. * @param vector0 defines the first operand
  2666. * @param vector1 defines the second operand
  2667. * @param axis defines the axis to use
  2668. * @param size defines the size along the axis
  2669. * @returns the clip factor
  2670. */
  2671. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2672. /**
  2673. * Get angle between two vectors
  2674. * @param vector0 angle between vector0 and vector1
  2675. * @param vector1 angle between vector0 and vector1
  2676. * @param normal direction of the normal
  2677. * @return the angle between vector0 and vector1
  2678. */
  2679. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2680. /**
  2681. * Returns a new Vector3 set from the index "offset" of the given array
  2682. * @param array defines the source array
  2683. * @param offset defines the offset in the source array
  2684. * @returns the new Vector3
  2685. */
  2686. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2687. /**
  2688. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2689. * @param array defines the source array
  2690. * @param offset defines the offset in the source array
  2691. * @returns the new Vector3
  2692. * @deprecated Please use FromArray instead.
  2693. */
  2694. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2695. /**
  2696. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @param result defines the Vector3 where to store the result
  2700. */
  2701. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2702. /**
  2703. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2704. * @param array defines the source array
  2705. * @param offset defines the offset in the source array
  2706. * @param result defines the Vector3 where to store the result
  2707. * @deprecated Please use FromArrayToRef instead.
  2708. */
  2709. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2710. /**
  2711. * Sets the given vector "result" with the given floats.
  2712. * @param x defines the x coordinate of the source
  2713. * @param y defines the y coordinate of the source
  2714. * @param z defines the z coordinate of the source
  2715. * @param result defines the Vector3 where to store the result
  2716. */
  2717. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2718. /**
  2719. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2720. * @returns a new empty Vector3
  2721. */
  2722. static Zero(): Vector3;
  2723. /**
  2724. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2725. * @returns a new unit Vector3
  2726. */
  2727. static One(): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2730. * @returns a new up Vector3
  2731. */
  2732. static Up(): Vector3;
  2733. /**
  2734. * Gets a up Vector3 that must not be updated
  2735. */
  2736. static get UpReadOnly(): DeepImmutable<Vector3>;
  2737. /**
  2738. * Gets a zero Vector3 that must not be updated
  2739. */
  2740. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2743. * @returns a new down Vector3
  2744. */
  2745. static Down(): Vector3;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2748. * @returns a new forward Vector3
  2749. */
  2750. static Forward(): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2753. * @returns a new forward Vector3
  2754. */
  2755. static Backward(): Vector3;
  2756. /**
  2757. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2758. * @returns a new right Vector3
  2759. */
  2760. static Right(): Vector3;
  2761. /**
  2762. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2763. * @returns a new left Vector3
  2764. */
  2765. static Left(): Vector3;
  2766. /**
  2767. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2768. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2769. * @param vector defines the Vector3 to transform
  2770. * @param transformation defines the transformation matrix
  2771. * @returns the transformed Vector3
  2772. */
  2773. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2774. /**
  2775. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2776. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2777. * @param vector defines the Vector3 to transform
  2778. * @param transformation defines the transformation matrix
  2779. * @param result defines the Vector3 where to store the result
  2780. */
  2781. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2782. /**
  2783. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2784. * This method computes tranformed coordinates only, not transformed direction vectors
  2785. * @param x define the x coordinate of the source vector
  2786. * @param y define the y coordinate of the source vector
  2787. * @param z define the z coordinate of the source vector
  2788. * @param transformation defines the transformation matrix
  2789. * @param result defines the Vector3 where to store the result
  2790. */
  2791. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2794. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the new Vector3
  2798. */
  2799. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2802. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2820. * @param value1 defines the first control point
  2821. * @param value2 defines the second control point
  2822. * @param value3 defines the third control point
  2823. * @param value4 defines the fourth control point
  2824. * @param amount defines the amount on the spline to use
  2825. * @returns the new Vector3
  2826. */
  2827. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2828. /**
  2829. * 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"
  2830. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2831. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2832. * @param value defines the current value
  2833. * @param min defines the lower range value
  2834. * @param max defines the upper range value
  2835. * @returns the new Vector3
  2836. */
  2837. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2838. /**
  2839. * 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"
  2840. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2841. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2842. * @param value defines the current value
  2843. * @param min defines the lower range value
  2844. * @param max defines the upper range value
  2845. * @param result defines the Vector3 where to store the result
  2846. */
  2847. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2848. /**
  2849. * Checks if a given vector is inside a specific range
  2850. * @param v defines the vector to test
  2851. * @param min defines the minimum range
  2852. * @param max defines the maximum range
  2853. */
  2854. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2857. * @param value1 defines the first control point
  2858. * @param tangent1 defines the first tangent vector
  2859. * @param value2 defines the second control point
  2860. * @param tangent2 defines the second tangent vector
  2861. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2862. * @returns the new Vector3
  2863. */
  2864. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2867. * @param start defines the start value
  2868. * @param end defines the end value
  2869. * @param amount max defines amount between both (between 0 and 1)
  2870. * @returns the new Vector3
  2871. */
  2872. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2873. /**
  2874. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2875. * @param start defines the start value
  2876. * @param end defines the end value
  2877. * @param amount max defines amount between both (between 0 and 1)
  2878. * @param result defines the Vector3 where to store the result
  2879. */
  2880. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2881. /**
  2882. * Returns the dot product (float) between the vectors "left" and "right"
  2883. * @param left defines the left operand
  2884. * @param right defines the right operand
  2885. * @returns the dot product
  2886. */
  2887. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2888. /**
  2889. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2890. * The cross product is then orthogonal to both "left" and "right"
  2891. * @param left defines the left operand
  2892. * @param right defines the right operand
  2893. * @returns the cross product
  2894. */
  2895. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2896. /**
  2897. * Sets the given vector "result" with the cross product of "left" and "right"
  2898. * The cross product is then orthogonal to both "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @param result defines the Vector3 where to store the result
  2902. */
  2903. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2904. /**
  2905. * Returns a new Vector3 as the normalization of the given vector
  2906. * @param vector defines the Vector3 to normalize
  2907. * @returns the new Vector3
  2908. */
  2909. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the normalization of the given first vector
  2912. * @param vector defines the Vector3 to normalize
  2913. * @param result defines the Vector3 where to store the result
  2914. */
  2915. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2916. /**
  2917. * Project a Vector3 onto screen space
  2918. * @param vector defines the Vector3 to project
  2919. * @param world defines the world matrix to use
  2920. * @param transform defines the transform (view x projection) matrix to use
  2921. * @param viewport defines the screen viewport to use
  2922. * @returns the new Vector3
  2923. */
  2924. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2925. /** @hidden */
  2926. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Unproject from screen space to object space
  2929. * @param source defines the screen space Vector3 to use
  2930. * @param viewportWidth defines the current width of the viewport
  2931. * @param viewportHeight defines the current height of the viewport
  2932. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @returns the new Vector3
  2935. */
  2936. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2937. /**
  2938. * Unproject from screen space to object space
  2939. * @param source defines the screen space Vector3 to use
  2940. * @param viewportWidth defines the current width of the viewport
  2941. * @param viewportHeight defines the current height of the viewport
  2942. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2943. * @param view defines the view matrix to use
  2944. * @param projection defines the projection matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @param result defines the Vector3 where to store the result
  2957. */
  2958. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param sourceX defines the screen space x coordinate to use
  2962. * @param sourceY defines the screen space y coordinate to use
  2963. * @param sourceZ defines the screen space z coordinate to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Gets the minimal coordinate values between two Vector3
  2974. * @param left defines the first operand
  2975. * @param right defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Gets the maximal coordinate values between two Vector3
  2981. * @param left defines the first operand
  2982. * @param right defines the second operand
  2983. * @returns the new Vector3
  2984. */
  2985. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2986. /**
  2987. * Returns the distance between the vectors "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the distance
  2991. */
  2992. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2993. /**
  2994. * Returns the squared distance between the vectors "value1" and "value2"
  2995. * @param value1 defines the first operand
  2996. * @param value2 defines the second operand
  2997. * @returns the squared distance
  2998. */
  2999. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3000. /**
  3001. * Returns a new Vector3 located at the center between "value1" and "value2"
  3002. * @param value1 defines the first operand
  3003. * @param value2 defines the second operand
  3004. * @returns the new Vector3
  3005. */
  3006. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3007. /**
  3008. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3009. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3010. * to something in order to rotate it from its local system to the given target system
  3011. * Note: axis1, axis2 and axis3 are normalized during this operation
  3012. * @param axis1 defines the first axis
  3013. * @param axis2 defines the second axis
  3014. * @param axis3 defines the third axis
  3015. * @returns a new Vector3
  3016. */
  3017. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3020. * @param axis1 defines the first axis
  3021. * @param axis2 defines the second axis
  3022. * @param axis3 defines the third axis
  3023. * @param ref defines the Vector3 where to store the result
  3024. */
  3025. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3026. }
  3027. /**
  3028. * Vector4 class created for EulerAngle class conversion to Quaternion
  3029. */
  3030. export class Vector4 {
  3031. /** x value of the vector */
  3032. x: number;
  3033. /** y value of the vector */
  3034. y: number;
  3035. /** z value of the vector */
  3036. z: number;
  3037. /** w value of the vector */
  3038. w: number;
  3039. /**
  3040. * Creates a Vector4 object from the given floats.
  3041. * @param x x value of the vector
  3042. * @param y y value of the vector
  3043. * @param z z value of the vector
  3044. * @param w w value of the vector
  3045. */
  3046. constructor(
  3047. /** x value of the vector */
  3048. x: number,
  3049. /** y value of the vector */
  3050. y: number,
  3051. /** z value of the vector */
  3052. z: number,
  3053. /** w value of the vector */
  3054. w: number);
  3055. /**
  3056. * Returns the string with the Vector4 coordinates.
  3057. * @returns a string containing all the vector values
  3058. */
  3059. toString(): string;
  3060. /**
  3061. * Returns the string "Vector4".
  3062. * @returns "Vector4"
  3063. */
  3064. getClassName(): string;
  3065. /**
  3066. * Returns the Vector4 hash code.
  3067. * @returns a unique hash code
  3068. */
  3069. getHashCode(): number;
  3070. /**
  3071. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3072. * @returns the resulting array
  3073. */
  3074. asArray(): number[];
  3075. /**
  3076. * Populates the given array from the given index with the Vector4 coordinates.
  3077. * @param array array to populate
  3078. * @param index index of the array to start at (default: 0)
  3079. * @returns the Vector4.
  3080. */
  3081. toArray(array: FloatArray, index?: number): Vector4;
  3082. /**
  3083. * Adds the given vector to the current Vector4.
  3084. * @param otherVector the vector to add
  3085. * @returns the updated Vector4.
  3086. */
  3087. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3090. * @param otherVector the vector to add
  3091. * @returns the resulting vector
  3092. */
  3093. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3096. * @param otherVector the vector to add
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Subtract in place the given vector from the current Vector4.
  3103. * @param otherVector the vector to subtract
  3104. * @returns the updated Vector4.
  3105. */
  3106. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3109. * @param otherVector the vector to add
  3110. * @returns the new vector with the result
  3111. */
  3112. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3113. /**
  3114. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3115. * @param otherVector the vector to subtract
  3116. * @param result the vector to store the result
  3117. * @returns the current Vector4.
  3118. */
  3119. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3120. /**
  3121. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3122. */
  3123. /**
  3124. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3125. * @param x value to subtract
  3126. * @param y value to subtract
  3127. * @param z value to subtract
  3128. * @param w value to subtract
  3129. * @returns new vector containing the result
  3130. */
  3131. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3132. /**
  3133. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3134. * @param x value to subtract
  3135. * @param y value to subtract
  3136. * @param z value to subtract
  3137. * @param w value to subtract
  3138. * @param result the vector to store the result in
  3139. * @returns the current Vector4.
  3140. */
  3141. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3142. /**
  3143. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3144. * @returns a new vector with the negated values
  3145. */
  3146. negate(): Vector4;
  3147. /**
  3148. * Multiplies the current Vector4 coordinates by scale (float).
  3149. * @param scale the number to scale with
  3150. * @returns the updated Vector4.
  3151. */
  3152. scaleInPlace(scale: number): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3155. * @param scale the number to scale with
  3156. * @returns a new vector with the result
  3157. */
  3158. scale(scale: number): Vector4;
  3159. /**
  3160. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3161. * @param scale the number to scale with
  3162. * @param result a vector to store the result in
  3163. * @returns the current Vector4.
  3164. */
  3165. scaleToRef(scale: number, result: Vector4): Vector4;
  3166. /**
  3167. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3168. * @param scale defines the scale factor
  3169. * @param result defines the Vector4 object where to store the result
  3170. * @returns the unmodified current Vector4
  3171. */
  3172. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3173. /**
  3174. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3175. * @param otherVector the vector to compare against
  3176. * @returns true if they are equal
  3177. */
  3178. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3179. /**
  3180. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3181. * @param otherVector vector to compare against
  3182. * @param epsilon (Default: very small number)
  3183. * @returns true if they are equal
  3184. */
  3185. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3186. /**
  3187. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3188. * @param x x value to compare against
  3189. * @param y y value to compare against
  3190. * @param z z value to compare against
  3191. * @param w w value to compare against
  3192. * @returns true if equal
  3193. */
  3194. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3195. /**
  3196. * Multiplies in place the current Vector4 by the given one.
  3197. * @param otherVector vector to multiple with
  3198. * @returns the updated Vector4.
  3199. */
  3200. multiplyInPlace(otherVector: Vector4): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3203. * @param otherVector vector to multiple with
  3204. * @returns resulting new vector
  3205. */
  3206. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3207. /**
  3208. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3209. * @param otherVector vector to multiple with
  3210. * @param result vector to store the result
  3211. * @returns the current Vector4.
  3212. */
  3213. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3214. /**
  3215. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3216. * @param x x value multiply with
  3217. * @param y y value multiply with
  3218. * @param z z value multiply with
  3219. * @param w w value multiply with
  3220. * @returns resulting new vector
  3221. */
  3222. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3223. /**
  3224. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3225. * @param otherVector vector to devide with
  3226. * @returns resulting new vector
  3227. */
  3228. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3231. * @param otherVector vector to devide with
  3232. * @param result vector to store the result
  3233. * @returns the current Vector4.
  3234. */
  3235. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3236. /**
  3237. * Divides the current Vector3 coordinates by the given ones.
  3238. * @param otherVector vector to devide with
  3239. * @returns the updated Vector3.
  3240. */
  3241. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3242. /**
  3243. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3244. * @param other defines the second operand
  3245. * @returns the current updated Vector4
  3246. */
  3247. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3250. * @param other defines the second operand
  3251. * @returns the current updated Vector4
  3252. */
  3253. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3254. /**
  3255. * Gets a new Vector4 from current Vector4 floored values
  3256. * @returns a new Vector4
  3257. */
  3258. floor(): Vector4;
  3259. /**
  3260. * Gets a new Vector4 from current Vector3 floored values
  3261. * @returns a new Vector4
  3262. */
  3263. fract(): Vector4;
  3264. /**
  3265. * Returns the Vector4 length (float).
  3266. * @returns the length
  3267. */
  3268. length(): number;
  3269. /**
  3270. * Returns the Vector4 squared length (float).
  3271. * @returns the length squared
  3272. */
  3273. lengthSquared(): number;
  3274. /**
  3275. * Normalizes in place the Vector4.
  3276. * @returns the updated Vector4.
  3277. */
  3278. normalize(): Vector4;
  3279. /**
  3280. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3281. * @returns this converted to a new vector3
  3282. */
  3283. toVector3(): Vector3;
  3284. /**
  3285. * Returns a new Vector4 copied from the current one.
  3286. * @returns the new cloned vector
  3287. */
  3288. clone(): Vector4;
  3289. /**
  3290. * Updates the current Vector4 with the given one coordinates.
  3291. * @param source the source vector to copy from
  3292. * @returns the updated Vector4.
  3293. */
  3294. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3295. /**
  3296. * Updates the current Vector4 coordinates with the given floats.
  3297. * @param x float to copy from
  3298. * @param y float to copy from
  3299. * @param z float to copy from
  3300. * @param w float to copy from
  3301. * @returns the updated Vector4.
  3302. */
  3303. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3304. /**
  3305. * Updates the current Vector4 coordinates with the given floats.
  3306. * @param x float to set from
  3307. * @param y float to set from
  3308. * @param z float to set from
  3309. * @param w float to set from
  3310. * @returns the updated Vector4.
  3311. */
  3312. set(x: number, y: number, z: number, w: number): Vector4;
  3313. /**
  3314. * Copies the given float to the current Vector3 coordinates
  3315. * @param v defines the x, y, z and w coordinates of the operand
  3316. * @returns the current updated Vector3
  3317. */
  3318. setAll(v: number): Vector4;
  3319. /**
  3320. * Returns a new Vector4 set from the starting index of the given array.
  3321. * @param array the array to pull values from
  3322. * @param offset the offset into the array to start at
  3323. * @returns the new vector
  3324. */
  3325. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3326. /**
  3327. * Updates the given vector "result" from the starting index of the given array.
  3328. * @param array the array to pull values from
  3329. * @param offset the offset into the array to start at
  3330. * @param result the vector to store the result in
  3331. */
  3332. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3333. /**
  3334. * Updates the given vector "result" from the starting index of the given Float32Array.
  3335. * @param array the array to pull values from
  3336. * @param offset the offset into the array to start at
  3337. * @param result the vector to store the result in
  3338. */
  3339. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3340. /**
  3341. * Updates the given vector "result" coordinates from the given floats.
  3342. * @param x float to set from
  3343. * @param y float to set from
  3344. * @param z float to set from
  3345. * @param w float to set from
  3346. * @param result the vector to the floats in
  3347. */
  3348. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3349. /**
  3350. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3351. * @returns the new vector
  3352. */
  3353. static Zero(): Vector4;
  3354. /**
  3355. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3356. * @returns the new vector
  3357. */
  3358. static One(): Vector4;
  3359. /**
  3360. * Returns a new normalized Vector4 from the given one.
  3361. * @param vector the vector to normalize
  3362. * @returns the vector
  3363. */
  3364. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3365. /**
  3366. * Updates the given vector "result" from the normalization of the given one.
  3367. * @param vector the vector to normalize
  3368. * @param result the vector to store the result in
  3369. */
  3370. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3371. /**
  3372. * Returns a vector with the minimum values from the left and right vectors
  3373. * @param left left vector to minimize
  3374. * @param right right vector to minimize
  3375. * @returns a new vector with the minimum of the left and right vector values
  3376. */
  3377. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Returns a vector with the maximum values from the left and right vectors
  3380. * @param left left vector to maximize
  3381. * @param right right vector to maximize
  3382. * @returns a new vector with the maximum of the left and right vector values
  3383. */
  3384. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Returns the distance (float) between the vectors "value1" and "value2".
  3387. * @param value1 value to calulate the distance between
  3388. * @param value2 value to calulate the distance between
  3389. * @return the distance between the two vectors
  3390. */
  3391. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3392. /**
  3393. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3394. * @param value1 value to calulate the distance between
  3395. * @param value2 value to calulate the distance between
  3396. * @return the distance between the two vectors squared
  3397. */
  3398. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3399. /**
  3400. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3401. * @param value1 value to calulate the center between
  3402. * @param value2 value to calulate the center between
  3403. * @return the center between the two vectors
  3404. */
  3405. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3408. * This methods computes transformed normalized direction vectors only.
  3409. * @param vector the vector to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @returns the new vector
  3412. */
  3413. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3414. /**
  3415. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3416. * This methods computes transformed normalized direction vectors only.
  3417. * @param vector the vector to transform
  3418. * @param transformation the transformation matrix to apply
  3419. * @param result the vector to store the result in
  3420. */
  3421. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3422. /**
  3423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3424. * This methods computes transformed normalized direction vectors only.
  3425. * @param x value to transform
  3426. * @param y value to transform
  3427. * @param z value to transform
  3428. * @param w value to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the results in
  3431. */
  3432. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Creates a new Vector4 from a Vector3
  3435. * @param source defines the source data
  3436. * @param w defines the 4th component (default is 0)
  3437. * @returns a new Vector4
  3438. */
  3439. static FromVector3(source: Vector3, w?: number): Vector4;
  3440. }
  3441. /**
  3442. * Class used to store quaternion data
  3443. * @see https://en.wikipedia.org/wiki/Quaternion
  3444. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3445. */
  3446. export class Quaternion {
  3447. /** defines the first component (0 by default) */
  3448. x: number;
  3449. /** defines the second component (0 by default) */
  3450. y: number;
  3451. /** defines the third component (0 by default) */
  3452. z: number;
  3453. /** defines the fourth component (1.0 by default) */
  3454. w: number;
  3455. /**
  3456. * Creates a new Quaternion from the given floats
  3457. * @param x defines the first component (0 by default)
  3458. * @param y defines the second component (0 by default)
  3459. * @param z defines the third component (0 by default)
  3460. * @param w defines the fourth component (1.0 by default)
  3461. */
  3462. constructor(
  3463. /** defines the first component (0 by default) */
  3464. x?: number,
  3465. /** defines the second component (0 by default) */
  3466. y?: number,
  3467. /** defines the third component (0 by default) */
  3468. z?: number,
  3469. /** defines the fourth component (1.0 by default) */
  3470. w?: number);
  3471. /**
  3472. * Gets a string representation for the current quaternion
  3473. * @returns a string with the Quaternion coordinates
  3474. */
  3475. toString(): string;
  3476. /**
  3477. * Gets the class name of the quaternion
  3478. * @returns the string "Quaternion"
  3479. */
  3480. getClassName(): string;
  3481. /**
  3482. * Gets a hash code for this quaternion
  3483. * @returns the quaternion hash code
  3484. */
  3485. getHashCode(): number;
  3486. /**
  3487. * Copy the quaternion to an array
  3488. * @returns a new array populated with 4 elements from the quaternion coordinates
  3489. */
  3490. asArray(): number[];
  3491. /**
  3492. * Check if two quaternions are equals
  3493. * @param otherQuaternion defines the second operand
  3494. * @return true if the current quaternion and the given one coordinates are strictly equals
  3495. */
  3496. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3497. /**
  3498. * Clone the current quaternion
  3499. * @returns a new quaternion copied from the current one
  3500. */
  3501. clone(): Quaternion;
  3502. /**
  3503. * Copy a quaternion to the current one
  3504. * @param other defines the other quaternion
  3505. * @returns the updated current quaternion
  3506. */
  3507. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3508. /**
  3509. * Updates the current quaternion with the given float coordinates
  3510. * @param x defines the x coordinate
  3511. * @param y defines the y coordinate
  3512. * @param z defines the z coordinate
  3513. * @param w defines the w coordinate
  3514. * @returns the updated current quaternion
  3515. */
  3516. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3517. /**
  3518. * Updates the current quaternion from the given float coordinates
  3519. * @param x defines the x coordinate
  3520. * @param y defines the y coordinate
  3521. * @param z defines the z coordinate
  3522. * @param w defines the w coordinate
  3523. * @returns the updated current quaternion
  3524. */
  3525. set(x: number, y: number, z: number, w: number): Quaternion;
  3526. /**
  3527. * Adds two quaternions
  3528. * @param other defines the second operand
  3529. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3530. */
  3531. add(other: DeepImmutable<Quaternion>): Quaternion;
  3532. /**
  3533. * Add a quaternion to the current one
  3534. * @param other defines the quaternion to add
  3535. * @returns the current quaternion
  3536. */
  3537. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3538. /**
  3539. * Subtract two quaternions
  3540. * @param other defines the second operand
  3541. * @returns a new quaternion as the subtraction result of the given one from the current one
  3542. */
  3543. subtract(other: Quaternion): Quaternion;
  3544. /**
  3545. * Multiplies the current quaternion by a scale factor
  3546. * @param value defines the scale factor
  3547. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3548. */
  3549. scale(value: number): Quaternion;
  3550. /**
  3551. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3552. * @param scale defines the scale factor
  3553. * @param result defines the Quaternion object where to store the result
  3554. * @returns the unmodified current quaternion
  3555. */
  3556. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3557. /**
  3558. * Multiplies in place the current quaternion by a scale factor
  3559. * @param value defines the scale factor
  3560. * @returns the current modified quaternion
  3561. */
  3562. scaleInPlace(value: number): Quaternion;
  3563. /**
  3564. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3565. * @param scale defines the scale factor
  3566. * @param result defines the Quaternion object where to store the result
  3567. * @returns the unmodified current quaternion
  3568. */
  3569. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3570. /**
  3571. * Multiplies two quaternions
  3572. * @param q1 defines the second operand
  3573. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3574. */
  3575. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3578. * @param q1 defines the second operand
  3579. * @param result defines the target quaternion
  3580. * @returns the current quaternion
  3581. */
  3582. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3583. /**
  3584. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3585. * @param q1 defines the second operand
  3586. * @returns the currentupdated quaternion
  3587. */
  3588. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3589. /**
  3590. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3591. * @param ref defines the target quaternion
  3592. * @returns the current quaternion
  3593. */
  3594. conjugateToRef(ref: Quaternion): Quaternion;
  3595. /**
  3596. * Conjugates in place (1-q) the current quaternion
  3597. * @returns the current updated quaternion
  3598. */
  3599. conjugateInPlace(): Quaternion;
  3600. /**
  3601. * Conjugates in place (1-q) the current quaternion
  3602. * @returns a new quaternion
  3603. */
  3604. conjugate(): Quaternion;
  3605. /**
  3606. * Gets length of current quaternion
  3607. * @returns the quaternion length (float)
  3608. */
  3609. length(): number;
  3610. /**
  3611. * Normalize in place the current quaternion
  3612. * @returns the current updated quaternion
  3613. */
  3614. normalize(): Quaternion;
  3615. /**
  3616. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3617. * @param order is a reserved parameter and is ignore for now
  3618. * @returns a new Vector3 containing the Euler angles
  3619. */
  3620. toEulerAngles(order?: string): Vector3;
  3621. /**
  3622. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3623. * @param result defines the vector which will be filled with the Euler angles
  3624. * @param order is a reserved parameter and is ignore for now
  3625. * @returns the current unchanged quaternion
  3626. */
  3627. toEulerAnglesToRef(result: Vector3): Quaternion;
  3628. /**
  3629. * Updates the given rotation matrix with the current quaternion values
  3630. * @param result defines the target matrix
  3631. * @returns the current unchanged quaternion
  3632. */
  3633. toRotationMatrix(result: Matrix): Quaternion;
  3634. /**
  3635. * Updates the current quaternion from the given rotation matrix values
  3636. * @param matrix defines the source matrix
  3637. * @returns the current updated quaternion
  3638. */
  3639. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3640. /**
  3641. * Creates a new quaternion from a rotation matrix
  3642. * @param matrix defines the source matrix
  3643. * @returns a new quaternion created from the given rotation matrix values
  3644. */
  3645. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3646. /**
  3647. * Updates the given quaternion with the given rotation matrix values
  3648. * @param matrix defines the source matrix
  3649. * @param result defines the target quaternion
  3650. */
  3651. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3652. /**
  3653. * Returns the dot product (float) between the quaternions "left" and "right"
  3654. * @param left defines the left operand
  3655. * @param right defines the right operand
  3656. * @returns the dot product
  3657. */
  3658. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3659. /**
  3660. * Checks if the two quaternions are close to each other
  3661. * @param quat0 defines the first quaternion to check
  3662. * @param quat1 defines the second quaternion to check
  3663. * @returns true if the two quaternions are close to each other
  3664. */
  3665. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3666. /**
  3667. * Creates an empty quaternion
  3668. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3669. */
  3670. static Zero(): Quaternion;
  3671. /**
  3672. * Inverse a given quaternion
  3673. * @param q defines the source quaternion
  3674. * @returns a new quaternion as the inverted current quaternion
  3675. */
  3676. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3677. /**
  3678. * Inverse a given quaternion
  3679. * @param q defines the source quaternion
  3680. * @param result the quaternion the result will be stored in
  3681. * @returns the result quaternion
  3682. */
  3683. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3684. /**
  3685. * Creates an identity quaternion
  3686. * @returns the identity quaternion
  3687. */
  3688. static Identity(): Quaternion;
  3689. /**
  3690. * Gets a boolean indicating if the given quaternion is identity
  3691. * @param quaternion defines the quaternion to check
  3692. * @returns true if the quaternion is identity
  3693. */
  3694. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3695. /**
  3696. * Creates a quaternion from a rotation around an axis
  3697. * @param axis defines the axis to use
  3698. * @param angle defines the angle to use
  3699. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3700. */
  3701. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3702. /**
  3703. * Creates a rotation around an axis and stores it into the given quaternion
  3704. * @param axis defines the axis to use
  3705. * @param angle defines the angle to use
  3706. * @param result defines the target quaternion
  3707. * @returns the target quaternion
  3708. */
  3709. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3710. /**
  3711. * Creates a new quaternion from data stored into an array
  3712. * @param array defines the data source
  3713. * @param offset defines the offset in the source array where the data starts
  3714. * @returns a new quaternion
  3715. */
  3716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3717. /**
  3718. * Create a quaternion from Euler rotation angles
  3719. * @param x Pitch
  3720. * @param y Yaw
  3721. * @param z Roll
  3722. * @returns the new Quaternion
  3723. */
  3724. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3725. /**
  3726. * Updates a quaternion from Euler rotation angles
  3727. * @param x Pitch
  3728. * @param y Yaw
  3729. * @param z Roll
  3730. * @param result the quaternion to store the result
  3731. * @returns the updated quaternion
  3732. */
  3733. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3734. /**
  3735. * Create a quaternion from Euler rotation vector
  3736. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3737. * @returns the new Quaternion
  3738. */
  3739. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3740. /**
  3741. * Updates a quaternion from Euler rotation vector
  3742. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3743. * @param result the quaternion to store the result
  3744. * @returns the updated quaternion
  3745. */
  3746. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3747. /**
  3748. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3749. * @param yaw defines the rotation around Y axis
  3750. * @param pitch defines the rotation around X axis
  3751. * @param roll defines the rotation around Z axis
  3752. * @returns the new quaternion
  3753. */
  3754. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3755. /**
  3756. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3757. * @param yaw defines the rotation around Y axis
  3758. * @param pitch defines the rotation around X axis
  3759. * @param roll defines the rotation around Z axis
  3760. * @param result defines the target quaternion
  3761. */
  3762. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3763. /**
  3764. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3765. * @param alpha defines the rotation around first axis
  3766. * @param beta defines the rotation around second axis
  3767. * @param gamma defines the rotation around third axis
  3768. * @returns the new quaternion
  3769. */
  3770. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3771. /**
  3772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3773. * @param alpha defines the rotation around first axis
  3774. * @param beta defines the rotation around second axis
  3775. * @param gamma defines the rotation around third axis
  3776. * @param result defines the target quaternion
  3777. */
  3778. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3779. /**
  3780. * 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)
  3781. * @param axis1 defines the first axis
  3782. * @param axis2 defines the second axis
  3783. * @param axis3 defines the third axis
  3784. * @returns the new quaternion
  3785. */
  3786. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3787. /**
  3788. * 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
  3789. * @param axis1 defines the first axis
  3790. * @param axis2 defines the second axis
  3791. * @param axis3 defines the third axis
  3792. * @param ref defines the target quaternion
  3793. */
  3794. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3795. /**
  3796. * Interpolates between two quaternions
  3797. * @param left defines first quaternion
  3798. * @param right defines second quaternion
  3799. * @param amount defines the gradient to use
  3800. * @returns the new interpolated quaternion
  3801. */
  3802. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3803. /**
  3804. * Interpolates between two quaternions and stores it into a target quaternion
  3805. * @param left defines first quaternion
  3806. * @param right defines second quaternion
  3807. * @param amount defines the gradient to use
  3808. * @param result defines the target quaternion
  3809. */
  3810. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3811. /**
  3812. * Interpolate between two quaternions using Hermite interpolation
  3813. * @param value1 defines first quaternion
  3814. * @param tangent1 defines the incoming tangent
  3815. * @param value2 defines second quaternion
  3816. * @param tangent2 defines the outgoing tangent
  3817. * @param amount defines the target quaternion
  3818. * @returns the new interpolated quaternion
  3819. */
  3820. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3821. }
  3822. /**
  3823. * Class used to store matrix data (4x4)
  3824. */
  3825. export class Matrix {
  3826. private static _updateFlagSeed;
  3827. private static _identityReadOnly;
  3828. private _isIdentity;
  3829. private _isIdentityDirty;
  3830. private _isIdentity3x2;
  3831. private _isIdentity3x2Dirty;
  3832. /**
  3833. * Gets the update flag of the matrix which is an unique number for the matrix.
  3834. * It will be incremented every time the matrix data change.
  3835. * You can use it to speed the comparison between two versions of the same matrix.
  3836. */
  3837. updateFlag: number;
  3838. private readonly _m;
  3839. /**
  3840. * Gets the internal data of the matrix
  3841. */
  3842. get m(): DeepImmutable<Float32Array>;
  3843. /** @hidden */
  3844. _markAsUpdated(): void;
  3845. /** @hidden */
  3846. private _updateIdentityStatus;
  3847. /**
  3848. * Creates an empty matrix (filled with zeros)
  3849. */
  3850. constructor();
  3851. /**
  3852. * Check if the current matrix is identity
  3853. * @returns true is the matrix is the identity matrix
  3854. */
  3855. isIdentity(): boolean;
  3856. /**
  3857. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3858. * @returns true is the matrix is the identity matrix
  3859. */
  3860. isIdentityAs3x2(): boolean;
  3861. /**
  3862. * Gets the determinant of the matrix
  3863. * @returns the matrix determinant
  3864. */
  3865. determinant(): number;
  3866. /**
  3867. * Returns the matrix as a Float32Array
  3868. * @returns the matrix underlying array
  3869. */
  3870. toArray(): DeepImmutable<Float32Array>;
  3871. /**
  3872. * Returns the matrix as a Float32Array
  3873. * @returns the matrix underlying array.
  3874. */
  3875. asArray(): DeepImmutable<Float32Array>;
  3876. /**
  3877. * Inverts the current matrix in place
  3878. * @returns the current inverted matrix
  3879. */
  3880. invert(): Matrix;
  3881. /**
  3882. * Sets all the matrix elements to zero
  3883. * @returns the current matrix
  3884. */
  3885. reset(): Matrix;
  3886. /**
  3887. * Adds the current matrix with a second one
  3888. * @param other defines the matrix to add
  3889. * @returns a new matrix as the addition of the current matrix and the given one
  3890. */
  3891. add(other: DeepImmutable<Matrix>): Matrix;
  3892. /**
  3893. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3894. * @param other defines the matrix to add
  3895. * @param result defines the target matrix
  3896. * @returns the current matrix
  3897. */
  3898. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3899. /**
  3900. * Adds in place the given matrix to the current matrix
  3901. * @param other defines the second operand
  3902. * @returns the current updated matrix
  3903. */
  3904. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3905. /**
  3906. * Sets the given matrix to the current inverted Matrix
  3907. * @param other defines the target matrix
  3908. * @returns the unmodified current matrix
  3909. */
  3910. invertToRef(other: Matrix): Matrix;
  3911. /**
  3912. * add a value at the specified position in the current Matrix
  3913. * @param index the index of the value within the matrix. between 0 and 15.
  3914. * @param value the value to be added
  3915. * @returns the current updated matrix
  3916. */
  3917. addAtIndex(index: number, value: number): Matrix;
  3918. /**
  3919. * mutiply the specified position in the current Matrix by a value
  3920. * @param index the index of the value within the matrix. between 0 and 15.
  3921. * @param value the value to be added
  3922. * @returns the current updated matrix
  3923. */
  3924. multiplyAtIndex(index: number, value: number): Matrix;
  3925. /**
  3926. * Inserts the translation vector (using 3 floats) in the current matrix
  3927. * @param x defines the 1st component of the translation
  3928. * @param y defines the 2nd component of the translation
  3929. * @param z defines the 3rd component of the translation
  3930. * @returns the current updated matrix
  3931. */
  3932. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3933. /**
  3934. * Adds the translation vector (using 3 floats) in the current matrix
  3935. * @param x defines the 1st component of the translation
  3936. * @param y defines the 2nd component of the translation
  3937. * @param z defines the 3rd component of the translation
  3938. * @returns the current updated matrix
  3939. */
  3940. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3941. /**
  3942. * Inserts the translation vector in the current matrix
  3943. * @param vector3 defines the translation to insert
  3944. * @returns the current updated matrix
  3945. */
  3946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3947. /**
  3948. * Gets the translation value of the current matrix
  3949. * @returns a new Vector3 as the extracted translation from the matrix
  3950. */
  3951. getTranslation(): Vector3;
  3952. /**
  3953. * Fill a Vector3 with the extracted translation from the matrix
  3954. * @param result defines the Vector3 where to store the translation
  3955. * @returns the current matrix
  3956. */
  3957. getTranslationToRef(result: Vector3): Matrix;
  3958. /**
  3959. * Remove rotation and scaling part from the matrix
  3960. * @returns the updated matrix
  3961. */
  3962. removeRotationAndScaling(): Matrix;
  3963. /**
  3964. * Multiply two matrices
  3965. * @param other defines the second operand
  3966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3967. */
  3968. multiply(other: DeepImmutable<Matrix>): Matrix;
  3969. /**
  3970. * Copy the current matrix from the given one
  3971. * @param other defines the source matrix
  3972. * @returns the current updated matrix
  3973. */
  3974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3975. /**
  3976. * Populates the given array from the starting index with the current matrix values
  3977. * @param array defines the target array
  3978. * @param offset defines the offset in the target array where to start storing values
  3979. * @returns the current matrix
  3980. */
  3981. copyToArray(array: Float32Array, offset?: number): Matrix;
  3982. /**
  3983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3984. * @param other defines the second operand
  3985. * @param result defines the matrix where to store the multiplication
  3986. * @returns the current matrix
  3987. */
  3988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3989. /**
  3990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3991. * @param other defines the second operand
  3992. * @param result defines the array where to store the multiplication
  3993. * @param offset defines the offset in the target array where to start storing values
  3994. * @returns the current matrix
  3995. */
  3996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3997. /**
  3998. * Check equality between this matrix and a second one
  3999. * @param value defines the second matrix to compare
  4000. * @returns true is the current matrix and the given one values are strictly equal
  4001. */
  4002. equals(value: DeepImmutable<Matrix>): boolean;
  4003. /**
  4004. * Clone the current matrix
  4005. * @returns a new matrix from the current matrix
  4006. */
  4007. clone(): Matrix;
  4008. /**
  4009. * Returns the name of the current matrix class
  4010. * @returns the string "Matrix"
  4011. */
  4012. getClassName(): string;
  4013. /**
  4014. * Gets the hash code of the current matrix
  4015. * @returns the hash code
  4016. */
  4017. getHashCode(): number;
  4018. /**
  4019. * Decomposes the current Matrix into a translation, rotation and scaling components
  4020. * @param scale defines the scale vector3 given as a reference to update
  4021. * @param rotation defines the rotation quaternion given as a reference to update
  4022. * @param translation defines the translation vector3 given as a reference to update
  4023. * @returns true if operation was successful
  4024. */
  4025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4026. /**
  4027. * Gets specific row of the matrix
  4028. * @param index defines the number of the row to get
  4029. * @returns the index-th row of the current matrix as a new Vector4
  4030. */
  4031. getRow(index: number): Nullable<Vector4>;
  4032. /**
  4033. * Sets the index-th row of the current matrix to the vector4 values
  4034. * @param index defines the number of the row to set
  4035. * @param row defines the target vector4
  4036. * @returns the updated current matrix
  4037. */
  4038. setRow(index: number, row: Vector4): Matrix;
  4039. /**
  4040. * Compute the transpose of the matrix
  4041. * @returns the new transposed matrix
  4042. */
  4043. transpose(): Matrix;
  4044. /**
  4045. * Compute the transpose of the matrix and store it in a given matrix
  4046. * @param result defines the target matrix
  4047. * @returns the current matrix
  4048. */
  4049. transposeToRef(result: Matrix): Matrix;
  4050. /**
  4051. * Sets the index-th row of the current matrix with the given 4 x float values
  4052. * @param index defines the row index
  4053. * @param x defines the x component to set
  4054. * @param y defines the y component to set
  4055. * @param z defines the z component to set
  4056. * @param w defines the w component to set
  4057. * @returns the updated current matrix
  4058. */
  4059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4060. /**
  4061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4062. * @param scale defines the scale factor
  4063. * @returns a new matrix
  4064. */
  4065. scale(scale: number): Matrix;
  4066. /**
  4067. * Scale the current matrix values by a factor to a given result matrix
  4068. * @param scale defines the scale factor
  4069. * @param result defines the matrix to store the result
  4070. * @returns the current matrix
  4071. */
  4072. scaleToRef(scale: number, result: Matrix): Matrix;
  4073. /**
  4074. * Scale the current matrix values by a factor and add the result to a given matrix
  4075. * @param scale defines the scale factor
  4076. * @param result defines the Matrix to store the result
  4077. * @returns the current matrix
  4078. */
  4079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4080. /**
  4081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4082. * @param ref matrix to store the result
  4083. */
  4084. toNormalMatrix(ref: Matrix): void;
  4085. /**
  4086. * Gets only rotation part of the current matrix
  4087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4088. */
  4089. getRotationMatrix(): Matrix;
  4090. /**
  4091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4092. * @param result defines the target matrix to store data to
  4093. * @returns the current matrix
  4094. */
  4095. getRotationMatrixToRef(result: Matrix): Matrix;
  4096. /**
  4097. * Toggles model matrix from being right handed to left handed in place and vice versa
  4098. */
  4099. toggleModelMatrixHandInPlace(): void;
  4100. /**
  4101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4102. */
  4103. toggleProjectionMatrixHandInPlace(): void;
  4104. /**
  4105. * Creates a matrix from an array
  4106. * @param array defines the source array
  4107. * @param offset defines an offset in the source array
  4108. * @returns a new Matrix set from the starting index of the given array
  4109. */
  4110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4111. /**
  4112. * Copy the content of an array into a given matrix
  4113. * @param array defines the source array
  4114. * @param offset defines an offset in the source array
  4115. * @param result defines the target matrix
  4116. */
  4117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4118. /**
  4119. * Stores an array into a matrix after having multiplied each component by a given factor
  4120. * @param array defines the source array
  4121. * @param offset defines the offset in the source array
  4122. * @param scale defines the scaling factor
  4123. * @param result defines the target matrix
  4124. */
  4125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4126. /**
  4127. * Gets an identity matrix that must not be updated
  4128. */
  4129. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4130. /**
  4131. * Stores a list of values (16) inside a given matrix
  4132. * @param initialM11 defines 1st value of 1st row
  4133. * @param initialM12 defines 2nd value of 1st row
  4134. * @param initialM13 defines 3rd value of 1st row
  4135. * @param initialM14 defines 4th value of 1st row
  4136. * @param initialM21 defines 1st value of 2nd row
  4137. * @param initialM22 defines 2nd value of 2nd row
  4138. * @param initialM23 defines 3rd value of 2nd row
  4139. * @param initialM24 defines 4th value of 2nd row
  4140. * @param initialM31 defines 1st value of 3rd row
  4141. * @param initialM32 defines 2nd value of 3rd row
  4142. * @param initialM33 defines 3rd value of 3rd row
  4143. * @param initialM34 defines 4th value of 3rd row
  4144. * @param initialM41 defines 1st value of 4th row
  4145. * @param initialM42 defines 2nd value of 4th row
  4146. * @param initialM43 defines 3rd value of 4th row
  4147. * @param initialM44 defines 4th value of 4th row
  4148. * @param result defines the target matrix
  4149. */
  4150. 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;
  4151. /**
  4152. * Creates new matrix from a list of values (16)
  4153. * @param initialM11 defines 1st value of 1st row
  4154. * @param initialM12 defines 2nd value of 1st row
  4155. * @param initialM13 defines 3rd value of 1st row
  4156. * @param initialM14 defines 4th value of 1st row
  4157. * @param initialM21 defines 1st value of 2nd row
  4158. * @param initialM22 defines 2nd value of 2nd row
  4159. * @param initialM23 defines 3rd value of 2nd row
  4160. * @param initialM24 defines 4th value of 2nd row
  4161. * @param initialM31 defines 1st value of 3rd row
  4162. * @param initialM32 defines 2nd value of 3rd row
  4163. * @param initialM33 defines 3rd value of 3rd row
  4164. * @param initialM34 defines 4th value of 3rd row
  4165. * @param initialM41 defines 1st value of 4th row
  4166. * @param initialM42 defines 2nd value of 4th row
  4167. * @param initialM43 defines 3rd value of 4th row
  4168. * @param initialM44 defines 4th value of 4th row
  4169. * @returns the new matrix
  4170. */
  4171. 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;
  4172. /**
  4173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4174. * @param scale defines the scale vector3
  4175. * @param rotation defines the rotation quaternion
  4176. * @param translation defines the translation vector3
  4177. * @returns a new matrix
  4178. */
  4179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4180. /**
  4181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4182. * @param scale defines the scale vector3
  4183. * @param rotation defines the rotation quaternion
  4184. * @param translation defines the translation vector3
  4185. * @param result defines the target matrix
  4186. */
  4187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4188. /**
  4189. * Creates a new identity matrix
  4190. * @returns a new identity matrix
  4191. */
  4192. static Identity(): Matrix;
  4193. /**
  4194. * Creates a new identity matrix and stores the result in a given matrix
  4195. * @param result defines the target matrix
  4196. */
  4197. static IdentityToRef(result: Matrix): void;
  4198. /**
  4199. * Creates a new zero matrix
  4200. * @returns a new zero matrix
  4201. */
  4202. static Zero(): Matrix;
  4203. /**
  4204. * Creates a new rotation matrix for "angle" radians around the X axis
  4205. * @param angle defines the angle (in radians) to use
  4206. * @return the new matrix
  4207. */
  4208. static RotationX(angle: number): Matrix;
  4209. /**
  4210. * Creates a new matrix as the invert of a given matrix
  4211. * @param source defines the source matrix
  4212. * @returns the new matrix
  4213. */
  4214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the Y axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationY(angle: number): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the Y 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 RotationYToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the Z axis
  4235. * @param angle defines the angle (in radians) to use
  4236. * @return the new matrix
  4237. */
  4238. static RotationZ(angle: number): Matrix;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationZToRef(angle: number, result: Matrix): void;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the given axis
  4247. * @param axis defines the axis to use
  4248. * @param angle defines the angle (in radians) to use
  4249. * @return the new matrix
  4250. */
  4251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4252. /**
  4253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4254. * @param axis defines the axis to use
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4259. /**
  4260. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4261. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4262. * @param from defines the vector to align
  4263. * @param to defines the vector to align to
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4267. /**
  4268. * Creates a rotation matrix
  4269. * @param yaw defines the yaw angle in radians (Y axis)
  4270. * @param pitch defines the pitch angle in radians (X axis)
  4271. * @param roll defines the roll angle in radians (X axis)
  4272. * @returns the new rotation matrix
  4273. */
  4274. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4275. /**
  4276. * Creates a rotation matrix and stores it in a given matrix
  4277. * @param yaw defines the yaw angle in radians (Y axis)
  4278. * @param pitch defines the pitch angle in radians (X axis)
  4279. * @param roll defines the roll angle in radians (X axis)
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4283. /**
  4284. * Creates a scaling matrix
  4285. * @param x defines the scale factor on X axis
  4286. * @param y defines the scale factor on Y axis
  4287. * @param z defines the scale factor on Z axis
  4288. * @returns the new matrix
  4289. */
  4290. static Scaling(x: number, y: number, z: number): Matrix;
  4291. /**
  4292. * Creates a scaling matrix and stores it in a given matrix
  4293. * @param x defines the scale factor on X axis
  4294. * @param y defines the scale factor on Y axis
  4295. * @param z defines the scale factor on Z axis
  4296. * @param result defines the target matrix
  4297. */
  4298. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4299. /**
  4300. * Creates a translation matrix
  4301. * @param x defines the translation on X axis
  4302. * @param y defines the translation on Y axis
  4303. * @param z defines the translationon Z axis
  4304. * @returns the new matrix
  4305. */
  4306. static Translation(x: number, y: number, z: number): Matrix;
  4307. /**
  4308. * Creates a translation matrix and stores it in a given matrix
  4309. * @param x defines the translation on X axis
  4310. * @param y defines the translation on Y axis
  4311. * @param z defines the translationon Z axis
  4312. * @param result defines the target matrix
  4313. */
  4314. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4315. /**
  4316. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4317. * @param startValue defines the start value
  4318. * @param endValue defines the end value
  4319. * @param gradient defines the gradient factor
  4320. * @returns the new matrix
  4321. */
  4322. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4325. * @param startValue defines the start value
  4326. * @param endValue defines the end value
  4327. * @param gradient defines the gradient factor
  4328. * @param result defines the Matrix object where to store data
  4329. */
  4330. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4331. /**
  4332. * Builds a new matrix whose values are computed by:
  4333. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4334. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4335. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4336. * @param startValue defines the first matrix
  4337. * @param endValue defines the second matrix
  4338. * @param gradient defines the gradient between the two matrices
  4339. * @returns the new matrix
  4340. */
  4341. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4342. /**
  4343. * Update a matrix to values which are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @param result defines the target matrix
  4351. */
  4352. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4353. /**
  4354. * 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"
  4355. * This function works in left handed mode
  4356. * @param eye defines the final position of the entity
  4357. * @param target defines where the entity should look at
  4358. * @param up defines the up vector for the entity
  4359. * @returns the new matrix
  4360. */
  4361. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4362. /**
  4363. * 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".
  4364. * This function works in left handed mode
  4365. * @param eye defines the final position of the entity
  4366. * @param target defines where the entity should look at
  4367. * @param up defines the up vector for the entity
  4368. * @param result defines the target matrix
  4369. */
  4370. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4371. /**
  4372. * 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"
  4373. * This function works in right handed mode
  4374. * @param eye defines the final position of the entity
  4375. * @param target defines where the entity should look at
  4376. * @param up defines the up vector for the entity
  4377. * @returns the new matrix
  4378. */
  4379. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4380. /**
  4381. * 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".
  4382. * This function works in right handed mode
  4383. * @param eye defines the final position of the entity
  4384. * @param target defines where the entity should look at
  4385. * @param up defines the up vector for the entity
  4386. * @param result defines the target matrix
  4387. */
  4388. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4389. /**
  4390. * Create a left-handed orthographic projection matrix
  4391. * @param width defines the viewport width
  4392. * @param height defines the viewport height
  4393. * @param znear defines the near clip plane
  4394. * @param zfar defines the far clip plane
  4395. * @returns a new matrix as a left-handed orthographic projection matrix
  4396. */
  4397. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4398. /**
  4399. * Store a left-handed orthographic projection to a given matrix
  4400. * @param width defines the viewport width
  4401. * @param height defines the viewport height
  4402. * @param znear defines the near clip plane
  4403. * @param zfar defines the far clip plane
  4404. * @param result defines the target matrix
  4405. */
  4406. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4407. /**
  4408. * Create a left-handed orthographic projection matrix
  4409. * @param left defines the viewport left coordinate
  4410. * @param right defines the viewport right coordinate
  4411. * @param bottom defines the viewport bottom coordinate
  4412. * @param top defines the viewport top coordinate
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @returns a new matrix as a left-handed orthographic projection matrix
  4416. */
  4417. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4418. /**
  4419. * Stores a left-handed orthographic projection into a given matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @param result defines the target matrix
  4427. */
  4428. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4429. /**
  4430. * Creates a right-handed orthographic projection matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @returns a new matrix as a right-handed orthographic projection matrix
  4438. */
  4439. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4440. /**
  4441. * Stores a right-handed orthographic projection into a given matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Creates a left-handed perspective projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed perspective projection matrix
  4458. */
  4459. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Creates a left-handed perspective projection matrix
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a left-handed perspective projection matrix
  4467. */
  4468. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a left-handed perspective projection into a given matrix
  4471. * @param fov defines the horizontal field of view
  4472. * @param aspect defines the aspect ratio
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4477. */
  4478. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4479. /**
  4480. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4481. * @param fov defines the horizontal field of view
  4482. * @param aspect defines the aspect ratio
  4483. * @param znear defines the near clip plane
  4484. * @param zfar not used as infinity is used as far clip
  4485. * @param result defines the target matrix
  4486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4487. */
  4488. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4489. /**
  4490. * Creates a right-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a right-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a right-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a right-handed perspective projection into a given matrix
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Stores a perspective projection for WebVR info a given matrix
  4520. * @param fov defines the field of view
  4521. * @param znear defines the near clip plane
  4522. * @param zfar defines the far clip plane
  4523. * @param result defines the target matrix
  4524. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4525. */
  4526. static PerspectiveFovWebVRToRef(fov: {
  4527. upDegrees: number;
  4528. downDegrees: number;
  4529. leftDegrees: number;
  4530. rightDegrees: number;
  4531. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4532. /**
  4533. * Computes a complete transformation matrix
  4534. * @param viewport defines the viewport to use
  4535. * @param world defines the world matrix
  4536. * @param view defines the view matrix
  4537. * @param projection defines the projection matrix
  4538. * @param zmin defines the near clip plane
  4539. * @param zmax defines the far clip plane
  4540. * @returns the transformation matrix
  4541. */
  4542. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4543. /**
  4544. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4545. * @param matrix defines the matrix to use
  4546. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4547. */
  4548. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4549. /**
  4550. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4551. * @param matrix defines the matrix to use
  4552. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4553. */
  4554. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4555. /**
  4556. * Compute the transpose of a given matrix
  4557. * @param matrix defines the matrix to transpose
  4558. * @returns the new matrix
  4559. */
  4560. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4561. /**
  4562. * Compute the transpose of a matrix and store it in a target matrix
  4563. * @param matrix defines the matrix to transpose
  4564. * @param result defines the target matrix
  4565. */
  4566. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4567. /**
  4568. * Computes a reflection matrix from a plane
  4569. * @param plane defines the reflection plane
  4570. * @returns a new matrix
  4571. */
  4572. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4573. /**
  4574. * Computes a reflection matrix from a plane
  4575. * @param plane defines the reflection plane
  4576. * @param result defines the target matrix
  4577. */
  4578. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4579. /**
  4580. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4581. * @param xaxis defines the value of the 1st axis
  4582. * @param yaxis defines the value of the 2nd axis
  4583. * @param zaxis defines the value of the 3rd axis
  4584. * @param result defines the target matrix
  4585. */
  4586. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4587. /**
  4588. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4589. * @param quat defines the quaternion to use
  4590. * @param result defines the target matrix
  4591. */
  4592. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4593. }
  4594. /**
  4595. * @hidden
  4596. */
  4597. export class TmpVectors {
  4598. static Vector2: Vector2[];
  4599. static Vector3: Vector3[];
  4600. static Vector4: Vector4[];
  4601. static Quaternion: Quaternion[];
  4602. static Matrix: Matrix[];
  4603. }
  4604. }
  4605. declare module BABYLON {
  4606. /**
  4607. * Defines potential orientation for back face culling
  4608. */
  4609. export enum Orientation {
  4610. /**
  4611. * Clockwise
  4612. */
  4613. CW = 0,
  4614. /** Counter clockwise */
  4615. CCW = 1
  4616. }
  4617. /** Class used to represent a Bezier curve */
  4618. export class BezierCurve {
  4619. /**
  4620. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4621. * @param t defines the time
  4622. * @param x1 defines the left coordinate on X axis
  4623. * @param y1 defines the left coordinate on Y axis
  4624. * @param x2 defines the right coordinate on X axis
  4625. * @param y2 defines the right coordinate on Y axis
  4626. * @returns the interpolated value
  4627. */
  4628. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4629. }
  4630. /**
  4631. * Defines angle representation
  4632. */
  4633. export class Angle {
  4634. private _radians;
  4635. /**
  4636. * Creates an Angle object of "radians" radians (float).
  4637. * @param radians the angle in radians
  4638. */
  4639. constructor(radians: number);
  4640. /**
  4641. * Get value in degrees
  4642. * @returns the Angle value in degrees (float)
  4643. */
  4644. degrees(): number;
  4645. /**
  4646. * Get value in radians
  4647. * @returns the Angle value in radians (float)
  4648. */
  4649. radians(): number;
  4650. /**
  4651. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4652. * @param a defines first vector
  4653. * @param b defines second vector
  4654. * @returns a new Angle
  4655. */
  4656. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4657. /**
  4658. * Gets a new Angle object from the given float in radians
  4659. * @param radians defines the angle value in radians
  4660. * @returns a new Angle
  4661. */
  4662. static FromRadians(radians: number): Angle;
  4663. /**
  4664. * Gets a new Angle object from the given float in degrees
  4665. * @param degrees defines the angle value in degrees
  4666. * @returns a new Angle
  4667. */
  4668. static FromDegrees(degrees: number): Angle;
  4669. }
  4670. /**
  4671. * This represents an arc in a 2d space.
  4672. */
  4673. export class Arc2 {
  4674. /** Defines the start point of the arc */
  4675. startPoint: Vector2;
  4676. /** Defines the mid point of the arc */
  4677. midPoint: Vector2;
  4678. /** Defines the end point of the arc */
  4679. endPoint: Vector2;
  4680. /**
  4681. * Defines the center point of the arc.
  4682. */
  4683. centerPoint: Vector2;
  4684. /**
  4685. * Defines the radius of the arc.
  4686. */
  4687. radius: number;
  4688. /**
  4689. * Defines the angle of the arc (from mid point to end point).
  4690. */
  4691. angle: Angle;
  4692. /**
  4693. * Defines the start angle of the arc (from start point to middle point).
  4694. */
  4695. startAngle: Angle;
  4696. /**
  4697. * Defines the orientation of the arc (clock wise/counter clock wise).
  4698. */
  4699. orientation: Orientation;
  4700. /**
  4701. * Creates an Arc object from the three given points : start, middle and end.
  4702. * @param startPoint Defines the start point of the arc
  4703. * @param midPoint Defines the midlle point of the arc
  4704. * @param endPoint Defines the end point of the arc
  4705. */
  4706. constructor(
  4707. /** Defines the start point of the arc */
  4708. startPoint: Vector2,
  4709. /** Defines the mid point of the arc */
  4710. midPoint: Vector2,
  4711. /** Defines the end point of the arc */
  4712. endPoint: Vector2);
  4713. }
  4714. /**
  4715. * Represents a 2D path made up of multiple 2D points
  4716. */
  4717. export class Path2 {
  4718. private _points;
  4719. private _length;
  4720. /**
  4721. * If the path start and end point are the same
  4722. */
  4723. closed: boolean;
  4724. /**
  4725. * Creates a Path2 object from the starting 2D coordinates x and y.
  4726. * @param x the starting points x value
  4727. * @param y the starting points y value
  4728. */
  4729. constructor(x: number, y: number);
  4730. /**
  4731. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4732. * @param x the added points x value
  4733. * @param y the added points y value
  4734. * @returns the updated Path2.
  4735. */
  4736. addLineTo(x: number, y: number): Path2;
  4737. /**
  4738. * 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.
  4739. * @param midX middle point x value
  4740. * @param midY middle point y value
  4741. * @param endX end point x value
  4742. * @param endY end point y value
  4743. * @param numberOfSegments (default: 36)
  4744. * @returns the updated Path2.
  4745. */
  4746. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4747. /**
  4748. * Closes the Path2.
  4749. * @returns the Path2.
  4750. */
  4751. close(): Path2;
  4752. /**
  4753. * Gets the sum of the distance between each sequential point in the path
  4754. * @returns the Path2 total length (float).
  4755. */
  4756. length(): number;
  4757. /**
  4758. * Gets the points which construct the path
  4759. * @returns the Path2 internal array of points.
  4760. */
  4761. getPoints(): Vector2[];
  4762. /**
  4763. * Retreives the point at the distance aways from the starting point
  4764. * @param normalizedLengthPosition the length along the path to retreive the point from
  4765. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4766. */
  4767. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4768. /**
  4769. * Creates a new path starting from an x and y position
  4770. * @param x starting x value
  4771. * @param y starting y value
  4772. * @returns a new Path2 starting at the coordinates (x, y).
  4773. */
  4774. static StartingAt(x: number, y: number): Path2;
  4775. }
  4776. /**
  4777. * Represents a 3D path made up of multiple 3D points
  4778. */
  4779. export class Path3D {
  4780. /**
  4781. * an array of Vector3, the curve axis of the Path3D
  4782. */
  4783. path: Vector3[];
  4784. private _curve;
  4785. private _distances;
  4786. private _tangents;
  4787. private _normals;
  4788. private _binormals;
  4789. private _raw;
  4790. private _alignTangentsWithPath;
  4791. private readonly _pointAtData;
  4792. /**
  4793. * new Path3D(path, normal, raw)
  4794. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4795. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4796. * @param path an array of Vector3, the curve axis of the Path3D
  4797. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4798. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4799. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4800. */
  4801. constructor(
  4802. /**
  4803. * an array of Vector3, the curve axis of the Path3D
  4804. */
  4805. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4806. /**
  4807. * Returns the Path3D array of successive Vector3 designing its curve.
  4808. * @returns the Path3D array of successive Vector3 designing its curve.
  4809. */
  4810. getCurve(): Vector3[];
  4811. /**
  4812. * Returns the Path3D array of successive Vector3 designing its curve.
  4813. * @returns the Path3D array of successive Vector3 designing its curve.
  4814. */
  4815. getPoints(): Vector3[];
  4816. /**
  4817. * @returns the computed length (float) of the path.
  4818. */
  4819. length(): number;
  4820. /**
  4821. * Returns an array populated with tangent vectors on each Path3D curve point.
  4822. * @returns an array populated with tangent vectors on each Path3D curve point.
  4823. */
  4824. getTangents(): Vector3[];
  4825. /**
  4826. * Returns an array populated with normal vectors on each Path3D curve point.
  4827. * @returns an array populated with normal vectors on each Path3D curve point.
  4828. */
  4829. getNormals(): Vector3[];
  4830. /**
  4831. * Returns an array populated with binormal vectors on each Path3D curve point.
  4832. * @returns an array populated with binormal vectors on each Path3D curve point.
  4833. */
  4834. getBinormals(): Vector3[];
  4835. /**
  4836. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4837. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4838. */
  4839. getDistances(): number[];
  4840. /**
  4841. * Returns an interpolated point along this path
  4842. * @param position the position of the point along this path, from 0.0 to 1.0
  4843. * @returns a new Vector3 as the point
  4844. */
  4845. getPointAt(position: number): Vector3;
  4846. /**
  4847. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4850. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4851. */
  4852. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4857. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4858. */
  4859. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4860. /**
  4861. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4864. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4865. */
  4866. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4867. /**
  4868. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4869. * @param position the position of the point along this path, from 0.0 to 1.0
  4870. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4871. */
  4872. getDistanceAt(position: number): number;
  4873. /**
  4874. * Returns the array index of the previous point of an interpolated point along this path
  4875. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4876. * @returns the array index
  4877. */
  4878. getPreviousPointIndexAt(position: number): number;
  4879. /**
  4880. * 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)
  4881. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4882. * @returns the sub position
  4883. */
  4884. getSubPositionAt(position: number): number;
  4885. /**
  4886. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4887. * @param target the vector of which to get the closest position to
  4888. * @returns the position of the closest virtual point on this path to the target vector
  4889. */
  4890. getClosestPositionTo(target: Vector3): number;
  4891. /**
  4892. * Returns a sub path (slice) of this path
  4893. * @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
  4894. * @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
  4895. * @returns a sub path (slice) of this path
  4896. */
  4897. slice(start?: number, end?: number): Path3D;
  4898. /**
  4899. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4900. * @param path path which all values are copied into the curves points
  4901. * @param firstNormal which should be projected onto the curve
  4902. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4903. * @returns the same object updated.
  4904. */
  4905. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4906. private _compute;
  4907. private _getFirstNonNullVector;
  4908. private _getLastNonNullVector;
  4909. private _normalVector;
  4910. /**
  4911. * Updates the point at data for an interpolated point along this curve
  4912. * @param position the position of the point along this curve, from 0.0 to 1.0
  4913. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4914. * @returns the (updated) point at data
  4915. */
  4916. private _updatePointAtData;
  4917. /**
  4918. * Updates the point at data from the specified parameters
  4919. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4920. * @param point the interpolated point
  4921. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4922. */
  4923. private _setPointAtData;
  4924. /**
  4925. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4926. */
  4927. private _updateInterpolationMatrix;
  4928. }
  4929. /**
  4930. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4931. * A Curve3 is designed from a series of successive Vector3.
  4932. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4933. */
  4934. export class Curve3 {
  4935. private _points;
  4936. private _length;
  4937. /**
  4938. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4939. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4940. * @param v1 (Vector3) the control point
  4941. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4942. * @param nbPoints (integer) the wanted number of points in the curve
  4943. * @returns the created Curve3
  4944. */
  4945. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4946. /**
  4947. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4948. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4949. * @param v1 (Vector3) the first control point
  4950. * @param v2 (Vector3) the second control point
  4951. * @param v3 (Vector3) the end point of the Cubic Bezier
  4952. * @param nbPoints (integer) the wanted number of points in the curve
  4953. * @returns the created Curve3
  4954. */
  4955. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4956. /**
  4957. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4958. * @param p1 (Vector3) the origin point of the Hermite Spline
  4959. * @param t1 (Vector3) the tangent vector at the origin point
  4960. * @param p2 (Vector3) the end point of the Hermite Spline
  4961. * @param t2 (Vector3) the tangent vector at the end point
  4962. * @param nbPoints (integer) the wanted number of points in the curve
  4963. * @returns the created Curve3
  4964. */
  4965. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4966. /**
  4967. * Returns a Curve3 object along a CatmullRom Spline curve :
  4968. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4969. * @param nbPoints (integer) the wanted number of points between each curve control points
  4970. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4971. * @returns the created Curve3
  4972. */
  4973. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4974. /**
  4975. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4976. * A Curve3 is designed from a series of successive Vector3.
  4977. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4978. * @param points points which make up the curve
  4979. */
  4980. constructor(points: Vector3[]);
  4981. /**
  4982. * @returns the Curve3 stored array of successive Vector3
  4983. */
  4984. getPoints(): Vector3[];
  4985. /**
  4986. * @returns the computed length (float) of the curve.
  4987. */
  4988. length(): number;
  4989. /**
  4990. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4991. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4992. * curveA and curveB keep unchanged.
  4993. * @param curve the curve to continue from this curve
  4994. * @returns the newly constructed curve
  4995. */
  4996. continue(curve: DeepImmutable<Curve3>): Curve3;
  4997. private _computeLength;
  4998. }
  4999. }
  5000. declare module BABYLON {
  5001. /**
  5002. * This represents the main contract an easing function should follow.
  5003. * Easing functions are used throughout the animation system.
  5004. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5005. */
  5006. export interface IEasingFunction {
  5007. /**
  5008. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5009. * of the easing function.
  5010. * The link below provides some of the most common examples of easing functions.
  5011. * @see https://easings.net/
  5012. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5013. * @returns the corresponding value on the curve defined by the easing function
  5014. */
  5015. ease(gradient: number): number;
  5016. }
  5017. /**
  5018. * Base class used for every default easing function.
  5019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5020. */
  5021. export class EasingFunction implements IEasingFunction {
  5022. /**
  5023. * Interpolation follows the mathematical formula associated with the easing function.
  5024. */
  5025. static readonly EASINGMODE_EASEIN: number;
  5026. /**
  5027. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5028. */
  5029. static readonly EASINGMODE_EASEOUT: number;
  5030. /**
  5031. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5032. */
  5033. static readonly EASINGMODE_EASEINOUT: number;
  5034. private _easingMode;
  5035. /**
  5036. * Sets the easing mode of the current function.
  5037. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5038. */
  5039. setEasingMode(easingMode: number): void;
  5040. /**
  5041. * Gets the current easing mode.
  5042. * @returns the easing mode
  5043. */
  5044. getEasingMode(): number;
  5045. /**
  5046. * @hidden
  5047. */
  5048. easeInCore(gradient: number): number;
  5049. /**
  5050. * Given an input gradient between 0 and 1, this returns the corresponding value
  5051. * of the easing function.
  5052. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5053. * @returns the corresponding value on the curve defined by the easing function
  5054. */
  5055. ease(gradient: number): number;
  5056. }
  5057. /**
  5058. * Easing function with a circle shape (see link below).
  5059. * @see https://easings.net/#easeInCirc
  5060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5061. */
  5062. export class CircleEase extends EasingFunction implements IEasingFunction {
  5063. /** @hidden */
  5064. easeInCore(gradient: number): number;
  5065. }
  5066. /**
  5067. * Easing function with a ease back shape (see link below).
  5068. * @see https://easings.net/#easeInBack
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class BackEase extends EasingFunction implements IEasingFunction {
  5072. /** Defines the amplitude of the function */
  5073. amplitude: number;
  5074. /**
  5075. * Instantiates a back ease easing
  5076. * @see https://easings.net/#easeInBack
  5077. * @param amplitude Defines the amplitude of the function
  5078. */
  5079. constructor(
  5080. /** Defines the amplitude of the function */
  5081. amplitude?: number);
  5082. /** @hidden */
  5083. easeInCore(gradient: number): number;
  5084. }
  5085. /**
  5086. * Easing function with a bouncing shape (see link below).
  5087. * @see https://easings.net/#easeInBounce
  5088. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5089. */
  5090. export class BounceEase extends EasingFunction implements IEasingFunction {
  5091. /** Defines the number of bounces */
  5092. bounces: number;
  5093. /** Defines the amplitude of the bounce */
  5094. bounciness: number;
  5095. /**
  5096. * Instantiates a bounce easing
  5097. * @see https://easings.net/#easeInBounce
  5098. * @param bounces Defines the number of bounces
  5099. * @param bounciness Defines the amplitude of the bounce
  5100. */
  5101. constructor(
  5102. /** Defines the number of bounces */
  5103. bounces?: number,
  5104. /** Defines the amplitude of the bounce */
  5105. bounciness?: number);
  5106. /** @hidden */
  5107. easeInCore(gradient: number): number;
  5108. }
  5109. /**
  5110. * Easing function with a power of 3 shape (see link below).
  5111. * @see https://easings.net/#easeInCubic
  5112. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5113. */
  5114. export class CubicEase extends EasingFunction implements IEasingFunction {
  5115. /** @hidden */
  5116. easeInCore(gradient: number): number;
  5117. }
  5118. /**
  5119. * Easing function with an elastic shape (see link below).
  5120. * @see https://easings.net/#easeInElastic
  5121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5122. */
  5123. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5124. /** Defines the number of oscillations*/
  5125. oscillations: number;
  5126. /** Defines the amplitude of the oscillations*/
  5127. springiness: number;
  5128. /**
  5129. * Instantiates an elastic easing function
  5130. * @see https://easings.net/#easeInElastic
  5131. * @param oscillations Defines the number of oscillations
  5132. * @param springiness Defines the amplitude of the oscillations
  5133. */
  5134. constructor(
  5135. /** Defines the number of oscillations*/
  5136. oscillations?: number,
  5137. /** Defines the amplitude of the oscillations*/
  5138. springiness?: number);
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with an exponential shape (see link below).
  5144. * @see https://easings.net/#easeInExpo
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5148. /** Defines the exponent of the function */
  5149. exponent: number;
  5150. /**
  5151. * Instantiates an exponential easing function
  5152. * @see https://easings.net/#easeInExpo
  5153. * @param exponent Defines the exponent of the function
  5154. */
  5155. constructor(
  5156. /** Defines the exponent of the function */
  5157. exponent?: number);
  5158. /** @hidden */
  5159. easeInCore(gradient: number): number;
  5160. }
  5161. /**
  5162. * Easing function with a power shape (see link below).
  5163. * @see https://easings.net/#easeInQuad
  5164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5165. */
  5166. export class PowerEase extends EasingFunction implements IEasingFunction {
  5167. /** Defines the power of the function */
  5168. power: number;
  5169. /**
  5170. * Instantiates an power base easing function
  5171. * @see https://easings.net/#easeInQuad
  5172. * @param power Defines the power of the function
  5173. */
  5174. constructor(
  5175. /** Defines the power of the function */
  5176. power?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with a power of 2 shape (see link below).
  5182. * @see https://easings.net/#easeInQuad
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5186. /** @hidden */
  5187. easeInCore(gradient: number): number;
  5188. }
  5189. /**
  5190. * Easing function with a power of 4 shape (see link below).
  5191. * @see https://easings.net/#easeInQuart
  5192. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5193. */
  5194. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5195. /** @hidden */
  5196. easeInCore(gradient: number): number;
  5197. }
  5198. /**
  5199. * Easing function with a power of 5 shape (see link below).
  5200. * @see https://easings.net/#easeInQuint
  5201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5202. */
  5203. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a sin shape (see link below).
  5209. * @see https://easings.net/#easeInSine
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class SineEase extends EasingFunction implements IEasingFunction {
  5213. /** @hidden */
  5214. easeInCore(gradient: number): number;
  5215. }
  5216. /**
  5217. * Easing function with a bezier shape (see link below).
  5218. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5222. /** Defines the x component of the start tangent in the bezier curve */
  5223. x1: number;
  5224. /** Defines the y component of the start tangent in the bezier curve */
  5225. y1: number;
  5226. /** Defines the x component of the end tangent in the bezier curve */
  5227. x2: number;
  5228. /** Defines the y component of the end tangent in the bezier curve */
  5229. y2: number;
  5230. /**
  5231. * Instantiates a bezier function
  5232. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5233. * @param x1 Defines the x component of the start tangent in the bezier curve
  5234. * @param y1 Defines the y component of the start tangent in the bezier curve
  5235. * @param x2 Defines the x component of the end tangent in the bezier curve
  5236. * @param y2 Defines the y component of the end tangent in the bezier curve
  5237. */
  5238. constructor(
  5239. /** Defines the x component of the start tangent in the bezier curve */
  5240. x1?: number,
  5241. /** Defines the y component of the start tangent in the bezier curve */
  5242. y1?: number,
  5243. /** Defines the x component of the end tangent in the bezier curve */
  5244. x2?: number,
  5245. /** Defines the y component of the end tangent in the bezier curve */
  5246. y2?: number);
  5247. /** @hidden */
  5248. easeInCore(gradient: number): number;
  5249. }
  5250. }
  5251. declare module BABYLON {
  5252. /**
  5253. * Class used to hold a RBG color
  5254. */
  5255. export class Color3 {
  5256. /**
  5257. * Defines the red component (between 0 and 1, default is 0)
  5258. */
  5259. r: number;
  5260. /**
  5261. * Defines the green component (between 0 and 1, default is 0)
  5262. */
  5263. g: number;
  5264. /**
  5265. * Defines the blue component (between 0 and 1, default is 0)
  5266. */
  5267. b: number;
  5268. /**
  5269. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5270. * @param r defines the red component (between 0 and 1, default is 0)
  5271. * @param g defines the green component (between 0 and 1, default is 0)
  5272. * @param b defines the blue component (between 0 and 1, default is 0)
  5273. */
  5274. constructor(
  5275. /**
  5276. * Defines the red component (between 0 and 1, default is 0)
  5277. */
  5278. r?: number,
  5279. /**
  5280. * Defines the green component (between 0 and 1, default is 0)
  5281. */
  5282. g?: number,
  5283. /**
  5284. * Defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. b?: number);
  5287. /**
  5288. * Creates a string with the Color3 current values
  5289. * @returns the string representation of the Color3 object
  5290. */
  5291. toString(): string;
  5292. /**
  5293. * Returns the string "Color3"
  5294. * @returns "Color3"
  5295. */
  5296. getClassName(): string;
  5297. /**
  5298. * Compute the Color3 hash code
  5299. * @returns an unique number that can be used to hash Color3 objects
  5300. */
  5301. getHashCode(): number;
  5302. /**
  5303. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5304. * @param array defines the array where to store the r,g,b components
  5305. * @param index defines an optional index in the target array to define where to start storing values
  5306. * @returns the current Color3 object
  5307. */
  5308. toArray(array: FloatArray, index?: number): Color3;
  5309. /**
  5310. * Returns a new Color4 object from the current Color3 and the given alpha
  5311. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5312. * @returns a new Color4 object
  5313. */
  5314. toColor4(alpha?: number): Color4;
  5315. /**
  5316. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5317. * @returns the new array
  5318. */
  5319. asArray(): number[];
  5320. /**
  5321. * Returns the luminance value
  5322. * @returns a float value
  5323. */
  5324. toLuminance(): number;
  5325. /**
  5326. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5327. * @param otherColor defines the second operand
  5328. * @returns the new Color3 object
  5329. */
  5330. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5331. /**
  5332. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5333. * @param otherColor defines the second operand
  5334. * @param result defines the Color3 object where to store the result
  5335. * @returns the current Color3
  5336. */
  5337. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5338. /**
  5339. * Determines equality between Color3 objects
  5340. * @param otherColor defines the second operand
  5341. * @returns true if the rgb values are equal to the given ones
  5342. */
  5343. equals(otherColor: DeepImmutable<Color3>): boolean;
  5344. /**
  5345. * Determines equality between the current Color3 object and a set of r,b,g values
  5346. * @param r defines the red component to check
  5347. * @param g defines the green component to check
  5348. * @param b defines the blue component to check
  5349. * @returns true if the rgb values are equal to the given ones
  5350. */
  5351. equalsFloats(r: number, g: number, b: number): boolean;
  5352. /**
  5353. * Multiplies in place each rgb value by scale
  5354. * @param scale defines the scaling factor
  5355. * @returns the updated Color3
  5356. */
  5357. scale(scale: number): Color3;
  5358. /**
  5359. * Multiplies the rgb values by scale and stores the result into "result"
  5360. * @param scale defines the scaling factor
  5361. * @param result defines the Color3 object where to store the result
  5362. * @returns the unmodified current Color3
  5363. */
  5364. scaleToRef(scale: number, result: Color3): Color3;
  5365. /**
  5366. * Scale the current Color3 values by a factor and add the result to a given Color3
  5367. * @param scale defines the scale factor
  5368. * @param result defines color to store the result into
  5369. * @returns the unmodified current Color3
  5370. */
  5371. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5372. /**
  5373. * Clamps the rgb values by the min and max values and stores the result into "result"
  5374. * @param min defines minimum clamping value (default is 0)
  5375. * @param max defines maximum clamping value (default is 1)
  5376. * @param result defines color to store the result into
  5377. * @returns the original Color3
  5378. */
  5379. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5380. /**
  5381. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5382. * @param otherColor defines the second operand
  5383. * @returns the new Color3
  5384. */
  5385. add(otherColor: DeepImmutable<Color3>): Color3;
  5386. /**
  5387. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5388. * @param otherColor defines the second operand
  5389. * @param result defines Color3 object to store the result into
  5390. * @returns the unmodified current Color3
  5391. */
  5392. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5393. /**
  5394. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5395. * @param otherColor defines the second operand
  5396. * @returns the new Color3
  5397. */
  5398. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5399. /**
  5400. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5401. * @param otherColor defines the second operand
  5402. * @param result defines Color3 object to store the result into
  5403. * @returns the unmodified current Color3
  5404. */
  5405. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5406. /**
  5407. * Copy the current object
  5408. * @returns a new Color3 copied the current one
  5409. */
  5410. clone(): Color3;
  5411. /**
  5412. * Copies the rgb values from the source in the current Color3
  5413. * @param source defines the source Color3 object
  5414. * @returns the updated Color3 object
  5415. */
  5416. copyFrom(source: DeepImmutable<Color3>): Color3;
  5417. /**
  5418. * Updates the Color3 rgb values from the given floats
  5419. * @param r defines the red component to read from
  5420. * @param g defines the green component to read from
  5421. * @param b defines the blue component to read from
  5422. * @returns the current Color3 object
  5423. */
  5424. copyFromFloats(r: number, g: number, b: number): Color3;
  5425. /**
  5426. * Updates the Color3 rgb values from the given floats
  5427. * @param r defines the red component to read from
  5428. * @param g defines the green component to read from
  5429. * @param b defines the blue component to read from
  5430. * @returns the current Color3 object
  5431. */
  5432. set(r: number, g: number, b: number): Color3;
  5433. /**
  5434. * Compute the Color3 hexadecimal code as a string
  5435. * @returns a string containing the hexadecimal representation of the Color3 object
  5436. */
  5437. toHexString(): string;
  5438. /**
  5439. * Computes a new Color3 converted from the current one to linear space
  5440. * @returns a new Color3 object
  5441. */
  5442. toLinearSpace(): Color3;
  5443. /**
  5444. * Converts current color in rgb space to HSV values
  5445. * @returns a new color3 representing the HSV values
  5446. */
  5447. toHSV(): Color3;
  5448. /**
  5449. * Converts current color in rgb space to HSV values
  5450. * @param result defines the Color3 where to store the HSV values
  5451. */
  5452. toHSVToRef(result: Color3): void;
  5453. /**
  5454. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5455. * @param convertedColor defines the Color3 object where to store the linear space version
  5456. * @returns the unmodified Color3
  5457. */
  5458. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5459. /**
  5460. * Computes a new Color3 converted from the current one to gamma space
  5461. * @returns a new Color3 object
  5462. */
  5463. toGammaSpace(): Color3;
  5464. /**
  5465. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5466. * @param convertedColor defines the Color3 object where to store the gamma space version
  5467. * @returns the unmodified Color3
  5468. */
  5469. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5470. private static _BlackReadOnly;
  5471. /**
  5472. * Convert Hue, saturation and value to a Color3 (RGB)
  5473. * @param hue defines the hue
  5474. * @param saturation defines the saturation
  5475. * @param value defines the value
  5476. * @param result defines the Color3 where to store the RGB values
  5477. */
  5478. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5479. /**
  5480. * Creates a new Color3 from the string containing valid hexadecimal values
  5481. * @param hex defines a string containing valid hexadecimal values
  5482. * @returns a new Color3 object
  5483. */
  5484. static FromHexString(hex: string): Color3;
  5485. /**
  5486. * Creates a new Color3 from the starting index of the given array
  5487. * @param array defines the source array
  5488. * @param offset defines an offset in the source array
  5489. * @returns a new Color3 object
  5490. */
  5491. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5492. /**
  5493. * Creates a new Color3 from integer values (< 256)
  5494. * @param r defines the red component to read from (value between 0 and 255)
  5495. * @param g defines the green component to read from (value between 0 and 255)
  5496. * @param b defines the blue component to read from (value between 0 and 255)
  5497. * @returns a new Color3 object
  5498. */
  5499. static FromInts(r: number, g: number, b: number): Color3;
  5500. /**
  5501. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5502. * @param start defines the start Color3 value
  5503. * @param end defines the end Color3 value
  5504. * @param amount defines the gradient value between start and end
  5505. * @returns a new Color3 object
  5506. */
  5507. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5508. /**
  5509. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5510. * @param left defines the start value
  5511. * @param right defines the end value
  5512. * @param amount defines the gradient factor
  5513. * @param result defines the Color3 object where to store the result
  5514. */
  5515. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5516. /**
  5517. * Returns a Color3 value containing a red color
  5518. * @returns a new Color3 object
  5519. */
  5520. static Red(): Color3;
  5521. /**
  5522. * Returns a Color3 value containing a green color
  5523. * @returns a new Color3 object
  5524. */
  5525. static Green(): Color3;
  5526. /**
  5527. * Returns a Color3 value containing a blue color
  5528. * @returns a new Color3 object
  5529. */
  5530. static Blue(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a black color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Black(): Color3;
  5536. /**
  5537. * Gets a Color3 value containing a black color that must not be updated
  5538. */
  5539. static get BlackReadOnly(): DeepImmutable<Color3>;
  5540. /**
  5541. * Returns a Color3 value containing a white color
  5542. * @returns a new Color3 object
  5543. */
  5544. static White(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a purple color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Purple(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a magenta color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Magenta(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a yellow color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Yellow(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a gray color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Gray(): Color3;
  5565. /**
  5566. * Returns a Color3 value containing a teal color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Teal(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a random color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Random(): Color3;
  5575. }
  5576. /**
  5577. * Class used to hold a RBGA color
  5578. */
  5579. export class Color4 {
  5580. /**
  5581. * Defines the red component (between 0 and 1, default is 0)
  5582. */
  5583. r: number;
  5584. /**
  5585. * Defines the green component (between 0 and 1, default is 0)
  5586. */
  5587. g: number;
  5588. /**
  5589. * Defines the blue component (between 0 and 1, default is 0)
  5590. */
  5591. b: number;
  5592. /**
  5593. * Defines the alpha component (between 0 and 1, default is 1)
  5594. */
  5595. a: number;
  5596. /**
  5597. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5598. * @param r defines the red component (between 0 and 1, default is 0)
  5599. * @param g defines the green component (between 0 and 1, default is 0)
  5600. * @param b defines the blue component (between 0 and 1, default is 0)
  5601. * @param a defines the alpha component (between 0 and 1, default is 1)
  5602. */
  5603. constructor(
  5604. /**
  5605. * Defines the red component (between 0 and 1, default is 0)
  5606. */
  5607. r?: number,
  5608. /**
  5609. * Defines the green component (between 0 and 1, default is 0)
  5610. */
  5611. g?: number,
  5612. /**
  5613. * Defines the blue component (between 0 and 1, default is 0)
  5614. */
  5615. b?: number,
  5616. /**
  5617. * Defines the alpha component (between 0 and 1, default is 1)
  5618. */
  5619. a?: number);
  5620. /**
  5621. * Adds in place the given Color4 values to the current Color4 object
  5622. * @param right defines the second operand
  5623. * @returns the current updated Color4 object
  5624. */
  5625. addInPlace(right: DeepImmutable<Color4>): Color4;
  5626. /**
  5627. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5628. * @returns the new array
  5629. */
  5630. asArray(): number[];
  5631. /**
  5632. * Stores from the starting index in the given array the Color4 successive values
  5633. * @param array defines the array where to store the r,g,b components
  5634. * @param index defines an optional index in the target array to define where to start storing values
  5635. * @returns the current Color4 object
  5636. */
  5637. toArray(array: number[], index?: number): Color4;
  5638. /**
  5639. * Determines equality between Color4 objects
  5640. * @param otherColor defines the second operand
  5641. * @returns true if the rgba values are equal to the given ones
  5642. */
  5643. equals(otherColor: DeepImmutable<Color4>): boolean;
  5644. /**
  5645. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5646. * @param right defines the second operand
  5647. * @returns a new Color4 object
  5648. */
  5649. add(right: DeepImmutable<Color4>): Color4;
  5650. /**
  5651. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5652. * @param right defines the second operand
  5653. * @returns a new Color4 object
  5654. */
  5655. subtract(right: DeepImmutable<Color4>): Color4;
  5656. /**
  5657. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5658. * @param right defines the second operand
  5659. * @param result defines the Color4 object where to store the result
  5660. * @returns the current Color4 object
  5661. */
  5662. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5663. /**
  5664. * Creates a new Color4 with the current Color4 values multiplied by scale
  5665. * @param scale defines the scaling factor to apply
  5666. * @returns a new Color4 object
  5667. */
  5668. scale(scale: number): Color4;
  5669. /**
  5670. * Multiplies the current Color4 values by scale and stores the result in "result"
  5671. * @param scale defines the scaling factor to apply
  5672. * @param result defines the Color4 object where to store the result
  5673. * @returns the current unmodified Color4
  5674. */
  5675. scaleToRef(scale: number, result: Color4): Color4;
  5676. /**
  5677. * Scale the current Color4 values by a factor and add the result to a given Color4
  5678. * @param scale defines the scale factor
  5679. * @param result defines the Color4 object where to store the result
  5680. * @returns the unmodified current Color4
  5681. */
  5682. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5683. /**
  5684. * Clamps the rgb values by the min and max values and stores the result into "result"
  5685. * @param min defines minimum clamping value (default is 0)
  5686. * @param max defines maximum clamping value (default is 1)
  5687. * @param result defines color to store the result into.
  5688. * @returns the cuurent Color4
  5689. */
  5690. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5691. /**
  5692. * Multipy an Color4 value by another and return a new Color4 object
  5693. * @param color defines the Color4 value to multiply by
  5694. * @returns a new Color4 object
  5695. */
  5696. multiply(color: Color4): Color4;
  5697. /**
  5698. * Multipy a Color4 value by another and push the result in a reference value
  5699. * @param color defines the Color4 value to multiply by
  5700. * @param result defines the Color4 to fill the result in
  5701. * @returns the result Color4
  5702. */
  5703. multiplyToRef(color: Color4, result: Color4): Color4;
  5704. /**
  5705. * Creates a string with the Color4 current values
  5706. * @returns the string representation of the Color4 object
  5707. */
  5708. toString(): string;
  5709. /**
  5710. * Returns the string "Color4"
  5711. * @returns "Color4"
  5712. */
  5713. getClassName(): string;
  5714. /**
  5715. * Compute the Color4 hash code
  5716. * @returns an unique number that can be used to hash Color4 objects
  5717. */
  5718. getHashCode(): number;
  5719. /**
  5720. * Creates a new Color4 copied from the current one
  5721. * @returns a new Color4 object
  5722. */
  5723. clone(): Color4;
  5724. /**
  5725. * Copies the given Color4 values into the current one
  5726. * @param source defines the source Color4 object
  5727. * @returns the current updated Color4 object
  5728. */
  5729. copyFrom(source: Color4): Color4;
  5730. /**
  5731. * Copies the given float values into the current one
  5732. * @param r defines the red component to read from
  5733. * @param g defines the green component to read from
  5734. * @param b defines the blue component to read from
  5735. * @param a defines the alpha component to read from
  5736. * @returns the current updated Color4 object
  5737. */
  5738. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5739. /**
  5740. * Copies the given float values into the current one
  5741. * @param r defines the red component to read from
  5742. * @param g defines the green component to read from
  5743. * @param b defines the blue component to read from
  5744. * @param a defines the alpha component to read from
  5745. * @returns the current updated Color4 object
  5746. */
  5747. set(r: number, g: number, b: number, a: number): Color4;
  5748. /**
  5749. * Compute the Color4 hexadecimal code as a string
  5750. * @returns a string containing the hexadecimal representation of the Color4 object
  5751. */
  5752. toHexString(): string;
  5753. /**
  5754. * Computes a new Color4 converted from the current one to linear space
  5755. * @returns a new Color4 object
  5756. */
  5757. toLinearSpace(): Color4;
  5758. /**
  5759. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5760. * @param convertedColor defines the Color4 object where to store the linear space version
  5761. * @returns the unmodified Color4
  5762. */
  5763. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5764. /**
  5765. * Computes a new Color4 converted from the current one to gamma space
  5766. * @returns a new Color4 object
  5767. */
  5768. toGammaSpace(): Color4;
  5769. /**
  5770. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5771. * @param convertedColor defines the Color4 object where to store the gamma space version
  5772. * @returns the unmodified Color4
  5773. */
  5774. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5775. /**
  5776. * Creates a new Color4 from the string containing valid hexadecimal values
  5777. * @param hex defines a string containing valid hexadecimal values
  5778. * @returns a new Color4 object
  5779. */
  5780. static FromHexString(hex: string): Color4;
  5781. /**
  5782. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5783. * @param left defines the start value
  5784. * @param right defines the end value
  5785. * @param amount defines the gradient factor
  5786. * @returns a new Color4 object
  5787. */
  5788. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5789. /**
  5790. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5791. * @param left defines the start value
  5792. * @param right defines the end value
  5793. * @param amount defines the gradient factor
  5794. * @param result defines the Color4 object where to store data
  5795. */
  5796. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5797. /**
  5798. * Creates a new Color4 from a Color3 and an alpha value
  5799. * @param color3 defines the source Color3 to read from
  5800. * @param alpha defines the alpha component (1.0 by default)
  5801. * @returns a new Color4 object
  5802. */
  5803. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5804. /**
  5805. * Creates a new Color4 from the starting index element of the given array
  5806. * @param array defines the source array to read from
  5807. * @param offset defines the offset in the source array
  5808. * @returns a new Color4 object
  5809. */
  5810. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5811. /**
  5812. * Creates a new Color3 from integer values (< 256)
  5813. * @param r defines the red component to read from (value between 0 and 255)
  5814. * @param g defines the green component to read from (value between 0 and 255)
  5815. * @param b defines the blue component to read from (value between 0 and 255)
  5816. * @param a defines the alpha component to read from (value between 0 and 255)
  5817. * @returns a new Color3 object
  5818. */
  5819. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5820. /**
  5821. * Check the content of a given array and convert it to an array containing RGBA data
  5822. * If the original array was already containing count * 4 values then it is returned directly
  5823. * @param colors defines the array to check
  5824. * @param count defines the number of RGBA data to expect
  5825. * @returns an array containing count * 4 values (RGBA)
  5826. */
  5827. static CheckColors4(colors: number[], count: number): number[];
  5828. }
  5829. /**
  5830. * @hidden
  5831. */
  5832. export class TmpColors {
  5833. static Color3: Color3[];
  5834. static Color4: Color4[];
  5835. }
  5836. }
  5837. declare module BABYLON {
  5838. /**
  5839. * Defines an interface which represents an animation key frame
  5840. */
  5841. export interface IAnimationKey {
  5842. /**
  5843. * Frame of the key frame
  5844. */
  5845. frame: number;
  5846. /**
  5847. * Value at the specifies key frame
  5848. */
  5849. value: any;
  5850. /**
  5851. * The input tangent for the cubic hermite spline
  5852. */
  5853. inTangent?: any;
  5854. /**
  5855. * The output tangent for the cubic hermite spline
  5856. */
  5857. outTangent?: any;
  5858. /**
  5859. * The animation interpolation type
  5860. */
  5861. interpolation?: AnimationKeyInterpolation;
  5862. }
  5863. /**
  5864. * Enum for the animation key frame interpolation type
  5865. */
  5866. export enum AnimationKeyInterpolation {
  5867. /**
  5868. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5869. */
  5870. STEP = 1
  5871. }
  5872. }
  5873. declare module BABYLON {
  5874. /**
  5875. * Represents the range of an animation
  5876. */
  5877. export class AnimationRange {
  5878. /**The name of the animation range**/
  5879. name: string;
  5880. /**The starting frame of the animation */
  5881. from: number;
  5882. /**The ending frame of the animation*/
  5883. to: number;
  5884. /**
  5885. * Initializes the range of an animation
  5886. * @param name The name of the animation range
  5887. * @param from The starting frame of the animation
  5888. * @param to The ending frame of the animation
  5889. */
  5890. constructor(
  5891. /**The name of the animation range**/
  5892. name: string,
  5893. /**The starting frame of the animation */
  5894. from: number,
  5895. /**The ending frame of the animation*/
  5896. to: number);
  5897. /**
  5898. * Makes a copy of the animation range
  5899. * @returns A copy of the animation range
  5900. */
  5901. clone(): AnimationRange;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * Composed of a frame, and an action function
  5907. */
  5908. export class AnimationEvent {
  5909. /** The frame for which the event is triggered **/
  5910. frame: number;
  5911. /** The event to perform when triggered **/
  5912. action: (currentFrame: number) => void;
  5913. /** Specifies if the event should be triggered only once**/
  5914. onlyOnce?: boolean | undefined;
  5915. /**
  5916. * Specifies if the animation event is done
  5917. */
  5918. isDone: boolean;
  5919. /**
  5920. * Initializes the animation event
  5921. * @param frame The frame for which the event is triggered
  5922. * @param action The event to perform when triggered
  5923. * @param onlyOnce Specifies if the event should be triggered only once
  5924. */
  5925. constructor(
  5926. /** The frame for which the event is triggered **/
  5927. frame: number,
  5928. /** The event to perform when triggered **/
  5929. action: (currentFrame: number) => void,
  5930. /** Specifies if the event should be triggered only once**/
  5931. onlyOnce?: boolean | undefined);
  5932. /** @hidden */
  5933. _clone(): AnimationEvent;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. /**
  5938. * Interface used to define a behavior
  5939. */
  5940. export interface Behavior<T> {
  5941. /** gets or sets behavior's name */
  5942. name: string;
  5943. /**
  5944. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5945. */
  5946. init(): void;
  5947. /**
  5948. * Called when the behavior is attached to a target
  5949. * @param target defines the target where the behavior is attached to
  5950. */
  5951. attach(target: T): void;
  5952. /**
  5953. * Called when the behavior is detached from its target
  5954. */
  5955. detach(): void;
  5956. }
  5957. /**
  5958. * Interface implemented by classes supporting behaviors
  5959. */
  5960. export interface IBehaviorAware<T> {
  5961. /**
  5962. * Attach a behavior
  5963. * @param behavior defines the behavior to attach
  5964. * @returns the current host
  5965. */
  5966. addBehavior(behavior: Behavior<T>): T;
  5967. /**
  5968. * Remove a behavior from the current object
  5969. * @param behavior defines the behavior to detach
  5970. * @returns the current host
  5971. */
  5972. removeBehavior(behavior: Behavior<T>): T;
  5973. /**
  5974. * Gets a behavior using its name to search
  5975. * @param name defines the name to search
  5976. * @returns the behavior or null if not found
  5977. */
  5978. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5979. }
  5980. }
  5981. declare module BABYLON {
  5982. /**
  5983. * Defines an array and its length.
  5984. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5985. */
  5986. export interface ISmartArrayLike<T> {
  5987. /**
  5988. * The data of the array.
  5989. */
  5990. data: Array<T>;
  5991. /**
  5992. * The active length of the array.
  5993. */
  5994. length: number;
  5995. }
  5996. /**
  5997. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5998. */
  5999. export class SmartArray<T> implements ISmartArrayLike<T> {
  6000. /**
  6001. * The full set of data from the array.
  6002. */
  6003. data: Array<T>;
  6004. /**
  6005. * The active length of the array.
  6006. */
  6007. length: number;
  6008. protected _id: number;
  6009. /**
  6010. * Instantiates a Smart Array.
  6011. * @param capacity defines the default capacity of the array.
  6012. */
  6013. constructor(capacity: number);
  6014. /**
  6015. * Pushes a value at the end of the active data.
  6016. * @param value defines the object to push in the array.
  6017. */
  6018. push(value: T): void;
  6019. /**
  6020. * Iterates over the active data and apply the lambda to them.
  6021. * @param func defines the action to apply on each value.
  6022. */
  6023. forEach(func: (content: T) => void): void;
  6024. /**
  6025. * Sorts the full sets of data.
  6026. * @param compareFn defines the comparison function to apply.
  6027. */
  6028. sort(compareFn: (a: T, b: T) => number): void;
  6029. /**
  6030. * Resets the active data to an empty array.
  6031. */
  6032. reset(): void;
  6033. /**
  6034. * Releases all the data from the array as well as the array.
  6035. */
  6036. dispose(): void;
  6037. /**
  6038. * Concats the active data with a given array.
  6039. * @param array defines the data to concatenate with.
  6040. */
  6041. concat(array: any): void;
  6042. /**
  6043. * Returns the position of a value in the active data.
  6044. * @param value defines the value to find the index for
  6045. * @returns the index if found in the active data otherwise -1
  6046. */
  6047. indexOf(value: T): number;
  6048. /**
  6049. * Returns whether an element is part of the active data.
  6050. * @param value defines the value to look for
  6051. * @returns true if found in the active data otherwise false
  6052. */
  6053. contains(value: T): boolean;
  6054. private static _GlobalId;
  6055. }
  6056. /**
  6057. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6058. * The data in this array can only be present once
  6059. */
  6060. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6061. private _duplicateId;
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6065. * @param value defines the object to push in the array.
  6066. */
  6067. push(value: T): void;
  6068. /**
  6069. * Pushes a value at the end of the active data.
  6070. * If the data is already present, it won t be added again
  6071. * @param value defines the object to push in the array.
  6072. * @returns true if added false if it was already present
  6073. */
  6074. pushNoDuplicate(value: T): boolean;
  6075. /**
  6076. * Resets the active data to an empty array.
  6077. */
  6078. reset(): void;
  6079. /**
  6080. * Concats the active data with a given array.
  6081. * This ensures no dupplicate will be present in the result.
  6082. * @param array defines the data to concatenate with.
  6083. */
  6084. concatWithNoDuplicate(array: any): void;
  6085. }
  6086. }
  6087. declare module BABYLON {
  6088. /**
  6089. * @ignore
  6090. * This is a list of all the different input types that are available in the application.
  6091. * Fo instance: ArcRotateCameraGamepadInput...
  6092. */
  6093. export var CameraInputTypes: {};
  6094. /**
  6095. * This is the contract to implement in order to create a new input class.
  6096. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6097. */
  6098. export interface ICameraInput<TCamera extends Camera> {
  6099. /**
  6100. * Defines the camera the input is attached to.
  6101. */
  6102. camera: Nullable<TCamera>;
  6103. /**
  6104. * Gets the class name of the current intput.
  6105. * @returns the class name
  6106. */
  6107. getClassName(): string;
  6108. /**
  6109. * Get the friendly name associated with the input class.
  6110. * @returns the input friendly name
  6111. */
  6112. getSimpleName(): string;
  6113. /**
  6114. * Attach the input controls to a specific dom element to get the input from.
  6115. * @param element Defines the element the controls should be listened from
  6116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6117. */
  6118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6119. /**
  6120. * Detach the current controls from the specified dom element.
  6121. * @param element Defines the element to stop listening the inputs from
  6122. */
  6123. detachControl(element: Nullable<HTMLElement>): void;
  6124. /**
  6125. * Update the current camera state depending on the inputs that have been used this frame.
  6126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6127. */
  6128. checkInputs?: () => void;
  6129. }
  6130. /**
  6131. * Represents a map of input types to input instance or input index to input instance.
  6132. */
  6133. export interface CameraInputsMap<TCamera extends Camera> {
  6134. /**
  6135. * Accessor to the input by input type.
  6136. */
  6137. [name: string]: ICameraInput<TCamera>;
  6138. /**
  6139. * Accessor to the input by input index.
  6140. */
  6141. [idx: number]: ICameraInput<TCamera>;
  6142. }
  6143. /**
  6144. * This represents the input manager used within a camera.
  6145. * It helps dealing with all the different kind of input attached to a camera.
  6146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6147. */
  6148. export class CameraInputsManager<TCamera extends Camera> {
  6149. /**
  6150. * Defines the list of inputs attahed to the camera.
  6151. */
  6152. attached: CameraInputsMap<TCamera>;
  6153. /**
  6154. * Defines the dom element the camera is collecting inputs from.
  6155. * This is null if the controls have not been attached.
  6156. */
  6157. attachedElement: Nullable<HTMLElement>;
  6158. /**
  6159. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6160. */
  6161. noPreventDefault: boolean;
  6162. /**
  6163. * Defined the camera the input manager belongs to.
  6164. */
  6165. camera: TCamera;
  6166. /**
  6167. * Update the current camera state depending on the inputs that have been used this frame.
  6168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6169. */
  6170. checkInputs: () => void;
  6171. /**
  6172. * Instantiate a new Camera Input Manager.
  6173. * @param camera Defines the camera the input manager blongs to
  6174. */
  6175. constructor(camera: TCamera);
  6176. /**
  6177. * Add an input method to a camera
  6178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6179. * @param input camera input method
  6180. */
  6181. add(input: ICameraInput<TCamera>): void;
  6182. /**
  6183. * Remove a specific input method from a camera
  6184. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6185. * @param inputToRemove camera input method
  6186. */
  6187. remove(inputToRemove: ICameraInput<TCamera>): void;
  6188. /**
  6189. * Remove a specific input type from a camera
  6190. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6191. * @param inputType the type of the input to remove
  6192. */
  6193. removeByType(inputType: string): void;
  6194. private _addCheckInputs;
  6195. /**
  6196. * Attach the input controls to the currently attached dom element to listen the events from.
  6197. * @param input Defines the input to attach
  6198. */
  6199. attachInput(input: ICameraInput<TCamera>): void;
  6200. /**
  6201. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6202. * @param element Defines the dom element to collect the events from
  6203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6204. */
  6205. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6206. /**
  6207. * Detach the current manager inputs controls from a specific dom element.
  6208. * @param element Defines the dom element to collect the events from
  6209. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6210. */
  6211. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6212. /**
  6213. * Rebuild the dynamic inputCheck function from the current list of
  6214. * defined inputs in the manager.
  6215. */
  6216. rebuildInputCheck(): void;
  6217. /**
  6218. * Remove all attached input methods from a camera
  6219. */
  6220. clear(): void;
  6221. /**
  6222. * Serialize the current input manager attached to a camera.
  6223. * This ensures than once parsed,
  6224. * the input associated to the camera will be identical to the current ones
  6225. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6226. */
  6227. serialize(serializedCamera: any): void;
  6228. /**
  6229. * Parses an input manager serialized JSON to restore the previous list of inputs
  6230. * and states associated to a camera.
  6231. * @param parsedCamera Defines the JSON to parse
  6232. */
  6233. parse(parsedCamera: any): void;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Class used to store data that will be store in GPU memory
  6239. */
  6240. export class Buffer {
  6241. private _engine;
  6242. private _buffer;
  6243. /** @hidden */
  6244. _data: Nullable<DataArray>;
  6245. private _updatable;
  6246. private _instanced;
  6247. private _divisor;
  6248. /**
  6249. * Gets the byte stride.
  6250. */
  6251. readonly byteStride: number;
  6252. /**
  6253. * Constructor
  6254. * @param engine the engine
  6255. * @param data the data to use for this buffer
  6256. * @param updatable whether the data is updatable
  6257. * @param stride the stride (optional)
  6258. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6259. * @param instanced whether the buffer is instanced (optional)
  6260. * @param useBytes set to true if the stride in in bytes (optional)
  6261. * @param divisor sets an optional divisor for instances (1 by default)
  6262. */
  6263. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6264. /**
  6265. * Create a new VertexBuffer based on the current buffer
  6266. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6267. * @param offset defines offset in the buffer (0 by default)
  6268. * @param size defines the size in floats of attributes (position is 3 for instance)
  6269. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6270. * @param instanced defines if the vertex buffer contains indexed data
  6271. * @param useBytes defines if the offset and stride are in bytes *
  6272. * @param divisor sets an optional divisor for instances (1 by default)
  6273. * @returns the new vertex buffer
  6274. */
  6275. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6276. /**
  6277. * Gets a boolean indicating if the Buffer is updatable?
  6278. * @returns true if the buffer is updatable
  6279. */
  6280. isUpdatable(): boolean;
  6281. /**
  6282. * Gets current buffer's data
  6283. * @returns a DataArray or null
  6284. */
  6285. getData(): Nullable<DataArray>;
  6286. /**
  6287. * Gets underlying native buffer
  6288. * @returns underlying native buffer
  6289. */
  6290. getBuffer(): Nullable<DataBuffer>;
  6291. /**
  6292. * Gets the stride in float32 units (i.e. byte stride / 4).
  6293. * May not be an integer if the byte stride is not divisible by 4.
  6294. * @returns the stride in float32 units
  6295. * @deprecated Please use byteStride instead.
  6296. */
  6297. getStrideSize(): number;
  6298. /**
  6299. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6300. * @param data defines the data to store
  6301. */
  6302. create(data?: Nullable<DataArray>): void;
  6303. /** @hidden */
  6304. _rebuild(): void;
  6305. /**
  6306. * Update current buffer data
  6307. * @param data defines the data to store
  6308. */
  6309. update(data: DataArray): void;
  6310. /**
  6311. * Updates the data directly.
  6312. * @param data the new data
  6313. * @param offset the new offset
  6314. * @param vertexCount the vertex count (optional)
  6315. * @param useBytes set to true if the offset is in bytes
  6316. */
  6317. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6318. /**
  6319. * Release all resources
  6320. */
  6321. dispose(): void;
  6322. }
  6323. /**
  6324. * Specialized buffer used to store vertex data
  6325. */
  6326. export class VertexBuffer {
  6327. /** @hidden */
  6328. _buffer: Buffer;
  6329. private _kind;
  6330. private _size;
  6331. private _ownsBuffer;
  6332. private _instanced;
  6333. private _instanceDivisor;
  6334. /**
  6335. * The byte type.
  6336. */
  6337. static readonly BYTE: number;
  6338. /**
  6339. * The unsigned byte type.
  6340. */
  6341. static readonly UNSIGNED_BYTE: number;
  6342. /**
  6343. * The short type.
  6344. */
  6345. static readonly SHORT: number;
  6346. /**
  6347. * The unsigned short type.
  6348. */
  6349. static readonly UNSIGNED_SHORT: number;
  6350. /**
  6351. * The integer type.
  6352. */
  6353. static readonly INT: number;
  6354. /**
  6355. * The unsigned integer type.
  6356. */
  6357. static readonly UNSIGNED_INT: number;
  6358. /**
  6359. * The float type.
  6360. */
  6361. static readonly FLOAT: number;
  6362. /**
  6363. * Gets or sets the instance divisor when in instanced mode
  6364. */
  6365. get instanceDivisor(): number;
  6366. set instanceDivisor(value: number);
  6367. /**
  6368. * Gets the byte stride.
  6369. */
  6370. readonly byteStride: number;
  6371. /**
  6372. * Gets the byte offset.
  6373. */
  6374. readonly byteOffset: number;
  6375. /**
  6376. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6377. */
  6378. readonly normalized: boolean;
  6379. /**
  6380. * Gets the data type of each component in the array.
  6381. */
  6382. readonly type: number;
  6383. /**
  6384. * Constructor
  6385. * @param engine the engine
  6386. * @param data the data to use for this vertex buffer
  6387. * @param kind the vertex buffer kind
  6388. * @param updatable whether the data is updatable
  6389. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6390. * @param stride the stride (optional)
  6391. * @param instanced whether the buffer is instanced (optional)
  6392. * @param offset the offset of the data (optional)
  6393. * @param size the number of components (optional)
  6394. * @param type the type of the component (optional)
  6395. * @param normalized whether the data contains normalized data (optional)
  6396. * @param useBytes set to true if stride and offset are in bytes (optional)
  6397. * @param divisor defines the instance divisor to use (1 by default)
  6398. */
  6399. 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);
  6400. /** @hidden */
  6401. _rebuild(): void;
  6402. /**
  6403. * Returns the kind of the VertexBuffer (string)
  6404. * @returns a string
  6405. */
  6406. getKind(): string;
  6407. /**
  6408. * Gets a boolean indicating if the VertexBuffer is updatable?
  6409. * @returns true if the buffer is updatable
  6410. */
  6411. isUpdatable(): boolean;
  6412. /**
  6413. * Gets current buffer's data
  6414. * @returns a DataArray or null
  6415. */
  6416. getData(): Nullable<DataArray>;
  6417. /**
  6418. * Gets underlying native buffer
  6419. * @returns underlying native buffer
  6420. */
  6421. getBuffer(): Nullable<DataBuffer>;
  6422. /**
  6423. * Gets the stride in float32 units (i.e. byte stride / 4).
  6424. * May not be an integer if the byte stride is not divisible by 4.
  6425. * @returns the stride in float32 units
  6426. * @deprecated Please use byteStride instead.
  6427. */
  6428. getStrideSize(): number;
  6429. /**
  6430. * Returns the offset as a multiple of the type byte length.
  6431. * @returns the offset in bytes
  6432. * @deprecated Please use byteOffset instead.
  6433. */
  6434. getOffset(): number;
  6435. /**
  6436. * Returns the number of components per vertex attribute (integer)
  6437. * @returns the size in float
  6438. */
  6439. getSize(): number;
  6440. /**
  6441. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6442. * @returns true if this buffer is instanced
  6443. */
  6444. getIsInstanced(): boolean;
  6445. /**
  6446. * Returns the instancing divisor, zero for non-instanced (integer).
  6447. * @returns a number
  6448. */
  6449. getInstanceDivisor(): number;
  6450. /**
  6451. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6452. * @param data defines the data to store
  6453. */
  6454. create(data?: DataArray): void;
  6455. /**
  6456. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6457. * This function will create a new buffer if the current one is not updatable
  6458. * @param data defines the data to store
  6459. */
  6460. update(data: DataArray): void;
  6461. /**
  6462. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6463. * Returns the directly updated WebGLBuffer.
  6464. * @param data the new data
  6465. * @param offset the new offset
  6466. * @param useBytes set to true if the offset is in bytes
  6467. */
  6468. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6469. /**
  6470. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6471. */
  6472. dispose(): void;
  6473. /**
  6474. * Enumerates each value of this vertex buffer as numbers.
  6475. * @param count the number of values to enumerate
  6476. * @param callback the callback function called for each value
  6477. */
  6478. forEach(count: number, callback: (value: number, index: number) => void): void;
  6479. /**
  6480. * Positions
  6481. */
  6482. static readonly PositionKind: string;
  6483. /**
  6484. * Normals
  6485. */
  6486. static readonly NormalKind: string;
  6487. /**
  6488. * Tangents
  6489. */
  6490. static readonly TangentKind: string;
  6491. /**
  6492. * Texture coordinates
  6493. */
  6494. static readonly UVKind: string;
  6495. /**
  6496. * Texture coordinates 2
  6497. */
  6498. static readonly UV2Kind: string;
  6499. /**
  6500. * Texture coordinates 3
  6501. */
  6502. static readonly UV3Kind: string;
  6503. /**
  6504. * Texture coordinates 4
  6505. */
  6506. static readonly UV4Kind: string;
  6507. /**
  6508. * Texture coordinates 5
  6509. */
  6510. static readonly UV5Kind: string;
  6511. /**
  6512. * Texture coordinates 6
  6513. */
  6514. static readonly UV6Kind: string;
  6515. /**
  6516. * Colors
  6517. */
  6518. static readonly ColorKind: string;
  6519. /**
  6520. * Matrix indices (for bones)
  6521. */
  6522. static readonly MatricesIndicesKind: string;
  6523. /**
  6524. * Matrix weights (for bones)
  6525. */
  6526. static readonly MatricesWeightsKind: string;
  6527. /**
  6528. * Additional matrix indices (for bones)
  6529. */
  6530. static readonly MatricesIndicesExtraKind: string;
  6531. /**
  6532. * Additional matrix weights (for bones)
  6533. */
  6534. static readonly MatricesWeightsExtraKind: string;
  6535. /**
  6536. * Deduces the stride given a kind.
  6537. * @param kind The kind string to deduce
  6538. * @returns The deduced stride
  6539. */
  6540. static DeduceStride(kind: string): number;
  6541. /**
  6542. * Gets the byte length of the given type.
  6543. * @param type the type
  6544. * @returns the number of bytes
  6545. */
  6546. static GetTypeByteLength(type: number): number;
  6547. /**
  6548. * Enumerates each value of the given parameters as numbers.
  6549. * @param data the data to enumerate
  6550. * @param byteOffset the byte offset of the data
  6551. * @param byteStride the byte stride of the data
  6552. * @param componentCount the number of components per element
  6553. * @param componentType the type of the component
  6554. * @param count the number of values to enumerate
  6555. * @param normalized whether the data is normalized
  6556. * @param callback the callback function called for each value
  6557. */
  6558. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6559. private static _GetFloatValue;
  6560. }
  6561. }
  6562. declare module BABYLON {
  6563. /**
  6564. * @hidden
  6565. */
  6566. export class IntersectionInfo {
  6567. bu: Nullable<number>;
  6568. bv: Nullable<number>;
  6569. distance: number;
  6570. faceId: number;
  6571. subMeshId: number;
  6572. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6573. }
  6574. }
  6575. declare module BABYLON {
  6576. /**
  6577. * Represens a plane by the equation ax + by + cz + d = 0
  6578. */
  6579. export class Plane {
  6580. private static _TmpMatrix;
  6581. /**
  6582. * Normal of the plane (a,b,c)
  6583. */
  6584. normal: Vector3;
  6585. /**
  6586. * d component of the plane
  6587. */
  6588. d: number;
  6589. /**
  6590. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6591. * @param a a component of the plane
  6592. * @param b b component of the plane
  6593. * @param c c component of the plane
  6594. * @param d d component of the plane
  6595. */
  6596. constructor(a: number, b: number, c: number, d: number);
  6597. /**
  6598. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6599. */
  6600. asArray(): number[];
  6601. /**
  6602. * @returns a new plane copied from the current Plane.
  6603. */
  6604. clone(): Plane;
  6605. /**
  6606. * @returns the string "Plane".
  6607. */
  6608. getClassName(): string;
  6609. /**
  6610. * @returns the Plane hash code.
  6611. */
  6612. getHashCode(): number;
  6613. /**
  6614. * Normalize the current Plane in place.
  6615. * @returns the updated Plane.
  6616. */
  6617. normalize(): Plane;
  6618. /**
  6619. * Applies a transformation the plane and returns the result
  6620. * @param transformation the transformation matrix to be applied to the plane
  6621. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6622. */
  6623. transform(transformation: DeepImmutable<Matrix>): Plane;
  6624. /**
  6625. * Calcualtte the dot product between the point and the plane normal
  6626. * @param point point to calculate the dot product with
  6627. * @returns the dot product (float) of the point coordinates and the plane normal.
  6628. */
  6629. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6630. /**
  6631. * Updates the current Plane from the plane defined by the three given points.
  6632. * @param point1 one of the points used to contruct the plane
  6633. * @param point2 one of the points used to contruct the plane
  6634. * @param point3 one of the points used to contruct the plane
  6635. * @returns the updated Plane.
  6636. */
  6637. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6638. /**
  6639. * Checks if the plane is facing a given direction
  6640. * @param direction the direction to check if the plane is facing
  6641. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6642. * @returns True is the vector "direction" is the same side than the plane normal.
  6643. */
  6644. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6645. /**
  6646. * Calculates the distance to a point
  6647. * @param point point to calculate distance to
  6648. * @returns the signed distance (float) from the given point to the Plane.
  6649. */
  6650. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Creates a plane from an array
  6653. * @param array the array to create a plane from
  6654. * @returns a new Plane from the given array.
  6655. */
  6656. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6657. /**
  6658. * Creates a plane from three points
  6659. * @param point1 point used to create the plane
  6660. * @param point2 point used to create the plane
  6661. * @param point3 point used to create the plane
  6662. * @returns a new Plane defined by the three given points.
  6663. */
  6664. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6665. /**
  6666. * Creates a plane from an origin point and a normal
  6667. * @param origin origin of the plane to be constructed
  6668. * @param normal normal of the plane to be constructed
  6669. * @returns a new Plane the normal vector to this plane at the given origin point.
  6670. * Note : the vector "normal" is updated because normalized.
  6671. */
  6672. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6673. /**
  6674. * Calculates the distance from a plane and a point
  6675. * @param origin origin of the plane to be constructed
  6676. * @param normal normal of the plane to be constructed
  6677. * @param point point to calculate distance to
  6678. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6679. */
  6680. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6681. }
  6682. }
  6683. declare module BABYLON {
  6684. /**
  6685. * Class used to store bounding sphere information
  6686. */
  6687. export class BoundingSphere {
  6688. /**
  6689. * Gets the center of the bounding sphere in local space
  6690. */
  6691. readonly center: Vector3;
  6692. /**
  6693. * Radius of the bounding sphere in local space
  6694. */
  6695. radius: number;
  6696. /**
  6697. * Gets the center of the bounding sphere in world space
  6698. */
  6699. readonly centerWorld: Vector3;
  6700. /**
  6701. * Radius of the bounding sphere in world space
  6702. */
  6703. radiusWorld: number;
  6704. /**
  6705. * Gets the minimum vector in local space
  6706. */
  6707. readonly minimum: Vector3;
  6708. /**
  6709. * Gets the maximum vector in local space
  6710. */
  6711. readonly maximum: Vector3;
  6712. private _worldMatrix;
  6713. private static readonly TmpVector3;
  6714. /**
  6715. * Creates a new bounding sphere
  6716. * @param min defines the minimum vector (in local space)
  6717. * @param max defines the maximum vector (in local space)
  6718. * @param worldMatrix defines the new world matrix
  6719. */
  6720. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6721. /**
  6722. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6723. * @param min defines the new minimum vector (in local space)
  6724. * @param max defines the new maximum vector (in local space)
  6725. * @param worldMatrix defines the new world matrix
  6726. */
  6727. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6728. /**
  6729. * Scale the current bounding sphere by applying a scale factor
  6730. * @param factor defines the scale factor to apply
  6731. * @returns the current bounding box
  6732. */
  6733. scale(factor: number): BoundingSphere;
  6734. /**
  6735. * Gets the world matrix of the bounding box
  6736. * @returns a matrix
  6737. */
  6738. getWorldMatrix(): DeepImmutable<Matrix>;
  6739. /** @hidden */
  6740. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6741. /**
  6742. * Tests if the bounding sphere is intersecting the frustum planes
  6743. * @param frustumPlanes defines the frustum planes to test
  6744. * @returns true if there is an intersection
  6745. */
  6746. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6747. /**
  6748. * Tests if the bounding sphere center is in between the frustum planes.
  6749. * Used for optimistic fast inclusion.
  6750. * @param frustumPlanes defines the frustum planes to test
  6751. * @returns true if the sphere center is in between the frustum planes
  6752. */
  6753. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6754. /**
  6755. * Tests if a point is inside the bounding sphere
  6756. * @param point defines the point to test
  6757. * @returns true if the point is inside the bounding sphere
  6758. */
  6759. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6760. /**
  6761. * Checks if two sphere intersct
  6762. * @param sphere0 sphere 0
  6763. * @param sphere1 sphere 1
  6764. * @returns true if the speres intersect
  6765. */
  6766. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6767. }
  6768. }
  6769. declare module BABYLON {
  6770. /**
  6771. * Class used to store bounding box information
  6772. */
  6773. export class BoundingBox implements ICullable {
  6774. /**
  6775. * Gets the 8 vectors representing the bounding box in local space
  6776. */
  6777. readonly vectors: Vector3[];
  6778. /**
  6779. * Gets the center of the bounding box in local space
  6780. */
  6781. readonly center: Vector3;
  6782. /**
  6783. * Gets the center of the bounding box in world space
  6784. */
  6785. readonly centerWorld: Vector3;
  6786. /**
  6787. * Gets the extend size in local space
  6788. */
  6789. readonly extendSize: Vector3;
  6790. /**
  6791. * Gets the extend size in world space
  6792. */
  6793. readonly extendSizeWorld: Vector3;
  6794. /**
  6795. * Gets the OBB (object bounding box) directions
  6796. */
  6797. readonly directions: Vector3[];
  6798. /**
  6799. * Gets the 8 vectors representing the bounding box in world space
  6800. */
  6801. readonly vectorsWorld: Vector3[];
  6802. /**
  6803. * Gets the minimum vector in world space
  6804. */
  6805. readonly minimumWorld: Vector3;
  6806. /**
  6807. * Gets the maximum vector in world space
  6808. */
  6809. readonly maximumWorld: Vector3;
  6810. /**
  6811. * Gets the minimum vector in local space
  6812. */
  6813. readonly minimum: Vector3;
  6814. /**
  6815. * Gets the maximum vector in local space
  6816. */
  6817. readonly maximum: Vector3;
  6818. private _worldMatrix;
  6819. private static readonly TmpVector3;
  6820. /**
  6821. * @hidden
  6822. */
  6823. _tag: number;
  6824. /**
  6825. * Creates a new bounding box
  6826. * @param min defines the minimum vector (in local space)
  6827. * @param max defines the maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6831. /**
  6832. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6833. * @param min defines the new minimum vector (in local space)
  6834. * @param max defines the new maximum vector (in local space)
  6835. * @param worldMatrix defines the new world matrix
  6836. */
  6837. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6838. /**
  6839. * Scale the current bounding box by applying a scale factor
  6840. * @param factor defines the scale factor to apply
  6841. * @returns the current bounding box
  6842. */
  6843. scale(factor: number): BoundingBox;
  6844. /**
  6845. * Gets the world matrix of the bounding box
  6846. * @returns a matrix
  6847. */
  6848. getWorldMatrix(): DeepImmutable<Matrix>;
  6849. /** @hidden */
  6850. _update(world: DeepImmutable<Matrix>): void;
  6851. /**
  6852. * Tests if the bounding box is intersecting the frustum planes
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if there is an intersection
  6855. */
  6856. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if the bounding box is entirely inside the frustum planes
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if there is an inclusion
  6861. */
  6862. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding box
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding box
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Tests if the bounding box intersects with a bounding sphere
  6871. * @param sphere defines the sphere to test
  6872. * @returns true if there is an intersection
  6873. */
  6874. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6875. /**
  6876. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6877. * @param min defines the min vector to use
  6878. * @param max defines the max vector to use
  6879. * @returns true if there is an intersection
  6880. */
  6881. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6882. /**
  6883. * Tests if two bounding boxes are intersections
  6884. * @param box0 defines the first box to test
  6885. * @param box1 defines the second box to test
  6886. * @returns true if there is an intersection
  6887. */
  6888. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6889. /**
  6890. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6891. * @param minPoint defines the minimum vector of the bounding box
  6892. * @param maxPoint defines the maximum vector of the bounding box
  6893. * @param sphereCenter defines the sphere center
  6894. * @param sphereRadius defines the sphere radius
  6895. * @returns true if there is an intersection
  6896. */
  6897. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6898. /**
  6899. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6900. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6901. * @param frustumPlanes defines the frustum planes to test
  6902. * @return true if there is an inclusion
  6903. */
  6904. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6905. /**
  6906. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6907. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6908. * @param frustumPlanes defines the frustum planes to test
  6909. * @return true if there is an intersection
  6910. */
  6911. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6912. }
  6913. }
  6914. declare module BABYLON {
  6915. /** @hidden */
  6916. export class Collider {
  6917. /** Define if a collision was found */
  6918. collisionFound: boolean;
  6919. /**
  6920. * Define last intersection point in local space
  6921. */
  6922. intersectionPoint: Vector3;
  6923. /**
  6924. * Define last collided mesh
  6925. */
  6926. collidedMesh: Nullable<AbstractMesh>;
  6927. private _collisionPoint;
  6928. private _planeIntersectionPoint;
  6929. private _tempVector;
  6930. private _tempVector2;
  6931. private _tempVector3;
  6932. private _tempVector4;
  6933. private _edge;
  6934. private _baseToVertex;
  6935. private _destinationPoint;
  6936. private _slidePlaneNormal;
  6937. private _displacementVector;
  6938. /** @hidden */
  6939. _radius: Vector3;
  6940. /** @hidden */
  6941. _retry: number;
  6942. private _velocity;
  6943. private _basePoint;
  6944. private _epsilon;
  6945. /** @hidden */
  6946. _velocityWorldLength: number;
  6947. /** @hidden */
  6948. _basePointWorld: Vector3;
  6949. private _velocityWorld;
  6950. private _normalizedVelocity;
  6951. /** @hidden */
  6952. _initialVelocity: Vector3;
  6953. /** @hidden */
  6954. _initialPosition: Vector3;
  6955. private _nearestDistance;
  6956. private _collisionMask;
  6957. get collisionMask(): number;
  6958. set collisionMask(mask: number);
  6959. /**
  6960. * Gets the plane normal used to compute the sliding response (in local space)
  6961. */
  6962. get slidePlaneNormal(): Vector3;
  6963. /** @hidden */
  6964. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6965. /** @hidden */
  6966. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6967. /** @hidden */
  6968. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6969. /** @hidden */
  6970. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6971. /** @hidden */
  6972. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6973. /** @hidden */
  6974. _getResponse(pos: Vector3, vel: Vector3): void;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /**
  6979. * Interface for cullable objects
  6980. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6981. */
  6982. export interface ICullable {
  6983. /**
  6984. * Checks if the object or part of the object is in the frustum
  6985. * @param frustumPlanes Camera near/planes
  6986. * @returns true if the object is in frustum otherwise false
  6987. */
  6988. isInFrustum(frustumPlanes: Plane[]): boolean;
  6989. /**
  6990. * Checks if a cullable object (mesh...) is in the camera frustum
  6991. * Unlike isInFrustum this cheks the full bounding box
  6992. * @param frustumPlanes Camera near/planes
  6993. * @returns true if the object is in frustum otherwise false
  6994. */
  6995. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6996. }
  6997. /**
  6998. * Info for a bounding data of a mesh
  6999. */
  7000. export class BoundingInfo implements ICullable {
  7001. /**
  7002. * Bounding box for the mesh
  7003. */
  7004. readonly boundingBox: BoundingBox;
  7005. /**
  7006. * Bounding sphere for the mesh
  7007. */
  7008. readonly boundingSphere: BoundingSphere;
  7009. private _isLocked;
  7010. private static readonly TmpVector3;
  7011. /**
  7012. * Constructs bounding info
  7013. * @param minimum min vector of the bounding box/sphere
  7014. * @param maximum max vector of the bounding box/sphere
  7015. * @param worldMatrix defines the new world matrix
  7016. */
  7017. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7018. /**
  7019. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7020. * @param min defines the new minimum vector (in local space)
  7021. * @param max defines the new maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7025. /**
  7026. * min vector of the bounding box/sphere
  7027. */
  7028. get minimum(): Vector3;
  7029. /**
  7030. * max vector of the bounding box/sphere
  7031. */
  7032. get maximum(): Vector3;
  7033. /**
  7034. * If the info is locked and won't be updated to avoid perf overhead
  7035. */
  7036. get isLocked(): boolean;
  7037. set isLocked(value: boolean);
  7038. /**
  7039. * Updates the bounding sphere and box
  7040. * @param world world matrix to be used to update
  7041. */
  7042. update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7045. * @param center New center of the bounding info
  7046. * @param extend New extend of the bounding info
  7047. * @returns the current bounding info
  7048. */
  7049. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7050. /**
  7051. * Scale the current bounding info by applying a scale factor
  7052. * @param factor defines the scale factor to apply
  7053. * @returns the current bounding info
  7054. */
  7055. scale(factor: number): BoundingInfo;
  7056. /**
  7057. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7058. * @param frustumPlanes defines the frustum to test
  7059. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7060. * @returns true if the bounding info is in the frustum planes
  7061. */
  7062. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7063. /**
  7064. * Gets the world distance between the min and max points of the bounding box
  7065. */
  7066. get diagonalLength(): number;
  7067. /**
  7068. * Checks if a cullable object (mesh...) is in the camera frustum
  7069. * Unlike isInFrustum this cheks the full bounding box
  7070. * @param frustumPlanes Camera near/planes
  7071. * @returns true if the object is in frustum otherwise false
  7072. */
  7073. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7074. /** @hidden */
  7075. _checkCollision(collider: Collider): boolean;
  7076. /**
  7077. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7078. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7079. * @param point the point to check intersection with
  7080. * @returns if the point intersects
  7081. */
  7082. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7083. /**
  7084. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7085. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7086. * @param boundingInfo the bounding info to check intersection with
  7087. * @param precise if the intersection should be done using OBB
  7088. * @returns if the bounding info intersects
  7089. */
  7090. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7091. }
  7092. }
  7093. declare module BABYLON {
  7094. /**
  7095. * Extracts minimum and maximum values from a list of indexed positions
  7096. * @param positions defines the positions to use
  7097. * @param indices defines the indices to the positions
  7098. * @param indexStart defines the start index
  7099. * @param indexCount defines the end index
  7100. * @param bias defines bias value to add to the result
  7101. * @return minimum and maximum values
  7102. */
  7103. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7104. minimum: Vector3;
  7105. maximum: Vector3;
  7106. };
  7107. /**
  7108. * Extracts minimum and maximum values from a list of positions
  7109. * @param positions defines the positions to use
  7110. * @param start defines the start index in the positions array
  7111. * @param count defines the number of positions to handle
  7112. * @param bias defines bias value to add to the result
  7113. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7114. * @return minimum and maximum values
  7115. */
  7116. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7117. minimum: Vector3;
  7118. maximum: Vector3;
  7119. };
  7120. }
  7121. declare module BABYLON {
  7122. /** @hidden */
  7123. export class WebGLDataBuffer extends DataBuffer {
  7124. private _buffer;
  7125. constructor(resource: WebGLBuffer);
  7126. get underlyingResource(): any;
  7127. }
  7128. }
  7129. declare module BABYLON {
  7130. /** @hidden */
  7131. export class WebGLPipelineContext implements IPipelineContext {
  7132. engine: ThinEngine;
  7133. program: Nullable<WebGLProgram>;
  7134. context?: WebGLRenderingContext;
  7135. vertexShader?: WebGLShader;
  7136. fragmentShader?: WebGLShader;
  7137. isParallelCompiled: boolean;
  7138. onCompiled?: () => void;
  7139. transformFeedback?: WebGLTransformFeedback | null;
  7140. vertexCompilationError: Nullable<string>;
  7141. fragmentCompilationError: Nullable<string>;
  7142. programLinkError: Nullable<string>;
  7143. programValidationError: Nullable<string>;
  7144. get isAsync(): boolean;
  7145. get isReady(): boolean;
  7146. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7147. }
  7148. }
  7149. declare module BABYLON {
  7150. interface ThinEngine {
  7151. /**
  7152. * Create an uniform buffer
  7153. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7154. * @param elements defines the content of the uniform buffer
  7155. * @returns the webGL uniform buffer
  7156. */
  7157. createUniformBuffer(elements: FloatArray): DataBuffer;
  7158. /**
  7159. * Create a dynamic uniform buffer
  7160. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7161. * @param elements defines the content of the uniform buffer
  7162. * @returns the webGL uniform buffer
  7163. */
  7164. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7165. /**
  7166. * Update an existing uniform buffer
  7167. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7168. * @param uniformBuffer defines the target uniform buffer
  7169. * @param elements defines the content to update
  7170. * @param offset defines the offset in the uniform buffer where update should start
  7171. * @param count defines the size of the data to update
  7172. */
  7173. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7174. /**
  7175. * Bind an uniform buffer to the current webGL context
  7176. * @param buffer defines the buffer to bind
  7177. */
  7178. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7179. /**
  7180. * Bind a buffer to the current webGL context at a given location
  7181. * @param buffer defines the buffer to bind
  7182. * @param location defines the index where to bind the buffer
  7183. */
  7184. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7185. /**
  7186. * Bind a specific block at a given index in a specific shader program
  7187. * @param pipelineContext defines the pipeline context to use
  7188. * @param blockName defines the block name
  7189. * @param index defines the index where to bind the block
  7190. */
  7191. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7192. }
  7193. }
  7194. declare module BABYLON {
  7195. /**
  7196. * Uniform buffer objects.
  7197. *
  7198. * Handles blocks of uniform on the GPU.
  7199. *
  7200. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7201. *
  7202. * For more information, please refer to :
  7203. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7204. */
  7205. export class UniformBuffer {
  7206. private _engine;
  7207. private _buffer;
  7208. private _data;
  7209. private _bufferData;
  7210. private _dynamic?;
  7211. private _uniformLocations;
  7212. private _uniformSizes;
  7213. private _uniformLocationPointer;
  7214. private _needSync;
  7215. private _noUBO;
  7216. private _currentEffect;
  7217. /** @hidden */
  7218. _alreadyBound: boolean;
  7219. private static _MAX_UNIFORM_SIZE;
  7220. private static _tempBuffer;
  7221. /**
  7222. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7227. /**
  7228. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7233. /**
  7234. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7239. /**
  7240. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7245. /**
  7246. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7251. /**
  7252. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7257. /**
  7258. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7263. /**
  7264. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7269. /**
  7270. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7275. /**
  7276. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7281. /**
  7282. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7287. /**
  7288. * Instantiates a new Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. * @param engine Define the engine the buffer is associated with
  7297. * @param data Define the data contained in the buffer
  7298. * @param dynamic Define if the buffer is updatable
  7299. */
  7300. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7301. /**
  7302. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7303. * or just falling back on setUniformXXX calls.
  7304. */
  7305. get useUbo(): boolean;
  7306. /**
  7307. * Indicates if the WebGL underlying uniform buffer is in sync
  7308. * with the javascript cache data.
  7309. */
  7310. get isSync(): boolean;
  7311. /**
  7312. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7313. * Also, a dynamic UniformBuffer will disable cache verification and always
  7314. * update the underlying WebGL uniform buffer to the GPU.
  7315. * @returns if Dynamic, otherwise false
  7316. */
  7317. isDynamic(): boolean;
  7318. /**
  7319. * The data cache on JS side.
  7320. * @returns the underlying data as a float array
  7321. */
  7322. getData(): Float32Array;
  7323. /**
  7324. * The underlying WebGL Uniform buffer.
  7325. * @returns the webgl buffer
  7326. */
  7327. getBuffer(): Nullable<DataBuffer>;
  7328. /**
  7329. * std140 layout specifies how to align data within an UBO structure.
  7330. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7331. * for specs.
  7332. */
  7333. private _fillAlignment;
  7334. /**
  7335. * Adds an uniform in the buffer.
  7336. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7337. * for the layout to be correct !
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. * @param size Data size, or data directly.
  7340. */
  7341. addUniform(name: string, size: number | number[]): void;
  7342. /**
  7343. * Adds a Matrix 4x4 to the uniform buffer.
  7344. * @param name Name of the uniform, as used in the uniform block in the shader.
  7345. * @param mat A 4x4 matrix.
  7346. */
  7347. addMatrix(name: string, mat: Matrix): void;
  7348. /**
  7349. * Adds a vec2 to the uniform buffer.
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param x Define the x component value of the vec2
  7352. * @param y Define the y component value of the vec2
  7353. */
  7354. addFloat2(name: string, x: number, y: number): void;
  7355. /**
  7356. * Adds a vec3 to the uniform buffer.
  7357. * @param name Name of the uniform, as used in the uniform block in the shader.
  7358. * @param x Define the x component value of the vec3
  7359. * @param y Define the y component value of the vec3
  7360. * @param z Define the z component value of the vec3
  7361. */
  7362. addFloat3(name: string, x: number, y: number, z: number): void;
  7363. /**
  7364. * Adds a vec3 to the uniform buffer.
  7365. * @param name Name of the uniform, as used in the uniform block in the shader.
  7366. * @param color Define the vec3 from a Color
  7367. */
  7368. addColor3(name: string, color: Color3): void;
  7369. /**
  7370. * Adds a vec4 to the uniform buffer.
  7371. * @param name Name of the uniform, as used in the uniform block in the shader.
  7372. * @param color Define the rgb components from a Color
  7373. * @param alpha Define the a component of the vec4
  7374. */
  7375. addColor4(name: string, color: Color3, alpha: number): void;
  7376. /**
  7377. * Adds a vec3 to the uniform buffer.
  7378. * @param name Name of the uniform, as used in the uniform block in the shader.
  7379. * @param vector Define the vec3 components from a Vector
  7380. */
  7381. addVector3(name: string, vector: Vector3): void;
  7382. /**
  7383. * Adds a Matrix 3x3 to the uniform buffer.
  7384. * @param name Name of the uniform, as used in the uniform block in the shader.
  7385. */
  7386. addMatrix3x3(name: string): void;
  7387. /**
  7388. * Adds a Matrix 2x2 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. */
  7391. addMatrix2x2(name: string): void;
  7392. /**
  7393. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7394. */
  7395. create(): void;
  7396. /** @hidden */
  7397. _rebuild(): void;
  7398. /**
  7399. * Updates the WebGL Uniform Buffer on the GPU.
  7400. * If the `dynamic` flag is set to true, no cache comparison is done.
  7401. * Otherwise, the buffer will be updated only if the cache differs.
  7402. */
  7403. update(): void;
  7404. /**
  7405. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7406. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7407. * @param data Define the flattened data
  7408. * @param size Define the size of the data.
  7409. */
  7410. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7411. private _valueCache;
  7412. private _cacheMatrix;
  7413. private _updateMatrix3x3ForUniform;
  7414. private _updateMatrix3x3ForEffect;
  7415. private _updateMatrix2x2ForEffect;
  7416. private _updateMatrix2x2ForUniform;
  7417. private _updateFloatForEffect;
  7418. private _updateFloatForUniform;
  7419. private _updateFloat2ForEffect;
  7420. private _updateFloat2ForUniform;
  7421. private _updateFloat3ForEffect;
  7422. private _updateFloat3ForUniform;
  7423. private _updateFloat4ForEffect;
  7424. private _updateFloat4ForUniform;
  7425. private _updateMatrixForEffect;
  7426. private _updateMatrixForUniform;
  7427. private _updateVector3ForEffect;
  7428. private _updateVector3ForUniform;
  7429. private _updateVector4ForEffect;
  7430. private _updateVector4ForUniform;
  7431. private _updateColor3ForEffect;
  7432. private _updateColor3ForUniform;
  7433. private _updateColor4ForEffect;
  7434. private _updateColor4ForUniform;
  7435. /**
  7436. * Sets a sampler uniform on the effect.
  7437. * @param name Define the name of the sampler.
  7438. * @param texture Define the texture to set in the sampler
  7439. */
  7440. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7441. /**
  7442. * Directly updates the value of the uniform in the cache AND on the GPU.
  7443. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7444. * @param data Define the flattened data
  7445. */
  7446. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7447. /**
  7448. * Binds this uniform buffer to an effect.
  7449. * @param effect Define the effect to bind the buffer to
  7450. * @param name Name of the uniform block in the shader.
  7451. */
  7452. bindToEffect(effect: Effect, name: string): void;
  7453. /**
  7454. * Disposes the uniform buffer.
  7455. */
  7456. dispose(): void;
  7457. }
  7458. }
  7459. declare module BABYLON {
  7460. /**
  7461. * Enum that determines the text-wrapping mode to use.
  7462. */
  7463. export enum InspectableType {
  7464. /**
  7465. * Checkbox for booleans
  7466. */
  7467. Checkbox = 0,
  7468. /**
  7469. * Sliders for numbers
  7470. */
  7471. Slider = 1,
  7472. /**
  7473. * Vector3
  7474. */
  7475. Vector3 = 2,
  7476. /**
  7477. * Quaternions
  7478. */
  7479. Quaternion = 3,
  7480. /**
  7481. * Color3
  7482. */
  7483. Color3 = 4,
  7484. /**
  7485. * String
  7486. */
  7487. String = 5
  7488. }
  7489. /**
  7490. * Interface used to define custom inspectable properties.
  7491. * This interface is used by the inspector to display custom property grids
  7492. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7493. */
  7494. export interface IInspectable {
  7495. /**
  7496. * Gets the label to display
  7497. */
  7498. label: string;
  7499. /**
  7500. * Gets the name of the property to edit
  7501. */
  7502. propertyName: string;
  7503. /**
  7504. * Gets the type of the editor to use
  7505. */
  7506. type: InspectableType;
  7507. /**
  7508. * Gets the minimum value of the property when using in "slider" mode
  7509. */
  7510. min?: number;
  7511. /**
  7512. * Gets the maximum value of the property when using in "slider" mode
  7513. */
  7514. max?: number;
  7515. /**
  7516. * Gets the setp to use when using in "slider" mode
  7517. */
  7518. step?: number;
  7519. }
  7520. }
  7521. declare module BABYLON {
  7522. /**
  7523. * Class used to provide helper for timing
  7524. */
  7525. export class TimingTools {
  7526. /**
  7527. * Polyfill for setImmediate
  7528. * @param action defines the action to execute after the current execution block
  7529. */
  7530. static SetImmediate(action: () => void): void;
  7531. }
  7532. }
  7533. declare module BABYLON {
  7534. /**
  7535. * Class used to enable instatition of objects by class name
  7536. */
  7537. export class InstantiationTools {
  7538. /**
  7539. * Use this object to register external classes like custom textures or material
  7540. * to allow the laoders to instantiate them
  7541. */
  7542. static RegisteredExternalClasses: {
  7543. [key: string]: Object;
  7544. };
  7545. /**
  7546. * Tries to instantiate a new object from a given class name
  7547. * @param className defines the class name to instantiate
  7548. * @returns the new object or null if the system was not able to do the instantiation
  7549. */
  7550. static Instantiate(className: string): any;
  7551. }
  7552. }
  7553. declare module BABYLON {
  7554. /**
  7555. * Define options used to create a depth texture
  7556. */
  7557. export class DepthTextureCreationOptions {
  7558. /** Specifies whether or not a stencil should be allocated in the texture */
  7559. generateStencil?: boolean;
  7560. /** Specifies whether or not bilinear filtering is enable on the texture */
  7561. bilinearFiltering?: boolean;
  7562. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7563. comparisonFunction?: number;
  7564. /** Specifies if the created texture is a cube texture */
  7565. isCube?: boolean;
  7566. }
  7567. }
  7568. declare module BABYLON {
  7569. interface ThinEngine {
  7570. /**
  7571. * Creates a depth stencil cube texture.
  7572. * This is only available in WebGL 2.
  7573. * @param size The size of face edge in the cube texture.
  7574. * @param options The options defining the cube texture.
  7575. * @returns The cube texture
  7576. */
  7577. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7578. /**
  7579. * Creates a cube texture
  7580. * @param rootUrl defines the url where the files to load is located
  7581. * @param scene defines the current scene
  7582. * @param files defines the list of files to load (1 per face)
  7583. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7584. * @param onLoad defines an optional callback raised when the texture is loaded
  7585. * @param onError defines an optional callback raised if there is an issue to load the texture
  7586. * @param format defines the format of the data
  7587. * @param forcedExtension defines the extension to use to pick the right loader
  7588. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7589. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7590. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7591. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7592. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7593. * @returns the cube texture as an InternalTexture
  7594. */
  7595. 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;
  7596. /**
  7597. * Creates a cube texture
  7598. * @param rootUrl defines the url where the files to load is located
  7599. * @param scene defines the current scene
  7600. * @param files defines the list of files to load (1 per face)
  7601. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7602. * @param onLoad defines an optional callback raised when the texture is loaded
  7603. * @param onError defines an optional callback raised if there is an issue to load the texture
  7604. * @param format defines the format of the data
  7605. * @param forcedExtension defines the extension to use to pick the right loader
  7606. * @returns the cube texture as an InternalTexture
  7607. */
  7608. 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;
  7609. /**
  7610. * Creates a cube texture
  7611. * @param rootUrl defines the url where the files to load is located
  7612. * @param scene defines the current scene
  7613. * @param files defines the list of files to load (1 per face)
  7614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7615. * @param onLoad defines an optional callback raised when the texture is loaded
  7616. * @param onError defines an optional callback raised if there is an issue to load the texture
  7617. * @param format defines the format of the data
  7618. * @param forcedExtension defines the extension to use to pick the right loader
  7619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. 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;
  7625. /** @hidden */
  7626. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7627. /** @hidden */
  7628. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7629. /** @hidden */
  7630. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7631. /** @hidden */
  7632. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7633. /**
  7634. * @hidden
  7635. */
  7636. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7637. }
  7638. }
  7639. declare module BABYLON {
  7640. /**
  7641. * Class for creating a cube texture
  7642. */
  7643. export class CubeTexture extends BaseTexture {
  7644. private _delayedOnLoad;
  7645. /**
  7646. * The url of the texture
  7647. */
  7648. url: string;
  7649. /**
  7650. * Gets or sets the center of the bounding box associated with the cube texture.
  7651. * It must define where the camera used to render the texture was set
  7652. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7653. */
  7654. boundingBoxPosition: Vector3;
  7655. private _boundingBoxSize;
  7656. /**
  7657. * Gets or sets the size of the bounding box associated with the cube texture
  7658. * When defined, the cubemap will switch to local mode
  7659. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7660. * @example https://www.babylonjs-playground.com/#RNASML
  7661. */
  7662. set boundingBoxSize(value: Vector3);
  7663. /**
  7664. * Returns the bounding box size
  7665. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7666. */
  7667. get boundingBoxSize(): Vector3;
  7668. protected _rotationY: number;
  7669. /**
  7670. * Sets texture matrix rotation angle around Y axis in radians.
  7671. */
  7672. set rotationY(value: number);
  7673. /**
  7674. * Gets texture matrix rotation angle around Y axis radians.
  7675. */
  7676. get rotationY(): number;
  7677. /**
  7678. * Are mip maps generated for this texture or not.
  7679. */
  7680. get noMipmap(): boolean;
  7681. private _noMipmap;
  7682. private _files;
  7683. protected _forcedExtension: Nullable<string>;
  7684. private _extensions;
  7685. private _textureMatrix;
  7686. private _format;
  7687. private _createPolynomials;
  7688. /** @hidden */
  7689. _prefiltered: boolean;
  7690. /**
  7691. * Creates a cube texture from an array of image urls
  7692. * @param files defines an array of image urls
  7693. * @param scene defines the hosting scene
  7694. * @param noMipmap specifies if mip maps are not used
  7695. * @returns a cube texture
  7696. */
  7697. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7698. /**
  7699. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7700. * @param url defines the url of the prefiltered texture
  7701. * @param scene defines the scene the texture is attached to
  7702. * @param forcedExtension defines the extension of the file if different from the url
  7703. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7704. * @return the prefiltered texture
  7705. */
  7706. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7707. /**
  7708. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7709. * as prefiltered data.
  7710. * @param rootUrl defines the url of the texture or the root name of the six images
  7711. * @param scene defines the scene the texture is attached to
  7712. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7713. * @param noMipmap defines if mipmaps should be created or not
  7714. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7715. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7716. * @param onError defines a callback triggered in case of error during load
  7717. * @param format defines the internal format to use for the texture once loaded
  7718. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7719. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7720. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7721. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7722. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7723. * @return the cube texture
  7724. */
  7725. 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);
  7726. /**
  7727. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7728. */
  7729. get isPrefiltered(): boolean;
  7730. /**
  7731. * Get the current class name of the texture useful for serialization or dynamic coding.
  7732. * @returns "CubeTexture"
  7733. */
  7734. getClassName(): string;
  7735. /**
  7736. * Update the url (and optional buffer) of this texture if url was null during construction.
  7737. * @param url the url of the texture
  7738. * @param forcedExtension defines the extension to use
  7739. * @param onLoad callback called when the texture is loaded (defaults to null)
  7740. */
  7741. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7742. /**
  7743. * Delays loading of the cube texture
  7744. * @param forcedExtension defines the extension to use
  7745. */
  7746. delayLoad(forcedExtension?: string): void;
  7747. /**
  7748. * Returns the reflection texture matrix
  7749. * @returns the reflection texture matrix
  7750. */
  7751. getReflectionTextureMatrix(): Matrix;
  7752. /**
  7753. * Sets the reflection texture matrix
  7754. * @param value Reflection texture matrix
  7755. */
  7756. setReflectionTextureMatrix(value: Matrix): void;
  7757. /**
  7758. * Parses text to create a cube texture
  7759. * @param parsedTexture define the serialized text to read from
  7760. * @param scene defines the hosting scene
  7761. * @param rootUrl defines the root url of the cube texture
  7762. * @returns a cube texture
  7763. */
  7764. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7765. /**
  7766. * Makes a clone, or deep copy, of the cube texture
  7767. * @returns a new cube texture
  7768. */
  7769. clone(): CubeTexture;
  7770. }
  7771. }
  7772. declare module BABYLON {
  7773. /**
  7774. * Manages the defines for the Material
  7775. */
  7776. export class MaterialDefines {
  7777. /** @hidden */
  7778. protected _keys: string[];
  7779. private _isDirty;
  7780. /** @hidden */
  7781. _renderId: number;
  7782. /** @hidden */
  7783. _areLightsDirty: boolean;
  7784. /** @hidden */
  7785. _areLightsDisposed: boolean;
  7786. /** @hidden */
  7787. _areAttributesDirty: boolean;
  7788. /** @hidden */
  7789. _areTexturesDirty: boolean;
  7790. /** @hidden */
  7791. _areFresnelDirty: boolean;
  7792. /** @hidden */
  7793. _areMiscDirty: boolean;
  7794. /** @hidden */
  7795. _areImageProcessingDirty: boolean;
  7796. /** @hidden */
  7797. _normals: boolean;
  7798. /** @hidden */
  7799. _uvs: boolean;
  7800. /** @hidden */
  7801. _needNormals: boolean;
  7802. /** @hidden */
  7803. _needUVs: boolean;
  7804. [id: string]: any;
  7805. /**
  7806. * Specifies if the material needs to be re-calculated
  7807. */
  7808. get isDirty(): boolean;
  7809. /**
  7810. * Marks the material to indicate that it has been re-calculated
  7811. */
  7812. markAsProcessed(): void;
  7813. /**
  7814. * Marks the material to indicate that it needs to be re-calculated
  7815. */
  7816. markAsUnprocessed(): void;
  7817. /**
  7818. * Marks the material to indicate all of its defines need to be re-calculated
  7819. */
  7820. markAllAsDirty(): void;
  7821. /**
  7822. * Marks the material to indicate that image processing needs to be re-calculated
  7823. */
  7824. markAsImageProcessingDirty(): void;
  7825. /**
  7826. * Marks the material to indicate the lights need to be re-calculated
  7827. * @param disposed Defines whether the light is dirty due to dispose or not
  7828. */
  7829. markAsLightDirty(disposed?: boolean): void;
  7830. /**
  7831. * Marks the attribute state as changed
  7832. */
  7833. markAsAttributesDirty(): void;
  7834. /**
  7835. * Marks the texture state as changed
  7836. */
  7837. markAsTexturesDirty(): void;
  7838. /**
  7839. * Marks the fresnel state as changed
  7840. */
  7841. markAsFresnelDirty(): void;
  7842. /**
  7843. * Marks the misc state as changed
  7844. */
  7845. markAsMiscDirty(): void;
  7846. /**
  7847. * Rebuilds the material defines
  7848. */
  7849. rebuild(): void;
  7850. /**
  7851. * Specifies if two material defines are equal
  7852. * @param other - A material define instance to compare to
  7853. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7854. */
  7855. isEqual(other: MaterialDefines): boolean;
  7856. /**
  7857. * Clones this instance's defines to another instance
  7858. * @param other - material defines to clone values to
  7859. */
  7860. cloneTo(other: MaterialDefines): void;
  7861. /**
  7862. * Resets the material define values
  7863. */
  7864. reset(): void;
  7865. /**
  7866. * Converts the material define values to a string
  7867. * @returns - String of material define information
  7868. */
  7869. toString(): string;
  7870. }
  7871. }
  7872. declare module BABYLON {
  7873. /**
  7874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7876. * 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;
  7877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7878. */
  7879. export class ColorCurves {
  7880. private _dirty;
  7881. private _tempColor;
  7882. private _globalCurve;
  7883. private _highlightsCurve;
  7884. private _midtonesCurve;
  7885. private _shadowsCurve;
  7886. private _positiveCurve;
  7887. private _negativeCurve;
  7888. private _globalHue;
  7889. private _globalDensity;
  7890. private _globalSaturation;
  7891. private _globalExposure;
  7892. /**
  7893. * Gets the global Hue value.
  7894. * 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).
  7895. */
  7896. get globalHue(): number;
  7897. /**
  7898. * Sets the global Hue value.
  7899. * 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).
  7900. */
  7901. set globalHue(value: number);
  7902. /**
  7903. * Gets the global Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. get globalDensity(): number;
  7908. /**
  7909. * Sets the global Density value.
  7910. * 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.
  7911. * Values less than zero provide a filter of opposite hue.
  7912. */
  7913. set globalDensity(value: number);
  7914. /**
  7915. * Gets the global Saturation value.
  7916. * 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.
  7917. */
  7918. get globalSaturation(): number;
  7919. /**
  7920. * Sets the global Saturation value.
  7921. * 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.
  7922. */
  7923. set globalSaturation(value: number);
  7924. /**
  7925. * Gets the global Exposure value.
  7926. * 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.
  7927. */
  7928. get globalExposure(): number;
  7929. /**
  7930. * Sets the global Exposure value.
  7931. * 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.
  7932. */
  7933. set globalExposure(value: number);
  7934. private _highlightsHue;
  7935. private _highlightsDensity;
  7936. private _highlightsSaturation;
  7937. private _highlightsExposure;
  7938. /**
  7939. * Gets the highlights Hue value.
  7940. * 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).
  7941. */
  7942. get highlightsHue(): number;
  7943. /**
  7944. * Sets the highlights Hue value.
  7945. * 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).
  7946. */
  7947. set highlightsHue(value: number);
  7948. /**
  7949. * Gets the highlights Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. get highlightsDensity(): number;
  7954. /**
  7955. * Sets the highlights Density value.
  7956. * 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.
  7957. * Values less than zero provide a filter of opposite hue.
  7958. */
  7959. set highlightsDensity(value: number);
  7960. /**
  7961. * Gets the highlights Saturation value.
  7962. * 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.
  7963. */
  7964. get highlightsSaturation(): number;
  7965. /**
  7966. * Sets the highlights Saturation value.
  7967. * 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.
  7968. */
  7969. set highlightsSaturation(value: number);
  7970. /**
  7971. * Gets the highlights Exposure value.
  7972. * 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.
  7973. */
  7974. get highlightsExposure(): number;
  7975. /**
  7976. * Sets the highlights Exposure value.
  7977. * 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.
  7978. */
  7979. set highlightsExposure(value: number);
  7980. private _midtonesHue;
  7981. private _midtonesDensity;
  7982. private _midtonesSaturation;
  7983. private _midtonesExposure;
  7984. /**
  7985. * Gets the midtones Hue value.
  7986. * 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).
  7987. */
  7988. get midtonesHue(): number;
  7989. /**
  7990. * Sets the midtones Hue value.
  7991. * 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).
  7992. */
  7993. set midtonesHue(value: number);
  7994. /**
  7995. * Gets the midtones Density value.
  7996. * 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.
  7997. * Values less than zero provide a filter of opposite hue.
  7998. */
  7999. get midtonesDensity(): number;
  8000. /**
  8001. * Sets the midtones Density value.
  8002. * 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.
  8003. * Values less than zero provide a filter of opposite hue.
  8004. */
  8005. set midtonesDensity(value: number);
  8006. /**
  8007. * Gets the midtones Saturation value.
  8008. * 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.
  8009. */
  8010. get midtonesSaturation(): number;
  8011. /**
  8012. * Sets the midtones Saturation value.
  8013. * 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.
  8014. */
  8015. set midtonesSaturation(value: number);
  8016. /**
  8017. * Gets the midtones Exposure value.
  8018. * 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.
  8019. */
  8020. get midtonesExposure(): number;
  8021. /**
  8022. * Sets the midtones Exposure value.
  8023. * 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.
  8024. */
  8025. set midtonesExposure(value: number);
  8026. private _shadowsHue;
  8027. private _shadowsDensity;
  8028. private _shadowsSaturation;
  8029. private _shadowsExposure;
  8030. /**
  8031. * Gets the shadows Hue value.
  8032. * 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).
  8033. */
  8034. get shadowsHue(): number;
  8035. /**
  8036. * Sets the shadows Hue value.
  8037. * 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).
  8038. */
  8039. set shadowsHue(value: number);
  8040. /**
  8041. * Gets the shadows Density value.
  8042. * 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.
  8043. * Values less than zero provide a filter of opposite hue.
  8044. */
  8045. get shadowsDensity(): number;
  8046. /**
  8047. * Sets the shadows Density value.
  8048. * 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.
  8049. * Values less than zero provide a filter of opposite hue.
  8050. */
  8051. set shadowsDensity(value: number);
  8052. /**
  8053. * Gets the shadows Saturation value.
  8054. * 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.
  8055. */
  8056. get shadowsSaturation(): number;
  8057. /**
  8058. * Sets the shadows Saturation value.
  8059. * 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.
  8060. */
  8061. set shadowsSaturation(value: number);
  8062. /**
  8063. * Gets the shadows Exposure value.
  8064. * 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.
  8065. */
  8066. get shadowsExposure(): number;
  8067. /**
  8068. * Sets the shadows Exposure value.
  8069. * 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.
  8070. */
  8071. set shadowsExposure(value: number);
  8072. /**
  8073. * Returns the class name
  8074. * @returns The class name
  8075. */
  8076. getClassName(): string;
  8077. /**
  8078. * Binds the color curves to the shader.
  8079. * @param colorCurves The color curve to bind
  8080. * @param effect The effect to bind to
  8081. * @param positiveUniform The positive uniform shader parameter
  8082. * @param neutralUniform The neutral uniform shader parameter
  8083. * @param negativeUniform The negative uniform shader parameter
  8084. */
  8085. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8086. /**
  8087. * Prepare the list of uniforms associated with the ColorCurves effects.
  8088. * @param uniformsList The list of uniforms used in the effect
  8089. */
  8090. static PrepareUniforms(uniformsList: string[]): void;
  8091. /**
  8092. * Returns color grading data based on a hue, density, saturation and exposure value.
  8093. * @param filterHue The hue of the color filter.
  8094. * @param filterDensity The density of the color filter.
  8095. * @param saturation The saturation.
  8096. * @param exposure The exposure.
  8097. * @param result The result data container.
  8098. */
  8099. private getColorGradingDataToRef;
  8100. /**
  8101. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8102. * @param value The input slider value in range [-100,100].
  8103. * @returns Adjusted value.
  8104. */
  8105. private static applyColorGradingSliderNonlinear;
  8106. /**
  8107. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8108. * @param hue The hue (H) input.
  8109. * @param saturation The saturation (S) input.
  8110. * @param brightness The brightness (B) input.
  8111. * @result An RGBA color represented as Vector4.
  8112. */
  8113. private static fromHSBToRef;
  8114. /**
  8115. * Returns a value clamped between min and max
  8116. * @param value The value to clamp
  8117. * @param min The minimum of value
  8118. * @param max The maximum of value
  8119. * @returns The clamped value.
  8120. */
  8121. private static clamp;
  8122. /**
  8123. * Clones the current color curve instance.
  8124. * @return The cloned curves
  8125. */
  8126. clone(): ColorCurves;
  8127. /**
  8128. * Serializes the current color curve instance to a json representation.
  8129. * @return a JSON representation
  8130. */
  8131. serialize(): any;
  8132. /**
  8133. * Parses the color curve from a json representation.
  8134. * @param source the JSON source to parse
  8135. * @return The parsed curves
  8136. */
  8137. static Parse(source: any): ColorCurves;
  8138. }
  8139. }
  8140. declare module BABYLON {
  8141. /**
  8142. * Interface to follow in your material defines to integrate easily the
  8143. * Image proccessing functions.
  8144. * @hidden
  8145. */
  8146. export interface IImageProcessingConfigurationDefines {
  8147. IMAGEPROCESSING: boolean;
  8148. VIGNETTE: boolean;
  8149. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8150. VIGNETTEBLENDMODEOPAQUE: boolean;
  8151. TONEMAPPING: boolean;
  8152. TONEMAPPING_ACES: boolean;
  8153. CONTRAST: boolean;
  8154. EXPOSURE: boolean;
  8155. COLORCURVES: boolean;
  8156. COLORGRADING: boolean;
  8157. COLORGRADING3D: boolean;
  8158. SAMPLER3DGREENDEPTH: boolean;
  8159. SAMPLER3DBGRMAP: boolean;
  8160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8161. }
  8162. /**
  8163. * @hidden
  8164. */
  8165. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8166. IMAGEPROCESSING: boolean;
  8167. VIGNETTE: boolean;
  8168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8169. VIGNETTEBLENDMODEOPAQUE: boolean;
  8170. TONEMAPPING: boolean;
  8171. TONEMAPPING_ACES: boolean;
  8172. CONTRAST: boolean;
  8173. COLORCURVES: boolean;
  8174. COLORGRADING: boolean;
  8175. COLORGRADING3D: boolean;
  8176. SAMPLER3DGREENDEPTH: boolean;
  8177. SAMPLER3DBGRMAP: boolean;
  8178. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8179. EXPOSURE: boolean;
  8180. constructor();
  8181. }
  8182. /**
  8183. * This groups together the common properties used for image processing either in direct forward pass
  8184. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8185. * or not.
  8186. */
  8187. export class ImageProcessingConfiguration {
  8188. /**
  8189. * Default tone mapping applied in BabylonJS.
  8190. */
  8191. static readonly TONEMAPPING_STANDARD: number;
  8192. /**
  8193. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8194. * to other engines rendering to increase portability.
  8195. */
  8196. static readonly TONEMAPPING_ACES: number;
  8197. /**
  8198. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8199. */
  8200. colorCurves: Nullable<ColorCurves>;
  8201. private _colorCurvesEnabled;
  8202. /**
  8203. * Gets wether the color curves effect is enabled.
  8204. */
  8205. get colorCurvesEnabled(): boolean;
  8206. /**
  8207. * Sets wether the color curves effect is enabled.
  8208. */
  8209. set colorCurvesEnabled(value: boolean);
  8210. private _colorGradingTexture;
  8211. /**
  8212. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8213. */
  8214. get colorGradingTexture(): Nullable<BaseTexture>;
  8215. /**
  8216. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8217. */
  8218. set colorGradingTexture(value: Nullable<BaseTexture>);
  8219. private _colorGradingEnabled;
  8220. /**
  8221. * Gets wether the color grading effect is enabled.
  8222. */
  8223. get colorGradingEnabled(): boolean;
  8224. /**
  8225. * Sets wether the color grading effect is enabled.
  8226. */
  8227. set colorGradingEnabled(value: boolean);
  8228. private _colorGradingWithGreenDepth;
  8229. /**
  8230. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8231. */
  8232. get colorGradingWithGreenDepth(): boolean;
  8233. /**
  8234. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8235. */
  8236. set colorGradingWithGreenDepth(value: boolean);
  8237. private _colorGradingBGR;
  8238. /**
  8239. * Gets wether the color grading texture contains BGR values.
  8240. */
  8241. get colorGradingBGR(): boolean;
  8242. /**
  8243. * Sets wether the color grading texture contains BGR values.
  8244. */
  8245. set colorGradingBGR(value: boolean);
  8246. /** @hidden */
  8247. _exposure: number;
  8248. /**
  8249. * Gets the Exposure used in the effect.
  8250. */
  8251. get exposure(): number;
  8252. /**
  8253. * Sets the Exposure used in the effect.
  8254. */
  8255. set exposure(value: number);
  8256. private _toneMappingEnabled;
  8257. /**
  8258. * Gets wether the tone mapping effect is enabled.
  8259. */
  8260. get toneMappingEnabled(): boolean;
  8261. /**
  8262. * Sets wether the tone mapping effect is enabled.
  8263. */
  8264. set toneMappingEnabled(value: boolean);
  8265. private _toneMappingType;
  8266. /**
  8267. * Gets the type of tone mapping effect.
  8268. */
  8269. get toneMappingType(): number;
  8270. /**
  8271. * Sets the type of tone mapping effect used in BabylonJS.
  8272. */
  8273. set toneMappingType(value: number);
  8274. protected _contrast: number;
  8275. /**
  8276. * Gets the contrast used in the effect.
  8277. */
  8278. get contrast(): number;
  8279. /**
  8280. * Sets the contrast used in the effect.
  8281. */
  8282. set contrast(value: number);
  8283. /**
  8284. * Vignette stretch size.
  8285. */
  8286. vignetteStretch: number;
  8287. /**
  8288. * Vignette centre X Offset.
  8289. */
  8290. vignetteCentreX: number;
  8291. /**
  8292. * Vignette centre Y Offset.
  8293. */
  8294. vignetteCentreY: number;
  8295. /**
  8296. * Vignette weight or intensity of the vignette effect.
  8297. */
  8298. vignetteWeight: number;
  8299. /**
  8300. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8301. * if vignetteEnabled is set to true.
  8302. */
  8303. vignetteColor: Color4;
  8304. /**
  8305. * Camera field of view used by the Vignette effect.
  8306. */
  8307. vignetteCameraFov: number;
  8308. private _vignetteBlendMode;
  8309. /**
  8310. * Gets the vignette blend mode allowing different kind of effect.
  8311. */
  8312. get vignetteBlendMode(): number;
  8313. /**
  8314. * Sets the vignette blend mode allowing different kind of effect.
  8315. */
  8316. set vignetteBlendMode(value: number);
  8317. private _vignetteEnabled;
  8318. /**
  8319. * Gets wether the vignette effect is enabled.
  8320. */
  8321. get vignetteEnabled(): boolean;
  8322. /**
  8323. * Sets wether the vignette effect is enabled.
  8324. */
  8325. set vignetteEnabled(value: boolean);
  8326. private _applyByPostProcess;
  8327. /**
  8328. * Gets wether the image processing is applied through a post process or not.
  8329. */
  8330. get applyByPostProcess(): boolean;
  8331. /**
  8332. * Sets wether the image processing is applied through a post process or not.
  8333. */
  8334. set applyByPostProcess(value: boolean);
  8335. private _isEnabled;
  8336. /**
  8337. * Gets wether the image processing is enabled or not.
  8338. */
  8339. get isEnabled(): boolean;
  8340. /**
  8341. * Sets wether the image processing is enabled or not.
  8342. */
  8343. set isEnabled(value: boolean);
  8344. /**
  8345. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8346. */
  8347. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8348. /**
  8349. * Method called each time the image processing information changes requires to recompile the effect.
  8350. */
  8351. protected _updateParameters(): void;
  8352. /**
  8353. * Gets the current class name.
  8354. * @return "ImageProcessingConfiguration"
  8355. */
  8356. getClassName(): string;
  8357. /**
  8358. * Prepare the list of uniforms associated with the Image Processing effects.
  8359. * @param uniforms The list of uniforms used in the effect
  8360. * @param defines the list of defines currently in use
  8361. */
  8362. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8363. /**
  8364. * Prepare the list of samplers associated with the Image Processing effects.
  8365. * @param samplersList The list of uniforms used in the effect
  8366. * @param defines the list of defines currently in use
  8367. */
  8368. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8369. /**
  8370. * Prepare the list of defines associated to the shader.
  8371. * @param defines the list of defines to complete
  8372. * @param forPostProcess Define if we are currently in post process mode or not
  8373. */
  8374. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8375. /**
  8376. * Returns true if all the image processing information are ready.
  8377. * @returns True if ready, otherwise, false
  8378. */
  8379. isReady(): boolean;
  8380. /**
  8381. * Binds the image processing to the shader.
  8382. * @param effect The effect to bind to
  8383. * @param overrideAspectRatio Override the aspect ratio of the effect
  8384. */
  8385. bind(effect: Effect, overrideAspectRatio?: number): void;
  8386. /**
  8387. * Clones the current image processing instance.
  8388. * @return The cloned image processing
  8389. */
  8390. clone(): ImageProcessingConfiguration;
  8391. /**
  8392. * Serializes the current image processing instance to a json representation.
  8393. * @return a JSON representation
  8394. */
  8395. serialize(): any;
  8396. /**
  8397. * Parses the image processing from a json representation.
  8398. * @param source the JSON source to parse
  8399. * @return The parsed image processing
  8400. */
  8401. static Parse(source: any): ImageProcessingConfiguration;
  8402. private static _VIGNETTEMODE_MULTIPLY;
  8403. private static _VIGNETTEMODE_OPAQUE;
  8404. /**
  8405. * Used to apply the vignette as a mix with the pixel color.
  8406. */
  8407. static get VIGNETTEMODE_MULTIPLY(): number;
  8408. /**
  8409. * Used to apply the vignette as a replacement of the pixel color.
  8410. */
  8411. static get VIGNETTEMODE_OPAQUE(): number;
  8412. }
  8413. }
  8414. declare module BABYLON {
  8415. /** @hidden */
  8416. export var postprocessVertexShader: {
  8417. name: string;
  8418. shader: string;
  8419. };
  8420. }
  8421. declare module BABYLON {
  8422. interface ThinEngine {
  8423. /**
  8424. * Creates a new render target texture
  8425. * @param size defines the size of the texture
  8426. * @param options defines the options used to create the texture
  8427. * @returns a new render target texture stored in an InternalTexture
  8428. */
  8429. createRenderTargetTexture(size: number | {
  8430. width: number;
  8431. height: number;
  8432. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8433. /**
  8434. * Creates a depth stencil texture.
  8435. * This is only available in WebGL 2 or with the depth texture extension available.
  8436. * @param size The size of face edge in the texture.
  8437. * @param options The options defining the texture.
  8438. * @returns The texture
  8439. */
  8440. createDepthStencilTexture(size: number | {
  8441. width: number;
  8442. height: number;
  8443. }, options: DepthTextureCreationOptions): InternalTexture;
  8444. /** @hidden */
  8445. _createDepthStencilTexture(size: number | {
  8446. width: number;
  8447. height: number;
  8448. }, options: DepthTextureCreationOptions): InternalTexture;
  8449. }
  8450. }
  8451. declare module BABYLON {
  8452. /** Defines supported spaces */
  8453. export enum Space {
  8454. /** Local (object) space */
  8455. LOCAL = 0,
  8456. /** World space */
  8457. WORLD = 1,
  8458. /** Bone space */
  8459. BONE = 2
  8460. }
  8461. /** Defines the 3 main axes */
  8462. export class Axis {
  8463. /** X axis */
  8464. static X: Vector3;
  8465. /** Y axis */
  8466. static Y: Vector3;
  8467. /** Z axis */
  8468. static Z: Vector3;
  8469. }
  8470. }
  8471. declare module BABYLON {
  8472. /**
  8473. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8474. * This is the base of the follow, arc rotate cameras and Free camera
  8475. * @see http://doc.babylonjs.com/features/cameras
  8476. */
  8477. export class TargetCamera extends Camera {
  8478. private static _RigCamTransformMatrix;
  8479. private static _TargetTransformMatrix;
  8480. private static _TargetFocalPoint;
  8481. /**
  8482. * Define the current direction the camera is moving to
  8483. */
  8484. cameraDirection: Vector3;
  8485. /**
  8486. * Define the current rotation the camera is rotating to
  8487. */
  8488. cameraRotation: Vector2;
  8489. /**
  8490. * When set, the up vector of the camera will be updated by the rotation of the camera
  8491. */
  8492. updateUpVectorFromRotation: boolean;
  8493. private _tmpQuaternion;
  8494. /**
  8495. * Define the current rotation of the camera
  8496. */
  8497. rotation: Vector3;
  8498. /**
  8499. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8500. */
  8501. rotationQuaternion: Quaternion;
  8502. /**
  8503. * Define the current speed of the camera
  8504. */
  8505. speed: number;
  8506. /**
  8507. * Add constraint to the camera to prevent it to move freely in all directions and
  8508. * around all axis.
  8509. */
  8510. noRotationConstraint: boolean;
  8511. /**
  8512. * Define the current target of the camera as an object or a position.
  8513. */
  8514. lockedTarget: any;
  8515. /** @hidden */
  8516. _currentTarget: Vector3;
  8517. /** @hidden */
  8518. _initialFocalDistance: number;
  8519. /** @hidden */
  8520. _viewMatrix: Matrix;
  8521. /** @hidden */
  8522. _camMatrix: Matrix;
  8523. /** @hidden */
  8524. _cameraTransformMatrix: Matrix;
  8525. /** @hidden */
  8526. _cameraRotationMatrix: Matrix;
  8527. /** @hidden */
  8528. _referencePoint: Vector3;
  8529. /** @hidden */
  8530. _transformedReferencePoint: Vector3;
  8531. protected _globalCurrentTarget: Vector3;
  8532. protected _globalCurrentUpVector: Vector3;
  8533. /** @hidden */
  8534. _reset: () => void;
  8535. private _defaultUp;
  8536. /**
  8537. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. * @param name Defines the name of the camera in the scene
  8541. * @param position Defines the start position of the camera in the scene
  8542. * @param scene Defines the scene the camera belongs to
  8543. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8544. */
  8545. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8546. /**
  8547. * Gets the position in front of the camera at a given distance.
  8548. * @param distance The distance from the camera we want the position to be
  8549. * @returns the position
  8550. */
  8551. getFrontPosition(distance: number): Vector3;
  8552. /** @hidden */
  8553. _getLockedTargetPosition(): Nullable<Vector3>;
  8554. private _storedPosition;
  8555. private _storedRotation;
  8556. private _storedRotationQuaternion;
  8557. /**
  8558. * Store current camera state of the camera (fov, position, rotation, etc..)
  8559. * @returns the camera
  8560. */
  8561. storeState(): Camera;
  8562. /**
  8563. * Restored camera state. You must call storeState() first
  8564. * @returns whether it was successful or not
  8565. * @hidden
  8566. */
  8567. _restoreStateValues(): boolean;
  8568. /** @hidden */
  8569. _initCache(): void;
  8570. /** @hidden */
  8571. _updateCache(ignoreParentClass?: boolean): void;
  8572. /** @hidden */
  8573. _isSynchronizedViewMatrix(): boolean;
  8574. /** @hidden */
  8575. _computeLocalCameraSpeed(): number;
  8576. /**
  8577. * Defines the target the camera should look at.
  8578. * @param target Defines the new target as a Vector or a mesh
  8579. */
  8580. setTarget(target: Vector3): void;
  8581. /**
  8582. * Return the current target position of the camera. This value is expressed in local space.
  8583. * @returns the target position
  8584. */
  8585. getTarget(): Vector3;
  8586. /** @hidden */
  8587. _decideIfNeedsToMove(): boolean;
  8588. /** @hidden */
  8589. _updatePosition(): void;
  8590. /** @hidden */
  8591. _checkInputs(): void;
  8592. protected _updateCameraRotationMatrix(): void;
  8593. /**
  8594. * 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)
  8595. * @returns the current camera
  8596. */
  8597. private _rotateUpVectorWithCameraRotationMatrix;
  8598. private _cachedRotationZ;
  8599. private _cachedQuaternionRotationZ;
  8600. /** @hidden */
  8601. _getViewMatrix(): Matrix;
  8602. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8603. /**
  8604. * @hidden
  8605. */
  8606. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8607. /**
  8608. * @hidden
  8609. */
  8610. _updateRigCameras(): void;
  8611. private _getRigCamPositionAndTarget;
  8612. /**
  8613. * Gets the current object class name.
  8614. * @return the class name
  8615. */
  8616. getClassName(): string;
  8617. }
  8618. }
  8619. declare module BABYLON {
  8620. /**
  8621. * Gather the list of keyboard event types as constants.
  8622. */
  8623. export class KeyboardEventTypes {
  8624. /**
  8625. * The keydown event is fired when a key becomes active (pressed).
  8626. */
  8627. static readonly KEYDOWN: number;
  8628. /**
  8629. * The keyup event is fired when a key has been released.
  8630. */
  8631. static readonly KEYUP: number;
  8632. }
  8633. /**
  8634. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8635. */
  8636. export class KeyboardInfo {
  8637. /**
  8638. * Defines the type of event (KeyboardEventTypes)
  8639. */
  8640. type: number;
  8641. /**
  8642. * Defines the related dom event
  8643. */
  8644. event: KeyboardEvent;
  8645. /**
  8646. * Instantiates a new keyboard info.
  8647. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8648. * @param type Defines the type of event (KeyboardEventTypes)
  8649. * @param event Defines the related dom event
  8650. */
  8651. constructor(
  8652. /**
  8653. * Defines the type of event (KeyboardEventTypes)
  8654. */
  8655. type: number,
  8656. /**
  8657. * Defines the related dom event
  8658. */
  8659. event: KeyboardEvent);
  8660. }
  8661. /**
  8662. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8663. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8664. */
  8665. export class KeyboardInfoPre extends KeyboardInfo {
  8666. /**
  8667. * Defines the type of event (KeyboardEventTypes)
  8668. */
  8669. type: number;
  8670. /**
  8671. * Defines the related dom event
  8672. */
  8673. event: KeyboardEvent;
  8674. /**
  8675. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8676. */
  8677. skipOnPointerObservable: boolean;
  8678. /**
  8679. * Instantiates a new keyboard pre info.
  8680. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8681. * @param type Defines the type of event (KeyboardEventTypes)
  8682. * @param event Defines the related dom event
  8683. */
  8684. constructor(
  8685. /**
  8686. * Defines the type of event (KeyboardEventTypes)
  8687. */
  8688. type: number,
  8689. /**
  8690. * Defines the related dom event
  8691. */
  8692. event: KeyboardEvent);
  8693. }
  8694. }
  8695. declare module BABYLON {
  8696. /**
  8697. * Manage the keyboard inputs to control the movement of a free camera.
  8698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8699. */
  8700. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8701. /**
  8702. * Defines the camera the input is attached to.
  8703. */
  8704. camera: FreeCamera;
  8705. /**
  8706. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8707. */
  8708. keysUp: number[];
  8709. /**
  8710. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8711. */
  8712. keysDown: number[];
  8713. /**
  8714. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8715. */
  8716. keysLeft: number[];
  8717. /**
  8718. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8719. */
  8720. keysRight: number[];
  8721. private _keys;
  8722. private _onCanvasBlurObserver;
  8723. private _onKeyboardObserver;
  8724. private _engine;
  8725. private _scene;
  8726. /**
  8727. * Attach the input controls to a specific dom element to get the input from.
  8728. * @param element Defines the element the controls should be listened from
  8729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8730. */
  8731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8732. /**
  8733. * Detach the current controls from the specified dom element.
  8734. * @param element Defines the element to stop listening the inputs from
  8735. */
  8736. detachControl(element: Nullable<HTMLElement>): void;
  8737. /**
  8738. * Update the current camera state depending on the inputs that have been used this frame.
  8739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8740. */
  8741. checkInputs(): void;
  8742. /**
  8743. * Gets the class name of the current intput.
  8744. * @returns the class name
  8745. */
  8746. getClassName(): string;
  8747. /** @hidden */
  8748. _onLostFocus(): void;
  8749. /**
  8750. * Get the friendly name associated with the input class.
  8751. * @returns the input friendly name
  8752. */
  8753. getSimpleName(): string;
  8754. }
  8755. }
  8756. declare module BABYLON {
  8757. /**
  8758. * Interface describing all the common properties and methods a shadow light needs to implement.
  8759. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8760. * as well as binding the different shadow properties to the effects.
  8761. */
  8762. export interface IShadowLight extends Light {
  8763. /**
  8764. * The light id in the scene (used in scene.findLighById for instance)
  8765. */
  8766. id: string;
  8767. /**
  8768. * The position the shdow will be casted from.
  8769. */
  8770. position: Vector3;
  8771. /**
  8772. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8773. */
  8774. direction: Vector3;
  8775. /**
  8776. * The transformed position. Position of the light in world space taking parenting in account.
  8777. */
  8778. transformedPosition: Vector3;
  8779. /**
  8780. * The transformed direction. Direction of the light in world space taking parenting in account.
  8781. */
  8782. transformedDirection: Vector3;
  8783. /**
  8784. * The friendly name of the light in the scene.
  8785. */
  8786. name: string;
  8787. /**
  8788. * Defines the shadow projection clipping minimum z value.
  8789. */
  8790. shadowMinZ: number;
  8791. /**
  8792. * Defines the shadow projection clipping maximum z value.
  8793. */
  8794. shadowMaxZ: number;
  8795. /**
  8796. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8797. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8798. */
  8799. computeTransformedInformation(): boolean;
  8800. /**
  8801. * Gets the scene the light belongs to.
  8802. * @returns The scene
  8803. */
  8804. getScene(): Scene;
  8805. /**
  8806. * Callback defining a custom Projection Matrix Builder.
  8807. * This can be used to override the default projection matrix computation.
  8808. */
  8809. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8810. /**
  8811. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8812. * @param matrix The materix to updated with the projection information
  8813. * @param viewMatrix The transform matrix of the light
  8814. * @param renderList The list of mesh to render in the map
  8815. * @returns The current light
  8816. */
  8817. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8818. /**
  8819. * Gets the current depth scale used in ESM.
  8820. * @returns The scale
  8821. */
  8822. getDepthScale(): number;
  8823. /**
  8824. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8825. * @returns true if a cube texture needs to be use
  8826. */
  8827. needCube(): boolean;
  8828. /**
  8829. * Detects if the projection matrix requires to be recomputed this frame.
  8830. * @returns true if it requires to be recomputed otherwise, false.
  8831. */
  8832. needProjectionMatrixCompute(): boolean;
  8833. /**
  8834. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8835. */
  8836. forceProjectionMatrixCompute(): void;
  8837. /**
  8838. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8839. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8840. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8841. */
  8842. getShadowDirection(faceIndex?: number): Vector3;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. }
  8856. /**
  8857. * Base implementation IShadowLight
  8858. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8859. */
  8860. export abstract class ShadowLight extends Light implements IShadowLight {
  8861. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8862. protected _position: Vector3;
  8863. protected _setPosition(value: Vector3): void;
  8864. /**
  8865. * Sets the position the shadow will be casted from. Also use as the light position for both
  8866. * point and spot lights.
  8867. */
  8868. get position(): Vector3;
  8869. /**
  8870. * Sets the position the shadow will be casted from. Also use as the light position for both
  8871. * point and spot lights.
  8872. */
  8873. set position(value: Vector3);
  8874. protected _direction: Vector3;
  8875. protected _setDirection(value: Vector3): void;
  8876. /**
  8877. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8878. * Also use as the light direction on spot and directional lights.
  8879. */
  8880. get direction(): Vector3;
  8881. /**
  8882. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8883. * Also use as the light direction on spot and directional lights.
  8884. */
  8885. set direction(value: Vector3);
  8886. private _shadowMinZ;
  8887. /**
  8888. * Gets the shadow projection clipping minimum z value.
  8889. */
  8890. get shadowMinZ(): number;
  8891. /**
  8892. * Sets the shadow projection clipping minimum z value.
  8893. */
  8894. set shadowMinZ(value: number);
  8895. private _shadowMaxZ;
  8896. /**
  8897. * Sets the shadow projection clipping maximum z value.
  8898. */
  8899. get shadowMaxZ(): number;
  8900. /**
  8901. * Gets the shadow projection clipping maximum z value.
  8902. */
  8903. set shadowMaxZ(value: number);
  8904. /**
  8905. * Callback defining a custom Projection Matrix Builder.
  8906. * This can be used to override the default projection matrix computation.
  8907. */
  8908. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8909. /**
  8910. * The transformed position. Position of the light in world space taking parenting in account.
  8911. */
  8912. transformedPosition: Vector3;
  8913. /**
  8914. * The transformed direction. Direction of the light in world space taking parenting in account.
  8915. */
  8916. transformedDirection: Vector3;
  8917. private _needProjectionMatrixCompute;
  8918. /**
  8919. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8920. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8921. */
  8922. computeTransformedInformation(): boolean;
  8923. /**
  8924. * Return the depth scale used for the shadow map.
  8925. * @returns the depth scale.
  8926. */
  8927. getDepthScale(): number;
  8928. /**
  8929. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8930. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8931. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8932. */
  8933. getShadowDirection(faceIndex?: number): Vector3;
  8934. /**
  8935. * Returns the ShadowLight absolute position in the World.
  8936. * @returns the position vector in world space
  8937. */
  8938. getAbsolutePosition(): Vector3;
  8939. /**
  8940. * Sets the ShadowLight direction toward the passed target.
  8941. * @param target The point to target in local space
  8942. * @returns the updated ShadowLight direction
  8943. */
  8944. setDirectionToTarget(target: Vector3): Vector3;
  8945. /**
  8946. * Returns the light rotation in euler definition.
  8947. * @returns the x y z rotation in local space.
  8948. */
  8949. getRotation(): Vector3;
  8950. /**
  8951. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8952. * @returns true if a cube texture needs to be use
  8953. */
  8954. needCube(): boolean;
  8955. /**
  8956. * Detects if the projection matrix requires to be recomputed this frame.
  8957. * @returns true if it requires to be recomputed otherwise, false.
  8958. */
  8959. needProjectionMatrixCompute(): boolean;
  8960. /**
  8961. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8962. */
  8963. forceProjectionMatrixCompute(): void;
  8964. /** @hidden */
  8965. _initCache(): void;
  8966. /** @hidden */
  8967. _isSynchronized(): boolean;
  8968. /**
  8969. * Computes the world matrix of the node
  8970. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8971. * @returns the world matrix
  8972. */
  8973. computeWorldMatrix(force?: boolean): Matrix;
  8974. /**
  8975. * Gets the minZ used for shadow according to both the scene and the light.
  8976. * @param activeCamera The camera we are returning the min for
  8977. * @returns the depth min z
  8978. */
  8979. getDepthMinZ(activeCamera: Camera): number;
  8980. /**
  8981. * Gets the maxZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the max for
  8983. * @returns the depth max z
  8984. */
  8985. getDepthMaxZ(activeCamera: Camera): number;
  8986. /**
  8987. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8988. * @param matrix The materix to updated with the projection information
  8989. * @param viewMatrix The transform matrix of the light
  8990. * @param renderList The list of mesh to render in the map
  8991. * @returns The current light
  8992. */
  8993. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8994. }
  8995. }
  8996. declare module BABYLON {
  8997. /**
  8998. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8999. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9000. */
  9001. export class EffectFallbacks implements IEffectFallbacks {
  9002. private _defines;
  9003. private _currentRank;
  9004. private _maxRank;
  9005. private _mesh;
  9006. /**
  9007. * Removes the fallback from the bound mesh.
  9008. */
  9009. unBindMesh(): void;
  9010. /**
  9011. * Adds a fallback on the specified property.
  9012. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9013. * @param define The name of the define in the shader
  9014. */
  9015. addFallback(rank: number, define: string): void;
  9016. /**
  9017. * Sets the mesh to use CPU skinning when needing to fallback.
  9018. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9019. * @param mesh The mesh to use the fallbacks.
  9020. */
  9021. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9022. /**
  9023. * Checks to see if more fallbacks are still availible.
  9024. */
  9025. get hasMoreFallbacks(): boolean;
  9026. /**
  9027. * Removes the defines that should be removed when falling back.
  9028. * @param currentDefines defines the current define statements for the shader.
  9029. * @param effect defines the current effect we try to compile
  9030. * @returns The resulting defines with defines of the current rank removed.
  9031. */
  9032. reduce(currentDefines: string, effect: Effect): string;
  9033. }
  9034. }
  9035. declare module BABYLON {
  9036. /**
  9037. * "Static Class" containing the most commonly used helper while dealing with material for
  9038. * rendering purpose.
  9039. *
  9040. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9041. *
  9042. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9043. */
  9044. export class MaterialHelper {
  9045. /**
  9046. * Bind the current view position to an effect.
  9047. * @param effect The effect to be bound
  9048. * @param scene The scene the eyes position is used from
  9049. */
  9050. static BindEyePosition(effect: Effect, scene: Scene): void;
  9051. /**
  9052. * Helps preparing the defines values about the UVs in used in the effect.
  9053. * UVs are shared as much as we can accross channels in the shaders.
  9054. * @param texture The texture we are preparing the UVs for
  9055. * @param defines The defines to update
  9056. * @param key The channel key "diffuse", "specular"... used in the shader
  9057. */
  9058. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9059. /**
  9060. * Binds a texture matrix value to its corrsponding uniform
  9061. * @param texture The texture to bind the matrix for
  9062. * @param uniformBuffer The uniform buffer receivin the data
  9063. * @param key The channel key "diffuse", "specular"... used in the shader
  9064. */
  9065. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9066. /**
  9067. * Gets the current status of the fog (should it be enabled?)
  9068. * @param mesh defines the mesh to evaluate for fog support
  9069. * @param scene defines the hosting scene
  9070. * @returns true if fog must be enabled
  9071. */
  9072. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9073. /**
  9074. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9075. * @param mesh defines the current mesh
  9076. * @param scene defines the current scene
  9077. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9078. * @param pointsCloud defines if point cloud rendering has to be turned on
  9079. * @param fogEnabled defines if fog has to be turned on
  9080. * @param alphaTest defines if alpha testing has to be turned on
  9081. * @param defines defines the current list of defines
  9082. */
  9083. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9084. /**
  9085. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9086. * @param scene defines the current scene
  9087. * @param engine defines the current engine
  9088. * @param defines specifies the list of active defines
  9089. * @param useInstances defines if instances have to be turned on
  9090. * @param useClipPlane defines if clip plane have to be turned on
  9091. */
  9092. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9093. /**
  9094. * Prepares the defines for bones
  9095. * @param mesh The mesh containing the geometry data we will draw
  9096. * @param defines The defines to update
  9097. */
  9098. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9099. /**
  9100. * Prepares the defines for morph targets
  9101. * @param mesh The mesh containing the geometry data we will draw
  9102. * @param defines The defines to update
  9103. */
  9104. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9105. /**
  9106. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9107. * @param mesh The mesh containing the geometry data we will draw
  9108. * @param defines The defines to update
  9109. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9110. * @param useBones Precise whether bones should be used or not (override mesh info)
  9111. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9112. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9113. * @returns false if defines are considered not dirty and have not been checked
  9114. */
  9115. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9116. /**
  9117. * Prepares the defines related to multiview
  9118. * @param scene The scene we are intending to draw
  9119. * @param defines The defines to update
  9120. */
  9121. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9122. /**
  9123. * Prepares the defines related to the light information passed in parameter
  9124. * @param scene The scene we are intending to draw
  9125. * @param mesh The mesh the effect is compiling for
  9126. * @param light The light the effect is compiling for
  9127. * @param lightIndex The index of the light
  9128. * @param defines The defines to update
  9129. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9130. * @param state Defines the current state regarding what is needed (normals, etc...)
  9131. */
  9132. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9133. needNormals: boolean;
  9134. needRebuild: boolean;
  9135. shadowEnabled: boolean;
  9136. specularEnabled: boolean;
  9137. lightmapMode: boolean;
  9138. }): void;
  9139. /**
  9140. * Prepares the defines related to the light information passed in parameter
  9141. * @param scene The scene we are intending to draw
  9142. * @param mesh The mesh the effect is compiling for
  9143. * @param defines The defines to update
  9144. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9145. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9146. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9147. * @returns true if normals will be required for the rest of the effect
  9148. */
  9149. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9150. /**
  9151. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9152. * @param lightIndex defines the light index
  9153. * @param uniformsList The uniform list
  9154. * @param samplersList The sampler list
  9155. * @param projectedLightTexture defines if projected texture must be used
  9156. * @param uniformBuffersList defines an optional list of uniform buffers
  9157. */
  9158. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9159. /**
  9160. * Prepares the uniforms and samplers list to be used in the effect
  9161. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9162. * @param samplersList The sampler list
  9163. * @param defines The defines helping in the list generation
  9164. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9165. */
  9166. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9167. /**
  9168. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9169. * @param defines The defines to update while falling back
  9170. * @param fallbacks The authorized effect fallbacks
  9171. * @param maxSimultaneousLights The maximum number of lights allowed
  9172. * @param rank the current rank of the Effect
  9173. * @returns The newly affected rank
  9174. */
  9175. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9176. private static _TmpMorphInfluencers;
  9177. /**
  9178. * Prepares the list of attributes required for morph targets according to the effect defines.
  9179. * @param attribs The current list of supported attribs
  9180. * @param mesh The mesh to prepare the morph targets attributes for
  9181. * @param influencers The number of influencers
  9182. */
  9183. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9184. /**
  9185. * Prepares the list of attributes required for morph targets according to the effect defines.
  9186. * @param attribs The current list of supported attribs
  9187. * @param mesh The mesh to prepare the morph targets attributes for
  9188. * @param defines The current Defines of the effect
  9189. */
  9190. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9191. /**
  9192. * Prepares the list of attributes required for bones according to the effect defines.
  9193. * @param attribs The current list of supported attribs
  9194. * @param mesh The mesh to prepare the bones attributes for
  9195. * @param defines The current Defines of the effect
  9196. * @param fallbacks The current efffect fallback strategy
  9197. */
  9198. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9199. /**
  9200. * Check and prepare the list of attributes required for instances according to the effect defines.
  9201. * @param attribs The current list of supported attribs
  9202. * @param defines The current MaterialDefines of the effect
  9203. */
  9204. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9205. /**
  9206. * Add the list of attributes required for instances to the attribs array.
  9207. * @param attribs The current list of supported attribs
  9208. */
  9209. static PushAttributesForInstances(attribs: string[]): void;
  9210. /**
  9211. * Binds the light information to the effect.
  9212. * @param light The light containing the generator
  9213. * @param effect The effect we are binding the data to
  9214. * @param lightIndex The light index in the effect used to render
  9215. */
  9216. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9217. /**
  9218. * Binds the lights information from the scene to the effect for the given mesh.
  9219. * @param light Light to bind
  9220. * @param lightIndex Light index
  9221. * @param scene The scene where the light belongs to
  9222. * @param effect The effect we are binding the data to
  9223. * @param useSpecular Defines if specular is supported
  9224. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9225. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9226. */
  9227. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9228. /**
  9229. * Binds the lights 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 defines The generated defines for the effect
  9234. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9235. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9236. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9237. */
  9238. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9239. private static _tempFogColor;
  9240. /**
  9241. * Binds the fog information from the scene to the effect for the given mesh.
  9242. * @param scene The scene the lights belongs to
  9243. * @param mesh The mesh we are binding the information to render
  9244. * @param effect The effect we are binding the data to
  9245. * @param linearSpace Defines if the fog effect is applied in linear space
  9246. */
  9247. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9248. /**
  9249. * Binds the bones information from the mesh to the effect.
  9250. * @param mesh The mesh we are binding the information to render
  9251. * @param effect The effect we are binding the data to
  9252. */
  9253. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9254. /**
  9255. * Binds the morph targets information from the mesh to the effect.
  9256. * @param abstractMesh The mesh we are binding the information to render
  9257. * @param effect The effect we are binding the data to
  9258. */
  9259. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9260. /**
  9261. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9262. * @param defines The generated defines used in the effect
  9263. * @param effect The effect we are binding the data to
  9264. * @param scene The scene we are willing to render with logarithmic scale for
  9265. */
  9266. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9267. /**
  9268. * Binds the clip plane information from the scene to the effect.
  9269. * @param scene The scene the clip plane information are extracted from
  9270. * @param effect The effect we are binding the data to
  9271. */
  9272. static BindClipPlane(effect: Effect, scene: Scene): void;
  9273. }
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var packingFunctions: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var shadowMapPixelShader: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var bonesDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var morphTargetsVertexGlobalDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var morphTargetsVertexDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var instancesDeclaration: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var helperFunctions: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var morphTargetsVertex: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var instancesVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var bonesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var shadowMapVertexShader: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var depthBoxBlurPixelShader: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /**
  9361. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9362. */
  9363. export interface ICustomShaderOptions {
  9364. /**
  9365. * Gets or sets the custom shader name to use
  9366. */
  9367. shaderName: string;
  9368. /**
  9369. * The list of attribute names used in the shader
  9370. */
  9371. attributes?: string[];
  9372. /**
  9373. * The list of unifrom names used in the shader
  9374. */
  9375. uniforms?: string[];
  9376. /**
  9377. * The list of sampler names used in the shader
  9378. */
  9379. samplers?: string[];
  9380. /**
  9381. * The list of defines used in the shader
  9382. */
  9383. defines?: string[];
  9384. }
  9385. /**
  9386. * Interface to implement to create a shadow generator compatible with BJS.
  9387. */
  9388. export interface IShadowGenerator {
  9389. /**
  9390. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9391. * @returns The render target texture if present otherwise, null
  9392. */
  9393. getShadowMap(): Nullable<RenderTargetTexture>;
  9394. /**
  9395. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9396. * @returns The render target texture if the shadow map is present otherwise, null
  9397. */
  9398. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9399. /**
  9400. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9401. * @param subMesh The submesh we want to render in the shadow map
  9402. * @param useInstances Defines wether will draw in the map using instances
  9403. * @returns true if ready otherwise, false
  9404. */
  9405. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9406. /**
  9407. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9408. * @param defines Defines of the material we want to update
  9409. * @param lightIndex Index of the light in the enabled light list of the material
  9410. */
  9411. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9412. /**
  9413. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9414. * defined in the generator but impacting the effect).
  9415. * It implies the unifroms available on the materials are the standard BJS ones.
  9416. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9417. * @param effect The effect we are binfing the information for
  9418. */
  9419. bindShadowLight(lightIndex: string, effect: Effect): void;
  9420. /**
  9421. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9422. * (eq to shadow prjection matrix * light transform matrix)
  9423. * @returns The transform matrix used to create the shadow map
  9424. */
  9425. getTransformMatrix(): Matrix;
  9426. /**
  9427. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9428. * Cube and 2D textures for instance.
  9429. */
  9430. recreateShadowMap(): void;
  9431. /**
  9432. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9433. * @param onCompiled Callback triggered at the and of the effects compilation
  9434. * @param options Sets of optional options forcing the compilation with different modes
  9435. */
  9436. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9437. useInstances: boolean;
  9438. }>): void;
  9439. /**
  9440. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9441. * @param options Sets of optional options forcing the compilation with different modes
  9442. * @returns A promise that resolves when the compilation completes
  9443. */
  9444. forceCompilationAsync(options?: Partial<{
  9445. useInstances: boolean;
  9446. }>): Promise<void>;
  9447. /**
  9448. * Serializes the shadow generator setup to a json object.
  9449. * @returns The serialized JSON object
  9450. */
  9451. serialize(): any;
  9452. /**
  9453. * Disposes the Shadow map and related Textures and effects.
  9454. */
  9455. dispose(): void;
  9456. }
  9457. /**
  9458. * Default implementation IShadowGenerator.
  9459. * This is the main object responsible of generating shadows in the framework.
  9460. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9461. */
  9462. export class ShadowGenerator implements IShadowGenerator {
  9463. /**
  9464. * Shadow generator mode None: no filtering applied.
  9465. */
  9466. static readonly FILTER_NONE: number;
  9467. /**
  9468. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9469. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9470. */
  9471. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9472. /**
  9473. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9474. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9475. */
  9476. static readonly FILTER_POISSONSAMPLING: number;
  9477. /**
  9478. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9480. */
  9481. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9482. /**
  9483. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9484. * edge artifacts on steep falloff.
  9485. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9486. */
  9487. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9488. /**
  9489. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9490. * edge artifacts on steep falloff.
  9491. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9492. */
  9493. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9494. /**
  9495. * Shadow generator mode PCF: Percentage Closer Filtering
  9496. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9497. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9498. */
  9499. static readonly FILTER_PCF: number;
  9500. /**
  9501. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9502. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9503. * Contact Hardening
  9504. */
  9505. static readonly FILTER_PCSS: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * Highest Quality.
  9509. *
  9510. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9511. *
  9512. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9513. */
  9514. static readonly QUALITY_HIGH: number;
  9515. /**
  9516. * Reserved for PCF and PCSS
  9517. * Good tradeoff for quality/perf cross devices
  9518. *
  9519. * Execute PCF on a 3*3 kernel.
  9520. *
  9521. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9522. */
  9523. static readonly QUALITY_MEDIUM: number;
  9524. /**
  9525. * Reserved for PCF and PCSS
  9526. * The lowest quality but the fastest.
  9527. *
  9528. * Execute PCF on a 1*1 kernel.
  9529. *
  9530. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9531. */
  9532. static readonly QUALITY_LOW: number;
  9533. /** Gets or sets the custom shader name to use */
  9534. customShaderOptions: ICustomShaderOptions;
  9535. /**
  9536. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9537. */
  9538. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9539. /**
  9540. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9541. */
  9542. onAfterShadowMapRenderObservable: Observable<Effect>;
  9543. /**
  9544. * Observable triggered before a mesh is rendered in the shadow map.
  9545. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9546. */
  9547. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9548. /**
  9549. * Observable triggered after a mesh is rendered in the shadow map.
  9550. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9551. */
  9552. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9553. private _bias;
  9554. /**
  9555. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9556. */
  9557. get bias(): number;
  9558. /**
  9559. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9560. */
  9561. set bias(bias: number);
  9562. private _normalBias;
  9563. /**
  9564. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9565. */
  9566. get normalBias(): number;
  9567. /**
  9568. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9569. */
  9570. set normalBias(normalBias: number);
  9571. private _blurBoxOffset;
  9572. /**
  9573. * Gets the blur box offset: offset applied during the blur pass.
  9574. * Only useful if useKernelBlur = false
  9575. */
  9576. get blurBoxOffset(): number;
  9577. /**
  9578. * Sets the blur box offset: offset applied during the blur pass.
  9579. * Only useful if useKernelBlur = false
  9580. */
  9581. set blurBoxOffset(value: number);
  9582. private _blurScale;
  9583. /**
  9584. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9585. * 2 means half of the size.
  9586. */
  9587. get blurScale(): number;
  9588. /**
  9589. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9590. * 2 means half of the size.
  9591. */
  9592. set blurScale(value: number);
  9593. private _blurKernel;
  9594. /**
  9595. * Gets the blur kernel: kernel size of the blur pass.
  9596. * Only useful if useKernelBlur = true
  9597. */
  9598. get blurKernel(): number;
  9599. /**
  9600. * Sets the blur kernel: kernel size of the blur pass.
  9601. * Only useful if useKernelBlur = true
  9602. */
  9603. set blurKernel(value: number);
  9604. private _useKernelBlur;
  9605. /**
  9606. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9607. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9608. */
  9609. get useKernelBlur(): boolean;
  9610. /**
  9611. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9613. */
  9614. set useKernelBlur(value: boolean);
  9615. private _depthScale;
  9616. /**
  9617. * Gets the depth scale used in ESM mode.
  9618. */
  9619. get depthScale(): number;
  9620. /**
  9621. * Sets the depth scale used in ESM mode.
  9622. * This can override the scale stored on the light.
  9623. */
  9624. set depthScale(value: number);
  9625. private _filter;
  9626. /**
  9627. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9628. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9629. */
  9630. get filter(): number;
  9631. /**
  9632. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9633. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9634. */
  9635. set filter(value: number);
  9636. /**
  9637. * Gets if the current filter is set to Poisson Sampling.
  9638. */
  9639. get usePoissonSampling(): boolean;
  9640. /**
  9641. * Sets the current filter to Poisson Sampling.
  9642. */
  9643. set usePoissonSampling(value: boolean);
  9644. /**
  9645. * Gets if the current filter is set to ESM.
  9646. */
  9647. get useExponentialShadowMap(): boolean;
  9648. /**
  9649. * Sets the current filter is to ESM.
  9650. */
  9651. set useExponentialShadowMap(value: boolean);
  9652. /**
  9653. * Gets if the current filter is set to filtered ESM.
  9654. */
  9655. get useBlurExponentialShadowMap(): boolean;
  9656. /**
  9657. * Gets if the current filter is set to filtered ESM.
  9658. */
  9659. set useBlurExponentialShadowMap(value: boolean);
  9660. /**
  9661. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9662. * exponential to prevent steep falloff artifacts).
  9663. */
  9664. get useCloseExponentialShadowMap(): boolean;
  9665. /**
  9666. * Sets the current filter to "close ESM" (using the inverse of the
  9667. * exponential to prevent steep falloff artifacts).
  9668. */
  9669. set useCloseExponentialShadowMap(value: boolean);
  9670. /**
  9671. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9672. * exponential to prevent steep falloff artifacts).
  9673. */
  9674. get useBlurCloseExponentialShadowMap(): boolean;
  9675. /**
  9676. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9677. * exponential to prevent steep falloff artifacts).
  9678. */
  9679. set useBlurCloseExponentialShadowMap(value: boolean);
  9680. /**
  9681. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9682. */
  9683. get usePercentageCloserFiltering(): boolean;
  9684. /**
  9685. * Sets the current filter to "PCF" (percentage closer filtering).
  9686. */
  9687. set usePercentageCloserFiltering(value: boolean);
  9688. private _filteringQuality;
  9689. /**
  9690. * Gets the PCF or PCSS Quality.
  9691. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9692. */
  9693. get filteringQuality(): number;
  9694. /**
  9695. * Sets the PCF or PCSS Quality.
  9696. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9697. */
  9698. set filteringQuality(filteringQuality: number);
  9699. /**
  9700. * Gets if the current filter is set to "PCSS" (contact hardening).
  9701. */
  9702. get useContactHardeningShadow(): boolean;
  9703. /**
  9704. * Sets the current filter to "PCSS" (contact hardening).
  9705. */
  9706. set useContactHardeningShadow(value: boolean);
  9707. private _contactHardeningLightSizeUVRatio;
  9708. /**
  9709. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9710. * Using a ratio helps keeping shape stability independently of the map size.
  9711. *
  9712. * It does not account for the light projection as it was having too much
  9713. * instability during the light setup or during light position changes.
  9714. *
  9715. * Only valid if useContactHardeningShadow is true.
  9716. */
  9717. get contactHardeningLightSizeUVRatio(): number;
  9718. /**
  9719. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9720. * Using a ratio helps keeping shape stability independently of the map size.
  9721. *
  9722. * It does not account for the light projection as it was having too much
  9723. * instability during the light setup or during light position changes.
  9724. *
  9725. * Only valid if useContactHardeningShadow is true.
  9726. */
  9727. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9728. private _darkness;
  9729. /** Gets or sets the actual darkness of a shadow */
  9730. get darkness(): number;
  9731. set darkness(value: number);
  9732. /**
  9733. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9734. * 0 means strongest and 1 would means no shadow.
  9735. * @returns the darkness.
  9736. */
  9737. getDarkness(): number;
  9738. /**
  9739. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9740. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9741. * @returns the shadow generator allowing fluent coding.
  9742. */
  9743. setDarkness(darkness: number): ShadowGenerator;
  9744. private _transparencyShadow;
  9745. /** Gets or sets the ability to have transparent shadow */
  9746. get transparencyShadow(): boolean;
  9747. set transparencyShadow(value: boolean);
  9748. /**
  9749. * Sets the ability to have transparent shadow (boolean).
  9750. * @param transparent True if transparent else False
  9751. * @returns the shadow generator allowing fluent coding
  9752. */
  9753. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9754. private _shadowMap;
  9755. private _shadowMap2;
  9756. /**
  9757. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9758. * @returns The render target texture if present otherwise, null
  9759. */
  9760. getShadowMap(): Nullable<RenderTargetTexture>;
  9761. /**
  9762. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9763. * @returns The render target texture if the shadow map is present otherwise, null
  9764. */
  9765. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9766. /**
  9767. * Gets the class name of that object
  9768. * @returns "ShadowGenerator"
  9769. */
  9770. getClassName(): string;
  9771. /**
  9772. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9773. * @param mesh Mesh to add
  9774. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9775. * @returns the Shadow Generator itself
  9776. */
  9777. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9778. /**
  9779. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9780. * @param mesh Mesh to remove
  9781. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9782. * @returns the Shadow Generator itself
  9783. */
  9784. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9785. /**
  9786. * Controls the extent to which the shadows fade out at the edge of the frustum
  9787. * Used only by directionals and spots
  9788. */
  9789. frustumEdgeFalloff: number;
  9790. private _light;
  9791. /**
  9792. * Returns the associated light object.
  9793. * @returns the light generating the shadow
  9794. */
  9795. getLight(): IShadowLight;
  9796. /**
  9797. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9798. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9799. * It might on the other hand introduce peter panning.
  9800. */
  9801. forceBackFacesOnly: boolean;
  9802. private _scene;
  9803. private _lightDirection;
  9804. private _effect;
  9805. private _viewMatrix;
  9806. private _projectionMatrix;
  9807. private _transformMatrix;
  9808. private _cachedPosition;
  9809. private _cachedDirection;
  9810. private _cachedDefines;
  9811. private _currentRenderID;
  9812. private _boxBlurPostprocess;
  9813. private _kernelBlurXPostprocess;
  9814. private _kernelBlurYPostprocess;
  9815. private _blurPostProcesses;
  9816. private _mapSize;
  9817. private _currentFaceIndex;
  9818. private _currentFaceIndexCache;
  9819. private _textureType;
  9820. private _defaultTextureMatrix;
  9821. private _storedUniqueId;
  9822. /** @hidden */
  9823. static _SceneComponentInitialization: (scene: Scene) => void;
  9824. /**
  9825. * Creates a ShadowGenerator object.
  9826. * A ShadowGenerator is the required tool to use the shadows.
  9827. * Each light casting shadows needs to use its own ShadowGenerator.
  9828. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9829. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9830. * @param light The light object generating the shadows.
  9831. * @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.
  9832. */
  9833. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9834. private _initializeGenerator;
  9835. private _initializeShadowMap;
  9836. private _initializeBlurRTTAndPostProcesses;
  9837. private _renderForShadowMap;
  9838. private _renderSubMeshForShadowMap;
  9839. private _applyFilterValues;
  9840. /**
  9841. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9842. * @param onCompiled Callback triggered at the and of the effects compilation
  9843. * @param options Sets of optional options forcing the compilation with different modes
  9844. */
  9845. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9846. useInstances: boolean;
  9847. }>): void;
  9848. /**
  9849. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9850. * @param options Sets of optional options forcing the compilation with different modes
  9851. * @returns A promise that resolves when the compilation completes
  9852. */
  9853. forceCompilationAsync(options?: Partial<{
  9854. useInstances: boolean;
  9855. }>): Promise<void>;
  9856. /**
  9857. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9858. * @param subMesh The submesh we want to render in the shadow map
  9859. * @param useInstances Defines wether will draw in the map using instances
  9860. * @returns true if ready otherwise, false
  9861. */
  9862. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9863. /**
  9864. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9865. * @param defines Defines of the material we want to update
  9866. * @param lightIndex Index of the light in the enabled light list of the material
  9867. */
  9868. prepareDefines(defines: any, lightIndex: number): void;
  9869. /**
  9870. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9871. * defined in the generator but impacting the effect).
  9872. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9873. * @param effect The effect we are binfing the information for
  9874. */
  9875. bindShadowLight(lightIndex: string, effect: Effect): void;
  9876. /**
  9877. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9878. * (eq to shadow prjection matrix * light transform matrix)
  9879. * @returns The transform matrix used to create the shadow map
  9880. */
  9881. getTransformMatrix(): Matrix;
  9882. /**
  9883. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9884. * Cube and 2D textures for instance.
  9885. */
  9886. recreateShadowMap(): void;
  9887. private _disposeBlurPostProcesses;
  9888. private _disposeRTTandPostProcesses;
  9889. /**
  9890. * Disposes the ShadowGenerator.
  9891. * Returns nothing.
  9892. */
  9893. dispose(): void;
  9894. /**
  9895. * Serializes the shadow generator setup to a json object.
  9896. * @returns The serialized JSON object
  9897. */
  9898. serialize(): any;
  9899. /**
  9900. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9901. * @param parsedShadowGenerator The JSON object to parse
  9902. * @param scene The scene to create the shadow map for
  9903. * @returns The parsed shadow generator
  9904. */
  9905. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9906. }
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9911. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9912. * 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.
  9913. */
  9914. export abstract class Light extends Node {
  9915. /**
  9916. * Falloff Default: light is falling off following the material specification:
  9917. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9918. */
  9919. static readonly FALLOFF_DEFAULT: number;
  9920. /**
  9921. * Falloff Physical: light is falling off following the inverse squared distance law.
  9922. */
  9923. static readonly FALLOFF_PHYSICAL: number;
  9924. /**
  9925. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9926. * to enhance interoperability with other engines.
  9927. */
  9928. static readonly FALLOFF_GLTF: number;
  9929. /**
  9930. * Falloff Standard: light is falling off like in the standard material
  9931. * to enhance interoperability with other materials.
  9932. */
  9933. static readonly FALLOFF_STANDARD: number;
  9934. /**
  9935. * If every light affecting the material is in this lightmapMode,
  9936. * material.lightmapTexture adds or multiplies
  9937. * (depends on material.useLightmapAsShadowmap)
  9938. * after every other light calculations.
  9939. */
  9940. static readonly LIGHTMAP_DEFAULT: number;
  9941. /**
  9942. * material.lightmapTexture as only diffuse lighting from this light
  9943. * adds only specular lighting from this light
  9944. * adds dynamic shadows
  9945. */
  9946. static readonly LIGHTMAP_SPECULAR: number;
  9947. /**
  9948. * material.lightmapTexture as only lighting
  9949. * no light calculation from this light
  9950. * only adds dynamic shadows from this light
  9951. */
  9952. static readonly LIGHTMAP_SHADOWSONLY: number;
  9953. /**
  9954. * Each light type uses the default quantity according to its type:
  9955. * point/spot lights use luminous intensity
  9956. * directional lights use illuminance
  9957. */
  9958. static readonly INTENSITYMODE_AUTOMATIC: number;
  9959. /**
  9960. * lumen (lm)
  9961. */
  9962. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9963. /**
  9964. * candela (lm/sr)
  9965. */
  9966. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9967. /**
  9968. * lux (lm/m^2)
  9969. */
  9970. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9971. /**
  9972. * nit (cd/m^2)
  9973. */
  9974. static readonly INTENSITYMODE_LUMINANCE: number;
  9975. /**
  9976. * Light type const id of the point light.
  9977. */
  9978. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9979. /**
  9980. * Light type const id of the directional light.
  9981. */
  9982. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9983. /**
  9984. * Light type const id of the spot light.
  9985. */
  9986. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9987. /**
  9988. * Light type const id of the hemispheric light.
  9989. */
  9990. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9991. /**
  9992. * Diffuse gives the basic color to an object.
  9993. */
  9994. diffuse: Color3;
  9995. /**
  9996. * Specular produces a highlight color on an object.
  9997. * Note: This is note affecting PBR materials.
  9998. */
  9999. specular: Color3;
  10000. /**
  10001. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10002. * falling off base on range or angle.
  10003. * This can be set to any values in Light.FALLOFF_x.
  10004. *
  10005. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10006. * other types of materials.
  10007. */
  10008. falloffType: number;
  10009. /**
  10010. * Strength of the light.
  10011. * Note: By default it is define in the framework own unit.
  10012. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10013. */
  10014. intensity: number;
  10015. private _range;
  10016. protected _inverseSquaredRange: number;
  10017. /**
  10018. * Defines how far from the source the light is impacting in scene units.
  10019. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10020. */
  10021. get range(): number;
  10022. /**
  10023. * Defines how far from the source the light is impacting in scene units.
  10024. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10025. */
  10026. set range(value: number);
  10027. /**
  10028. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10029. * of light.
  10030. */
  10031. private _photometricScale;
  10032. private _intensityMode;
  10033. /**
  10034. * Gets the photometric scale used to interpret the intensity.
  10035. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10036. */
  10037. get intensityMode(): number;
  10038. /**
  10039. * Sets the photometric scale used to interpret the intensity.
  10040. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10041. */
  10042. set intensityMode(value: number);
  10043. private _radius;
  10044. /**
  10045. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10046. */
  10047. get radius(): number;
  10048. /**
  10049. * sets the light radius used by PBR Materials to simulate soft area lights.
  10050. */
  10051. set radius(value: number);
  10052. private _renderPriority;
  10053. /**
  10054. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10055. * exceeding the number allowed of the materials.
  10056. */
  10057. renderPriority: number;
  10058. private _shadowEnabled;
  10059. /**
  10060. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10061. * the current shadow generator.
  10062. */
  10063. get shadowEnabled(): boolean;
  10064. /**
  10065. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10066. * the current shadow generator.
  10067. */
  10068. set shadowEnabled(value: boolean);
  10069. private _includedOnlyMeshes;
  10070. /**
  10071. * Gets the only meshes impacted by this light.
  10072. */
  10073. get includedOnlyMeshes(): AbstractMesh[];
  10074. /**
  10075. * Sets the only meshes impacted by this light.
  10076. */
  10077. set includedOnlyMeshes(value: AbstractMesh[]);
  10078. private _excludedMeshes;
  10079. /**
  10080. * Gets the meshes not impacted by this light.
  10081. */
  10082. get excludedMeshes(): AbstractMesh[];
  10083. /**
  10084. * Sets the meshes not impacted by this light.
  10085. */
  10086. set excludedMeshes(value: AbstractMesh[]);
  10087. private _excludeWithLayerMask;
  10088. /**
  10089. * Gets the layer id use to find what meshes are not impacted by the light.
  10090. * Inactive if 0
  10091. */
  10092. get excludeWithLayerMask(): number;
  10093. /**
  10094. * Sets the layer id use to find what meshes are not impacted by the light.
  10095. * Inactive if 0
  10096. */
  10097. set excludeWithLayerMask(value: number);
  10098. private _includeOnlyWithLayerMask;
  10099. /**
  10100. * Gets the layer id use to find what meshes are impacted by the light.
  10101. * Inactive if 0
  10102. */
  10103. get includeOnlyWithLayerMask(): number;
  10104. /**
  10105. * Sets the layer id use to find what meshes are impacted by the light.
  10106. * Inactive if 0
  10107. */
  10108. set includeOnlyWithLayerMask(value: number);
  10109. private _lightmapMode;
  10110. /**
  10111. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10112. */
  10113. get lightmapMode(): number;
  10114. /**
  10115. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10116. */
  10117. set lightmapMode(value: number);
  10118. /**
  10119. * Shadow generator associted to the light.
  10120. * @hidden Internal use only.
  10121. */
  10122. _shadowGenerator: Nullable<IShadowGenerator>;
  10123. /**
  10124. * @hidden Internal use only.
  10125. */
  10126. _excludedMeshesIds: string[];
  10127. /**
  10128. * @hidden Internal use only.
  10129. */
  10130. _includedOnlyMeshesIds: string[];
  10131. /**
  10132. * The current light unifom buffer.
  10133. * @hidden Internal use only.
  10134. */
  10135. _uniformBuffer: UniformBuffer;
  10136. /** @hidden */
  10137. _renderId: number;
  10138. /**
  10139. * Creates a Light object in the scene.
  10140. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10141. * @param name The firendly name of the light
  10142. * @param scene The scene the light belongs too
  10143. */
  10144. constructor(name: string, scene: Scene);
  10145. protected abstract _buildUniformLayout(): void;
  10146. /**
  10147. * Sets the passed Effect "effect" with the Light information.
  10148. * @param effect The effect to update
  10149. * @param lightIndex The index of the light in the effect to update
  10150. * @returns The light
  10151. */
  10152. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10153. /**
  10154. * Sets the passed Effect "effect" with the Light textures.
  10155. * @param effect The effect to update
  10156. * @param lightIndex The index of the light in the effect to update
  10157. * @returns The light
  10158. */
  10159. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10160. /**
  10161. * Binds the lights information from the scene to the effect for the given mesh.
  10162. * @param lightIndex Light index
  10163. * @param scene The scene where the light belongs to
  10164. * @param effect The effect we are binding the data to
  10165. * @param useSpecular Defines if specular is supported
  10166. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10167. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10168. */
  10169. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10170. /**
  10171. * Sets the passed Effect "effect" with the Light information.
  10172. * @param effect The effect to update
  10173. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10174. * @returns The light
  10175. */
  10176. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10177. /**
  10178. * Returns the string "Light".
  10179. * @returns the class name
  10180. */
  10181. getClassName(): string;
  10182. /** @hidden */
  10183. readonly _isLight: boolean;
  10184. /**
  10185. * Converts the light information to a readable string for debug purpose.
  10186. * @param fullDetails Supports for multiple levels of logging within scene loading
  10187. * @returns the human readable light info
  10188. */
  10189. toString(fullDetails?: boolean): string;
  10190. /** @hidden */
  10191. protected _syncParentEnabledState(): void;
  10192. /**
  10193. * Set the enabled state of this node.
  10194. * @param value - the new enabled state
  10195. */
  10196. setEnabled(value: boolean): void;
  10197. /**
  10198. * Returns the Light associated shadow generator if any.
  10199. * @return the associated shadow generator.
  10200. */
  10201. getShadowGenerator(): Nullable<IShadowGenerator>;
  10202. /**
  10203. * Returns a Vector3, the absolute light position in the World.
  10204. * @returns the world space position of the light
  10205. */
  10206. getAbsolutePosition(): Vector3;
  10207. /**
  10208. * Specifies if the light will affect the passed mesh.
  10209. * @param mesh The mesh to test against the light
  10210. * @return true the mesh is affected otherwise, false.
  10211. */
  10212. canAffectMesh(mesh: AbstractMesh): boolean;
  10213. /**
  10214. * Sort function to order lights for rendering.
  10215. * @param a First Light object to compare to second.
  10216. * @param b Second Light object to compare first.
  10217. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10218. */
  10219. static CompareLightsPriority(a: Light, b: Light): number;
  10220. /**
  10221. * Releases resources associated with this node.
  10222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10224. */
  10225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10226. /**
  10227. * Returns the light type ID (integer).
  10228. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10229. */
  10230. getTypeID(): number;
  10231. /**
  10232. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10233. * @returns the scaled intensity in intensity mode unit
  10234. */
  10235. getScaledIntensity(): number;
  10236. /**
  10237. * Returns a new Light object, named "name", from the current one.
  10238. * @param name The name of the cloned light
  10239. * @returns the new created light
  10240. */
  10241. clone(name: string): Nullable<Light>;
  10242. /**
  10243. * Serializes the current light into a Serialization object.
  10244. * @returns the serialized object.
  10245. */
  10246. serialize(): any;
  10247. /**
  10248. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10249. * This new light is named "name" and added to the passed scene.
  10250. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10251. * @param name The friendly name of the light
  10252. * @param scene The scene the new light will belong to
  10253. * @returns the constructor function
  10254. */
  10255. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10256. /**
  10257. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10258. * @param parsedLight The JSON representation of the light
  10259. * @param scene The scene to create the parsed light in
  10260. * @returns the created light after parsing
  10261. */
  10262. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10263. private _hookArrayForExcluded;
  10264. private _hookArrayForIncludedOnly;
  10265. private _resyncMeshes;
  10266. /**
  10267. * Forces the meshes to update their light related information in their rendering used effects
  10268. * @hidden Internal Use Only
  10269. */
  10270. _markMeshesAsLightDirty(): void;
  10271. /**
  10272. * Recomputes the cached photometric scale if needed.
  10273. */
  10274. private _computePhotometricScale;
  10275. /**
  10276. * Returns the Photometric Scale according to the light type and intensity mode.
  10277. */
  10278. private _getPhotometricScale;
  10279. /**
  10280. * Reorder the light in the scene according to their defined priority.
  10281. * @hidden Internal Use Only
  10282. */
  10283. _reorderLightsInScene(): void;
  10284. /**
  10285. * Prepares the list of defines specific to the light type.
  10286. * @param defines the list of defines
  10287. * @param lightIndex defines the index of the light for the effect
  10288. */
  10289. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10290. }
  10291. }
  10292. declare module BABYLON {
  10293. /**
  10294. * Interface used to define Action
  10295. */
  10296. export interface IAction {
  10297. /**
  10298. * Trigger for the action
  10299. */
  10300. trigger: number;
  10301. /** Options of the trigger */
  10302. triggerOptions: any;
  10303. /**
  10304. * Gets the trigger parameters
  10305. * @returns the trigger parameters
  10306. */
  10307. getTriggerParameter(): any;
  10308. /**
  10309. * Internal only - executes current action event
  10310. * @hidden
  10311. */
  10312. _executeCurrent(evt?: ActionEvent): void;
  10313. /**
  10314. * Serialize placeholder for child classes
  10315. * @param parent of child
  10316. * @returns the serialized object
  10317. */
  10318. serialize(parent: any): any;
  10319. /**
  10320. * Internal only
  10321. * @hidden
  10322. */
  10323. _prepare(): void;
  10324. /**
  10325. * Internal only - manager for action
  10326. * @hidden
  10327. */
  10328. _actionManager: AbstractActionManager;
  10329. /**
  10330. * Adds action to chain of actions, may be a DoNothingAction
  10331. * @param action defines the next action to execute
  10332. * @returns The action passed in
  10333. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10334. */
  10335. then(action: IAction): IAction;
  10336. }
  10337. /**
  10338. * The action to be carried out following a trigger
  10339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10340. */
  10341. export class Action implements IAction {
  10342. /** the trigger, with or without parameters, for the action */
  10343. triggerOptions: any;
  10344. /**
  10345. * Trigger for the action
  10346. */
  10347. trigger: number;
  10348. /**
  10349. * Internal only - manager for action
  10350. * @hidden
  10351. */
  10352. _actionManager: ActionManager;
  10353. private _nextActiveAction;
  10354. private _child;
  10355. private _condition?;
  10356. private _triggerParameter;
  10357. /**
  10358. * An event triggered prior to action being executed.
  10359. */
  10360. onBeforeExecuteObservable: Observable<Action>;
  10361. /**
  10362. * Creates a new Action
  10363. * @param triggerOptions the trigger, with or without parameters, for the action
  10364. * @param condition an optional determinant of action
  10365. */
  10366. constructor(
  10367. /** the trigger, with or without parameters, for the action */
  10368. triggerOptions: any, condition?: Condition);
  10369. /**
  10370. * Internal only
  10371. * @hidden
  10372. */
  10373. _prepare(): void;
  10374. /**
  10375. * Gets the trigger parameters
  10376. * @returns the trigger parameters
  10377. */
  10378. getTriggerParameter(): any;
  10379. /**
  10380. * Internal only - executes current action event
  10381. * @hidden
  10382. */
  10383. _executeCurrent(evt?: ActionEvent): void;
  10384. /**
  10385. * Execute placeholder for child classes
  10386. * @param evt optional action event
  10387. */
  10388. execute(evt?: ActionEvent): void;
  10389. /**
  10390. * Skips to next active action
  10391. */
  10392. skipToNextActiveAction(): void;
  10393. /**
  10394. * Adds action to chain of actions, may be a DoNothingAction
  10395. * @param action defines the next action to execute
  10396. * @returns The action passed in
  10397. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10398. */
  10399. then(action: Action): Action;
  10400. /**
  10401. * Internal only
  10402. * @hidden
  10403. */
  10404. _getProperty(propertyPath: string): string;
  10405. /**
  10406. * Internal only
  10407. * @hidden
  10408. */
  10409. _getEffectiveTarget(target: any, propertyPath: string): any;
  10410. /**
  10411. * Serialize placeholder for child classes
  10412. * @param parent of child
  10413. * @returns the serialized object
  10414. */
  10415. serialize(parent: any): any;
  10416. /**
  10417. * Internal only called by serialize
  10418. * @hidden
  10419. */
  10420. protected _serialize(serializedAction: any, parent?: any): any;
  10421. /**
  10422. * Internal only
  10423. * @hidden
  10424. */
  10425. static _SerializeValueAsString: (value: any) => string;
  10426. /**
  10427. * Internal only
  10428. * @hidden
  10429. */
  10430. static _GetTargetProperty: (target: Node | Scene) => {
  10431. name: string;
  10432. targetType: string;
  10433. value: string;
  10434. };
  10435. }
  10436. }
  10437. declare module BABYLON {
  10438. /**
  10439. * A Condition applied to an Action
  10440. */
  10441. export class Condition {
  10442. /**
  10443. * Internal only - manager for action
  10444. * @hidden
  10445. */
  10446. _actionManager: ActionManager;
  10447. /**
  10448. * Internal only
  10449. * @hidden
  10450. */
  10451. _evaluationId: number;
  10452. /**
  10453. * Internal only
  10454. * @hidden
  10455. */
  10456. _currentResult: boolean;
  10457. /**
  10458. * Creates a new Condition
  10459. * @param actionManager the manager of the action the condition is applied to
  10460. */
  10461. constructor(actionManager: ActionManager);
  10462. /**
  10463. * Check if the current condition is valid
  10464. * @returns a boolean
  10465. */
  10466. isValid(): boolean;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. _getProperty(propertyPath: string): string;
  10472. /**
  10473. * Internal only
  10474. * @hidden
  10475. */
  10476. _getEffectiveTarget(target: any, propertyPath: string): any;
  10477. /**
  10478. * Serialize placeholder for child classes
  10479. * @returns the serialized object
  10480. */
  10481. serialize(): any;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. protected _serialize(serializedCondition: any): any;
  10487. }
  10488. /**
  10489. * Defines specific conditional operators as extensions of Condition
  10490. */
  10491. export class ValueCondition extends Condition {
  10492. /** path to specify the property of the target the conditional operator uses */
  10493. propertyPath: string;
  10494. /** the value compared by the conditional operator against the current value of the property */
  10495. value: any;
  10496. /** the conditional operator, default ValueCondition.IsEqual */
  10497. operator: number;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. private static _IsEqual;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. private static _IsDifferent;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. private static _IsGreater;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. private static _IsLesser;
  10518. /**
  10519. * returns the number for IsEqual
  10520. */
  10521. static get IsEqual(): number;
  10522. /**
  10523. * Returns the number for IsDifferent
  10524. */
  10525. static get IsDifferent(): number;
  10526. /**
  10527. * Returns the number for IsGreater
  10528. */
  10529. static get IsGreater(): number;
  10530. /**
  10531. * Returns the number for IsLesser
  10532. */
  10533. static get IsLesser(): number;
  10534. /**
  10535. * Internal only The action manager for the condition
  10536. * @hidden
  10537. */
  10538. _actionManager: ActionManager;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. private _target;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. private _effectiveTarget;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private _property;
  10554. /**
  10555. * Creates a new ValueCondition
  10556. * @param actionManager manager for the action the condition applies to
  10557. * @param target for the action
  10558. * @param propertyPath path to specify the property of the target the conditional operator uses
  10559. * @param value the value compared by the conditional operator against the current value of the property
  10560. * @param operator the conditional operator, default ValueCondition.IsEqual
  10561. */
  10562. constructor(actionManager: ActionManager, target: any,
  10563. /** path to specify the property of the target the conditional operator uses */
  10564. propertyPath: string,
  10565. /** the value compared by the conditional operator against the current value of the property */
  10566. value: any,
  10567. /** the conditional operator, default ValueCondition.IsEqual */
  10568. operator?: number);
  10569. /**
  10570. * Compares the given value with the property value for the specified conditional operator
  10571. * @returns the result of the comparison
  10572. */
  10573. isValid(): boolean;
  10574. /**
  10575. * Serialize the ValueCondition into a JSON compatible object
  10576. * @returns serialization object
  10577. */
  10578. serialize(): any;
  10579. /**
  10580. * Gets the name of the conditional operator for the ValueCondition
  10581. * @param operator the conditional operator
  10582. * @returns the name
  10583. */
  10584. static GetOperatorName(operator: number): string;
  10585. }
  10586. /**
  10587. * Defines a predicate condition as an extension of Condition
  10588. */
  10589. export class PredicateCondition extends Condition {
  10590. /** defines the predicate function used to validate the condition */
  10591. predicate: () => boolean;
  10592. /**
  10593. * Internal only - manager for action
  10594. * @hidden
  10595. */
  10596. _actionManager: ActionManager;
  10597. /**
  10598. * Creates a new PredicateCondition
  10599. * @param actionManager manager for the action the condition applies to
  10600. * @param predicate defines the predicate function used to validate the condition
  10601. */
  10602. constructor(actionManager: ActionManager,
  10603. /** defines the predicate function used to validate the condition */
  10604. predicate: () => boolean);
  10605. /**
  10606. * @returns the validity of the predicate condition
  10607. */
  10608. isValid(): boolean;
  10609. }
  10610. /**
  10611. * Defines a state condition as an extension of Condition
  10612. */
  10613. export class StateCondition extends Condition {
  10614. /** Value to compare with target state */
  10615. value: string;
  10616. /**
  10617. * Internal only - manager for action
  10618. * @hidden
  10619. */
  10620. _actionManager: ActionManager;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. private _target;
  10626. /**
  10627. * Creates a new StateCondition
  10628. * @param actionManager manager for the action the condition applies to
  10629. * @param target of the condition
  10630. * @param value to compare with target state
  10631. */
  10632. constructor(actionManager: ActionManager, target: any,
  10633. /** Value to compare with target state */
  10634. value: string);
  10635. /**
  10636. * Gets a boolean indicating if the current condition is met
  10637. * @returns the validity of the state
  10638. */
  10639. isValid(): boolean;
  10640. /**
  10641. * Serialize the StateCondition into a JSON compatible object
  10642. * @returns serialization object
  10643. */
  10644. serialize(): any;
  10645. }
  10646. }
  10647. declare module BABYLON {
  10648. /**
  10649. * This defines an action responsible to toggle a boolean once triggered.
  10650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10651. */
  10652. export class SwitchBooleanAction extends Action {
  10653. /**
  10654. * The path to the boolean property in the target object
  10655. */
  10656. propertyPath: string;
  10657. private _target;
  10658. private _effectiveTarget;
  10659. private _property;
  10660. /**
  10661. * Instantiate the action
  10662. * @param triggerOptions defines the trigger options
  10663. * @param target defines the object containing the boolean
  10664. * @param propertyPath defines the path to the boolean property in the target object
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action toggle the boolean value.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible to set a the state field of the target
  10683. * to a desired value once triggered.
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10685. */
  10686. export class SetStateAction extends Action {
  10687. /**
  10688. * The value to store in the state field.
  10689. */
  10690. value: string;
  10691. private _target;
  10692. /**
  10693. * Instantiate the action
  10694. * @param triggerOptions defines the trigger options
  10695. * @param target defines the object containing the state property
  10696. * @param value defines the value to store in the state field
  10697. * @param condition defines the trigger related conditions
  10698. */
  10699. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10700. /**
  10701. * Execute the action and store the value on the target state property.
  10702. */
  10703. execute(): void;
  10704. /**
  10705. * Serializes the actions and its related information.
  10706. * @param parent defines the object to serialize in
  10707. * @returns the serialized object
  10708. */
  10709. serialize(parent: any): any;
  10710. }
  10711. /**
  10712. * This defines an action responsible to set a property of the target
  10713. * to a desired value once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SetValueAction extends Action {
  10717. /**
  10718. * The path of the property to set in the target.
  10719. */
  10720. propertyPath: string;
  10721. /**
  10722. * The value to set in the property
  10723. */
  10724. value: any;
  10725. private _target;
  10726. private _effectiveTarget;
  10727. private _property;
  10728. /**
  10729. * Instantiate the action
  10730. * @param triggerOptions defines the trigger options
  10731. * @param target defines the object containing the property
  10732. * @param propertyPath defines the path of the property to set in the target
  10733. * @param value defines the value to set in the property
  10734. * @param condition defines the trigger related conditions
  10735. */
  10736. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10737. /** @hidden */
  10738. _prepare(): void;
  10739. /**
  10740. * Execute the action and set the targetted property to the desired value.
  10741. */
  10742. execute(): void;
  10743. /**
  10744. * Serializes the actions and its related information.
  10745. * @param parent defines the object to serialize in
  10746. * @returns the serialized object
  10747. */
  10748. serialize(parent: any): any;
  10749. }
  10750. /**
  10751. * This defines an action responsible to increment the target value
  10752. * to a desired value once triggered.
  10753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10754. */
  10755. export class IncrementValueAction extends Action {
  10756. /**
  10757. * The path of the property to increment in the target.
  10758. */
  10759. propertyPath: string;
  10760. /**
  10761. * The value we should increment the property by.
  10762. */
  10763. value: any;
  10764. private _target;
  10765. private _effectiveTarget;
  10766. private _property;
  10767. /**
  10768. * Instantiate the action
  10769. * @param triggerOptions defines the trigger options
  10770. * @param target defines the object containing the property
  10771. * @param propertyPath defines the path of the property to increment in the target
  10772. * @param value defines the value value we should increment the property by
  10773. * @param condition defines the trigger related conditions
  10774. */
  10775. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10776. /** @hidden */
  10777. _prepare(): void;
  10778. /**
  10779. * Execute the action and increment the target of the value amount.
  10780. */
  10781. execute(): void;
  10782. /**
  10783. * Serializes the actions and its related information.
  10784. * @param parent defines the object to serialize in
  10785. * @returns the serialized object
  10786. */
  10787. serialize(parent: any): any;
  10788. }
  10789. /**
  10790. * This defines an action responsible to start an animation once triggered.
  10791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10792. */
  10793. export class PlayAnimationAction extends Action {
  10794. /**
  10795. * Where the animation should start (animation frame)
  10796. */
  10797. from: number;
  10798. /**
  10799. * Where the animation should stop (animation frame)
  10800. */
  10801. to: number;
  10802. /**
  10803. * Define if the animation should loop or stop after the first play.
  10804. */
  10805. loop?: boolean;
  10806. private _target;
  10807. /**
  10808. * Instantiate the action
  10809. * @param triggerOptions defines the trigger options
  10810. * @param target defines the target animation or animation name
  10811. * @param from defines from where the animation should start (animation frame)
  10812. * @param end defines where the animation should stop (animation frame)
  10813. * @param loop defines if the animation should loop or stop after the first play
  10814. * @param condition defines the trigger related conditions
  10815. */
  10816. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10817. /** @hidden */
  10818. _prepare(): void;
  10819. /**
  10820. * Execute the action and play the animation.
  10821. */
  10822. execute(): void;
  10823. /**
  10824. * Serializes the actions and its related information.
  10825. * @param parent defines the object to serialize in
  10826. * @returns the serialized object
  10827. */
  10828. serialize(parent: any): any;
  10829. }
  10830. /**
  10831. * This defines an action responsible to stop an animation once triggered.
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10833. */
  10834. export class StopAnimationAction extends Action {
  10835. private _target;
  10836. /**
  10837. * Instantiate the action
  10838. * @param triggerOptions defines the trigger options
  10839. * @param target defines the target animation or animation name
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, target: any, condition?: Condition);
  10843. /** @hidden */
  10844. _prepare(): void;
  10845. /**
  10846. * Execute the action and stop the animation.
  10847. */
  10848. execute(): void;
  10849. /**
  10850. * Serializes the actions and its related information.
  10851. * @param parent defines the object to serialize in
  10852. * @returns the serialized object
  10853. */
  10854. serialize(parent: any): any;
  10855. }
  10856. /**
  10857. * This defines an action responsible that does nothing once triggered.
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10859. */
  10860. export class DoNothingAction extends Action {
  10861. /**
  10862. * Instantiate the action
  10863. * @param triggerOptions defines the trigger options
  10864. * @param condition defines the trigger related conditions
  10865. */
  10866. constructor(triggerOptions?: any, condition?: Condition);
  10867. /**
  10868. * Execute the action and do nothing.
  10869. */
  10870. execute(): void;
  10871. /**
  10872. * Serializes the actions and its related information.
  10873. * @param parent defines the object to serialize in
  10874. * @returns the serialized object
  10875. */
  10876. serialize(parent: any): any;
  10877. }
  10878. /**
  10879. * This defines an action responsible to trigger several actions once triggered.
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10881. */
  10882. export class CombineAction extends Action {
  10883. /**
  10884. * The list of aggregated animations to run.
  10885. */
  10886. children: Action[];
  10887. /**
  10888. * Instantiate the action
  10889. * @param triggerOptions defines the trigger options
  10890. * @param children defines the list of aggregated animations to run
  10891. * @param condition defines the trigger related conditions
  10892. */
  10893. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10894. /** @hidden */
  10895. _prepare(): void;
  10896. /**
  10897. * Execute the action and executes all the aggregated actions.
  10898. */
  10899. execute(evt: ActionEvent): void;
  10900. /**
  10901. * Serializes the actions and its related information.
  10902. * @param parent defines the object to serialize in
  10903. * @returns the serialized object
  10904. */
  10905. serialize(parent: any): any;
  10906. }
  10907. /**
  10908. * This defines an action responsible to run code (external event) once triggered.
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10910. */
  10911. export class ExecuteCodeAction extends Action {
  10912. /**
  10913. * The callback function to run.
  10914. */
  10915. func: (evt: ActionEvent) => void;
  10916. /**
  10917. * Instantiate the action
  10918. * @param triggerOptions defines the trigger options
  10919. * @param func defines the callback function to run
  10920. * @param condition defines the trigger related conditions
  10921. */
  10922. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10923. /**
  10924. * Execute the action and run the attached code.
  10925. */
  10926. execute(evt: ActionEvent): void;
  10927. }
  10928. /**
  10929. * This defines an action responsible to set the parent property of the target once triggered.
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10931. */
  10932. export class SetParentAction extends Action {
  10933. private _parent;
  10934. private _target;
  10935. /**
  10936. * Instantiate the action
  10937. * @param triggerOptions defines the trigger options
  10938. * @param target defines the target containing the parent property
  10939. * @param parent defines from where the animation should start (animation frame)
  10940. * @param condition defines the trigger related conditions
  10941. */
  10942. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10943. /** @hidden */
  10944. _prepare(): void;
  10945. /**
  10946. * Execute the action and set the parent property.
  10947. */
  10948. execute(): void;
  10949. /**
  10950. * Serializes the actions and its related information.
  10951. * @param parent defines the object to serialize in
  10952. * @returns the serialized object
  10953. */
  10954. serialize(parent: any): any;
  10955. }
  10956. }
  10957. declare module BABYLON {
  10958. /**
  10959. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10960. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class ActionManager extends AbstractActionManager {
  10964. /**
  10965. * Nothing
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10967. */
  10968. static readonly NothingTrigger: number;
  10969. /**
  10970. * On pick
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10972. */
  10973. static readonly OnPickTrigger: number;
  10974. /**
  10975. * On left pick
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10977. */
  10978. static readonly OnLeftPickTrigger: number;
  10979. /**
  10980. * On right pick
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10982. */
  10983. static readonly OnRightPickTrigger: number;
  10984. /**
  10985. * On center pick
  10986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10987. */
  10988. static readonly OnCenterPickTrigger: number;
  10989. /**
  10990. * On pick down
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10992. */
  10993. static readonly OnPickDownTrigger: number;
  10994. /**
  10995. * On double pick
  10996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10997. */
  10998. static readonly OnDoublePickTrigger: number;
  10999. /**
  11000. * On pick up
  11001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11002. */
  11003. static readonly OnPickUpTrigger: number;
  11004. /**
  11005. * On pick out.
  11006. * This trigger will only be raised if you also declared a OnPickDown
  11007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11008. */
  11009. static readonly OnPickOutTrigger: number;
  11010. /**
  11011. * On long press
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11013. */
  11014. static readonly OnLongPressTrigger: number;
  11015. /**
  11016. * On pointer over
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11018. */
  11019. static readonly OnPointerOverTrigger: number;
  11020. /**
  11021. * On pointer out
  11022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11023. */
  11024. static readonly OnPointerOutTrigger: number;
  11025. /**
  11026. * On every frame
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11028. */
  11029. static readonly OnEveryFrameTrigger: number;
  11030. /**
  11031. * On intersection enter
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly OnIntersectionEnterTrigger: number;
  11035. /**
  11036. * On intersection exit
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnIntersectionExitTrigger: number;
  11040. /**
  11041. * On key down
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnKeyDownTrigger: number;
  11045. /**
  11046. * On key up
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnKeyUpTrigger: number;
  11050. private _scene;
  11051. /**
  11052. * Creates a new action manager
  11053. * @param scene defines the hosting scene
  11054. */
  11055. constructor(scene: Scene);
  11056. /**
  11057. * Releases all associated resources
  11058. */
  11059. dispose(): void;
  11060. /**
  11061. * Gets hosting scene
  11062. * @returns the hosting scene
  11063. */
  11064. getScene(): Scene;
  11065. /**
  11066. * Does this action manager handles actions of any of the given triggers
  11067. * @param triggers defines the triggers to be tested
  11068. * @return a boolean indicating whether one (or more) of the triggers is handled
  11069. */
  11070. hasSpecificTriggers(triggers: number[]): boolean;
  11071. /**
  11072. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11073. * speed.
  11074. * @param triggerA defines the trigger to be tested
  11075. * @param triggerB defines the trigger to be tested
  11076. * @return a boolean indicating whether one (or more) of the triggers is handled
  11077. */
  11078. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11079. /**
  11080. * Does this action manager handles actions of a given trigger
  11081. * @param trigger defines the trigger to be tested
  11082. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11083. * @return whether the trigger is handled
  11084. */
  11085. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11086. /**
  11087. * Does this action manager has pointer triggers
  11088. */
  11089. get hasPointerTriggers(): boolean;
  11090. /**
  11091. * Does this action manager has pick triggers
  11092. */
  11093. get hasPickTriggers(): boolean;
  11094. /**
  11095. * Registers an action to this action manager
  11096. * @param action defines the action to be registered
  11097. * @return the action amended (prepared) after registration
  11098. */
  11099. registerAction(action: IAction): Nullable<IAction>;
  11100. /**
  11101. * Unregisters an action to this action manager
  11102. * @param action defines the action to be unregistered
  11103. * @return a boolean indicating whether the action has been unregistered
  11104. */
  11105. unregisterAction(action: IAction): Boolean;
  11106. /**
  11107. * Process a specific trigger
  11108. * @param trigger defines the trigger to process
  11109. * @param evt defines the event details to be processed
  11110. */
  11111. processTrigger(trigger: number, evt?: IActionEvent): void;
  11112. /** @hidden */
  11113. _getEffectiveTarget(target: any, propertyPath: string): any;
  11114. /** @hidden */
  11115. _getProperty(propertyPath: string): string;
  11116. /**
  11117. * Serialize this manager to a JSON object
  11118. * @param name defines the property name to store this manager
  11119. * @returns a JSON representation of this manager
  11120. */
  11121. serialize(name: string): any;
  11122. /**
  11123. * Creates a new ActionManager from a JSON data
  11124. * @param parsedActions defines the JSON data to read from
  11125. * @param object defines the hosting mesh
  11126. * @param scene defines the hosting scene
  11127. */
  11128. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11129. /**
  11130. * Get a trigger name by index
  11131. * @param trigger defines the trigger index
  11132. * @returns a trigger name
  11133. */
  11134. static GetTriggerName(trigger: number): string;
  11135. }
  11136. }
  11137. declare module BABYLON {
  11138. /**
  11139. * Class representing a ray with position and direction
  11140. */
  11141. export class Ray {
  11142. /** origin point */
  11143. origin: Vector3;
  11144. /** direction */
  11145. direction: Vector3;
  11146. /** length of the ray */
  11147. length: number;
  11148. private static readonly TmpVector3;
  11149. private _tmpRay;
  11150. /**
  11151. * Creates a new ray
  11152. * @param origin origin point
  11153. * @param direction direction
  11154. * @param length length of the ray
  11155. */
  11156. constructor(
  11157. /** origin point */
  11158. origin: Vector3,
  11159. /** direction */
  11160. direction: Vector3,
  11161. /** length of the ray */
  11162. length?: number);
  11163. /**
  11164. * Checks if the ray intersects a box
  11165. * @param minimum bound of the box
  11166. * @param maximum bound of the box
  11167. * @param intersectionTreshold extra extend to be added to the box in all direction
  11168. * @returns if the box was hit
  11169. */
  11170. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11171. /**
  11172. * Checks if the ray intersects a box
  11173. * @param box the bounding box to check
  11174. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11175. * @returns if the box was hit
  11176. */
  11177. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11178. /**
  11179. * If the ray hits a sphere
  11180. * @param sphere the bounding sphere to check
  11181. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11182. * @returns true if it hits the sphere
  11183. */
  11184. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11185. /**
  11186. * If the ray hits a triange
  11187. * @param vertex0 triangle vertex
  11188. * @param vertex1 triangle vertex
  11189. * @param vertex2 triangle vertex
  11190. * @returns intersection information if hit
  11191. */
  11192. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11193. /**
  11194. * Checks if ray intersects a plane
  11195. * @param plane the plane to check
  11196. * @returns the distance away it was hit
  11197. */
  11198. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11199. /**
  11200. * Calculate the intercept of a ray on a given axis
  11201. * @param axis to check 'x' | 'y' | 'z'
  11202. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11203. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11204. */
  11205. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11206. /**
  11207. * Checks if ray intersects a mesh
  11208. * @param mesh the mesh to check
  11209. * @param fastCheck if only the bounding box should checked
  11210. * @returns picking info of the intersecton
  11211. */
  11212. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11213. /**
  11214. * Checks if ray intersects a mesh
  11215. * @param meshes the meshes to check
  11216. * @param fastCheck if only the bounding box should checked
  11217. * @param results array to store result in
  11218. * @returns Array of picking infos
  11219. */
  11220. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11221. private _comparePickingInfo;
  11222. private static smallnum;
  11223. private static rayl;
  11224. /**
  11225. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11226. * @param sega the first point of the segment to test the intersection against
  11227. * @param segb the second point of the segment to test the intersection against
  11228. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11229. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11230. */
  11231. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11232. /**
  11233. * Update the ray from viewport position
  11234. * @param x position
  11235. * @param y y position
  11236. * @param viewportWidth viewport width
  11237. * @param viewportHeight viewport height
  11238. * @param world world matrix
  11239. * @param view view matrix
  11240. * @param projection projection matrix
  11241. * @returns this ray updated
  11242. */
  11243. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11244. /**
  11245. * Creates a ray with origin and direction of 0,0,0
  11246. * @returns the new ray
  11247. */
  11248. static Zero(): Ray;
  11249. /**
  11250. * Creates a new ray from screen space and viewport
  11251. * @param x position
  11252. * @param y y position
  11253. * @param viewportWidth viewport width
  11254. * @param viewportHeight viewport height
  11255. * @param world world matrix
  11256. * @param view view matrix
  11257. * @param projection projection matrix
  11258. * @returns new ray
  11259. */
  11260. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11261. /**
  11262. * 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
  11263. * transformed to the given world matrix.
  11264. * @param origin The origin point
  11265. * @param end The end point
  11266. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11267. * @returns the new ray
  11268. */
  11269. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11270. /**
  11271. * Transforms a ray by a matrix
  11272. * @param ray ray to transform
  11273. * @param matrix matrix to apply
  11274. * @returns the resulting new ray
  11275. */
  11276. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11277. /**
  11278. * Transforms a ray by a matrix
  11279. * @param ray ray to transform
  11280. * @param matrix matrix to apply
  11281. * @param result ray to store result in
  11282. */
  11283. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11284. /**
  11285. * Unproject a ray from screen space to object space
  11286. * @param sourceX defines the screen space x coordinate to use
  11287. * @param sourceY defines the screen space y coordinate to use
  11288. * @param viewportWidth defines the current width of the viewport
  11289. * @param viewportHeight defines the current height of the viewport
  11290. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11291. * @param view defines the view matrix to use
  11292. * @param projection defines the projection matrix to use
  11293. */
  11294. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11295. }
  11296. /**
  11297. * Type used to define predicate used to select faces when a mesh intersection is detected
  11298. */
  11299. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11300. interface Scene {
  11301. /** @hidden */
  11302. _tempPickingRay: Nullable<Ray>;
  11303. /** @hidden */
  11304. _cachedRayForTransform: Ray;
  11305. /** @hidden */
  11306. _pickWithRayInverseMatrix: Matrix;
  11307. /** @hidden */
  11308. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11309. /** @hidden */
  11310. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11311. }
  11312. }
  11313. declare module BABYLON {
  11314. /**
  11315. * Groups all the scene component constants in one place to ease maintenance.
  11316. * @hidden
  11317. */
  11318. export class SceneComponentConstants {
  11319. static readonly NAME_EFFECTLAYER: string;
  11320. static readonly NAME_LAYER: string;
  11321. static readonly NAME_LENSFLARESYSTEM: string;
  11322. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11323. static readonly NAME_PARTICLESYSTEM: string;
  11324. static readonly NAME_GAMEPAD: string;
  11325. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11326. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11327. static readonly NAME_DEPTHRENDERER: string;
  11328. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11329. static readonly NAME_SPRITE: string;
  11330. static readonly NAME_OUTLINERENDERER: string;
  11331. static readonly NAME_PROCEDURALTEXTURE: string;
  11332. static readonly NAME_SHADOWGENERATOR: string;
  11333. static readonly NAME_OCTREE: string;
  11334. static readonly NAME_PHYSICSENGINE: string;
  11335. static readonly NAME_AUDIO: string;
  11336. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11337. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11338. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11339. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11340. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11341. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11342. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11343. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11344. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11345. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11346. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11347. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11348. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11349. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11350. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11351. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11352. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11353. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11354. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11355. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11356. static readonly STEP_AFTERRENDER_AUDIO: number;
  11357. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11358. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11359. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11360. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11361. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11362. static readonly STEP_POINTERMOVE_SPRITE: number;
  11363. static readonly STEP_POINTERDOWN_SPRITE: number;
  11364. static readonly STEP_POINTERUP_SPRITE: number;
  11365. }
  11366. /**
  11367. * This represents a scene component.
  11368. *
  11369. * This is used to decouple the dependency the scene is having on the different workloads like
  11370. * layers, post processes...
  11371. */
  11372. export interface ISceneComponent {
  11373. /**
  11374. * The name of the component. Each component must have a unique name.
  11375. */
  11376. name: string;
  11377. /**
  11378. * The scene the component belongs to.
  11379. */
  11380. scene: Scene;
  11381. /**
  11382. * Register the component to one instance of a scene.
  11383. */
  11384. register(): void;
  11385. /**
  11386. * Rebuilds the elements related to this component in case of
  11387. * context lost for instance.
  11388. */
  11389. rebuild(): void;
  11390. /**
  11391. * Disposes the component and the associated ressources.
  11392. */
  11393. dispose(): void;
  11394. }
  11395. /**
  11396. * This represents a SERIALIZABLE scene component.
  11397. *
  11398. * This extends Scene Component to add Serialization methods on top.
  11399. */
  11400. export interface ISceneSerializableComponent extends ISceneComponent {
  11401. /**
  11402. * Adds all the elements from the container to the scene
  11403. * @param container the container holding the elements
  11404. */
  11405. addFromContainer(container: AbstractScene): void;
  11406. /**
  11407. * Removes all the elements in the container from the scene
  11408. * @param container contains the elements to remove
  11409. * @param dispose if the removed element should be disposed (default: false)
  11410. */
  11411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11412. /**
  11413. * Serializes the component data to the specified json object
  11414. * @param serializationObject The object to serialize to
  11415. */
  11416. serialize(serializationObject: any): void;
  11417. }
  11418. /**
  11419. * Strong typing of a Mesh related stage step action
  11420. */
  11421. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11422. /**
  11423. * Strong typing of a Evaluate Sub Mesh related stage step action
  11424. */
  11425. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11426. /**
  11427. * Strong typing of a Active Mesh related stage step action
  11428. */
  11429. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11430. /**
  11431. * Strong typing of a Camera related stage step action
  11432. */
  11433. export type CameraStageAction = (camera: Camera) => void;
  11434. /**
  11435. * Strong typing of a Camera Frame buffer related stage step action
  11436. */
  11437. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11438. /**
  11439. * Strong typing of a Render Target related stage step action
  11440. */
  11441. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11442. /**
  11443. * Strong typing of a RenderingGroup related stage step action
  11444. */
  11445. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11446. /**
  11447. * Strong typing of a Mesh Render related stage step action
  11448. */
  11449. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11450. /**
  11451. * Strong typing of a simple stage step action
  11452. */
  11453. export type SimpleStageAction = () => void;
  11454. /**
  11455. * Strong typing of a render target action.
  11456. */
  11457. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11458. /**
  11459. * Strong typing of a pointer move action.
  11460. */
  11461. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11462. /**
  11463. * Strong typing of a pointer up/down action.
  11464. */
  11465. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11466. /**
  11467. * Representation of a stage in the scene (Basically a list of ordered steps)
  11468. * @hidden
  11469. */
  11470. export class Stage<T extends Function> extends Array<{
  11471. index: number;
  11472. component: ISceneComponent;
  11473. action: T;
  11474. }> {
  11475. /**
  11476. * Hide ctor from the rest of the world.
  11477. * @param items The items to add.
  11478. */
  11479. private constructor();
  11480. /**
  11481. * Creates a new Stage.
  11482. * @returns A new instance of a Stage
  11483. */
  11484. static Create<T extends Function>(): Stage<T>;
  11485. /**
  11486. * Registers a step in an ordered way in the targeted stage.
  11487. * @param index Defines the position to register the step in
  11488. * @param component Defines the component attached to the step
  11489. * @param action Defines the action to launch during the step
  11490. */
  11491. registerStep(index: number, component: ISceneComponent, action: T): void;
  11492. /**
  11493. * Clears all the steps from the stage.
  11494. */
  11495. clear(): void;
  11496. }
  11497. }
  11498. declare module BABYLON {
  11499. interface Scene {
  11500. /** @hidden */
  11501. _pointerOverSprite: Nullable<Sprite>;
  11502. /** @hidden */
  11503. _pickedDownSprite: Nullable<Sprite>;
  11504. /** @hidden */
  11505. _tempSpritePickingRay: Nullable<Ray>;
  11506. /**
  11507. * All of the sprite managers added to this scene
  11508. * @see http://doc.babylonjs.com/babylon101/sprites
  11509. */
  11510. spriteManagers: Array<ISpriteManager>;
  11511. /**
  11512. * An event triggered when sprites rendering is about to start
  11513. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11514. */
  11515. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11516. /**
  11517. * An event triggered when sprites rendering is done
  11518. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11519. */
  11520. onAfterSpritesRenderingObservable: Observable<Scene>;
  11521. /** @hidden */
  11522. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11523. /** Launch a ray to try to pick a sprite in the scene
  11524. * @param x position on screen
  11525. * @param y position on screen
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** Use the given ray to pick a sprite in the scene
  11533. * @param ray The ray (in world space) to use to pick meshes
  11534. * @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
  11535. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11536. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11537. * @returns a PickingInfo
  11538. */
  11539. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11540. /** @hidden */
  11541. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Launch a ray to try to pick sprites in the scene
  11543. * @param x position on screen
  11544. * @param y position on screen
  11545. * @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
  11546. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11547. * @returns a PickingInfo array
  11548. */
  11549. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11550. /** Use the given ray to pick sprites in the scene
  11551. * @param ray The ray (in world space) to use to pick meshes
  11552. * @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
  11553. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11554. * @returns a PickingInfo array
  11555. */
  11556. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11557. /**
  11558. * Force the sprite under the pointer
  11559. * @param sprite defines the sprite to use
  11560. */
  11561. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11562. /**
  11563. * Gets the sprite under the pointer
  11564. * @returns a Sprite or null if no sprite is under the pointer
  11565. */
  11566. getPointerOverSprite(): Nullable<Sprite>;
  11567. }
  11568. /**
  11569. * Defines the sprite scene component responsible to manage sprites
  11570. * in a given scene.
  11571. */
  11572. export class SpriteSceneComponent implements ISceneComponent {
  11573. /**
  11574. * The component name helpfull to identify the component in the list of scene components.
  11575. */
  11576. readonly name: string;
  11577. /**
  11578. * The scene the component belongs to.
  11579. */
  11580. scene: Scene;
  11581. /** @hidden */
  11582. private _spritePredicate;
  11583. /**
  11584. * Creates a new instance of the component for the given scene
  11585. * @param scene Defines the scene to register the component in
  11586. */
  11587. constructor(scene: Scene);
  11588. /**
  11589. * Registers the component in a given scene
  11590. */
  11591. register(): void;
  11592. /**
  11593. * Rebuilds the elements related to this component in case of
  11594. * context lost for instance.
  11595. */
  11596. rebuild(): void;
  11597. /**
  11598. * Disposes the component and the associated ressources.
  11599. */
  11600. dispose(): void;
  11601. private _pickSpriteButKeepRay;
  11602. private _pointerMove;
  11603. private _pointerDown;
  11604. private _pointerUp;
  11605. }
  11606. }
  11607. declare module BABYLON {
  11608. /** @hidden */
  11609. export var fogFragmentDeclaration: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module BABYLON {
  11615. /** @hidden */
  11616. export var fogFragment: {
  11617. name: string;
  11618. shader: string;
  11619. };
  11620. }
  11621. declare module BABYLON {
  11622. /** @hidden */
  11623. export var spritesPixelShader: {
  11624. name: string;
  11625. shader: string;
  11626. };
  11627. }
  11628. declare module BABYLON {
  11629. /** @hidden */
  11630. export var fogVertexDeclaration: {
  11631. name: string;
  11632. shader: string;
  11633. };
  11634. }
  11635. declare module BABYLON {
  11636. /** @hidden */
  11637. export var spritesVertexShader: {
  11638. name: string;
  11639. shader: string;
  11640. };
  11641. }
  11642. declare module BABYLON {
  11643. /**
  11644. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11645. */
  11646. export interface ISpriteManager extends IDisposable {
  11647. /**
  11648. * Restricts the camera to viewing objects with the same layerMask.
  11649. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11650. */
  11651. layerMask: number;
  11652. /**
  11653. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11654. */
  11655. isPickable: boolean;
  11656. /**
  11657. * Specifies the rendering group id for this mesh (0 by default)
  11658. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11659. */
  11660. renderingGroupId: number;
  11661. /**
  11662. * Defines the list of sprites managed by the manager.
  11663. */
  11664. sprites: Array<Sprite>;
  11665. /**
  11666. * Tests the intersection of a sprite with a specific ray.
  11667. * @param ray The ray we are sending to test the collision
  11668. * @param camera The camera space we are sending rays in
  11669. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11670. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11671. * @returns picking info or null.
  11672. */
  11673. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11674. /**
  11675. * Intersects the sprites with a ray
  11676. * @param ray defines the ray to intersect with
  11677. * @param camera defines the current active camera
  11678. * @param predicate defines a predicate used to select candidate sprites
  11679. * @returns null if no hit or a PickingInfo array
  11680. */
  11681. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11682. /**
  11683. * Renders the list of sprites on screen.
  11684. */
  11685. render(): void;
  11686. }
  11687. /**
  11688. * Class used to manage multiple sprites on the same spritesheet
  11689. * @see http://doc.babylonjs.com/babylon101/sprites
  11690. */
  11691. export class SpriteManager implements ISpriteManager {
  11692. /** defines the manager's name */
  11693. name: string;
  11694. /** Gets the list of sprites */
  11695. sprites: Sprite[];
  11696. /** Gets or sets the rendering group id (0 by default) */
  11697. renderingGroupId: number;
  11698. /** Gets or sets camera layer mask */
  11699. layerMask: number;
  11700. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11701. fogEnabled: boolean;
  11702. /** Gets or sets a boolean indicating if the sprites are pickable */
  11703. isPickable: boolean;
  11704. /** Defines the default width of a cell in the spritesheet */
  11705. cellWidth: number;
  11706. /** Defines the default height of a cell in the spritesheet */
  11707. cellHeight: number;
  11708. /** Associative array from JSON sprite data file */
  11709. private _cellData;
  11710. /** Array of sprite names from JSON sprite data file */
  11711. private _spriteMap;
  11712. /** True when packed cell data from JSON file is ready*/
  11713. private _packedAndReady;
  11714. /**
  11715. * An event triggered when the manager is disposed.
  11716. */
  11717. onDisposeObservable: Observable<SpriteManager>;
  11718. private _onDisposeObserver;
  11719. /**
  11720. * Callback called when the manager is disposed
  11721. */
  11722. set onDispose(callback: () => void);
  11723. private _capacity;
  11724. private _fromPacked;
  11725. private _spriteTexture;
  11726. private _epsilon;
  11727. private _scene;
  11728. private _vertexData;
  11729. private _buffer;
  11730. private _vertexBuffers;
  11731. private _indexBuffer;
  11732. private _effectBase;
  11733. private _effectFog;
  11734. /**
  11735. * Gets or sets the spritesheet texture
  11736. */
  11737. get texture(): Texture;
  11738. set texture(value: Texture);
  11739. /**
  11740. * Creates a new sprite manager
  11741. * @param name defines the manager's name
  11742. * @param imgUrl defines the sprite sheet url
  11743. * @param capacity defines the maximum allowed number of sprites
  11744. * @param cellSize defines the size of a sprite cell
  11745. * @param scene defines the hosting scene
  11746. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11747. * @param samplingMode defines the smapling mode to use with spritesheet
  11748. * @param fromPacked set to false; do not alter
  11749. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11750. */
  11751. constructor(
  11752. /** defines the manager's name */
  11753. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11754. private _makePacked;
  11755. private _appendSpriteVertex;
  11756. /**
  11757. * Intersects the sprites with a ray
  11758. * @param ray defines the ray to intersect with
  11759. * @param camera defines the current active camera
  11760. * @param predicate defines a predicate used to select candidate sprites
  11761. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11762. * @returns null if no hit or a PickingInfo
  11763. */
  11764. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11765. /**
  11766. * Intersects the sprites with a ray
  11767. * @param ray defines the ray to intersect with
  11768. * @param camera defines the current active camera
  11769. * @param predicate defines a predicate used to select candidate sprites
  11770. * @returns null if no hit or a PickingInfo array
  11771. */
  11772. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11773. /**
  11774. * Render all child sprites
  11775. */
  11776. render(): void;
  11777. /**
  11778. * Release associated resources
  11779. */
  11780. dispose(): void;
  11781. }
  11782. }
  11783. declare module BABYLON {
  11784. /**
  11785. * Class used to represent a sprite
  11786. * @see http://doc.babylonjs.com/babylon101/sprites
  11787. */
  11788. export class Sprite {
  11789. /** defines the name */
  11790. name: string;
  11791. /** Gets or sets the current world position */
  11792. position: Vector3;
  11793. /** Gets or sets the main color */
  11794. color: Color4;
  11795. /** Gets or sets the width */
  11796. width: number;
  11797. /** Gets or sets the height */
  11798. height: number;
  11799. /** Gets or sets rotation angle */
  11800. angle: number;
  11801. /** Gets or sets the cell index in the sprite sheet */
  11802. cellIndex: number;
  11803. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11804. cellRef: string;
  11805. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11806. invertU: number;
  11807. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11808. invertV: number;
  11809. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11810. disposeWhenFinishedAnimating: boolean;
  11811. /** Gets the list of attached animations */
  11812. animations: Animation[];
  11813. /** Gets or sets a boolean indicating if the sprite can be picked */
  11814. isPickable: boolean;
  11815. /**
  11816. * Gets or sets the associated action manager
  11817. */
  11818. actionManager: Nullable<ActionManager>;
  11819. private _animationStarted;
  11820. private _loopAnimation;
  11821. private _fromIndex;
  11822. private _toIndex;
  11823. private _delay;
  11824. private _direction;
  11825. private _manager;
  11826. private _time;
  11827. private _onAnimationEnd;
  11828. /**
  11829. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11830. */
  11831. isVisible: boolean;
  11832. /**
  11833. * Gets or sets the sprite size
  11834. */
  11835. get size(): number;
  11836. set size(value: number);
  11837. /**
  11838. * Creates a new Sprite
  11839. * @param name defines the name
  11840. * @param manager defines the manager
  11841. */
  11842. constructor(
  11843. /** defines the name */
  11844. name: string, manager: ISpriteManager);
  11845. /**
  11846. * Starts an animation
  11847. * @param from defines the initial key
  11848. * @param to defines the end key
  11849. * @param loop defines if the animation must loop
  11850. * @param delay defines the start delay (in ms)
  11851. * @param onAnimationEnd defines a callback to call when animation ends
  11852. */
  11853. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11854. /** Stops current animation (if any) */
  11855. stopAnimation(): void;
  11856. /** @hidden */
  11857. _animate(deltaTime: number): void;
  11858. /** Release associated resources */
  11859. dispose(): void;
  11860. }
  11861. }
  11862. declare module BABYLON {
  11863. /**
  11864. * Information about the result of picking within a scene
  11865. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11866. */
  11867. export class PickingInfo {
  11868. /** @hidden */
  11869. _pickingUnavailable: boolean;
  11870. /**
  11871. * If the pick collided with an object
  11872. */
  11873. hit: boolean;
  11874. /**
  11875. * Distance away where the pick collided
  11876. */
  11877. distance: number;
  11878. /**
  11879. * The location of pick collision
  11880. */
  11881. pickedPoint: Nullable<Vector3>;
  11882. /**
  11883. * The mesh corresponding the the pick collision
  11884. */
  11885. pickedMesh: Nullable<AbstractMesh>;
  11886. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11887. bu: number;
  11888. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11889. bv: number;
  11890. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11891. faceId: number;
  11892. /** Id of the the submesh that was picked */
  11893. subMeshId: number;
  11894. /** If a sprite was picked, this will be the sprite the pick collided with */
  11895. pickedSprite: Nullable<Sprite>;
  11896. /**
  11897. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11898. */
  11899. originMesh: Nullable<AbstractMesh>;
  11900. /**
  11901. * The ray that was used to perform the picking.
  11902. */
  11903. ray: Nullable<Ray>;
  11904. /**
  11905. * Gets the normal correspodning to the face the pick collided with
  11906. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11907. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11908. * @returns The normal correspodning to the face the pick collided with
  11909. */
  11910. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11911. /**
  11912. * Gets the texture coordinates of where the pick occured
  11913. * @returns the vector containing the coordnates of the texture
  11914. */
  11915. getTextureCoordinates(): Nullable<Vector2>;
  11916. }
  11917. }
  11918. declare module BABYLON {
  11919. /**
  11920. * Gather the list of pointer event types as constants.
  11921. */
  11922. export class PointerEventTypes {
  11923. /**
  11924. * 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.
  11925. */
  11926. static readonly POINTERDOWN: number;
  11927. /**
  11928. * The pointerup event is fired when a pointer is no longer active.
  11929. */
  11930. static readonly POINTERUP: number;
  11931. /**
  11932. * The pointermove event is fired when a pointer changes coordinates.
  11933. */
  11934. static readonly POINTERMOVE: number;
  11935. /**
  11936. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11937. */
  11938. static readonly POINTERWHEEL: number;
  11939. /**
  11940. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11941. */
  11942. static readonly POINTERPICK: number;
  11943. /**
  11944. * The pointertap event is fired when a the object has been touched and released without drag.
  11945. */
  11946. static readonly POINTERTAP: number;
  11947. /**
  11948. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11949. */
  11950. static readonly POINTERDOUBLETAP: number;
  11951. }
  11952. /**
  11953. * Base class of pointer info types.
  11954. */
  11955. export class PointerInfoBase {
  11956. /**
  11957. * Defines the type of event (PointerEventTypes)
  11958. */
  11959. type: number;
  11960. /**
  11961. * Defines the related dom event
  11962. */
  11963. event: PointerEvent | MouseWheelEvent;
  11964. /**
  11965. * Instantiates the base class of pointers info.
  11966. * @param type Defines the type of event (PointerEventTypes)
  11967. * @param event Defines the related dom event
  11968. */
  11969. constructor(
  11970. /**
  11971. * Defines the type of event (PointerEventTypes)
  11972. */
  11973. type: number,
  11974. /**
  11975. * Defines the related dom event
  11976. */
  11977. event: PointerEvent | MouseWheelEvent);
  11978. }
  11979. /**
  11980. * This class is used to store pointer related info for the onPrePointerObservable event.
  11981. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11982. */
  11983. export class PointerInfoPre extends PointerInfoBase {
  11984. /**
  11985. * Ray from a pointer if availible (eg. 6dof controller)
  11986. */
  11987. ray: Nullable<Ray>;
  11988. /**
  11989. * Defines the local position of the pointer on the canvas.
  11990. */
  11991. localPosition: Vector2;
  11992. /**
  11993. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11994. */
  11995. skipOnPointerObservable: boolean;
  11996. /**
  11997. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11998. * @param type Defines the type of event (PointerEventTypes)
  11999. * @param event Defines the related dom event
  12000. * @param localX Defines the local x coordinates of the pointer when the event occured
  12001. * @param localY Defines the local y coordinates of the pointer when the event occured
  12002. */
  12003. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12004. }
  12005. /**
  12006. * This type contains all the data related to a pointer event in Babylon.js.
  12007. * 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.
  12008. */
  12009. export class PointerInfo extends PointerInfoBase {
  12010. /**
  12011. * Defines the picking info associated to the info (if any)\
  12012. */
  12013. pickInfo: Nullable<PickingInfo>;
  12014. /**
  12015. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param pickInfo Defines the picking info associated to the info (if any)\
  12019. */
  12020. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12021. /**
  12022. * Defines the picking info associated to the info (if any)\
  12023. */
  12024. pickInfo: Nullable<PickingInfo>);
  12025. }
  12026. /**
  12027. * Data relating to a touch event on the screen.
  12028. */
  12029. export interface PointerTouch {
  12030. /**
  12031. * X coordinate of touch.
  12032. */
  12033. x: number;
  12034. /**
  12035. * Y coordinate of touch.
  12036. */
  12037. y: number;
  12038. /**
  12039. * Id of touch. Unique for each finger.
  12040. */
  12041. pointerId: number;
  12042. /**
  12043. * Event type passed from DOM.
  12044. */
  12045. type: any;
  12046. }
  12047. }
  12048. declare module BABYLON {
  12049. /**
  12050. * Manage the mouse inputs to control the movement of a free camera.
  12051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12052. */
  12053. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12054. /**
  12055. * Define if touch is enabled in the mouse input
  12056. */
  12057. touchEnabled: boolean;
  12058. /**
  12059. * Defines the camera the input is attached to.
  12060. */
  12061. camera: FreeCamera;
  12062. /**
  12063. * Defines the buttons associated with the input to handle camera move.
  12064. */
  12065. buttons: number[];
  12066. /**
  12067. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12068. */
  12069. angularSensibility: number;
  12070. private _pointerInput;
  12071. private _onMouseMove;
  12072. private _observer;
  12073. private previousPosition;
  12074. /**
  12075. * Observable for when a pointer move event occurs containing the move offset
  12076. */
  12077. onPointerMovedObservable: Observable<{
  12078. offsetX: number;
  12079. offsetY: number;
  12080. }>;
  12081. /**
  12082. * @hidden
  12083. * If the camera should be rotated automatically based on pointer movement
  12084. */
  12085. _allowCameraRotation: boolean;
  12086. /**
  12087. * Manage the mouse inputs to control the movement of a free camera.
  12088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12089. * @param touchEnabled Defines if touch is enabled or not
  12090. */
  12091. constructor(
  12092. /**
  12093. * Define if touch is enabled in the mouse input
  12094. */
  12095. touchEnabled?: boolean);
  12096. /**
  12097. * Attach the input controls to a specific dom element to get the input from.
  12098. * @param element Defines the element the controls should be listened from
  12099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12100. */
  12101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12102. /**
  12103. * Called on JS contextmenu event.
  12104. * Override this method to provide functionality.
  12105. */
  12106. protected onContextMenu(evt: PointerEvent): void;
  12107. /**
  12108. * Detach the current controls from the specified dom element.
  12109. * @param element Defines the element to stop listening the inputs from
  12110. */
  12111. detachControl(element: Nullable<HTMLElement>): void;
  12112. /**
  12113. * Gets the class name of the current intput.
  12114. * @returns the class name
  12115. */
  12116. getClassName(): string;
  12117. /**
  12118. * Get the friendly name associated with the input class.
  12119. * @returns the input friendly name
  12120. */
  12121. getSimpleName(): string;
  12122. }
  12123. }
  12124. declare module BABYLON {
  12125. /**
  12126. * Manage the touch inputs to control the movement of a free camera.
  12127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12128. */
  12129. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12130. /**
  12131. * Defines the camera the input is attached to.
  12132. */
  12133. camera: FreeCamera;
  12134. /**
  12135. * Defines the touch sensibility for rotation.
  12136. * The higher the faster.
  12137. */
  12138. touchAngularSensibility: number;
  12139. /**
  12140. * Defines the touch sensibility for move.
  12141. * The higher the faster.
  12142. */
  12143. touchMoveSensibility: number;
  12144. private _offsetX;
  12145. private _offsetY;
  12146. private _pointerPressed;
  12147. private _pointerInput;
  12148. private _observer;
  12149. private _onLostFocus;
  12150. /**
  12151. * Attach the input controls to a specific dom element to get the input from.
  12152. * @param element Defines the element the controls should be listened from
  12153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12154. */
  12155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12156. /**
  12157. * Detach the current controls from the specified dom element.
  12158. * @param element Defines the element to stop listening the inputs from
  12159. */
  12160. detachControl(element: Nullable<HTMLElement>): void;
  12161. /**
  12162. * Update the current camera state depending on the inputs that have been used this frame.
  12163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12164. */
  12165. checkInputs(): void;
  12166. /**
  12167. * Gets the class name of the current intput.
  12168. * @returns the class name
  12169. */
  12170. getClassName(): string;
  12171. /**
  12172. * Get the friendly name associated with the input class.
  12173. * @returns the input friendly name
  12174. */
  12175. getSimpleName(): string;
  12176. }
  12177. }
  12178. declare module BABYLON {
  12179. /**
  12180. * Default Inputs manager for the FreeCamera.
  12181. * It groups all the default supported inputs for ease of use.
  12182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12183. */
  12184. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12185. /**
  12186. * @hidden
  12187. */
  12188. _mouseInput: Nullable<FreeCameraMouseInput>;
  12189. /**
  12190. * Instantiates a new FreeCameraInputsManager.
  12191. * @param camera Defines the camera the inputs belong to
  12192. */
  12193. constructor(camera: FreeCamera);
  12194. /**
  12195. * Add keyboard input support to the input manager.
  12196. * @returns the current input manager
  12197. */
  12198. addKeyboard(): FreeCameraInputsManager;
  12199. /**
  12200. * Add mouse input support to the input manager.
  12201. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12202. * @returns the current input manager
  12203. */
  12204. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12205. /**
  12206. * Removes the mouse input support from the manager
  12207. * @returns the current input manager
  12208. */
  12209. removeMouse(): FreeCameraInputsManager;
  12210. /**
  12211. * Add touch input support to the input manager.
  12212. * @returns the current input manager
  12213. */
  12214. addTouch(): FreeCameraInputsManager;
  12215. /**
  12216. * Remove all attached input methods from a camera
  12217. */
  12218. clear(): void;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12224. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12226. */
  12227. export class FreeCamera extends TargetCamera {
  12228. /**
  12229. * Define the collision ellipsoid of the camera.
  12230. * This is helpful to simulate a camera body like the player body around the camera
  12231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12232. */
  12233. ellipsoid: Vector3;
  12234. /**
  12235. * Define an offset for the position of the ellipsoid around the camera.
  12236. * This can be helpful to determine the center of the body near the gravity center of the body
  12237. * instead of its head.
  12238. */
  12239. ellipsoidOffset: Vector3;
  12240. /**
  12241. * Enable or disable collisions of the camera with the rest of the scene objects.
  12242. */
  12243. checkCollisions: boolean;
  12244. /**
  12245. * Enable or disable gravity on the camera.
  12246. */
  12247. applyGravity: boolean;
  12248. /**
  12249. * Define the input manager associated to the camera.
  12250. */
  12251. inputs: FreeCameraInputsManager;
  12252. /**
  12253. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12254. * Higher values reduce sensitivity.
  12255. */
  12256. get angularSensibility(): number;
  12257. /**
  12258. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12259. * Higher values reduce sensitivity.
  12260. */
  12261. set angularSensibility(value: number);
  12262. /**
  12263. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12264. */
  12265. get keysUp(): number[];
  12266. set keysUp(value: number[]);
  12267. /**
  12268. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12269. */
  12270. get keysDown(): number[];
  12271. set keysDown(value: number[]);
  12272. /**
  12273. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12274. */
  12275. get keysLeft(): number[];
  12276. set keysLeft(value: number[]);
  12277. /**
  12278. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12279. */
  12280. get keysRight(): number[];
  12281. set keysRight(value: number[]);
  12282. /**
  12283. * Event raised when the camera collide with a mesh in the scene.
  12284. */
  12285. onCollide: (collidedMesh: AbstractMesh) => void;
  12286. private _collider;
  12287. private _needMoveForGravity;
  12288. private _oldPosition;
  12289. private _diffPosition;
  12290. private _newPosition;
  12291. /** @hidden */
  12292. _localDirection: Vector3;
  12293. /** @hidden */
  12294. _transformedDirection: Vector3;
  12295. /**
  12296. * Instantiates a Free Camera.
  12297. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12298. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12299. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12300. * @param name Define the name of the camera in the scene
  12301. * @param position Define the start position of the camera in the scene
  12302. * @param scene Define the scene the camera belongs to
  12303. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12304. */
  12305. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12306. /**
  12307. * Attached controls to the current camera.
  12308. * @param element Defines the element the controls should be listened from
  12309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12310. */
  12311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12312. /**
  12313. * Detach the current controls from the camera.
  12314. * The camera will stop reacting to inputs.
  12315. * @param element Defines the element to stop listening the inputs from
  12316. */
  12317. detachControl(element: HTMLElement): void;
  12318. private _collisionMask;
  12319. /**
  12320. * Define a collision mask to limit the list of object the camera can collide with
  12321. */
  12322. get collisionMask(): number;
  12323. set collisionMask(mask: number);
  12324. /** @hidden */
  12325. _collideWithWorld(displacement: Vector3): void;
  12326. private _onCollisionPositionChange;
  12327. /** @hidden */
  12328. _checkInputs(): void;
  12329. /** @hidden */
  12330. _decideIfNeedsToMove(): boolean;
  12331. /** @hidden */
  12332. _updatePosition(): void;
  12333. /**
  12334. * Destroy the camera and release the current resources hold by it.
  12335. */
  12336. dispose(): void;
  12337. /**
  12338. * Gets the current object class name.
  12339. * @return the class name
  12340. */
  12341. getClassName(): string;
  12342. }
  12343. }
  12344. declare module BABYLON {
  12345. /**
  12346. * Represents a gamepad control stick position
  12347. */
  12348. export class StickValues {
  12349. /**
  12350. * The x component of the control stick
  12351. */
  12352. x: number;
  12353. /**
  12354. * The y component of the control stick
  12355. */
  12356. y: number;
  12357. /**
  12358. * Initializes the gamepad x and y control stick values
  12359. * @param x The x component of the gamepad control stick value
  12360. * @param y The y component of the gamepad control stick value
  12361. */
  12362. constructor(
  12363. /**
  12364. * The x component of the control stick
  12365. */
  12366. x: number,
  12367. /**
  12368. * The y component of the control stick
  12369. */
  12370. y: number);
  12371. }
  12372. /**
  12373. * An interface which manages callbacks for gamepad button changes
  12374. */
  12375. export interface GamepadButtonChanges {
  12376. /**
  12377. * Called when a gamepad has been changed
  12378. */
  12379. changed: boolean;
  12380. /**
  12381. * Called when a gamepad press event has been triggered
  12382. */
  12383. pressChanged: boolean;
  12384. /**
  12385. * Called when a touch event has been triggered
  12386. */
  12387. touchChanged: boolean;
  12388. /**
  12389. * Called when a value has changed
  12390. */
  12391. valueChanged: boolean;
  12392. }
  12393. /**
  12394. * Represents a gamepad
  12395. */
  12396. export class Gamepad {
  12397. /**
  12398. * The id of the gamepad
  12399. */
  12400. id: string;
  12401. /**
  12402. * The index of the gamepad
  12403. */
  12404. index: number;
  12405. /**
  12406. * The browser gamepad
  12407. */
  12408. browserGamepad: any;
  12409. /**
  12410. * Specifies what type of gamepad this represents
  12411. */
  12412. type: number;
  12413. private _leftStick;
  12414. private _rightStick;
  12415. /** @hidden */
  12416. _isConnected: boolean;
  12417. private _leftStickAxisX;
  12418. private _leftStickAxisY;
  12419. private _rightStickAxisX;
  12420. private _rightStickAxisY;
  12421. /**
  12422. * Triggered when the left control stick has been changed
  12423. */
  12424. private _onleftstickchanged;
  12425. /**
  12426. * Triggered when the right control stick has been changed
  12427. */
  12428. private _onrightstickchanged;
  12429. /**
  12430. * Represents a gamepad controller
  12431. */
  12432. static GAMEPAD: number;
  12433. /**
  12434. * Represents a generic controller
  12435. */
  12436. static GENERIC: number;
  12437. /**
  12438. * Represents an XBox controller
  12439. */
  12440. static XBOX: number;
  12441. /**
  12442. * Represents a pose-enabled controller
  12443. */
  12444. static POSE_ENABLED: number;
  12445. /**
  12446. * Represents an Dual Shock controller
  12447. */
  12448. static DUALSHOCK: number;
  12449. /**
  12450. * Specifies whether the left control stick should be Y-inverted
  12451. */
  12452. protected _invertLeftStickY: boolean;
  12453. /**
  12454. * Specifies if the gamepad has been connected
  12455. */
  12456. get isConnected(): boolean;
  12457. /**
  12458. * Initializes the gamepad
  12459. * @param id The id of the gamepad
  12460. * @param index The index of the gamepad
  12461. * @param browserGamepad The browser gamepad
  12462. * @param leftStickX The x component of the left joystick
  12463. * @param leftStickY The y component of the left joystick
  12464. * @param rightStickX The x component of the right joystick
  12465. * @param rightStickY The y component of the right joystick
  12466. */
  12467. constructor(
  12468. /**
  12469. * The id of the gamepad
  12470. */
  12471. id: string,
  12472. /**
  12473. * The index of the gamepad
  12474. */
  12475. index: number,
  12476. /**
  12477. * The browser gamepad
  12478. */
  12479. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12480. /**
  12481. * Callback triggered when the left joystick has changed
  12482. * @param callback
  12483. */
  12484. onleftstickchanged(callback: (values: StickValues) => void): void;
  12485. /**
  12486. * Callback triggered when the right joystick has changed
  12487. * @param callback
  12488. */
  12489. onrightstickchanged(callback: (values: StickValues) => void): void;
  12490. /**
  12491. * Gets the left joystick
  12492. */
  12493. get leftStick(): StickValues;
  12494. /**
  12495. * Sets the left joystick values
  12496. */
  12497. set leftStick(newValues: StickValues);
  12498. /**
  12499. * Gets the right joystick
  12500. */
  12501. get rightStick(): StickValues;
  12502. /**
  12503. * Sets the right joystick value
  12504. */
  12505. set rightStick(newValues: StickValues);
  12506. /**
  12507. * Updates the gamepad joystick positions
  12508. */
  12509. update(): void;
  12510. /**
  12511. * Disposes the gamepad
  12512. */
  12513. dispose(): void;
  12514. }
  12515. /**
  12516. * Represents a generic gamepad
  12517. */
  12518. export class GenericPad extends Gamepad {
  12519. private _buttons;
  12520. private _onbuttondown;
  12521. private _onbuttonup;
  12522. /**
  12523. * Observable triggered when a button has been pressed
  12524. */
  12525. onButtonDownObservable: Observable<number>;
  12526. /**
  12527. * Observable triggered when a button has been released
  12528. */
  12529. onButtonUpObservable: Observable<number>;
  12530. /**
  12531. * Callback triggered when a button has been pressed
  12532. * @param callback Called when a button has been pressed
  12533. */
  12534. onbuttondown(callback: (buttonPressed: number) => void): void;
  12535. /**
  12536. * Callback triggered when a button has been released
  12537. * @param callback Called when a button has been released
  12538. */
  12539. onbuttonup(callback: (buttonReleased: number) => void): void;
  12540. /**
  12541. * Initializes the generic gamepad
  12542. * @param id The id of the generic gamepad
  12543. * @param index The index of the generic gamepad
  12544. * @param browserGamepad The browser gamepad
  12545. */
  12546. constructor(id: string, index: number, browserGamepad: any);
  12547. private _setButtonValue;
  12548. /**
  12549. * Updates the generic gamepad
  12550. */
  12551. update(): void;
  12552. /**
  12553. * Disposes the generic gamepad
  12554. */
  12555. dispose(): void;
  12556. }
  12557. }
  12558. declare module BABYLON {
  12559. interface Engine {
  12560. /**
  12561. * Creates a raw texture
  12562. * @param data defines the data to store in the texture
  12563. * @param width defines the width of the texture
  12564. * @param height defines the height of the texture
  12565. * @param format defines the format of the data
  12566. * @param generateMipMaps defines if the engine should generate the mip levels
  12567. * @param invertY defines if data must be stored with Y axis inverted
  12568. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12569. * @param compression defines the compression used (null by default)
  12570. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12571. * @returns the raw texture inside an InternalTexture
  12572. */
  12573. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12574. /**
  12575. * Update a raw texture
  12576. * @param texture defines the texture to update
  12577. * @param data defines the data to store in the texture
  12578. * @param format defines the format of the data
  12579. * @param invertY defines if data must be stored with Y axis inverted
  12580. */
  12581. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12582. /**
  12583. * Update a raw texture
  12584. * @param texture defines the texture to update
  12585. * @param data defines the data to store in the texture
  12586. * @param format defines the format of the data
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param compression defines the compression used (null by default)
  12589. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12590. */
  12591. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12592. /**
  12593. * Creates a new raw cube texture
  12594. * @param data defines the array of data to use to create each face
  12595. * @param size defines the size of the textures
  12596. * @param format defines the format of the data
  12597. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12598. * @param generateMipMaps defines if the engine should generate the mip levels
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12601. * @param compression defines the compression used (null by default)
  12602. * @returns the cube texture as an InternalTexture
  12603. */
  12604. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12605. /**
  12606. * Update a raw cube texture
  12607. * @param texture defines the texture to udpdate
  12608. * @param data defines the data to store
  12609. * @param format defines the data format
  12610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. */
  12613. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12614. /**
  12615. * Update a raw cube texture
  12616. * @param texture defines the texture to udpdate
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12620. * @param invertY defines if data must be stored with Y axis inverted
  12621. * @param compression defines the compression used (null by default)
  12622. */
  12623. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12624. /**
  12625. * Update a raw cube texture
  12626. * @param texture defines the texture to udpdate
  12627. * @param data defines the data to store
  12628. * @param format defines the data format
  12629. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param compression defines the compression used (null by default)
  12632. * @param level defines which level of the texture to update
  12633. */
  12634. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12635. /**
  12636. * Creates a new raw cube texture from a specified url
  12637. * @param url defines the url where the data is located
  12638. * @param scene defines the current scene
  12639. * @param size defines the size of the textures
  12640. * @param format defines the format of the data
  12641. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12642. * @param noMipmap defines if the engine should avoid generating the mip levels
  12643. * @param callback defines a callback used to extract texture data from loaded data
  12644. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12645. * @param onLoad defines a callback called when texture is loaded
  12646. * @param onError defines a callback called if there is an error
  12647. * @returns the cube texture as an InternalTexture
  12648. */
  12649. 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;
  12650. /**
  12651. * Creates a new raw cube texture from a specified url
  12652. * @param url defines the url where the data is located
  12653. * @param scene defines the current scene
  12654. * @param size defines the size of the textures
  12655. * @param format defines the format of the data
  12656. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12657. * @param noMipmap defines if the engine should avoid generating the mip levels
  12658. * @param callback defines a callback used to extract texture data from loaded data
  12659. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12660. * @param onLoad defines a callback called when texture is loaded
  12661. * @param onError defines a callback called if there is an error
  12662. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12663. * @param invertY defines if data must be stored with Y axis inverted
  12664. * @returns the cube texture as an InternalTexture
  12665. */
  12666. 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;
  12667. /**
  12668. * Creates a new raw 3D texture
  12669. * @param data defines the data used to create the texture
  12670. * @param width defines the width of the texture
  12671. * @param height defines the height of the texture
  12672. * @param depth defines the depth of the texture
  12673. * @param format defines the format of the texture
  12674. * @param generateMipMaps defines if the engine must generate mip levels
  12675. * @param invertY defines if data must be stored with Y axis inverted
  12676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12677. * @param compression defines the compressed used (can be null)
  12678. * @param textureType defines the compressed used (can be null)
  12679. * @returns a new raw 3D texture (stored in an InternalTexture)
  12680. */
  12681. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12682. /**
  12683. * Update a raw 3D texture
  12684. * @param texture defines the texture to update
  12685. * @param data defines the data to store
  12686. * @param format defines the data format
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. */
  12689. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12690. /**
  12691. * Update a raw 3D texture
  12692. * @param texture defines the texture to update
  12693. * @param data defines the data to store
  12694. * @param format defines the data format
  12695. * @param invertY defines if data must be stored with Y axis inverted
  12696. * @param compression defines the used compression (can be null)
  12697. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12698. */
  12699. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12700. /**
  12701. * Creates a new raw 2D array texture
  12702. * @param data defines the data used to create the texture
  12703. * @param width defines the width of the texture
  12704. * @param height defines the height of the texture
  12705. * @param depth defines the number of layers of the texture
  12706. * @param format defines the format of the texture
  12707. * @param generateMipMaps defines if the engine must generate mip levels
  12708. * @param invertY defines if data must be stored with Y axis inverted
  12709. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12710. * @param compression defines the compressed used (can be null)
  12711. * @param textureType defines the compressed used (can be null)
  12712. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12713. */
  12714. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12715. /**
  12716. * Update a raw 2D array texture
  12717. * @param texture defines the texture to update
  12718. * @param data defines the data to store
  12719. * @param format defines the data format
  12720. * @param invertY defines if data must be stored with Y axis inverted
  12721. */
  12722. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12723. /**
  12724. * Update a raw 2D array texture
  12725. * @param texture defines the texture to update
  12726. * @param data defines the data to store
  12727. * @param format defines the data format
  12728. * @param invertY defines if data must be stored with Y axis inverted
  12729. * @param compression defines the used compression (can be null)
  12730. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12731. */
  12732. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12733. }
  12734. }
  12735. declare module BABYLON {
  12736. /**
  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. */
  12741. export class RawTexture extends Texture {
  12742. /**
  12743. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12744. */
  12745. format: number;
  12746. private _engine;
  12747. /**
  12748. * Instantiates a new RawTexture.
  12749. * Raw texture can help creating a texture directly from an array of data.
  12750. * This can be super useful if you either get the data from an uncompressed source or
  12751. * if you wish to create your texture pixel by pixel.
  12752. * @param data define the array of data to use to create the texture
  12753. * @param width define the width of the texture
  12754. * @param height define the height of the texture
  12755. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12756. * @param scene define the scene the texture belongs to
  12757. * @param generateMipMaps define whether mip maps should be generated or not
  12758. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12759. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12760. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12761. */
  12762. constructor(data: ArrayBufferView, width: number, height: number,
  12763. /**
  12764. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12765. */
  12766. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12767. /**
  12768. * Updates the texture underlying data.
  12769. * @param data Define the new data of the texture
  12770. */
  12771. update(data: ArrayBufferView): void;
  12772. /**
  12773. * Creates a luminance 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 texture
  12782. */
  12783. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12784. /**
  12785. * Creates a luminance 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 luminance alpha texture
  12794. */
  12795. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12796. /**
  12797. * Creates an alpha 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. * @returns the alpha texture
  12806. */
  12807. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12808. /**
  12809. * Creates a RGB texture from some data.
  12810. * @param data Define the texture data
  12811. * @param width Define the width of the texture
  12812. * @param height Define the height of the texture
  12813. * @param scene Define the scene the texture belongs to
  12814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12818. * @returns the RGB alpha texture
  12819. */
  12820. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12821. /**
  12822. * Creates a RGBA texture from some data.
  12823. * @param data Define the texture data
  12824. * @param width Define the width of the texture
  12825. * @param height Define the height of the texture
  12826. * @param scene Define the scene the texture belongs to
  12827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12830. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12831. * @returns the RGBA texture
  12832. */
  12833. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12834. /**
  12835. * Creates a R texture from some data.
  12836. * @param data Define the texture data
  12837. * @param width Define the width of the texture
  12838. * @param height Define the height of the texture
  12839. * @param scene Define the scene the texture belongs to
  12840. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12841. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12842. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12843. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12844. * @returns the R texture
  12845. */
  12846. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12847. }
  12848. }
  12849. declare module BABYLON {
  12850. /**
  12851. * Interface for the size containing width and height
  12852. */
  12853. export interface ISize {
  12854. /**
  12855. * Width
  12856. */
  12857. width: number;
  12858. /**
  12859. * Heighht
  12860. */
  12861. height: number;
  12862. }
  12863. /**
  12864. * Size containing widht and height
  12865. */
  12866. export class Size implements ISize {
  12867. /**
  12868. * Width
  12869. */
  12870. width: number;
  12871. /**
  12872. * Height
  12873. */
  12874. height: number;
  12875. /**
  12876. * Creates a Size object from the given width and height (floats).
  12877. * @param width width of the new size
  12878. * @param height height of the new size
  12879. */
  12880. constructor(width: number, height: number);
  12881. /**
  12882. * Returns a string with the Size width and height
  12883. * @returns a string with the Size width and height
  12884. */
  12885. toString(): string;
  12886. /**
  12887. * "Size"
  12888. * @returns the string "Size"
  12889. */
  12890. getClassName(): string;
  12891. /**
  12892. * Returns the Size hash code.
  12893. * @returns a hash code for a unique width and height
  12894. */
  12895. getHashCode(): number;
  12896. /**
  12897. * Updates the current size from the given one.
  12898. * @param src the given size
  12899. */
  12900. copyFrom(src: Size): void;
  12901. /**
  12902. * Updates in place the current Size from the given floats.
  12903. * @param width width of the new size
  12904. * @param height height of the new size
  12905. * @returns the updated Size.
  12906. */
  12907. copyFromFloats(width: number, height: number): Size;
  12908. /**
  12909. * Updates in place the current Size from the given floats.
  12910. * @param width width to set
  12911. * @param height height to set
  12912. * @returns the updated Size.
  12913. */
  12914. set(width: number, height: number): Size;
  12915. /**
  12916. * Multiplies the width and height by numbers
  12917. * @param w factor to multiple the width by
  12918. * @param h factor to multiple the height by
  12919. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12920. */
  12921. multiplyByFloats(w: number, h: number): Size;
  12922. /**
  12923. * Clones the size
  12924. * @returns a new Size copied from the given one.
  12925. */
  12926. clone(): Size;
  12927. /**
  12928. * True if the current Size and the given one width and height are strictly equal.
  12929. * @param other the other size to compare against
  12930. * @returns True if the current Size and the given one width and height are strictly equal.
  12931. */
  12932. equals(other: Size): boolean;
  12933. /**
  12934. * The surface of the Size : width * height (float).
  12935. */
  12936. get surface(): number;
  12937. /**
  12938. * Create a new size of zero
  12939. * @returns a new Size set to (0.0, 0.0)
  12940. */
  12941. static Zero(): Size;
  12942. /**
  12943. * Sums the width and height of two sizes
  12944. * @param otherSize size to add to this size
  12945. * @returns a new Size set as the addition result of the current Size and the given one.
  12946. */
  12947. add(otherSize: Size): Size;
  12948. /**
  12949. * Subtracts the width and height of two
  12950. * @param otherSize size to subtract to this size
  12951. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12952. */
  12953. subtract(otherSize: Size): Size;
  12954. /**
  12955. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12956. * @param start starting size to lerp between
  12957. * @param end end size to lerp between
  12958. * @param amount amount to lerp between the start and end values
  12959. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12960. */
  12961. static Lerp(start: Size, end: Size, amount: number): Size;
  12962. }
  12963. }
  12964. declare module BABYLON {
  12965. /**
  12966. * Defines a runtime animation
  12967. */
  12968. export class RuntimeAnimation {
  12969. private _events;
  12970. /**
  12971. * The current frame of the runtime animation
  12972. */
  12973. private _currentFrame;
  12974. /**
  12975. * The animation used by the runtime animation
  12976. */
  12977. private _animation;
  12978. /**
  12979. * The target of the runtime animation
  12980. */
  12981. private _target;
  12982. /**
  12983. * The initiating animatable
  12984. */
  12985. private _host;
  12986. /**
  12987. * The original value of the runtime animation
  12988. */
  12989. private _originalValue;
  12990. /**
  12991. * The original blend value of the runtime animation
  12992. */
  12993. private _originalBlendValue;
  12994. /**
  12995. * The offsets cache of the runtime animation
  12996. */
  12997. private _offsetsCache;
  12998. /**
  12999. * The high limits cache of the runtime animation
  13000. */
  13001. private _highLimitsCache;
  13002. /**
  13003. * Specifies if the runtime animation has been stopped
  13004. */
  13005. private _stopped;
  13006. /**
  13007. * The blending factor of the runtime animation
  13008. */
  13009. private _blendingFactor;
  13010. /**
  13011. * The BabylonJS scene
  13012. */
  13013. private _scene;
  13014. /**
  13015. * The current value of the runtime animation
  13016. */
  13017. private _currentValue;
  13018. /** @hidden */
  13019. _animationState: _IAnimationState;
  13020. /**
  13021. * The active target of the runtime animation
  13022. */
  13023. private _activeTargets;
  13024. private _currentActiveTarget;
  13025. private _directTarget;
  13026. /**
  13027. * The target path of the runtime animation
  13028. */
  13029. private _targetPath;
  13030. /**
  13031. * The weight of the runtime animation
  13032. */
  13033. private _weight;
  13034. /**
  13035. * The ratio offset of the runtime animation
  13036. */
  13037. private _ratioOffset;
  13038. /**
  13039. * The previous delay of the runtime animation
  13040. */
  13041. private _previousDelay;
  13042. /**
  13043. * The previous ratio of the runtime animation
  13044. */
  13045. private _previousRatio;
  13046. private _enableBlending;
  13047. private _keys;
  13048. private _minFrame;
  13049. private _maxFrame;
  13050. private _minValue;
  13051. private _maxValue;
  13052. private _targetIsArray;
  13053. /**
  13054. * Gets the current frame of the runtime animation
  13055. */
  13056. get currentFrame(): number;
  13057. /**
  13058. * Gets the weight of the runtime animation
  13059. */
  13060. get weight(): number;
  13061. /**
  13062. * Gets the current value of the runtime animation
  13063. */
  13064. get currentValue(): any;
  13065. /**
  13066. * Gets the target path of the runtime animation
  13067. */
  13068. get targetPath(): string;
  13069. /**
  13070. * Gets the actual target of the runtime animation
  13071. */
  13072. get target(): any;
  13073. /** @hidden */
  13074. _onLoop: () => void;
  13075. /**
  13076. * Create a new RuntimeAnimation object
  13077. * @param target defines the target of the animation
  13078. * @param animation defines the source animation object
  13079. * @param scene defines the hosting scene
  13080. * @param host defines the initiating Animatable
  13081. */
  13082. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13083. private _preparePath;
  13084. /**
  13085. * Gets the animation from the runtime animation
  13086. */
  13087. get animation(): Animation;
  13088. /**
  13089. * Resets the runtime animation to the beginning
  13090. * @param restoreOriginal defines whether to restore the target property to the original value
  13091. */
  13092. reset(restoreOriginal?: boolean): void;
  13093. /**
  13094. * Specifies if the runtime animation is stopped
  13095. * @returns Boolean specifying if the runtime animation is stopped
  13096. */
  13097. isStopped(): boolean;
  13098. /**
  13099. * Disposes of the runtime animation
  13100. */
  13101. dispose(): void;
  13102. /**
  13103. * Apply the interpolated value to the target
  13104. * @param currentValue defines the value computed by the animation
  13105. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13106. */
  13107. setValue(currentValue: any, weight: number): void;
  13108. private _getOriginalValues;
  13109. private _setValue;
  13110. /**
  13111. * Gets the loop pmode of the runtime animation
  13112. * @returns Loop Mode
  13113. */
  13114. private _getCorrectLoopMode;
  13115. /**
  13116. * Move the current animation to a given frame
  13117. * @param frame defines the frame to move to
  13118. */
  13119. goToFrame(frame: number): void;
  13120. /**
  13121. * @hidden Internal use only
  13122. */
  13123. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13124. /**
  13125. * Execute the current animation
  13126. * @param delay defines the delay to add to the current frame
  13127. * @param from defines the lower bound of the animation range
  13128. * @param to defines the upper bound of the animation range
  13129. * @param loop defines if the current animation must loop
  13130. * @param speedRatio defines the current speed ratio
  13131. * @param weight defines the weight of the animation (default is -1 so no weight)
  13132. * @param onLoop optional callback called when animation loops
  13133. * @returns a boolean indicating if the animation is running
  13134. */
  13135. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13136. }
  13137. }
  13138. declare module BABYLON {
  13139. /**
  13140. * Class used to store an actual running animation
  13141. */
  13142. export class Animatable {
  13143. /** defines the target object */
  13144. target: any;
  13145. /** defines the starting frame number (default is 0) */
  13146. fromFrame: number;
  13147. /** defines the ending frame number (default is 100) */
  13148. toFrame: number;
  13149. /** defines if the animation must loop (default is false) */
  13150. loopAnimation: boolean;
  13151. /** defines a callback to call when animation ends if it is not looping */
  13152. onAnimationEnd?: (() => void) | null | undefined;
  13153. /** defines a callback to call when animation loops */
  13154. onAnimationLoop?: (() => void) | null | undefined;
  13155. private _localDelayOffset;
  13156. private _pausedDelay;
  13157. private _runtimeAnimations;
  13158. private _paused;
  13159. private _scene;
  13160. private _speedRatio;
  13161. private _weight;
  13162. private _syncRoot;
  13163. /**
  13164. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13165. * This will only apply for non looping animation (default is true)
  13166. */
  13167. disposeOnEnd: boolean;
  13168. /**
  13169. * Gets a boolean indicating if the animation has started
  13170. */
  13171. animationStarted: boolean;
  13172. /**
  13173. * Observer raised when the animation ends
  13174. */
  13175. onAnimationEndObservable: Observable<Animatable>;
  13176. /**
  13177. * Observer raised when the animation loops
  13178. */
  13179. onAnimationLoopObservable: Observable<Animatable>;
  13180. /**
  13181. * Gets the root Animatable used to synchronize and normalize animations
  13182. */
  13183. get syncRoot(): Nullable<Animatable>;
  13184. /**
  13185. * Gets the current frame of the first RuntimeAnimation
  13186. * Used to synchronize Animatables
  13187. */
  13188. get masterFrame(): number;
  13189. /**
  13190. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13191. */
  13192. get weight(): number;
  13193. set weight(value: number);
  13194. /**
  13195. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13196. */
  13197. get speedRatio(): number;
  13198. set speedRatio(value: number);
  13199. /**
  13200. * Creates a new Animatable
  13201. * @param scene defines the hosting scene
  13202. * @param target defines the target object
  13203. * @param fromFrame defines the starting frame number (default is 0)
  13204. * @param toFrame defines the ending frame number (default is 100)
  13205. * @param loopAnimation defines if the animation must loop (default is false)
  13206. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13207. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13208. * @param animations defines a group of animation to add to the new Animatable
  13209. * @param onAnimationLoop defines a callback to call when animation loops
  13210. */
  13211. constructor(scene: Scene,
  13212. /** defines the target object */
  13213. target: any,
  13214. /** defines the starting frame number (default is 0) */
  13215. fromFrame?: number,
  13216. /** defines the ending frame number (default is 100) */
  13217. toFrame?: number,
  13218. /** defines if the animation must loop (default is false) */
  13219. loopAnimation?: boolean, speedRatio?: number,
  13220. /** defines a callback to call when animation ends if it is not looping */
  13221. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13222. /** defines a callback to call when animation loops */
  13223. onAnimationLoop?: (() => void) | null | undefined);
  13224. /**
  13225. * Synchronize and normalize current Animatable with a source Animatable
  13226. * This is useful when using animation weights and when animations are not of the same length
  13227. * @param root defines the root Animatable to synchronize with
  13228. * @returns the current Animatable
  13229. */
  13230. syncWith(root: Animatable): Animatable;
  13231. /**
  13232. * Gets the list of runtime animations
  13233. * @returns an array of RuntimeAnimation
  13234. */
  13235. getAnimations(): RuntimeAnimation[];
  13236. /**
  13237. * Adds more animations to the current animatable
  13238. * @param target defines the target of the animations
  13239. * @param animations defines the new animations to add
  13240. */
  13241. appendAnimations(target: any, animations: Animation[]): void;
  13242. /**
  13243. * Gets the source animation for a specific property
  13244. * @param property defines the propertyu to look for
  13245. * @returns null or the source animation for the given property
  13246. */
  13247. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13248. /**
  13249. * Gets the runtime animation for a specific property
  13250. * @param property defines the propertyu to look for
  13251. * @returns null or the runtime animation for the given property
  13252. */
  13253. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13254. /**
  13255. * Resets the animatable to its original state
  13256. */
  13257. reset(): void;
  13258. /**
  13259. * Allows the animatable to blend with current running animations
  13260. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13261. * @param blendingSpeed defines the blending speed to use
  13262. */
  13263. enableBlending(blendingSpeed: number): void;
  13264. /**
  13265. * Disable animation blending
  13266. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13267. */
  13268. disableBlending(): void;
  13269. /**
  13270. * Jump directly to a given frame
  13271. * @param frame defines the frame to jump to
  13272. */
  13273. goToFrame(frame: number): void;
  13274. /**
  13275. * Pause the animation
  13276. */
  13277. pause(): void;
  13278. /**
  13279. * Restart the animation
  13280. */
  13281. restart(): void;
  13282. private _raiseOnAnimationEnd;
  13283. /**
  13284. * Stop and delete the current animation
  13285. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13286. * @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)
  13287. */
  13288. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13289. /**
  13290. * Wait asynchronously for the animation to end
  13291. * @returns a promise which will be fullfilled when the animation ends
  13292. */
  13293. waitAsync(): Promise<Animatable>;
  13294. /** @hidden */
  13295. _animate(delay: number): boolean;
  13296. }
  13297. interface Scene {
  13298. /** @hidden */
  13299. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13300. /** @hidden */
  13301. _processLateAnimationBindingsForMatrices(holder: {
  13302. totalWeight: number;
  13303. animations: RuntimeAnimation[];
  13304. originalValue: Matrix;
  13305. }): any;
  13306. /** @hidden */
  13307. _processLateAnimationBindingsForQuaternions(holder: {
  13308. totalWeight: number;
  13309. animations: RuntimeAnimation[];
  13310. originalValue: Quaternion;
  13311. }, refQuaternion: Quaternion): Quaternion;
  13312. /** @hidden */
  13313. _processLateAnimationBindings(): void;
  13314. /**
  13315. * Will start the animation sequence of a given target
  13316. * @param target defines the target
  13317. * @param from defines from which frame should animation start
  13318. * @param to defines until which frame should animation run.
  13319. * @param weight defines the weight to apply to the animation (1.0 by default)
  13320. * @param loop defines if the animation loops
  13321. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13322. * @param onAnimationEnd defines the function to be executed when the animation ends
  13323. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13324. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13325. * @param onAnimationLoop defines the callback to call when an animation loops
  13326. * @returns the animatable object created for this animation
  13327. */
  13328. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13329. /**
  13330. * Will start the animation sequence of a given target
  13331. * @param target defines the target
  13332. * @param from defines from which frame should animation start
  13333. * @param to defines until which frame should animation run.
  13334. * @param loop defines if the animation loops
  13335. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13336. * @param onAnimationEnd defines the function to be executed when the animation ends
  13337. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13338. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13339. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13340. * @param onAnimationLoop defines the callback to call when an animation loops
  13341. * @returns the animatable object created for this animation
  13342. */
  13343. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13344. /**
  13345. * Will start the animation sequence of a given target and its hierarchy
  13346. * @param target defines the target
  13347. * @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.
  13348. * @param from defines from which frame should animation start
  13349. * @param to defines until which frame should animation run.
  13350. * @param loop defines if the animation loops
  13351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13352. * @param onAnimationEnd defines the function to be executed when the animation ends
  13353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13354. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13355. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13356. * @param onAnimationLoop defines the callback to call when an animation loops
  13357. * @returns the list of created animatables
  13358. */
  13359. 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[];
  13360. /**
  13361. * Begin a new animation on a given node
  13362. * @param target defines the target where the animation will take place
  13363. * @param animations defines the list of animations to start
  13364. * @param from defines the initial value
  13365. * @param to defines the final value
  13366. * @param loop defines if you want animation to loop (off by default)
  13367. * @param speedRatio defines the speed ratio to apply to all animations
  13368. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13369. * @param onAnimationLoop defines the callback to call when an animation loops
  13370. * @returns the list of created animatables
  13371. */
  13372. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13373. /**
  13374. * Begin a new animation on a given node and its hierarchy
  13375. * @param target defines the root node where the animation will take place
  13376. * @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.
  13377. * @param animations defines the list of animations to start
  13378. * @param from defines the initial value
  13379. * @param to defines the final value
  13380. * @param loop defines if you want animation to loop (off by default)
  13381. * @param speedRatio defines the speed ratio to apply to all animations
  13382. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13383. * @param onAnimationLoop defines the callback to call when an animation loops
  13384. * @returns the list of animatables created for all nodes
  13385. */
  13386. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13387. /**
  13388. * Gets the animatable associated with a specific target
  13389. * @param target defines the target of the animatable
  13390. * @returns the required animatable if found
  13391. */
  13392. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13393. /**
  13394. * Gets all animatables associated with a given target
  13395. * @param target defines the target to look animatables for
  13396. * @returns an array of Animatables
  13397. */
  13398. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13399. /**
  13400. * Stops and removes all animations that have been applied to the scene
  13401. */
  13402. stopAllAnimations(): void;
  13403. /**
  13404. * Gets the current delta time used by animation engine
  13405. */
  13406. deltaTime: number;
  13407. }
  13408. interface Bone {
  13409. /**
  13410. * Copy an animation range from another bone
  13411. * @param source defines the source bone
  13412. * @param rangeName defines the range name to copy
  13413. * @param frameOffset defines the frame offset
  13414. * @param rescaleAsRequired defines if rescaling must be applied if required
  13415. * @param skelDimensionsRatio defines the scaling ratio
  13416. * @returns true if operation was successful
  13417. */
  13418. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13419. }
  13420. }
  13421. declare module BABYLON {
  13422. /**
  13423. * Class used to override all child animations of a given target
  13424. */
  13425. export class AnimationPropertiesOverride {
  13426. /**
  13427. * Gets or sets a value indicating if animation blending must be used
  13428. */
  13429. enableBlending: boolean;
  13430. /**
  13431. * Gets or sets the blending speed to use when enableBlending is true
  13432. */
  13433. blendingSpeed: number;
  13434. /**
  13435. * Gets or sets the default loop mode to use
  13436. */
  13437. loopMode: number;
  13438. }
  13439. }
  13440. declare module BABYLON {
  13441. /**
  13442. * Class used to handle skinning animations
  13443. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13444. */
  13445. export class Skeleton implements IAnimatable {
  13446. /** defines the skeleton name */
  13447. name: string;
  13448. /** defines the skeleton Id */
  13449. id: string;
  13450. /**
  13451. * Defines the list of child bones
  13452. */
  13453. bones: Bone[];
  13454. /**
  13455. * Defines an estimate of the dimension of the skeleton at rest
  13456. */
  13457. dimensionsAtRest: Vector3;
  13458. /**
  13459. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13460. */
  13461. needInitialSkinMatrix: boolean;
  13462. /**
  13463. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13464. */
  13465. overrideMesh: Nullable<AbstractMesh>;
  13466. /**
  13467. * Gets the list of animations attached to this skeleton
  13468. */
  13469. animations: Array<Animation>;
  13470. private _scene;
  13471. private _isDirty;
  13472. private _transformMatrices;
  13473. private _transformMatrixTexture;
  13474. private _meshesWithPoseMatrix;
  13475. private _animatables;
  13476. private _identity;
  13477. private _synchronizedWithMesh;
  13478. private _ranges;
  13479. private _lastAbsoluteTransformsUpdateId;
  13480. private _canUseTextureForBones;
  13481. private _uniqueId;
  13482. /** @hidden */
  13483. _numBonesWithLinkedTransformNode: number;
  13484. /** @hidden */
  13485. _hasWaitingData: Nullable<boolean>;
  13486. /**
  13487. * Specifies if the skeleton should be serialized
  13488. */
  13489. doNotSerialize: boolean;
  13490. private _useTextureToStoreBoneMatrices;
  13491. /**
  13492. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13493. * Please note that this option is not available if the hardware does not support it
  13494. */
  13495. get useTextureToStoreBoneMatrices(): boolean;
  13496. set useTextureToStoreBoneMatrices(value: boolean);
  13497. private _animationPropertiesOverride;
  13498. /**
  13499. * Gets or sets the animation properties override
  13500. */
  13501. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13502. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13503. /**
  13504. * List of inspectable custom properties (used by the Inspector)
  13505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13506. */
  13507. inspectableCustomProperties: IInspectable[];
  13508. /**
  13509. * An observable triggered before computing the skeleton's matrices
  13510. */
  13511. onBeforeComputeObservable: Observable<Skeleton>;
  13512. /**
  13513. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13514. */
  13515. get isUsingTextureForMatrices(): boolean;
  13516. /**
  13517. * Gets the unique ID of this skeleton
  13518. */
  13519. get uniqueId(): number;
  13520. /**
  13521. * Creates a new skeleton
  13522. * @param name defines the skeleton name
  13523. * @param id defines the skeleton Id
  13524. * @param scene defines the hosting scene
  13525. */
  13526. constructor(
  13527. /** defines the skeleton name */
  13528. name: string,
  13529. /** defines the skeleton Id */
  13530. id: string, scene: Scene);
  13531. /**
  13532. * Gets the current object class name.
  13533. * @return the class name
  13534. */
  13535. getClassName(): string;
  13536. /**
  13537. * Returns an array containing the root bones
  13538. * @returns an array containing the root bones
  13539. */
  13540. getChildren(): Array<Bone>;
  13541. /**
  13542. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13543. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13544. * @returns a Float32Array containing matrices data
  13545. */
  13546. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13547. /**
  13548. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13549. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13550. * @returns a raw texture containing the data
  13551. */
  13552. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13553. /**
  13554. * Gets the current hosting scene
  13555. * @returns a scene object
  13556. */
  13557. getScene(): Scene;
  13558. /**
  13559. * Gets a string representing the current skeleton data
  13560. * @param fullDetails defines a boolean indicating if we want a verbose version
  13561. * @returns a string representing the current skeleton data
  13562. */
  13563. toString(fullDetails?: boolean): string;
  13564. /**
  13565. * Get bone's index searching by name
  13566. * @param name defines bone's name to search for
  13567. * @return the indice of the bone. Returns -1 if not found
  13568. */
  13569. getBoneIndexByName(name: string): number;
  13570. /**
  13571. * Creater a new animation range
  13572. * @param name defines the name of the range
  13573. * @param from defines the start key
  13574. * @param to defines the end key
  13575. */
  13576. createAnimationRange(name: string, from: number, to: number): void;
  13577. /**
  13578. * Delete a specific animation range
  13579. * @param name defines the name of the range
  13580. * @param deleteFrames defines if frames must be removed as well
  13581. */
  13582. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13583. /**
  13584. * Gets a specific animation range
  13585. * @param name defines the name of the range to look for
  13586. * @returns the requested animation range or null if not found
  13587. */
  13588. getAnimationRange(name: string): Nullable<AnimationRange>;
  13589. /**
  13590. * Gets the list of all animation ranges defined on this skeleton
  13591. * @returns an array
  13592. */
  13593. getAnimationRanges(): Nullable<AnimationRange>[];
  13594. /**
  13595. * Copy animation range from a source skeleton.
  13596. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13597. * @param source defines the source skeleton
  13598. * @param name defines the name of the range to copy
  13599. * @param rescaleAsRequired defines if rescaling must be applied if required
  13600. * @returns true if operation was successful
  13601. */
  13602. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13603. /**
  13604. * Forces the skeleton to go to rest pose
  13605. */
  13606. returnToRest(): void;
  13607. private _getHighestAnimationFrame;
  13608. /**
  13609. * Begin a specific animation range
  13610. * @param name defines the name of the range to start
  13611. * @param loop defines if looping must be turned on (false by default)
  13612. * @param speedRatio defines the speed ratio to apply (1 by default)
  13613. * @param onAnimationEnd defines a callback which will be called when animation will end
  13614. * @returns a new animatable
  13615. */
  13616. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13617. /** @hidden */
  13618. _markAsDirty(): void;
  13619. /** @hidden */
  13620. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13621. /** @hidden */
  13622. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13623. private _computeTransformMatrices;
  13624. /**
  13625. * Build all resources required to render a skeleton
  13626. */
  13627. prepare(): void;
  13628. /**
  13629. * Gets the list of animatables currently running for this skeleton
  13630. * @returns an array of animatables
  13631. */
  13632. getAnimatables(): IAnimatable[];
  13633. /**
  13634. * Clone the current skeleton
  13635. * @param name defines the name of the new skeleton
  13636. * @param id defines the id of the new skeleton
  13637. * @returns the new skeleton
  13638. */
  13639. clone(name: string, id?: string): Skeleton;
  13640. /**
  13641. * Enable animation blending for this skeleton
  13642. * @param blendingSpeed defines the blending speed to apply
  13643. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13644. */
  13645. enableBlending(blendingSpeed?: number): void;
  13646. /**
  13647. * Releases all resources associated with the current skeleton
  13648. */
  13649. dispose(): void;
  13650. /**
  13651. * Serialize the skeleton in a JSON object
  13652. * @returns a JSON object
  13653. */
  13654. serialize(): any;
  13655. /**
  13656. * Creates a new skeleton from serialized data
  13657. * @param parsedSkeleton defines the serialized data
  13658. * @param scene defines the hosting scene
  13659. * @returns a new skeleton
  13660. */
  13661. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13662. /**
  13663. * Compute all node absolute transforms
  13664. * @param forceUpdate defines if computation must be done even if cache is up to date
  13665. */
  13666. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13667. /**
  13668. * Gets the root pose matrix
  13669. * @returns a matrix
  13670. */
  13671. getPoseMatrix(): Nullable<Matrix>;
  13672. /**
  13673. * Sorts bones per internal index
  13674. */
  13675. sortBones(): void;
  13676. private _sortBones;
  13677. }
  13678. }
  13679. declare module BABYLON {
  13680. /**
  13681. * Class used to store bone information
  13682. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13683. */
  13684. export class Bone extends Node {
  13685. /**
  13686. * defines the bone name
  13687. */
  13688. name: string;
  13689. private static _tmpVecs;
  13690. private static _tmpQuat;
  13691. private static _tmpMats;
  13692. /**
  13693. * Gets the list of child bones
  13694. */
  13695. children: Bone[];
  13696. /** Gets the animations associated with this bone */
  13697. animations: Animation[];
  13698. /**
  13699. * Gets or sets bone length
  13700. */
  13701. length: number;
  13702. /**
  13703. * @hidden Internal only
  13704. * Set this value to map this bone to a different index in the transform matrices
  13705. * Set this value to -1 to exclude the bone from the transform matrices
  13706. */
  13707. _index: Nullable<number>;
  13708. private _skeleton;
  13709. private _localMatrix;
  13710. private _restPose;
  13711. private _baseMatrix;
  13712. private _absoluteTransform;
  13713. private _invertedAbsoluteTransform;
  13714. private _parent;
  13715. private _scalingDeterminant;
  13716. private _worldTransform;
  13717. private _localScaling;
  13718. private _localRotation;
  13719. private _localPosition;
  13720. private _needToDecompose;
  13721. private _needToCompose;
  13722. /** @hidden */
  13723. _linkedTransformNode: Nullable<TransformNode>;
  13724. /** @hidden */
  13725. _waitingTransformNodeId: Nullable<string>;
  13726. /** @hidden */
  13727. get _matrix(): Matrix;
  13728. /** @hidden */
  13729. set _matrix(value: Matrix);
  13730. /**
  13731. * Create a new bone
  13732. * @param name defines the bone name
  13733. * @param skeleton defines the parent skeleton
  13734. * @param parentBone defines the parent (can be null if the bone is the root)
  13735. * @param localMatrix defines the local matrix
  13736. * @param restPose defines the rest pose matrix
  13737. * @param baseMatrix defines the base matrix
  13738. * @param index defines index of the bone in the hiearchy
  13739. */
  13740. constructor(
  13741. /**
  13742. * defines the bone name
  13743. */
  13744. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13745. /**
  13746. * Gets the current object class name.
  13747. * @return the class name
  13748. */
  13749. getClassName(): string;
  13750. /**
  13751. * Gets the parent skeleton
  13752. * @returns a skeleton
  13753. */
  13754. getSkeleton(): Skeleton;
  13755. /**
  13756. * Gets parent bone
  13757. * @returns a bone or null if the bone is the root of the bone hierarchy
  13758. */
  13759. getParent(): Nullable<Bone>;
  13760. /**
  13761. * Returns an array containing the root bones
  13762. * @returns an array containing the root bones
  13763. */
  13764. getChildren(): Array<Bone>;
  13765. /**
  13766. * Gets the node index in matrix array generated for rendering
  13767. * @returns the node index
  13768. */
  13769. getIndex(): number;
  13770. /**
  13771. * Sets the parent bone
  13772. * @param parent defines the parent (can be null if the bone is the root)
  13773. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13774. */
  13775. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13776. /**
  13777. * Gets the local matrix
  13778. * @returns a matrix
  13779. */
  13780. getLocalMatrix(): Matrix;
  13781. /**
  13782. * Gets the base matrix (initial matrix which remains unchanged)
  13783. * @returns a matrix
  13784. */
  13785. getBaseMatrix(): Matrix;
  13786. /**
  13787. * Gets the rest pose matrix
  13788. * @returns a matrix
  13789. */
  13790. getRestPose(): Matrix;
  13791. /**
  13792. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13793. */
  13794. getWorldMatrix(): Matrix;
  13795. /**
  13796. * Sets the local matrix to rest pose matrix
  13797. */
  13798. returnToRest(): void;
  13799. /**
  13800. * Gets the inverse of the absolute transform matrix.
  13801. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13802. * @returns a matrix
  13803. */
  13804. getInvertedAbsoluteTransform(): Matrix;
  13805. /**
  13806. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13807. * @returns a matrix
  13808. */
  13809. getAbsoluteTransform(): Matrix;
  13810. /**
  13811. * Links with the given transform node.
  13812. * The local matrix of this bone is copied from the transform node every frame.
  13813. * @param transformNode defines the transform node to link to
  13814. */
  13815. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13816. /**
  13817. * Gets the node used to drive the bone's transformation
  13818. * @returns a transform node or null
  13819. */
  13820. getTransformNode(): Nullable<TransformNode>;
  13821. /** Gets or sets current position (in local space) */
  13822. get position(): Vector3;
  13823. set position(newPosition: Vector3);
  13824. /** Gets or sets current rotation (in local space) */
  13825. get rotation(): Vector3;
  13826. set rotation(newRotation: Vector3);
  13827. /** Gets or sets current rotation quaternion (in local space) */
  13828. get rotationQuaternion(): Quaternion;
  13829. set rotationQuaternion(newRotation: Quaternion);
  13830. /** Gets or sets current scaling (in local space) */
  13831. get scaling(): Vector3;
  13832. set scaling(newScaling: Vector3);
  13833. /**
  13834. * Gets the animation properties override
  13835. */
  13836. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13837. private _decompose;
  13838. private _compose;
  13839. /**
  13840. * Update the base and local matrices
  13841. * @param matrix defines the new base or local matrix
  13842. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13843. * @param updateLocalMatrix defines if the local matrix should be updated
  13844. */
  13845. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13846. /** @hidden */
  13847. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13848. /**
  13849. * Flag the bone as dirty (Forcing it to update everything)
  13850. */
  13851. markAsDirty(): void;
  13852. /** @hidden */
  13853. _markAsDirtyAndCompose(): void;
  13854. private _markAsDirtyAndDecompose;
  13855. /**
  13856. * Translate the bone in local or world space
  13857. * @param vec The amount to translate the bone
  13858. * @param space The space that the translation is in
  13859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13860. */
  13861. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13862. /**
  13863. * Set the postion of the bone in local or world space
  13864. * @param position The position to set the bone
  13865. * @param space The space that the position is in
  13866. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13867. */
  13868. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13869. /**
  13870. * Set the absolute position of the bone (world space)
  13871. * @param position The position to set the bone
  13872. * @param mesh The mesh that this bone is attached to
  13873. */
  13874. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13875. /**
  13876. * Scale the bone on the x, y and z axes (in local space)
  13877. * @param x The amount to scale the bone on the x axis
  13878. * @param y The amount to scale the bone on the y axis
  13879. * @param z The amount to scale the bone on the z axis
  13880. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13881. */
  13882. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13883. /**
  13884. * Set the bone scaling in local space
  13885. * @param scale defines the scaling vector
  13886. */
  13887. setScale(scale: Vector3): void;
  13888. /**
  13889. * Gets the current scaling in local space
  13890. * @returns the current scaling vector
  13891. */
  13892. getScale(): Vector3;
  13893. /**
  13894. * Gets the current scaling in local space and stores it in a target vector
  13895. * @param result defines the target vector
  13896. */
  13897. getScaleToRef(result: Vector3): void;
  13898. /**
  13899. * Set the yaw, pitch, and roll of the bone in local or world space
  13900. * @param yaw The rotation of the bone on the y axis
  13901. * @param pitch The rotation of the bone on the x axis
  13902. * @param roll The rotation of the bone on the z axis
  13903. * @param space The space that the axes of rotation are in
  13904. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13905. */
  13906. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13907. /**
  13908. * Add a rotation to the bone on an axis in local or world space
  13909. * @param axis The axis to rotate the bone on
  13910. * @param amount The amount to rotate the bone
  13911. * @param space The space that the axis is in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. */
  13914. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13915. /**
  13916. * Set the rotation of the bone to a particular axis angle in local or world space
  13917. * @param axis The axis to rotate the bone on
  13918. * @param angle The angle that the bone should be rotated to
  13919. * @param space The space that the axis is in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. */
  13922. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Set the euler rotation of the bone in local of world space
  13925. * @param rotation The euler rotation that the bone should be set to
  13926. * @param space The space that the rotation is in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Set the quaternion rotation of the bone in local of world space
  13932. * @param quat The quaternion rotation that the bone should be set to
  13933. * @param space The space that the rotation is in
  13934. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13935. */
  13936. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13937. /**
  13938. * Set the rotation matrix of the bone in local of world space
  13939. * @param rotMat The rotation matrix that the bone should be set to
  13940. * @param space The space that the rotation is in
  13941. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13942. */
  13943. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13944. private _rotateWithMatrix;
  13945. private _getNegativeRotationToRef;
  13946. /**
  13947. * Get the position of the bone in local or world space
  13948. * @param space The space that the returned position is in
  13949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13950. * @returns The position of the bone
  13951. */
  13952. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13953. /**
  13954. * Copy the position of the bone to a vector3 in local or world space
  13955. * @param space The space that the returned position is in
  13956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13957. * @param result The vector3 to copy the position to
  13958. */
  13959. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13960. /**
  13961. * Get the absolute position of the bone (world space)
  13962. * @param mesh The mesh that this bone is attached to
  13963. * @returns The absolute position of the bone
  13964. */
  13965. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13966. /**
  13967. * Copy the absolute position of the bone (world space) to the result param
  13968. * @param mesh The mesh that this bone is attached to
  13969. * @param result The vector3 to copy the absolute position to
  13970. */
  13971. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13972. /**
  13973. * Compute the absolute transforms of this bone and its children
  13974. */
  13975. computeAbsoluteTransforms(): void;
  13976. /**
  13977. * Get the world direction from an axis that is in the local space of the bone
  13978. * @param localAxis The local direction that is used to compute the world direction
  13979. * @param mesh The mesh that this bone is attached to
  13980. * @returns The world direction
  13981. */
  13982. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13983. /**
  13984. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13985. * @param localAxis The local direction that is used to compute the world direction
  13986. * @param mesh The mesh that this bone is attached to
  13987. * @param result The vector3 that the world direction will be copied to
  13988. */
  13989. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13990. /**
  13991. * Get the euler rotation of the bone in local or world space
  13992. * @param space The space that the rotation should be in
  13993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13994. * @returns The euler rotation
  13995. */
  13996. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13997. /**
  13998. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13999. * @param space The space that the rotation should be in
  14000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14001. * @param result The vector3 that the rotation should be copied to
  14002. */
  14003. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14004. /**
  14005. * Get the quaternion rotation of the bone in either local or world space
  14006. * @param space The space that the rotation should be in
  14007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14008. * @returns The quaternion rotation
  14009. */
  14010. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14011. /**
  14012. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14013. * @param space The space that the rotation should be in
  14014. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14015. * @param result The quaternion that the rotation should be copied to
  14016. */
  14017. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14018. /**
  14019. * Get the rotation matrix of the bone in local or world space
  14020. * @param space The space that the rotation should be in
  14021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14022. * @returns The rotation matrix
  14023. */
  14024. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14025. /**
  14026. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14027. * @param space The space that the rotation should be in
  14028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14029. * @param result The quaternion that the rotation should be copied to
  14030. */
  14031. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14032. /**
  14033. * Get the world position of a point that is in the local space of the bone
  14034. * @param position The local position
  14035. * @param mesh The mesh that this bone is attached to
  14036. * @returns The world position
  14037. */
  14038. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14039. /**
  14040. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14041. * @param position The local position
  14042. * @param mesh The mesh that this bone is attached to
  14043. * @param result The vector3 that the world position should be copied to
  14044. */
  14045. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14046. /**
  14047. * Get the local position of a point that is in world space
  14048. * @param position The world position
  14049. * @param mesh The mesh that this bone is attached to
  14050. * @returns The local position
  14051. */
  14052. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14053. /**
  14054. * Get the local position of a point that is in world space and copy it to the result param
  14055. * @param position The world position
  14056. * @param mesh The mesh that this bone is attached to
  14057. * @param result The vector3 that the local position should be copied to
  14058. */
  14059. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14060. }
  14061. }
  14062. declare module BABYLON {
  14063. /**
  14064. * 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.
  14065. * @see https://doc.babylonjs.com/how_to/transformnode
  14066. */
  14067. export class TransformNode extends Node {
  14068. /**
  14069. * Object will not rotate to face the camera
  14070. */
  14071. static BILLBOARDMODE_NONE: number;
  14072. /**
  14073. * Object will rotate to face the camera but only on the x axis
  14074. */
  14075. static BILLBOARDMODE_X: number;
  14076. /**
  14077. * Object will rotate to face the camera but only on the y axis
  14078. */
  14079. static BILLBOARDMODE_Y: number;
  14080. /**
  14081. * Object will rotate to face the camera but only on the z axis
  14082. */
  14083. static BILLBOARDMODE_Z: number;
  14084. /**
  14085. * Object will rotate to face the camera
  14086. */
  14087. static BILLBOARDMODE_ALL: number;
  14088. /**
  14089. * Object will rotate to face the camera's position instead of orientation
  14090. */
  14091. static BILLBOARDMODE_USE_POSITION: number;
  14092. private _forward;
  14093. private _forwardInverted;
  14094. private _up;
  14095. private _right;
  14096. private _rightInverted;
  14097. private _position;
  14098. private _rotation;
  14099. private _rotationQuaternion;
  14100. protected _scaling: Vector3;
  14101. protected _isDirty: boolean;
  14102. private _transformToBoneReferal;
  14103. private _isAbsoluteSynced;
  14104. private _billboardMode;
  14105. /**
  14106. * Gets or sets the billboard mode. Default is 0.
  14107. *
  14108. * | Value | Type | Description |
  14109. * | --- | --- | --- |
  14110. * | 0 | BILLBOARDMODE_NONE | |
  14111. * | 1 | BILLBOARDMODE_X | |
  14112. * | 2 | BILLBOARDMODE_Y | |
  14113. * | 4 | BILLBOARDMODE_Z | |
  14114. * | 7 | BILLBOARDMODE_ALL | |
  14115. *
  14116. */
  14117. get billboardMode(): number;
  14118. set billboardMode(value: number);
  14119. private _preserveParentRotationForBillboard;
  14120. /**
  14121. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14122. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14123. */
  14124. get preserveParentRotationForBillboard(): boolean;
  14125. set preserveParentRotationForBillboard(value: boolean);
  14126. /**
  14127. * 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
  14128. */
  14129. scalingDeterminant: number;
  14130. private _infiniteDistance;
  14131. /**
  14132. * Gets or sets the distance of the object to max, often used by skybox
  14133. */
  14134. get infiniteDistance(): boolean;
  14135. set infiniteDistance(value: boolean);
  14136. /**
  14137. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14138. * By default the system will update normals to compensate
  14139. */
  14140. ignoreNonUniformScaling: boolean;
  14141. /**
  14142. * 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
  14143. */
  14144. reIntegrateRotationIntoRotationQuaternion: boolean;
  14145. /** @hidden */
  14146. _poseMatrix: Nullable<Matrix>;
  14147. /** @hidden */
  14148. _localMatrix: Matrix;
  14149. private _usePivotMatrix;
  14150. private _absolutePosition;
  14151. private _absoluteScaling;
  14152. private _absoluteRotationQuaternion;
  14153. private _pivotMatrix;
  14154. private _pivotMatrixInverse;
  14155. protected _postMultiplyPivotMatrix: boolean;
  14156. protected _isWorldMatrixFrozen: boolean;
  14157. /** @hidden */
  14158. _indexInSceneTransformNodesArray: number;
  14159. /**
  14160. * An event triggered after the world matrix is updated
  14161. */
  14162. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14163. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14164. /**
  14165. * Gets a string identifying the name of the class
  14166. * @returns "TransformNode" string
  14167. */
  14168. getClassName(): string;
  14169. /**
  14170. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14171. */
  14172. get position(): Vector3;
  14173. set position(newPosition: Vector3);
  14174. /**
  14175. * 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)).
  14176. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14177. */
  14178. get rotation(): Vector3;
  14179. set rotation(newRotation: Vector3);
  14180. /**
  14181. * 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)).
  14182. */
  14183. get scaling(): Vector3;
  14184. set scaling(newScaling: Vector3);
  14185. /**
  14186. * 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).
  14187. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14188. */
  14189. get rotationQuaternion(): Nullable<Quaternion>;
  14190. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14191. /**
  14192. * The forward direction of that transform in world space.
  14193. */
  14194. get forward(): Vector3;
  14195. /**
  14196. * The up direction of that transform in world space.
  14197. */
  14198. get up(): Vector3;
  14199. /**
  14200. * The right direction of that transform in world space.
  14201. */
  14202. get right(): Vector3;
  14203. /**
  14204. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14205. * @param matrix the matrix to copy the pose from
  14206. * @returns this TransformNode.
  14207. */
  14208. updatePoseMatrix(matrix: Matrix): TransformNode;
  14209. /**
  14210. * Returns the mesh Pose matrix.
  14211. * @returns the pose matrix
  14212. */
  14213. getPoseMatrix(): Matrix;
  14214. /** @hidden */
  14215. _isSynchronized(): boolean;
  14216. /** @hidden */
  14217. _initCache(): void;
  14218. /**
  14219. * Flag the transform node as dirty (Forcing it to update everything)
  14220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14221. * @returns this transform node
  14222. */
  14223. markAsDirty(property: string): TransformNode;
  14224. /**
  14225. * Returns the current mesh absolute position.
  14226. * Returns a Vector3.
  14227. */
  14228. get absolutePosition(): Vector3;
  14229. /**
  14230. * Returns the current mesh absolute scaling.
  14231. * Returns a Vector3.
  14232. */
  14233. get absoluteScaling(): Vector3;
  14234. /**
  14235. * Returns the current mesh absolute rotation.
  14236. * Returns a Quaternion.
  14237. */
  14238. get absoluteRotationQuaternion(): Quaternion;
  14239. /**
  14240. * Sets a new matrix to apply before all other transformation
  14241. * @param matrix defines the transform matrix
  14242. * @returns the current TransformNode
  14243. */
  14244. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14245. /**
  14246. * Sets a new pivot matrix to the current node
  14247. * @param matrix defines the new pivot matrix to use
  14248. * @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
  14249. * @returns the current TransformNode
  14250. */
  14251. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14252. /**
  14253. * Returns the mesh pivot matrix.
  14254. * Default : Identity.
  14255. * @returns the matrix
  14256. */
  14257. getPivotMatrix(): Matrix;
  14258. /**
  14259. * Instantiate (when possible) or clone that node with its hierarchy
  14260. * @param newParent defines the new parent to use for the instance (or clone)
  14261. * @param options defines options to configure how copy is done
  14262. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14263. * @returns an instance (or a clone) of the current node with its hiearchy
  14264. */
  14265. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14266. doNotInstantiate: boolean;
  14267. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14268. /**
  14269. * Prevents the World matrix to be computed any longer
  14270. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14271. * @returns the TransformNode.
  14272. */
  14273. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14274. /**
  14275. * Allows back the World matrix computation.
  14276. * @returns the TransformNode.
  14277. */
  14278. unfreezeWorldMatrix(): this;
  14279. /**
  14280. * True if the World matrix has been frozen.
  14281. */
  14282. get isWorldMatrixFrozen(): boolean;
  14283. /**
  14284. * Retuns the mesh absolute position in the World.
  14285. * @returns a Vector3.
  14286. */
  14287. getAbsolutePosition(): Vector3;
  14288. /**
  14289. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14290. * @param absolutePosition the absolute position to set
  14291. * @returns the TransformNode.
  14292. */
  14293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14294. /**
  14295. * Sets the mesh position in its local space.
  14296. * @param vector3 the position to set in localspace
  14297. * @returns the TransformNode.
  14298. */
  14299. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14300. /**
  14301. * Returns the mesh position in the local space from the current World matrix values.
  14302. * @returns a new Vector3.
  14303. */
  14304. getPositionExpressedInLocalSpace(): Vector3;
  14305. /**
  14306. * Translates the mesh along the passed Vector3 in its local space.
  14307. * @param vector3 the distance to translate in localspace
  14308. * @returns the TransformNode.
  14309. */
  14310. locallyTranslate(vector3: Vector3): TransformNode;
  14311. private static _lookAtVectorCache;
  14312. /**
  14313. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14314. * @param targetPoint the position (must be in same space as current mesh) to look at
  14315. * @param yawCor optional yaw (y-axis) correction in radians
  14316. * @param pitchCor optional pitch (x-axis) correction in radians
  14317. * @param rollCor optional roll (z-axis) correction in radians
  14318. * @param space the choosen space of the target
  14319. * @returns the TransformNode.
  14320. */
  14321. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14322. /**
  14323. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14324. * This Vector3 is expressed in the World space.
  14325. * @param localAxis axis to rotate
  14326. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14327. */
  14328. getDirection(localAxis: Vector3): Vector3;
  14329. /**
  14330. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14331. * localAxis is expressed in the mesh local space.
  14332. * result is computed in the Wordl space from the mesh World matrix.
  14333. * @param localAxis axis to rotate
  14334. * @param result the resulting transformnode
  14335. * @returns this TransformNode.
  14336. */
  14337. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14338. /**
  14339. * Sets this transform node rotation to the given local axis.
  14340. * @param localAxis the axis in local space
  14341. * @param yawCor optional yaw (y-axis) correction in radians
  14342. * @param pitchCor optional pitch (x-axis) correction in radians
  14343. * @param rollCor optional roll (z-axis) correction in radians
  14344. * @returns this TransformNode
  14345. */
  14346. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14347. /**
  14348. * Sets a new pivot point to the current node
  14349. * @param point defines the new pivot point to use
  14350. * @param space defines if the point is in world or local space (local by default)
  14351. * @returns the current TransformNode
  14352. */
  14353. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14354. /**
  14355. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14356. * @returns the pivot point
  14357. */
  14358. getPivotPoint(): Vector3;
  14359. /**
  14360. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14361. * @param result the vector3 to store the result
  14362. * @returns this TransformNode.
  14363. */
  14364. getPivotPointToRef(result: Vector3): TransformNode;
  14365. /**
  14366. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14367. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14368. */
  14369. getAbsolutePivotPoint(): Vector3;
  14370. /**
  14371. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14372. * @param result vector3 to store the result
  14373. * @returns this TransformNode.
  14374. */
  14375. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14376. /**
  14377. * Defines the passed node as the parent of the current node.
  14378. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14379. * @see https://doc.babylonjs.com/how_to/parenting
  14380. * @param node the node ot set as the parent
  14381. * @returns this TransformNode.
  14382. */
  14383. setParent(node: Nullable<Node>): TransformNode;
  14384. private _nonUniformScaling;
  14385. /**
  14386. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14387. */
  14388. get nonUniformScaling(): boolean;
  14389. /** @hidden */
  14390. _updateNonUniformScalingState(value: boolean): boolean;
  14391. /**
  14392. * Attach the current TransformNode to another TransformNode associated with a bone
  14393. * @param bone Bone affecting the TransformNode
  14394. * @param affectedTransformNode TransformNode associated with the bone
  14395. * @returns this object
  14396. */
  14397. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14398. /**
  14399. * Detach the transform node if its associated with a bone
  14400. * @returns this object
  14401. */
  14402. detachFromBone(): TransformNode;
  14403. private static _rotationAxisCache;
  14404. /**
  14405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14406. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14408. * The passed axis is also normalized.
  14409. * @param axis the axis to rotate around
  14410. * @param amount the amount to rotate in radians
  14411. * @param space Space to rotate in (Default: local)
  14412. * @returns the TransformNode.
  14413. */
  14414. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14415. /**
  14416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14418. * The passed axis is also normalized. .
  14419. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14420. * @param point the point to rotate around
  14421. * @param axis the axis to rotate around
  14422. * @param amount the amount to rotate in radians
  14423. * @returns the TransformNode
  14424. */
  14425. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14426. /**
  14427. * Translates the mesh along the axis vector for the passed distance in the given space.
  14428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14429. * @param axis the axis to translate in
  14430. * @param distance the distance to translate
  14431. * @param space Space to rotate in (Default: local)
  14432. * @returns the TransformNode.
  14433. */
  14434. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14435. /**
  14436. * Adds a rotation step to the mesh current rotation.
  14437. * x, y, z are Euler angles expressed in radians.
  14438. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14439. * This means this rotation is made in the mesh local space only.
  14440. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14441. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14442. * ```javascript
  14443. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14444. * ```
  14445. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14446. * 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.
  14447. * @param x Rotation to add
  14448. * @param y Rotation to add
  14449. * @param z Rotation to add
  14450. * @returns the TransformNode.
  14451. */
  14452. addRotation(x: number, y: number, z: number): TransformNode;
  14453. /**
  14454. * @hidden
  14455. */
  14456. protected _getEffectiveParent(): Nullable<Node>;
  14457. /**
  14458. * Computes the world matrix of the node
  14459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14460. * @returns the world matrix
  14461. */
  14462. computeWorldMatrix(force?: boolean): Matrix;
  14463. protected _afterComputeWorldMatrix(): void;
  14464. /**
  14465. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14466. * @param func callback function to add
  14467. *
  14468. * @returns the TransformNode.
  14469. */
  14470. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14471. /**
  14472. * Removes a registered callback function.
  14473. * @param func callback function to remove
  14474. * @returns the TransformNode.
  14475. */
  14476. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14477. /**
  14478. * Gets the position of the current mesh in camera space
  14479. * @param camera defines the camera to use
  14480. * @returns a position
  14481. */
  14482. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14483. /**
  14484. * Returns the distance from the mesh to the active camera
  14485. * @param camera defines the camera to use
  14486. * @returns the distance
  14487. */
  14488. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14489. /**
  14490. * Clone the current transform node
  14491. * @param name Name of the new clone
  14492. * @param newParent New parent for the clone
  14493. * @param doNotCloneChildren Do not clone children hierarchy
  14494. * @returns the new transform node
  14495. */
  14496. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14497. /**
  14498. * Serializes the objects information.
  14499. * @param currentSerializationObject defines the object to serialize in
  14500. * @returns the serialized object
  14501. */
  14502. serialize(currentSerializationObject?: any): any;
  14503. /**
  14504. * Returns a new TransformNode object parsed from the source provided.
  14505. * @param parsedTransformNode is the source.
  14506. * @param scene the scne the object belongs to
  14507. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14508. * @returns a new TransformNode object parsed from the source provided.
  14509. */
  14510. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14511. /**
  14512. * Get all child-transformNodes of this node
  14513. * @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
  14514. * @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
  14515. * @returns an array of TransformNode
  14516. */
  14517. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14518. /**
  14519. * Releases resources associated with this transform node.
  14520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14522. */
  14523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14524. /**
  14525. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14526. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14527. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14528. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14529. * @returns the current mesh
  14530. */
  14531. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14532. private _syncAbsoluteScalingAndRotation;
  14533. }
  14534. }
  14535. declare module BABYLON {
  14536. /**
  14537. * Defines the types of pose enabled controllers that are supported
  14538. */
  14539. export enum PoseEnabledControllerType {
  14540. /**
  14541. * HTC Vive
  14542. */
  14543. VIVE = 0,
  14544. /**
  14545. * Oculus Rift
  14546. */
  14547. OCULUS = 1,
  14548. /**
  14549. * Windows mixed reality
  14550. */
  14551. WINDOWS = 2,
  14552. /**
  14553. * Samsung gear VR
  14554. */
  14555. GEAR_VR = 3,
  14556. /**
  14557. * Google Daydream
  14558. */
  14559. DAYDREAM = 4,
  14560. /**
  14561. * Generic
  14562. */
  14563. GENERIC = 5
  14564. }
  14565. /**
  14566. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14567. */
  14568. export interface MutableGamepadButton {
  14569. /**
  14570. * Value of the button/trigger
  14571. */
  14572. value: number;
  14573. /**
  14574. * If the button/trigger is currently touched
  14575. */
  14576. touched: boolean;
  14577. /**
  14578. * If the button/trigger is currently pressed
  14579. */
  14580. pressed: boolean;
  14581. }
  14582. /**
  14583. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14584. * @hidden
  14585. */
  14586. export interface ExtendedGamepadButton extends GamepadButton {
  14587. /**
  14588. * If the button/trigger is currently pressed
  14589. */
  14590. readonly pressed: boolean;
  14591. /**
  14592. * If the button/trigger is currently touched
  14593. */
  14594. readonly touched: boolean;
  14595. /**
  14596. * Value of the button/trigger
  14597. */
  14598. readonly value: number;
  14599. }
  14600. /** @hidden */
  14601. export interface _GamePadFactory {
  14602. /**
  14603. * Returns wether or not the current gamepad can be created for this type of controller.
  14604. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14605. * @returns true if it can be created, otherwise false
  14606. */
  14607. canCreate(gamepadInfo: any): boolean;
  14608. /**
  14609. * Creates a new instance of the Gamepad.
  14610. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14611. * @returns the new gamepad instance
  14612. */
  14613. create(gamepadInfo: any): Gamepad;
  14614. }
  14615. /**
  14616. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14617. */
  14618. export class PoseEnabledControllerHelper {
  14619. /** @hidden */
  14620. static _ControllerFactories: _GamePadFactory[];
  14621. /** @hidden */
  14622. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14623. /**
  14624. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14625. * @param vrGamepad the gamepad to initialized
  14626. * @returns a vr controller of the type the gamepad identified as
  14627. */
  14628. static InitiateController(vrGamepad: any): Gamepad;
  14629. }
  14630. /**
  14631. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14632. */
  14633. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14634. /**
  14635. * If the controller is used in a webXR session
  14636. */
  14637. isXR: boolean;
  14638. private _deviceRoomPosition;
  14639. private _deviceRoomRotationQuaternion;
  14640. /**
  14641. * The device position in babylon space
  14642. */
  14643. devicePosition: Vector3;
  14644. /**
  14645. * The device rotation in babylon space
  14646. */
  14647. deviceRotationQuaternion: Quaternion;
  14648. /**
  14649. * The scale factor of the device in babylon space
  14650. */
  14651. deviceScaleFactor: number;
  14652. /**
  14653. * (Likely devicePosition should be used instead) The device position in its room space
  14654. */
  14655. position: Vector3;
  14656. /**
  14657. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14658. */
  14659. rotationQuaternion: Quaternion;
  14660. /**
  14661. * The type of controller (Eg. Windows mixed reality)
  14662. */
  14663. controllerType: PoseEnabledControllerType;
  14664. protected _calculatedPosition: Vector3;
  14665. private _calculatedRotation;
  14666. /**
  14667. * The raw pose from the device
  14668. */
  14669. rawPose: DevicePose;
  14670. private _trackPosition;
  14671. private _maxRotationDistFromHeadset;
  14672. private _draggedRoomRotation;
  14673. /**
  14674. * @hidden
  14675. */
  14676. _disableTrackPosition(fixedPosition: Vector3): void;
  14677. /**
  14678. * Internal, the mesh attached to the controller
  14679. * @hidden
  14680. */
  14681. _mesh: Nullable<AbstractMesh>;
  14682. private _poseControlledCamera;
  14683. private _leftHandSystemQuaternion;
  14684. /**
  14685. * Internal, matrix used to convert room space to babylon space
  14686. * @hidden
  14687. */
  14688. _deviceToWorld: Matrix;
  14689. /**
  14690. * Node to be used when casting a ray from the controller
  14691. * @hidden
  14692. */
  14693. _pointingPoseNode: Nullable<TransformNode>;
  14694. /**
  14695. * Name of the child mesh that can be used to cast a ray from the controller
  14696. */
  14697. static readonly POINTING_POSE: string;
  14698. /**
  14699. * Creates a new PoseEnabledController from a gamepad
  14700. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14701. */
  14702. constructor(browserGamepad: any);
  14703. private _workingMatrix;
  14704. /**
  14705. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14706. */
  14707. update(): void;
  14708. /**
  14709. * Updates only the pose device and mesh without doing any button event checking
  14710. */
  14711. protected _updatePoseAndMesh(): void;
  14712. /**
  14713. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14714. * @param poseData raw pose fromthe device
  14715. */
  14716. updateFromDevice(poseData: DevicePose): void;
  14717. /**
  14718. * @hidden
  14719. */
  14720. _meshAttachedObservable: Observable<AbstractMesh>;
  14721. /**
  14722. * Attaches a mesh to the controller
  14723. * @param mesh the mesh to be attached
  14724. */
  14725. attachToMesh(mesh: AbstractMesh): void;
  14726. /**
  14727. * Attaches the controllers mesh to a camera
  14728. * @param camera the camera the mesh should be attached to
  14729. */
  14730. attachToPoseControlledCamera(camera: TargetCamera): void;
  14731. /**
  14732. * Disposes of the controller
  14733. */
  14734. dispose(): void;
  14735. /**
  14736. * The mesh that is attached to the controller
  14737. */
  14738. get mesh(): Nullable<AbstractMesh>;
  14739. /**
  14740. * Gets the ray of the controller in the direction the controller is pointing
  14741. * @param length the length the resulting ray should be
  14742. * @returns a ray in the direction the controller is pointing
  14743. */
  14744. getForwardRay(length?: number): Ray;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. /**
  14749. * Defines the WebVRController object that represents controllers tracked in 3D space
  14750. */
  14751. export abstract class WebVRController extends PoseEnabledController {
  14752. /**
  14753. * Internal, the default controller model for the controller
  14754. */
  14755. protected _defaultModel: Nullable<AbstractMesh>;
  14756. /**
  14757. * Fired when the trigger state has changed
  14758. */
  14759. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14760. /**
  14761. * Fired when the main button state has changed
  14762. */
  14763. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14764. /**
  14765. * Fired when the secondary button state has changed
  14766. */
  14767. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14768. /**
  14769. * Fired when the pad state has changed
  14770. */
  14771. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14772. /**
  14773. * Fired when controllers stick values have changed
  14774. */
  14775. onPadValuesChangedObservable: Observable<StickValues>;
  14776. /**
  14777. * Array of button availible on the controller
  14778. */
  14779. protected _buttons: Array<MutableGamepadButton>;
  14780. private _onButtonStateChange;
  14781. /**
  14782. * Fired when a controller button's state has changed
  14783. * @param callback the callback containing the button that was modified
  14784. */
  14785. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14786. /**
  14787. * X and Y axis corresponding to the controllers joystick
  14788. */
  14789. pad: StickValues;
  14790. /**
  14791. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14792. */
  14793. hand: string;
  14794. /**
  14795. * The default controller model for the controller
  14796. */
  14797. get defaultModel(): Nullable<AbstractMesh>;
  14798. /**
  14799. * Creates a new WebVRController from a gamepad
  14800. * @param vrGamepad the gamepad that the WebVRController should be created from
  14801. */
  14802. constructor(vrGamepad: any);
  14803. /**
  14804. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14805. */
  14806. update(): void;
  14807. /**
  14808. * Function to be called when a button is modified
  14809. */
  14810. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14811. /**
  14812. * Loads a mesh and attaches it to the controller
  14813. * @param scene the scene the mesh should be added to
  14814. * @param meshLoaded callback for when the mesh has been loaded
  14815. */
  14816. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14817. private _setButtonValue;
  14818. private _changes;
  14819. private _checkChanges;
  14820. /**
  14821. * Disposes of th webVRCOntroller
  14822. */
  14823. dispose(): void;
  14824. }
  14825. }
  14826. declare module BABYLON {
  14827. /**
  14828. * The HemisphericLight simulates the ambient environment light,
  14829. * so the passed direction is the light reflection direction, not the incoming direction.
  14830. */
  14831. export class HemisphericLight extends Light {
  14832. /**
  14833. * The groundColor is the light in the opposite direction to the one specified during creation.
  14834. * 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.
  14835. */
  14836. groundColor: Color3;
  14837. /**
  14838. * The light reflection direction, not the incoming direction.
  14839. */
  14840. direction: Vector3;
  14841. /**
  14842. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14843. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14844. * The HemisphericLight can't cast shadows.
  14845. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14846. * @param name The friendly name of the light
  14847. * @param direction The direction of the light reflection
  14848. * @param scene The scene the light belongs to
  14849. */
  14850. constructor(name: string, direction: Vector3, scene: Scene);
  14851. protected _buildUniformLayout(): void;
  14852. /**
  14853. * Returns the string "HemisphericLight".
  14854. * @return The class name
  14855. */
  14856. getClassName(): string;
  14857. /**
  14858. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14859. * Returns the updated direction.
  14860. * @param target The target the direction should point to
  14861. * @return The computed direction
  14862. */
  14863. setDirectionToTarget(target: Vector3): Vector3;
  14864. /**
  14865. * Returns the shadow generator associated to the light.
  14866. * @returns Always null for hemispheric lights because it does not support shadows.
  14867. */
  14868. getShadowGenerator(): Nullable<IShadowGenerator>;
  14869. /**
  14870. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14871. * @param effect The effect to update
  14872. * @param lightIndex The index of the light in the effect to update
  14873. * @returns The hemispheric light
  14874. */
  14875. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14876. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14877. /**
  14878. * Computes the world matrix of the node
  14879. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14880. * @param useWasUpdatedFlag defines a reserved property
  14881. * @returns the world matrix
  14882. */
  14883. computeWorldMatrix(): Matrix;
  14884. /**
  14885. * Returns the integer 3.
  14886. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14887. */
  14888. getTypeID(): number;
  14889. /**
  14890. * Prepares the list of defines specific to the light type.
  14891. * @param defines the list of defines
  14892. * @param lightIndex defines the index of the light for the effect
  14893. */
  14894. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14895. }
  14896. }
  14897. declare module BABYLON {
  14898. /** @hidden */
  14899. export var vrMultiviewToSingleviewPixelShader: {
  14900. name: string;
  14901. shader: string;
  14902. };
  14903. }
  14904. declare module BABYLON {
  14905. /**
  14906. * Renders to multiple views with a single draw call
  14907. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14908. */
  14909. export class MultiviewRenderTarget extends RenderTargetTexture {
  14910. /**
  14911. * Creates a multiview render target
  14912. * @param scene scene used with the render target
  14913. * @param size the size of the render target (used for each view)
  14914. */
  14915. constructor(scene: Scene, size?: number | {
  14916. width: number;
  14917. height: number;
  14918. } | {
  14919. ratio: number;
  14920. });
  14921. /**
  14922. * @hidden
  14923. * @param faceIndex the face index, if its a cube texture
  14924. */
  14925. _bindFrameBuffer(faceIndex?: number): void;
  14926. /**
  14927. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14928. * @returns the view count
  14929. */
  14930. getViewCount(): number;
  14931. }
  14932. }
  14933. declare module BABYLON {
  14934. /**
  14935. * Represents a camera frustum
  14936. */
  14937. export class Frustum {
  14938. /**
  14939. * Gets the planes representing the frustum
  14940. * @param transform matrix to be applied to the returned planes
  14941. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14942. */
  14943. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14944. /**
  14945. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14950. /**
  14951. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14956. /**
  14957. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14962. /**
  14963. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14968. /**
  14969. * Gets the top frustum plane transformed by the transform matrix
  14970. * @param transform transformation matrix to be applied to the resulting frustum plane
  14971. * @param frustumPlane the resuling frustum plane
  14972. */
  14973. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14974. /**
  14975. * Gets the bottom frustum plane transformed by the transform matrix
  14976. * @param transform transformation matrix to be applied to the resulting frustum plane
  14977. * @param frustumPlane the resuling frustum plane
  14978. */
  14979. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14980. /**
  14981. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14982. * @param transform transformation matrix to be applied to the resulting frustum planes
  14983. * @param frustumPlanes the resuling frustum planes
  14984. */
  14985. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14986. }
  14987. }
  14988. declare module BABYLON {
  14989. interface Engine {
  14990. /**
  14991. * Creates a new multiview render target
  14992. * @param width defines the width of the texture
  14993. * @param height defines the height of the texture
  14994. * @returns the created multiview texture
  14995. */
  14996. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14997. /**
  14998. * Binds a multiview framebuffer to be drawn to
  14999. * @param multiviewTexture texture to bind
  15000. */
  15001. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15002. }
  15003. interface Camera {
  15004. /**
  15005. * @hidden
  15006. * 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)
  15007. */
  15008. _useMultiviewToSingleView: boolean;
  15009. /**
  15010. * @hidden
  15011. * 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)
  15012. */
  15013. _multiviewTexture: Nullable<RenderTargetTexture>;
  15014. /**
  15015. * @hidden
  15016. * ensures the multiview texture of the camera exists and has the specified width/height
  15017. * @param width height to set on the multiview texture
  15018. * @param height width to set on the multiview texture
  15019. */
  15020. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15021. }
  15022. interface Scene {
  15023. /** @hidden */
  15024. _transformMatrixR: Matrix;
  15025. /** @hidden */
  15026. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15027. /** @hidden */
  15028. _createMultiviewUbo(): void;
  15029. /** @hidden */
  15030. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15031. /** @hidden */
  15032. _renderMultiviewToSingleView(camera: Camera): void;
  15033. }
  15034. }
  15035. declare module BABYLON {
  15036. /**
  15037. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15038. * This will not be used for webXR as it supports displaying texture arrays directly
  15039. */
  15040. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15041. /**
  15042. * Initializes a VRMultiviewToSingleview
  15043. * @param name name of the post process
  15044. * @param camera camera to be applied to
  15045. * @param scaleFactor scaling factor to the size of the output texture
  15046. */
  15047. constructor(name: string, camera: Camera, scaleFactor: number);
  15048. }
  15049. }
  15050. declare module BABYLON {
  15051. /**
  15052. * Interface used to define additional presentation attributes
  15053. */
  15054. export interface IVRPresentationAttributes {
  15055. /**
  15056. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15057. */
  15058. highRefreshRate: boolean;
  15059. /**
  15060. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15061. */
  15062. foveationLevel: number;
  15063. }
  15064. interface Engine {
  15065. /** @hidden */
  15066. _vrDisplay: any;
  15067. /** @hidden */
  15068. _vrSupported: boolean;
  15069. /** @hidden */
  15070. _oldSize: Size;
  15071. /** @hidden */
  15072. _oldHardwareScaleFactor: number;
  15073. /** @hidden */
  15074. _vrExclusivePointerMode: boolean;
  15075. /** @hidden */
  15076. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15077. /** @hidden */
  15078. _onVRDisplayPointerRestricted: () => void;
  15079. /** @hidden */
  15080. _onVRDisplayPointerUnrestricted: () => void;
  15081. /** @hidden */
  15082. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15083. /** @hidden */
  15084. _onVrDisplayDisconnect: Nullable<() => void>;
  15085. /** @hidden */
  15086. _onVrDisplayPresentChange: Nullable<() => void>;
  15087. /**
  15088. * Observable signaled when VR display mode changes
  15089. */
  15090. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15091. /**
  15092. * Observable signaled when VR request present is complete
  15093. */
  15094. onVRRequestPresentComplete: Observable<boolean>;
  15095. /**
  15096. * Observable signaled when VR request present starts
  15097. */
  15098. onVRRequestPresentStart: Observable<Engine>;
  15099. /**
  15100. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15101. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15102. */
  15103. isInVRExclusivePointerMode: boolean;
  15104. /**
  15105. * Gets a boolean indicating if a webVR device was detected
  15106. * @returns true if a webVR device was detected
  15107. */
  15108. isVRDevicePresent(): boolean;
  15109. /**
  15110. * Gets the current webVR device
  15111. * @returns the current webVR device (or null)
  15112. */
  15113. getVRDevice(): any;
  15114. /**
  15115. * Initializes a webVR display and starts listening to display change events
  15116. * The onVRDisplayChangedObservable will be notified upon these changes
  15117. * @returns A promise containing a VRDisplay and if vr is supported
  15118. */
  15119. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15120. /** @hidden */
  15121. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15122. /**
  15123. * Gets or sets the presentation attributes used to configure VR rendering
  15124. */
  15125. vrPresentationAttributes?: IVRPresentationAttributes;
  15126. /**
  15127. * Call this function to switch to webVR mode
  15128. * Will do nothing if webVR is not supported or if there is no webVR device
  15129. * @param options the webvr options provided to the camera. mainly used for multiview
  15130. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15131. */
  15132. enableVR(options: WebVROptions): void;
  15133. /** @hidden */
  15134. _onVRFullScreenTriggered(): void;
  15135. }
  15136. }
  15137. declare module BABYLON {
  15138. /**
  15139. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15140. * IMPORTANT!! The data is right-hand data.
  15141. * @export
  15142. * @interface DevicePose
  15143. */
  15144. export interface DevicePose {
  15145. /**
  15146. * The position of the device, values in array are [x,y,z].
  15147. */
  15148. readonly position: Nullable<Float32Array>;
  15149. /**
  15150. * The linearVelocity of the device, values in array are [x,y,z].
  15151. */
  15152. readonly linearVelocity: Nullable<Float32Array>;
  15153. /**
  15154. * The linearAcceleration of the device, values in array are [x,y,z].
  15155. */
  15156. readonly linearAcceleration: Nullable<Float32Array>;
  15157. /**
  15158. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15159. */
  15160. readonly orientation: Nullable<Float32Array>;
  15161. /**
  15162. * The angularVelocity of the device, values in array are [x,y,z].
  15163. */
  15164. readonly angularVelocity: Nullable<Float32Array>;
  15165. /**
  15166. * The angularAcceleration of the device, values in array are [x,y,z].
  15167. */
  15168. readonly angularAcceleration: Nullable<Float32Array>;
  15169. }
  15170. /**
  15171. * Interface representing a pose controlled object in Babylon.
  15172. * A pose controlled object has both regular pose values as well as pose values
  15173. * from an external device such as a VR head mounted display
  15174. */
  15175. export interface PoseControlled {
  15176. /**
  15177. * The position of the object in babylon space.
  15178. */
  15179. position: Vector3;
  15180. /**
  15181. * The rotation quaternion of the object in babylon space.
  15182. */
  15183. rotationQuaternion: Quaternion;
  15184. /**
  15185. * The position of the device in babylon space.
  15186. */
  15187. devicePosition?: Vector3;
  15188. /**
  15189. * The rotation quaternion of the device in babylon space.
  15190. */
  15191. deviceRotationQuaternion: Quaternion;
  15192. /**
  15193. * The raw pose coming from the device.
  15194. */
  15195. rawPose: Nullable<DevicePose>;
  15196. /**
  15197. * The scale of the device to be used when translating from device space to babylon space.
  15198. */
  15199. deviceScaleFactor: number;
  15200. /**
  15201. * Updates the poseControlled values based on the input device pose.
  15202. * @param poseData the pose data to update the object with
  15203. */
  15204. updateFromDevice(poseData: DevicePose): void;
  15205. }
  15206. /**
  15207. * Set of options to customize the webVRCamera
  15208. */
  15209. export interface WebVROptions {
  15210. /**
  15211. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15212. */
  15213. trackPosition?: boolean;
  15214. /**
  15215. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15216. */
  15217. positionScale?: number;
  15218. /**
  15219. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15220. */
  15221. displayName?: string;
  15222. /**
  15223. * Should the native controller meshes be initialized. (default: true)
  15224. */
  15225. controllerMeshes?: boolean;
  15226. /**
  15227. * Creating a default HemiLight only on controllers. (default: true)
  15228. */
  15229. defaultLightingOnControllers?: boolean;
  15230. /**
  15231. * If you don't want to use the default VR button of the helper. (default: false)
  15232. */
  15233. useCustomVRButton?: boolean;
  15234. /**
  15235. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15236. */
  15237. customVRButton?: HTMLButtonElement;
  15238. /**
  15239. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15240. */
  15241. rayLength?: number;
  15242. /**
  15243. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15244. */
  15245. defaultHeight?: number;
  15246. /**
  15247. * If multiview should be used if availible (default: false)
  15248. */
  15249. useMultiview?: boolean;
  15250. }
  15251. /**
  15252. * This represents a WebVR camera.
  15253. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15254. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15255. */
  15256. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15257. private webVROptions;
  15258. /**
  15259. * @hidden
  15260. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15261. */
  15262. _vrDevice: any;
  15263. /**
  15264. * The rawPose of the vrDevice.
  15265. */
  15266. rawPose: Nullable<DevicePose>;
  15267. private _onVREnabled;
  15268. private _specsVersion;
  15269. private _attached;
  15270. private _frameData;
  15271. protected _descendants: Array<Node>;
  15272. private _deviceRoomPosition;
  15273. /** @hidden */
  15274. _deviceRoomRotationQuaternion: Quaternion;
  15275. private _standingMatrix;
  15276. /**
  15277. * Represents device position in babylon space.
  15278. */
  15279. devicePosition: Vector3;
  15280. /**
  15281. * Represents device rotation in babylon space.
  15282. */
  15283. deviceRotationQuaternion: Quaternion;
  15284. /**
  15285. * The scale of the device to be used when translating from device space to babylon space.
  15286. */
  15287. deviceScaleFactor: number;
  15288. private _deviceToWorld;
  15289. private _worldToDevice;
  15290. /**
  15291. * References to the webVR controllers for the vrDevice.
  15292. */
  15293. controllers: Array<WebVRController>;
  15294. /**
  15295. * Emits an event when a controller is attached.
  15296. */
  15297. onControllersAttachedObservable: Observable<WebVRController[]>;
  15298. /**
  15299. * Emits an event when a controller's mesh has been loaded;
  15300. */
  15301. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15302. /**
  15303. * Emits an event when the HMD's pose has been updated.
  15304. */
  15305. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15306. private _poseSet;
  15307. /**
  15308. * If the rig cameras be used as parent instead of this camera.
  15309. */
  15310. rigParenting: boolean;
  15311. private _lightOnControllers;
  15312. private _defaultHeight?;
  15313. /**
  15314. * Instantiates a WebVRFreeCamera.
  15315. * @param name The name of the WebVRFreeCamera
  15316. * @param position The starting anchor position for the camera
  15317. * @param scene The scene the camera belongs to
  15318. * @param webVROptions a set of customizable options for the webVRCamera
  15319. */
  15320. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15321. /**
  15322. * Gets the device distance from the ground in meters.
  15323. * @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.
  15324. */
  15325. deviceDistanceToRoomGround(): number;
  15326. /**
  15327. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15328. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15329. */
  15330. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15331. /**
  15332. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15333. * @returns A promise with a boolean set to if the standing matrix is supported.
  15334. */
  15335. useStandingMatrixAsync(): Promise<boolean>;
  15336. /**
  15337. * Disposes the camera
  15338. */
  15339. dispose(): void;
  15340. /**
  15341. * Gets a vrController by name.
  15342. * @param name The name of the controller to retreive
  15343. * @returns the controller matching the name specified or null if not found
  15344. */
  15345. getControllerByName(name: string): Nullable<WebVRController>;
  15346. private _leftController;
  15347. /**
  15348. * The controller corresponding to the users left hand.
  15349. */
  15350. get leftController(): Nullable<WebVRController>;
  15351. private _rightController;
  15352. /**
  15353. * The controller corresponding to the users right hand.
  15354. */
  15355. get rightController(): Nullable<WebVRController>;
  15356. /**
  15357. * Casts a ray forward from the vrCamera's gaze.
  15358. * @param length Length of the ray (default: 100)
  15359. * @returns the ray corresponding to the gaze
  15360. */
  15361. getForwardRay(length?: number): Ray;
  15362. /**
  15363. * @hidden
  15364. * Updates the camera based on device's frame data
  15365. */
  15366. _checkInputs(): void;
  15367. /**
  15368. * Updates the poseControlled values based on the input device pose.
  15369. * @param poseData Pose coming from the device
  15370. */
  15371. updateFromDevice(poseData: DevicePose): void;
  15372. private _htmlElementAttached;
  15373. private _detachIfAttached;
  15374. /**
  15375. * WebVR's attach control will start broadcasting frames to the device.
  15376. * Note that in certain browsers (chrome for example) this function must be called
  15377. * within a user-interaction callback. Example:
  15378. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15379. *
  15380. * @param element html element to attach the vrDevice to
  15381. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15382. */
  15383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15384. /**
  15385. * Detaches the camera from the html element and disables VR
  15386. *
  15387. * @param element html element to detach from
  15388. */
  15389. detachControl(element: HTMLElement): void;
  15390. /**
  15391. * @returns the name of this class
  15392. */
  15393. getClassName(): string;
  15394. /**
  15395. * Calls resetPose on the vrDisplay
  15396. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15397. */
  15398. resetToCurrentRotation(): void;
  15399. /**
  15400. * @hidden
  15401. * Updates the rig cameras (left and right eye)
  15402. */
  15403. _updateRigCameras(): void;
  15404. private _workingVector;
  15405. private _oneVector;
  15406. private _workingMatrix;
  15407. private updateCacheCalled;
  15408. private _correctPositionIfNotTrackPosition;
  15409. /**
  15410. * @hidden
  15411. * Updates the cached values of the camera
  15412. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15413. */
  15414. _updateCache(ignoreParentClass?: boolean): void;
  15415. /**
  15416. * @hidden
  15417. * Get current device position in babylon world
  15418. */
  15419. _computeDevicePosition(): void;
  15420. /**
  15421. * Updates the current device position and rotation in the babylon world
  15422. */
  15423. update(): void;
  15424. /**
  15425. * @hidden
  15426. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15427. * @returns an identity matrix
  15428. */
  15429. _getViewMatrix(): Matrix;
  15430. private _tmpMatrix;
  15431. /**
  15432. * This function is called by the two RIG cameras.
  15433. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15434. * @hidden
  15435. */
  15436. _getWebVRViewMatrix(): Matrix;
  15437. /** @hidden */
  15438. _getWebVRProjectionMatrix(): Matrix;
  15439. private _onGamepadConnectedObserver;
  15440. private _onGamepadDisconnectedObserver;
  15441. private _updateCacheWhenTrackingDisabledObserver;
  15442. /**
  15443. * Initializes the controllers and their meshes
  15444. */
  15445. initControllers(): void;
  15446. }
  15447. }
  15448. declare module BABYLON {
  15449. /**
  15450. * Size options for a post process
  15451. */
  15452. export type PostProcessOptions = {
  15453. width: number;
  15454. height: number;
  15455. };
  15456. /**
  15457. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15458. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15459. */
  15460. export class PostProcess {
  15461. /** Name of the PostProcess. */
  15462. name: string;
  15463. /**
  15464. * Gets or sets the unique id of the post process
  15465. */
  15466. uniqueId: number;
  15467. /**
  15468. * Width of the texture to apply the post process on
  15469. */
  15470. width: number;
  15471. /**
  15472. * Height of the texture to apply the post process on
  15473. */
  15474. height: number;
  15475. /**
  15476. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15477. * @hidden
  15478. */
  15479. _outputTexture: Nullable<InternalTexture>;
  15480. /**
  15481. * Sampling mode used by the shader
  15482. * See https://doc.babylonjs.com/classes/3.1/texture
  15483. */
  15484. renderTargetSamplingMode: number;
  15485. /**
  15486. * Clear color to use when screen clearing
  15487. */
  15488. clearColor: Color4;
  15489. /**
  15490. * If the buffer needs to be cleared before applying the post process. (default: true)
  15491. * Should be set to false if shader will overwrite all previous pixels.
  15492. */
  15493. autoClear: boolean;
  15494. /**
  15495. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15496. */
  15497. alphaMode: number;
  15498. /**
  15499. * Sets the setAlphaBlendConstants of the babylon engine
  15500. */
  15501. alphaConstants: Color4;
  15502. /**
  15503. * Animations to be used for the post processing
  15504. */
  15505. animations: Animation[];
  15506. /**
  15507. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15508. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15509. */
  15510. enablePixelPerfectMode: boolean;
  15511. /**
  15512. * Force the postprocess to be applied without taking in account viewport
  15513. */
  15514. forceFullscreenViewport: boolean;
  15515. /**
  15516. * List of inspectable custom properties (used by the Inspector)
  15517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15518. */
  15519. inspectableCustomProperties: IInspectable[];
  15520. /**
  15521. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15522. *
  15523. * | Value | Type | Description |
  15524. * | ----- | ----------------------------------- | ----------- |
  15525. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15526. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15527. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15528. *
  15529. */
  15530. scaleMode: number;
  15531. /**
  15532. * Force textures to be a power of two (default: false)
  15533. */
  15534. alwaysForcePOT: boolean;
  15535. private _samples;
  15536. /**
  15537. * Number of sample textures (default: 1)
  15538. */
  15539. get samples(): number;
  15540. set samples(n: number);
  15541. /**
  15542. * Modify the scale of the post process to be the same as the viewport (default: false)
  15543. */
  15544. adaptScaleToCurrentViewport: boolean;
  15545. private _camera;
  15546. private _scene;
  15547. private _engine;
  15548. private _options;
  15549. private _reusable;
  15550. private _textureType;
  15551. /**
  15552. * Smart array of input and output textures for the post process.
  15553. * @hidden
  15554. */
  15555. _textures: SmartArray<InternalTexture>;
  15556. /**
  15557. * The index in _textures that corresponds to the output texture.
  15558. * @hidden
  15559. */
  15560. _currentRenderTextureInd: number;
  15561. private _effect;
  15562. private _samplers;
  15563. private _fragmentUrl;
  15564. private _vertexUrl;
  15565. private _parameters;
  15566. private _scaleRatio;
  15567. protected _indexParameters: any;
  15568. private _shareOutputWithPostProcess;
  15569. private _texelSize;
  15570. private _forcedOutputTexture;
  15571. /**
  15572. * Returns the fragment url or shader name used in the post process.
  15573. * @returns the fragment url or name in the shader store.
  15574. */
  15575. getEffectName(): string;
  15576. /**
  15577. * An event triggered when the postprocess is activated.
  15578. */
  15579. onActivateObservable: Observable<Camera>;
  15580. private _onActivateObserver;
  15581. /**
  15582. * A function that is added to the onActivateObservable
  15583. */
  15584. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15585. /**
  15586. * An event triggered when the postprocess changes its size.
  15587. */
  15588. onSizeChangedObservable: Observable<PostProcess>;
  15589. private _onSizeChangedObserver;
  15590. /**
  15591. * A function that is added to the onSizeChangedObservable
  15592. */
  15593. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15594. /**
  15595. * An event triggered when the postprocess applies its effect.
  15596. */
  15597. onApplyObservable: Observable<Effect>;
  15598. private _onApplyObserver;
  15599. /**
  15600. * A function that is added to the onApplyObservable
  15601. */
  15602. set onApply(callback: (effect: Effect) => void);
  15603. /**
  15604. * An event triggered before rendering the postprocess
  15605. */
  15606. onBeforeRenderObservable: Observable<Effect>;
  15607. private _onBeforeRenderObserver;
  15608. /**
  15609. * A function that is added to the onBeforeRenderObservable
  15610. */
  15611. set onBeforeRender(callback: (effect: Effect) => void);
  15612. /**
  15613. * An event triggered after rendering the postprocess
  15614. */
  15615. onAfterRenderObservable: Observable<Effect>;
  15616. private _onAfterRenderObserver;
  15617. /**
  15618. * A function that is added to the onAfterRenderObservable
  15619. */
  15620. set onAfterRender(callback: (efect: Effect) => void);
  15621. /**
  15622. * 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
  15623. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15624. */
  15625. get inputTexture(): InternalTexture;
  15626. set inputTexture(value: InternalTexture);
  15627. /**
  15628. * Gets the camera which post process is applied to.
  15629. * @returns The camera the post process is applied to.
  15630. */
  15631. getCamera(): Camera;
  15632. /**
  15633. * Gets the texel size of the postprocess.
  15634. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15635. */
  15636. get texelSize(): Vector2;
  15637. /**
  15638. * Creates a new instance PostProcess
  15639. * @param name The name of the PostProcess.
  15640. * @param fragmentUrl The url of the fragment shader to be used.
  15641. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15642. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15643. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15644. * @param camera The camera to apply the render pass to.
  15645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15646. * @param engine The engine which the post process will be applied. (default: current engine)
  15647. * @param reusable If the post process can be reused on the same frame. (default: false)
  15648. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15649. * @param textureType Type of textures used when performing the post process. (default: 0)
  15650. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15651. * @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
  15652. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15653. */
  15654. constructor(
  15655. /** Name of the PostProcess. */
  15656. 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);
  15657. /**
  15658. * Gets a string idenfifying the name of the class
  15659. * @returns "PostProcess" string
  15660. */
  15661. getClassName(): string;
  15662. /**
  15663. * Gets the engine which this post process belongs to.
  15664. * @returns The engine the post process was enabled with.
  15665. */
  15666. getEngine(): Engine;
  15667. /**
  15668. * The effect that is created when initializing the post process.
  15669. * @returns The created effect corresponding the the postprocess.
  15670. */
  15671. getEffect(): Effect;
  15672. /**
  15673. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15674. * @param postProcess The post process to share the output with.
  15675. * @returns This post process.
  15676. */
  15677. shareOutputWith(postProcess: PostProcess): PostProcess;
  15678. /**
  15679. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15680. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15681. */
  15682. useOwnOutput(): void;
  15683. /**
  15684. * Updates the effect with the current post process compile time values and recompiles the shader.
  15685. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15686. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15687. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15688. * @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
  15689. * @param onCompiled Called when the shader has been compiled.
  15690. * @param onError Called if there is an error when compiling a shader.
  15691. */
  15692. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15693. /**
  15694. * The post process is reusable if it can be used multiple times within one frame.
  15695. * @returns If the post process is reusable
  15696. */
  15697. isReusable(): boolean;
  15698. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15699. markTextureDirty(): void;
  15700. /**
  15701. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15702. * 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.
  15703. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15704. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15705. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15706. * @returns The target texture that was bound to be written to.
  15707. */
  15708. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15709. /**
  15710. * If the post process is supported.
  15711. */
  15712. get isSupported(): boolean;
  15713. /**
  15714. * The aspect ratio of the output texture.
  15715. */
  15716. get aspectRatio(): number;
  15717. /**
  15718. * Get a value indicating if the post-process is ready to be used
  15719. * @returns true if the post-process is ready (shader is compiled)
  15720. */
  15721. isReady(): boolean;
  15722. /**
  15723. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15724. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15725. */
  15726. apply(): Nullable<Effect>;
  15727. private _disposeTextures;
  15728. /**
  15729. * Disposes the post process.
  15730. * @param camera The camera to dispose the post process on.
  15731. */
  15732. dispose(camera?: Camera): void;
  15733. }
  15734. }
  15735. declare module BABYLON {
  15736. /** @hidden */
  15737. export var kernelBlurVaryingDeclaration: {
  15738. name: string;
  15739. shader: string;
  15740. };
  15741. }
  15742. declare module BABYLON {
  15743. /** @hidden */
  15744. export var kernelBlurFragment: {
  15745. name: string;
  15746. shader: string;
  15747. };
  15748. }
  15749. declare module BABYLON {
  15750. /** @hidden */
  15751. export var kernelBlurFragment2: {
  15752. name: string;
  15753. shader: string;
  15754. };
  15755. }
  15756. declare module BABYLON {
  15757. /** @hidden */
  15758. export var kernelBlurPixelShader: {
  15759. name: string;
  15760. shader: string;
  15761. };
  15762. }
  15763. declare module BABYLON {
  15764. /** @hidden */
  15765. export var kernelBlurVertex: {
  15766. name: string;
  15767. shader: string;
  15768. };
  15769. }
  15770. declare module BABYLON {
  15771. /** @hidden */
  15772. export var kernelBlurVertexShader: {
  15773. name: string;
  15774. shader: string;
  15775. };
  15776. }
  15777. declare module BABYLON {
  15778. /**
  15779. * The Blur Post Process which blurs an image based on a kernel and direction.
  15780. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15781. */
  15782. export class BlurPostProcess extends PostProcess {
  15783. /** The direction in which to blur the image. */
  15784. direction: Vector2;
  15785. private blockCompilation;
  15786. protected _kernel: number;
  15787. protected _idealKernel: number;
  15788. protected _packedFloat: boolean;
  15789. private _staticDefines;
  15790. /**
  15791. * Sets the length in pixels of the blur sample region
  15792. */
  15793. set kernel(v: number);
  15794. /**
  15795. * Gets the length in pixels of the blur sample region
  15796. */
  15797. get kernel(): number;
  15798. /**
  15799. * Sets wether or not the blur needs to unpack/repack floats
  15800. */
  15801. set packedFloat(v: boolean);
  15802. /**
  15803. * Gets wether or not the blur is unpacking/repacking floats
  15804. */
  15805. get packedFloat(): boolean;
  15806. /**
  15807. * Creates a new instance BlurPostProcess
  15808. * @param name The name of the effect.
  15809. * @param direction The direction in which to blur the image.
  15810. * @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.
  15811. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15812. * @param camera The camera to apply the render pass to.
  15813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15814. * @param engine The engine which the post process will be applied. (default: current engine)
  15815. * @param reusable If the post process can be reused on the same frame. (default: false)
  15816. * @param textureType Type of textures used when performing the post process. (default: 0)
  15817. * @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)
  15818. */
  15819. constructor(name: string,
  15820. /** The direction in which to blur the image. */
  15821. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15822. /**
  15823. * Updates the effect with the current post process compile time values and recompiles the shader.
  15824. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15825. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15826. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15827. * @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
  15828. * @param onCompiled Called when the shader has been compiled.
  15829. * @param onError Called if there is an error when compiling a shader.
  15830. */
  15831. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15832. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15833. /**
  15834. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15835. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15836. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15837. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15838. * The gaps between physical kernels are compensated for in the weighting of the samples
  15839. * @param idealKernel Ideal blur kernel.
  15840. * @return Nearest best kernel.
  15841. */
  15842. protected _nearestBestKernel(idealKernel: number): number;
  15843. /**
  15844. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15845. * @param x The point on the Gaussian distribution to sample.
  15846. * @return the value of the Gaussian function at x.
  15847. */
  15848. protected _gaussianWeight(x: number): number;
  15849. /**
  15850. * Generates a string that can be used as a floating point number in GLSL.
  15851. * @param x Value to print.
  15852. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15853. * @return GLSL float string.
  15854. */
  15855. protected _glslFloat(x: number, decimalFigures?: number): string;
  15856. }
  15857. }
  15858. declare module BABYLON {
  15859. /**
  15860. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15861. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15862. * You can then easily use it as a reflectionTexture on a flat surface.
  15863. * In case the surface is not a plane, please consider relying on reflection probes.
  15864. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15865. */
  15866. export class MirrorTexture extends RenderTargetTexture {
  15867. private scene;
  15868. /**
  15869. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15870. * 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.
  15871. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15872. */
  15873. mirrorPlane: Plane;
  15874. /**
  15875. * Define the blur ratio used to blur the reflection if needed.
  15876. */
  15877. set blurRatio(value: number);
  15878. get blurRatio(): number;
  15879. /**
  15880. * Define the adaptive blur kernel used to blur the reflection if needed.
  15881. * This will autocompute the closest best match for the `blurKernel`
  15882. */
  15883. set adaptiveBlurKernel(value: number);
  15884. /**
  15885. * Define the blur kernel used to blur the reflection if needed.
  15886. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15887. */
  15888. set blurKernel(value: number);
  15889. /**
  15890. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15891. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15892. */
  15893. set blurKernelX(value: number);
  15894. get blurKernelX(): number;
  15895. /**
  15896. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15897. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15898. */
  15899. set blurKernelY(value: number);
  15900. get blurKernelY(): number;
  15901. private _autoComputeBlurKernel;
  15902. protected _onRatioRescale(): void;
  15903. private _updateGammaSpace;
  15904. private _imageProcessingConfigChangeObserver;
  15905. private _transformMatrix;
  15906. private _mirrorMatrix;
  15907. private _savedViewMatrix;
  15908. private _blurX;
  15909. private _blurY;
  15910. private _adaptiveBlurKernel;
  15911. private _blurKernelX;
  15912. private _blurKernelY;
  15913. private _blurRatio;
  15914. /**
  15915. * Instantiates a Mirror Texture.
  15916. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15917. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15918. * You can then easily use it as a reflectionTexture on a flat surface.
  15919. * In case the surface is not a plane, please consider relying on reflection probes.
  15920. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15921. * @param name
  15922. * @param size
  15923. * @param scene
  15924. * @param generateMipMaps
  15925. * @param type
  15926. * @param samplingMode
  15927. * @param generateDepthBuffer
  15928. */
  15929. constructor(name: string, size: number | {
  15930. width: number;
  15931. height: number;
  15932. } | {
  15933. ratio: number;
  15934. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15935. private _preparePostProcesses;
  15936. /**
  15937. * Clone the mirror texture.
  15938. * @returns the cloned texture
  15939. */
  15940. clone(): MirrorTexture;
  15941. /**
  15942. * Serialize the texture to a JSON representation you could use in Parse later on
  15943. * @returns the serialized JSON representation
  15944. */
  15945. serialize(): any;
  15946. /**
  15947. * Dispose the texture and release its associated resources.
  15948. */
  15949. dispose(): void;
  15950. }
  15951. }
  15952. declare module BABYLON {
  15953. /**
  15954. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15955. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15956. */
  15957. export class Texture extends BaseTexture {
  15958. /**
  15959. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15960. */
  15961. static SerializeBuffers: boolean;
  15962. /** @hidden */
  15963. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15964. /** @hidden */
  15965. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15966. /** @hidden */
  15967. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15968. /** nearest is mag = nearest and min = nearest and mip = linear */
  15969. static readonly NEAREST_SAMPLINGMODE: number;
  15970. /** nearest is mag = nearest and min = nearest and mip = linear */
  15971. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15972. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15973. static readonly BILINEAR_SAMPLINGMODE: number;
  15974. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15975. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15976. /** Trilinear is mag = linear and min = linear and mip = linear */
  15977. static readonly TRILINEAR_SAMPLINGMODE: number;
  15978. /** Trilinear is mag = linear and min = linear and mip = linear */
  15979. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15980. /** mag = nearest and min = nearest and mip = nearest */
  15981. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15982. /** mag = nearest and min = linear and mip = nearest */
  15983. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15984. /** mag = nearest and min = linear and mip = linear */
  15985. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15986. /** mag = nearest and min = linear and mip = none */
  15987. static readonly NEAREST_LINEAR: number;
  15988. /** mag = nearest and min = nearest and mip = none */
  15989. static readonly NEAREST_NEAREST: number;
  15990. /** mag = linear and min = nearest and mip = nearest */
  15991. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15992. /** mag = linear and min = nearest and mip = linear */
  15993. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15994. /** mag = linear and min = linear and mip = none */
  15995. static readonly LINEAR_LINEAR: number;
  15996. /** mag = linear and min = nearest and mip = none */
  15997. static readonly LINEAR_NEAREST: number;
  15998. /** Explicit coordinates mode */
  15999. static readonly EXPLICIT_MODE: number;
  16000. /** Spherical coordinates mode */
  16001. static readonly SPHERICAL_MODE: number;
  16002. /** Planar coordinates mode */
  16003. static readonly PLANAR_MODE: number;
  16004. /** Cubic coordinates mode */
  16005. static readonly CUBIC_MODE: number;
  16006. /** Projection coordinates mode */
  16007. static readonly PROJECTION_MODE: number;
  16008. /** Inverse Cubic coordinates mode */
  16009. static readonly SKYBOX_MODE: number;
  16010. /** Inverse Cubic coordinates mode */
  16011. static readonly INVCUBIC_MODE: number;
  16012. /** Equirectangular coordinates mode */
  16013. static readonly EQUIRECTANGULAR_MODE: number;
  16014. /** Equirectangular Fixed coordinates mode */
  16015. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16016. /** Equirectangular Fixed Mirrored coordinates mode */
  16017. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16018. /** Texture is not repeating outside of 0..1 UVs */
  16019. static readonly CLAMP_ADDRESSMODE: number;
  16020. /** Texture is repeating outside of 0..1 UVs */
  16021. static readonly WRAP_ADDRESSMODE: number;
  16022. /** Texture is repeating and mirrored */
  16023. static readonly MIRROR_ADDRESSMODE: number;
  16024. /**
  16025. * 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
  16026. */
  16027. static UseSerializedUrlIfAny: boolean;
  16028. /**
  16029. * Define the url of the texture.
  16030. */
  16031. url: Nullable<string>;
  16032. /**
  16033. * Define an offset on the texture to offset the u coordinates of the UVs
  16034. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16035. */
  16036. uOffset: number;
  16037. /**
  16038. * Define an offset on the texture to offset the v coordinates of the UVs
  16039. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16040. */
  16041. vOffset: number;
  16042. /**
  16043. * Define an offset on the texture to scale the u coordinates of the UVs
  16044. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16045. */
  16046. uScale: number;
  16047. /**
  16048. * Define an offset on the texture to scale the v coordinates of the UVs
  16049. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16050. */
  16051. vScale: number;
  16052. /**
  16053. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16054. * @see http://doc.babylonjs.com/how_to/more_materials
  16055. */
  16056. uAng: number;
  16057. /**
  16058. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16059. * @see http://doc.babylonjs.com/how_to/more_materials
  16060. */
  16061. vAng: number;
  16062. /**
  16063. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16064. * @see http://doc.babylonjs.com/how_to/more_materials
  16065. */
  16066. wAng: number;
  16067. /**
  16068. * Defines the center of rotation (U)
  16069. */
  16070. uRotationCenter: number;
  16071. /**
  16072. * Defines the center of rotation (V)
  16073. */
  16074. vRotationCenter: number;
  16075. /**
  16076. * Defines the center of rotation (W)
  16077. */
  16078. wRotationCenter: number;
  16079. /**
  16080. * Are mip maps generated for this texture or not.
  16081. */
  16082. get noMipmap(): boolean;
  16083. /**
  16084. * List of inspectable custom properties (used by the Inspector)
  16085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16086. */
  16087. inspectableCustomProperties: Nullable<IInspectable[]>;
  16088. private _noMipmap;
  16089. /** @hidden */
  16090. _invertY: boolean;
  16091. private _rowGenerationMatrix;
  16092. private _cachedTextureMatrix;
  16093. private _projectionModeMatrix;
  16094. private _t0;
  16095. private _t1;
  16096. private _t2;
  16097. private _cachedUOffset;
  16098. private _cachedVOffset;
  16099. private _cachedUScale;
  16100. private _cachedVScale;
  16101. private _cachedUAng;
  16102. private _cachedVAng;
  16103. private _cachedWAng;
  16104. private _cachedProjectionMatrixId;
  16105. private _cachedCoordinatesMode;
  16106. /** @hidden */
  16107. protected _initialSamplingMode: number;
  16108. /** @hidden */
  16109. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16110. private _deleteBuffer;
  16111. protected _format: Nullable<number>;
  16112. private _delayedOnLoad;
  16113. private _delayedOnError;
  16114. private _mimeType?;
  16115. /**
  16116. * Observable triggered once the texture has been loaded.
  16117. */
  16118. onLoadObservable: Observable<Texture>;
  16119. protected _isBlocking: boolean;
  16120. /**
  16121. * Is the texture preventing material to render while loading.
  16122. * If false, a default texture will be used instead of the loading one during the preparation step.
  16123. */
  16124. set isBlocking(value: boolean);
  16125. get isBlocking(): boolean;
  16126. /**
  16127. * Get the current sampling mode associated with the texture.
  16128. */
  16129. get samplingMode(): number;
  16130. /**
  16131. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16132. */
  16133. get invertY(): boolean;
  16134. /**
  16135. * Instantiates a new texture.
  16136. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16137. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16138. * @param url defines the url of the picture to load as a texture
  16139. * @param scene defines the scene or engine the texture will belong to
  16140. * @param noMipmap defines if the texture will require mip maps or not
  16141. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16142. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16143. * @param onLoad defines a callback triggered when the texture has been loaded
  16144. * @param onError defines a callback triggered when an error occurred during the loading session
  16145. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16146. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16147. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16148. * @param mimeType defines an optional mime type information
  16149. */
  16150. 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);
  16151. /**
  16152. * Update the url (and optional buffer) of this texture if url was null during construction.
  16153. * @param url the url of the texture
  16154. * @param buffer the buffer of the texture (defaults to null)
  16155. * @param onLoad callback called when the texture is loaded (defaults to null)
  16156. */
  16157. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16158. /**
  16159. * Finish the loading sequence of a texture flagged as delayed load.
  16160. * @hidden
  16161. */
  16162. delayLoad(): void;
  16163. private _prepareRowForTextureGeneration;
  16164. /**
  16165. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16166. * @returns the transform matrix of the texture.
  16167. */
  16168. getTextureMatrix(uBase?: number): Matrix;
  16169. /**
  16170. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16171. * @returns The reflection texture transform
  16172. */
  16173. getReflectionTextureMatrix(): Matrix;
  16174. /**
  16175. * Clones the texture.
  16176. * @returns the cloned texture
  16177. */
  16178. clone(): Texture;
  16179. /**
  16180. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16181. * @returns The JSON representation of the texture
  16182. */
  16183. serialize(): any;
  16184. /**
  16185. * Get the current class name of the texture useful for serialization or dynamic coding.
  16186. * @returns "Texture"
  16187. */
  16188. getClassName(): string;
  16189. /**
  16190. * Dispose the texture and release its associated resources.
  16191. */
  16192. dispose(): void;
  16193. /**
  16194. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16195. * @param parsedTexture Define the JSON representation of the texture
  16196. * @param scene Define the scene the parsed texture should be instantiated in
  16197. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16198. * @returns The parsed texture if successful
  16199. */
  16200. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16201. /**
  16202. * Creates a texture from its base 64 representation.
  16203. * @param data Define the base64 payload without the data: prefix
  16204. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16205. * @param scene Define the scene the texture should belong to
  16206. * @param noMipmap Forces the texture to not create mip map information if true
  16207. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16208. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16209. * @param onLoad define a callback triggered when the texture has been loaded
  16210. * @param onError define a callback triggered when an error occurred during the loading session
  16211. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16212. * @returns the created texture
  16213. */
  16214. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16215. /**
  16216. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16217. * @param data Define the base64 payload without the data: prefix
  16218. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16219. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16220. * @param scene Define the scene the texture should belong to
  16221. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16222. * @param noMipmap Forces the texture to not create mip map information if true
  16223. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16224. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16225. * @param onLoad define a callback triggered when the texture has been loaded
  16226. * @param onError define a callback triggered when an error occurred during the loading session
  16227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16228. * @returns the created texture
  16229. */
  16230. 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;
  16231. }
  16232. }
  16233. declare module BABYLON {
  16234. /**
  16235. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16236. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16237. */
  16238. export class PostProcessManager {
  16239. private _scene;
  16240. private _indexBuffer;
  16241. private _vertexBuffers;
  16242. /**
  16243. * Creates a new instance PostProcess
  16244. * @param scene The scene that the post process is associated with.
  16245. */
  16246. constructor(scene: Scene);
  16247. private _prepareBuffers;
  16248. private _buildIndexBuffer;
  16249. /**
  16250. * Rebuilds the vertex buffers of the manager.
  16251. * @hidden
  16252. */
  16253. _rebuild(): void;
  16254. /**
  16255. * Prepares a frame to be run through a post process.
  16256. * @param sourceTexture The input texture to the post procesess. (default: null)
  16257. * @param postProcesses An array of post processes to be run. (default: null)
  16258. * @returns True if the post processes were able to be run.
  16259. * @hidden
  16260. */
  16261. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16262. /**
  16263. * Manually render a set of post processes to a texture.
  16264. * @param postProcesses An array of post processes to be run.
  16265. * @param targetTexture The target texture to render to.
  16266. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16267. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16268. * @param lodLevel defines which lod of the texture to render to
  16269. */
  16270. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16271. /**
  16272. * Finalize the result of the output of the postprocesses.
  16273. * @param doNotPresent If true the result will not be displayed to the screen.
  16274. * @param targetTexture The target texture to render to.
  16275. * @param faceIndex The index of the face to bind the target texture to.
  16276. * @param postProcesses The array of post processes to render.
  16277. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16278. * @hidden
  16279. */
  16280. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16281. /**
  16282. * Disposes of the post process manager.
  16283. */
  16284. dispose(): void;
  16285. }
  16286. }
  16287. declare module BABYLON {
  16288. /** Interface used by value gradients (color, factor, ...) */
  16289. export interface IValueGradient {
  16290. /**
  16291. * Gets or sets the gradient value (between 0 and 1)
  16292. */
  16293. gradient: number;
  16294. }
  16295. /** Class used to store color4 gradient */
  16296. export class ColorGradient implements IValueGradient {
  16297. /**
  16298. * Gets or sets the gradient value (between 0 and 1)
  16299. */
  16300. gradient: number;
  16301. /**
  16302. * Gets or sets first associated color
  16303. */
  16304. color1: Color4;
  16305. /**
  16306. * Gets or sets second associated color
  16307. */
  16308. color2?: Color4;
  16309. /**
  16310. * Will get a color picked randomly between color1 and color2.
  16311. * If color2 is undefined then color1 will be used
  16312. * @param result defines the target Color4 to store the result in
  16313. */
  16314. getColorToRef(result: Color4): void;
  16315. }
  16316. /** Class used to store color 3 gradient */
  16317. export class Color3Gradient implements IValueGradient {
  16318. /**
  16319. * Gets or sets the gradient value (between 0 and 1)
  16320. */
  16321. gradient: number;
  16322. /**
  16323. * Gets or sets the associated color
  16324. */
  16325. color: Color3;
  16326. }
  16327. /** Class used to store factor gradient */
  16328. export class FactorGradient implements IValueGradient {
  16329. /**
  16330. * Gets or sets the gradient value (between 0 and 1)
  16331. */
  16332. gradient: number;
  16333. /**
  16334. * Gets or sets first associated factor
  16335. */
  16336. factor1: number;
  16337. /**
  16338. * Gets or sets second associated factor
  16339. */
  16340. factor2?: number;
  16341. /**
  16342. * Will get a number picked randomly between factor1 and factor2.
  16343. * If factor2 is undefined then factor1 will be used
  16344. * @returns the picked number
  16345. */
  16346. getFactor(): number;
  16347. }
  16348. /**
  16349. * Helper used to simplify some generic gradient tasks
  16350. */
  16351. export class GradientHelper {
  16352. /**
  16353. * Gets the current gradient from an array of IValueGradient
  16354. * @param ratio defines the current ratio to get
  16355. * @param gradients defines the array of IValueGradient
  16356. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16357. */
  16358. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16359. }
  16360. }
  16361. declare module BABYLON {
  16362. interface ThinEngine {
  16363. /**
  16364. * Creates a dynamic texture
  16365. * @param width defines the width of the texture
  16366. * @param height defines the height of the texture
  16367. * @param generateMipMaps defines if the engine should generate the mip levels
  16368. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16369. * @returns the dynamic texture inside an InternalTexture
  16370. */
  16371. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16372. /**
  16373. * Update the content of a dynamic texture
  16374. * @param texture defines the texture to update
  16375. * @param canvas defines the canvas containing the source
  16376. * @param invertY defines if data must be stored with Y axis inverted
  16377. * @param premulAlpha defines if alpha is stored as premultiplied
  16378. * @param format defines the format of the data
  16379. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16380. */
  16381. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16382. }
  16383. }
  16384. declare module BABYLON {
  16385. /**
  16386. * Helper class used to generate a canvas to manipulate images
  16387. */
  16388. export class CanvasGenerator {
  16389. /**
  16390. * Create a new canvas (or offscreen canvas depending on the context)
  16391. * @param width defines the expected width
  16392. * @param height defines the expected height
  16393. * @return a new canvas or offscreen canvas
  16394. */
  16395. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16396. }
  16397. }
  16398. declare module BABYLON {
  16399. /**
  16400. * A class extending Texture allowing drawing on a texture
  16401. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16402. */
  16403. export class DynamicTexture extends Texture {
  16404. private _generateMipMaps;
  16405. private _canvas;
  16406. private _context;
  16407. private _engine;
  16408. /**
  16409. * Creates a DynamicTexture
  16410. * @param name defines the name of the texture
  16411. * @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
  16412. * @param scene defines the scene where you want the texture
  16413. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16414. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16415. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16416. */
  16417. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16418. /**
  16419. * Get the current class name of the texture useful for serialization or dynamic coding.
  16420. * @returns "DynamicTexture"
  16421. */
  16422. getClassName(): string;
  16423. /**
  16424. * Gets the current state of canRescale
  16425. */
  16426. get canRescale(): boolean;
  16427. private _recreate;
  16428. /**
  16429. * Scales the texture
  16430. * @param ratio the scale factor to apply to both width and height
  16431. */
  16432. scale(ratio: number): void;
  16433. /**
  16434. * Resizes the texture
  16435. * @param width the new width
  16436. * @param height the new height
  16437. */
  16438. scaleTo(width: number, height: number): void;
  16439. /**
  16440. * Gets the context of the canvas used by the texture
  16441. * @returns the canvas context of the dynamic texture
  16442. */
  16443. getContext(): CanvasRenderingContext2D;
  16444. /**
  16445. * Clears the texture
  16446. */
  16447. clear(): void;
  16448. /**
  16449. * Updates the texture
  16450. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16451. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16452. */
  16453. update(invertY?: boolean, premulAlpha?: boolean): void;
  16454. /**
  16455. * Draws text onto the texture
  16456. * @param text defines the text to be drawn
  16457. * @param x defines the placement of the text from the left
  16458. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16459. * @param font defines the font to be used with font-style, font-size, font-name
  16460. * @param color defines the color used for the text
  16461. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16462. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16463. * @param update defines whether texture is immediately update (default is true)
  16464. */
  16465. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16466. /**
  16467. * Clones the texture
  16468. * @returns the clone of the texture.
  16469. */
  16470. clone(): DynamicTexture;
  16471. /**
  16472. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16473. * @returns a serialized dynamic texture object
  16474. */
  16475. serialize(): any;
  16476. /** @hidden */
  16477. _rebuild(): void;
  16478. }
  16479. }
  16480. declare module BABYLON {
  16481. interface AbstractScene {
  16482. /**
  16483. * The list of procedural textures added to the scene
  16484. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16485. */
  16486. proceduralTextures: Array<ProceduralTexture>;
  16487. }
  16488. /**
  16489. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16490. * in a given scene.
  16491. */
  16492. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16493. /**
  16494. * The component name helpfull to identify the component in the list of scene components.
  16495. */
  16496. readonly name: string;
  16497. /**
  16498. * The scene the component belongs to.
  16499. */
  16500. scene: Scene;
  16501. /**
  16502. * Creates a new instance of the component for the given scene
  16503. * @param scene Defines the scene to register the component in
  16504. */
  16505. constructor(scene: Scene);
  16506. /**
  16507. * Registers the component in a given scene
  16508. */
  16509. register(): void;
  16510. /**
  16511. * Rebuilds the elements related to this component in case of
  16512. * context lost for instance.
  16513. */
  16514. rebuild(): void;
  16515. /**
  16516. * Disposes the component and the associated ressources.
  16517. */
  16518. dispose(): void;
  16519. private _beforeClear;
  16520. }
  16521. }
  16522. declare module BABYLON {
  16523. interface ThinEngine {
  16524. /**
  16525. * Creates a new render target cube texture
  16526. * @param size defines the size of the texture
  16527. * @param options defines the options used to create the texture
  16528. * @returns a new render target cube texture stored in an InternalTexture
  16529. */
  16530. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16531. }
  16532. }
  16533. declare module BABYLON {
  16534. /** @hidden */
  16535. export var proceduralVertexShader: {
  16536. name: string;
  16537. shader: string;
  16538. };
  16539. }
  16540. declare module BABYLON {
  16541. /**
  16542. * 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.
  16543. * This is the base class of any Procedural texture and contains most of the shareable code.
  16544. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16545. */
  16546. export class ProceduralTexture extends Texture {
  16547. isCube: boolean;
  16548. /**
  16549. * Define if the texture is enabled or not (disabled texture will not render)
  16550. */
  16551. isEnabled: boolean;
  16552. /**
  16553. * Define if the texture must be cleared before rendering (default is true)
  16554. */
  16555. autoClear: boolean;
  16556. /**
  16557. * Callback called when the texture is generated
  16558. */
  16559. onGenerated: () => void;
  16560. /**
  16561. * Event raised when the texture is generated
  16562. */
  16563. onGeneratedObservable: Observable<ProceduralTexture>;
  16564. /** @hidden */
  16565. _generateMipMaps: boolean;
  16566. /** @hidden **/
  16567. _effect: Effect;
  16568. /** @hidden */
  16569. _textures: {
  16570. [key: string]: Texture;
  16571. };
  16572. private _size;
  16573. private _currentRefreshId;
  16574. private _frameId;
  16575. private _refreshRate;
  16576. private _vertexBuffers;
  16577. private _indexBuffer;
  16578. private _uniforms;
  16579. private _samplers;
  16580. private _fragment;
  16581. private _floats;
  16582. private _ints;
  16583. private _floatsArrays;
  16584. private _colors3;
  16585. private _colors4;
  16586. private _vectors2;
  16587. private _vectors3;
  16588. private _matrices;
  16589. private _fallbackTexture;
  16590. private _fallbackTextureUsed;
  16591. private _engine;
  16592. private _cachedDefines;
  16593. private _contentUpdateId;
  16594. private _contentData;
  16595. /**
  16596. * Instantiates a new procedural texture.
  16597. * 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.
  16598. * This is the base class of any Procedural texture and contains most of the shareable code.
  16599. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16600. * @param name Define the name of the texture
  16601. * @param size Define the size of the texture to create
  16602. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16603. * @param scene Define the scene the texture belongs to
  16604. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16605. * @param generateMipMaps Define if the texture should creates mip maps or not
  16606. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16607. */
  16608. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16609. /**
  16610. * The effect that is created when initializing the post process.
  16611. * @returns The created effect corresponding the the postprocess.
  16612. */
  16613. getEffect(): Effect;
  16614. /**
  16615. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16616. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16617. */
  16618. getContent(): Nullable<ArrayBufferView>;
  16619. private _createIndexBuffer;
  16620. /** @hidden */
  16621. _rebuild(): void;
  16622. /**
  16623. * Resets the texture in order to recreate its associated resources.
  16624. * This can be called in case of context loss
  16625. */
  16626. reset(): void;
  16627. protected _getDefines(): string;
  16628. /**
  16629. * Is the texture ready to be used ? (rendered at least once)
  16630. * @returns true if ready, otherwise, false.
  16631. */
  16632. isReady(): boolean;
  16633. /**
  16634. * Resets the refresh counter of the texture and start bak from scratch.
  16635. * Could be useful to regenerate the texture if it is setup to render only once.
  16636. */
  16637. resetRefreshCounter(): void;
  16638. /**
  16639. * Set the fragment shader to use in order to render the texture.
  16640. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16641. */
  16642. setFragment(fragment: any): void;
  16643. /**
  16644. * Define the refresh rate of the texture or the rendering frequency.
  16645. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16646. */
  16647. get refreshRate(): number;
  16648. set refreshRate(value: number);
  16649. /** @hidden */
  16650. _shouldRender(): boolean;
  16651. /**
  16652. * Get the size the texture is rendering at.
  16653. * @returns the size (texture is always squared)
  16654. */
  16655. getRenderSize(): number;
  16656. /**
  16657. * Resize the texture to new value.
  16658. * @param size Define the new size the texture should have
  16659. * @param generateMipMaps Define whether the new texture should create mip maps
  16660. */
  16661. resize(size: number, generateMipMaps: boolean): void;
  16662. private _checkUniform;
  16663. /**
  16664. * Set a texture in the shader program used to render.
  16665. * @param name Define the name of the uniform samplers as defined in the shader
  16666. * @param texture Define the texture to bind to this sampler
  16667. * @return the texture itself allowing "fluent" like uniform updates
  16668. */
  16669. setTexture(name: string, texture: Texture): ProceduralTexture;
  16670. /**
  16671. * Set a float in the shader.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the texture itself allowing "fluent" like uniform updates
  16675. */
  16676. setFloat(name: string, value: number): ProceduralTexture;
  16677. /**
  16678. * Set a int in the shader.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the texture itself allowing "fluent" like uniform updates
  16682. */
  16683. setInt(name: string, value: number): ProceduralTexture;
  16684. /**
  16685. * Set an array of floats in the shader.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the texture itself allowing "fluent" like uniform updates
  16689. */
  16690. setFloats(name: string, value: number[]): ProceduralTexture;
  16691. /**
  16692. * Set a vec3 in the shader from a Color3.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the texture itself allowing "fluent" like uniform updates
  16696. */
  16697. setColor3(name: string, value: Color3): ProceduralTexture;
  16698. /**
  16699. * Set a vec4 in the shader from a Color4.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the texture itself allowing "fluent" like uniform updates
  16703. */
  16704. setColor4(name: string, value: Color4): ProceduralTexture;
  16705. /**
  16706. * Set a vec2 in the shader from a Vector2.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the texture itself allowing "fluent" like uniform updates
  16710. */
  16711. setVector2(name: string, value: Vector2): ProceduralTexture;
  16712. /**
  16713. * Set a vec3 in the shader from a Vector3.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the texture itself allowing "fluent" like uniform updates
  16717. */
  16718. setVector3(name: string, value: Vector3): ProceduralTexture;
  16719. /**
  16720. * Set a mat4 in the shader from a MAtrix.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the texture itself allowing "fluent" like uniform updates
  16724. */
  16725. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16726. /**
  16727. * Render the texture to its associated render target.
  16728. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16729. */
  16730. render(useCameraPostProcess?: boolean): void;
  16731. /**
  16732. * Clone the texture.
  16733. * @returns the cloned texture
  16734. */
  16735. clone(): ProceduralTexture;
  16736. /**
  16737. * Dispose the texture and release its asoociated resources.
  16738. */
  16739. dispose(): void;
  16740. }
  16741. }
  16742. declare module BABYLON {
  16743. /**
  16744. * This represents the base class for particle system in Babylon.
  16745. * 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.
  16746. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16747. * @example https://doc.babylonjs.com/babylon101/particles
  16748. */
  16749. export class BaseParticleSystem {
  16750. /**
  16751. * Source color is added to the destination color without alpha affecting the result
  16752. */
  16753. static BLENDMODE_ONEONE: number;
  16754. /**
  16755. * Blend current color and particle color using particle’s alpha
  16756. */
  16757. static BLENDMODE_STANDARD: number;
  16758. /**
  16759. * Add current color and particle color multiplied by particle’s alpha
  16760. */
  16761. static BLENDMODE_ADD: number;
  16762. /**
  16763. * Multiply current color with particle color
  16764. */
  16765. static BLENDMODE_MULTIPLY: number;
  16766. /**
  16767. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16768. */
  16769. static BLENDMODE_MULTIPLYADD: number;
  16770. /**
  16771. * List of animations used by the particle system.
  16772. */
  16773. animations: Animation[];
  16774. /**
  16775. * The id of the Particle system.
  16776. */
  16777. id: string;
  16778. /**
  16779. * The friendly name of the Particle system.
  16780. */
  16781. name: string;
  16782. /**
  16783. * The rendering group used by the Particle system to chose when to render.
  16784. */
  16785. renderingGroupId: number;
  16786. /**
  16787. * The emitter represents the Mesh or position we are attaching the particle system to.
  16788. */
  16789. emitter: Nullable<AbstractMesh | Vector3>;
  16790. /**
  16791. * The maximum number of particles to emit per frame
  16792. */
  16793. emitRate: number;
  16794. /**
  16795. * If you want to launch only a few particles at once, that can be done, as well.
  16796. */
  16797. manualEmitCount: number;
  16798. /**
  16799. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16800. */
  16801. updateSpeed: number;
  16802. /**
  16803. * The amount of time the particle system is running (depends of the overall update speed).
  16804. */
  16805. targetStopDuration: number;
  16806. /**
  16807. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16808. */
  16809. disposeOnStop: boolean;
  16810. /**
  16811. * Minimum power of emitting particles.
  16812. */
  16813. minEmitPower: number;
  16814. /**
  16815. * Maximum power of emitting particles.
  16816. */
  16817. maxEmitPower: number;
  16818. /**
  16819. * Minimum life time of emitting particles.
  16820. */
  16821. minLifeTime: number;
  16822. /**
  16823. * Maximum life time of emitting particles.
  16824. */
  16825. maxLifeTime: number;
  16826. /**
  16827. * Minimum Size of emitting particles.
  16828. */
  16829. minSize: number;
  16830. /**
  16831. * Maximum Size of emitting particles.
  16832. */
  16833. maxSize: number;
  16834. /**
  16835. * Minimum scale of emitting particles on X axis.
  16836. */
  16837. minScaleX: number;
  16838. /**
  16839. * Maximum scale of emitting particles on X axis.
  16840. */
  16841. maxScaleX: number;
  16842. /**
  16843. * Minimum scale of emitting particles on Y axis.
  16844. */
  16845. minScaleY: number;
  16846. /**
  16847. * Maximum scale of emitting particles on Y axis.
  16848. */
  16849. maxScaleY: number;
  16850. /**
  16851. * Gets or sets the minimal initial rotation in radians.
  16852. */
  16853. minInitialRotation: number;
  16854. /**
  16855. * Gets or sets the maximal initial rotation in radians.
  16856. */
  16857. maxInitialRotation: number;
  16858. /**
  16859. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16860. */
  16861. minAngularSpeed: number;
  16862. /**
  16863. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16864. */
  16865. maxAngularSpeed: number;
  16866. /**
  16867. * The texture used to render each particle. (this can be a spritesheet)
  16868. */
  16869. particleTexture: Nullable<Texture>;
  16870. /**
  16871. * The layer mask we are rendering the particles through.
  16872. */
  16873. layerMask: number;
  16874. /**
  16875. * This can help using your own shader to render the particle system.
  16876. * The according effect will be created
  16877. */
  16878. customShader: any;
  16879. /**
  16880. * By default particle system starts as soon as they are created. This prevents the
  16881. * automatic start to happen and let you decide when to start emitting particles.
  16882. */
  16883. preventAutoStart: boolean;
  16884. private _noiseTexture;
  16885. /**
  16886. * Gets or sets a texture used to add random noise to particle positions
  16887. */
  16888. get noiseTexture(): Nullable<ProceduralTexture>;
  16889. set noiseTexture(value: Nullable<ProceduralTexture>);
  16890. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16891. noiseStrength: Vector3;
  16892. /**
  16893. * Callback triggered when the particle animation is ending.
  16894. */
  16895. onAnimationEnd: Nullable<() => void>;
  16896. /**
  16897. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16898. */
  16899. blendMode: number;
  16900. /**
  16901. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16902. * to override the particles.
  16903. */
  16904. forceDepthWrite: boolean;
  16905. /** 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 */
  16906. preWarmCycles: number;
  16907. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16908. preWarmStepOffset: number;
  16909. /**
  16910. * 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)
  16911. */
  16912. spriteCellChangeSpeed: number;
  16913. /**
  16914. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16915. */
  16916. startSpriteCellID: number;
  16917. /**
  16918. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16919. */
  16920. endSpriteCellID: number;
  16921. /**
  16922. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16923. */
  16924. spriteCellWidth: number;
  16925. /**
  16926. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16927. */
  16928. spriteCellHeight: number;
  16929. /**
  16930. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16931. */
  16932. spriteRandomStartCell: boolean;
  16933. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16934. translationPivot: Vector2;
  16935. /** @hidden */
  16936. protected _isAnimationSheetEnabled: boolean;
  16937. /**
  16938. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16939. */
  16940. beginAnimationOnStart: boolean;
  16941. /**
  16942. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16943. */
  16944. beginAnimationFrom: number;
  16945. /**
  16946. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16947. */
  16948. beginAnimationTo: number;
  16949. /**
  16950. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16951. */
  16952. beginAnimationLoop: boolean;
  16953. /**
  16954. * Gets or sets a world offset applied to all particles
  16955. */
  16956. worldOffset: Vector3;
  16957. /**
  16958. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16959. */
  16960. get isAnimationSheetEnabled(): boolean;
  16961. set isAnimationSheetEnabled(value: boolean);
  16962. /**
  16963. * Get hosting scene
  16964. * @returns the scene
  16965. */
  16966. getScene(): Scene;
  16967. /**
  16968. * You can use gravity if you want to give an orientation to your particles.
  16969. */
  16970. gravity: Vector3;
  16971. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16972. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16973. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16974. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16975. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16976. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16977. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16978. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16979. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16980. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16981. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16982. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16983. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16984. /**
  16985. * Defines the delay in milliseconds before starting the system (0 by default)
  16986. */
  16987. startDelay: number;
  16988. /**
  16989. * Gets the current list of drag gradients.
  16990. * You must use addDragGradient and removeDragGradient to udpate this list
  16991. * @returns the list of drag gradients
  16992. */
  16993. getDragGradients(): Nullable<Array<FactorGradient>>;
  16994. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16995. limitVelocityDamping: number;
  16996. /**
  16997. * Gets the current list of limit velocity gradients.
  16998. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16999. * @returns the list of limit velocity gradients
  17000. */
  17001. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17002. /**
  17003. * Gets the current list of color gradients.
  17004. * You must use addColorGradient and removeColorGradient to udpate this list
  17005. * @returns the list of color gradients
  17006. */
  17007. getColorGradients(): Nullable<Array<ColorGradient>>;
  17008. /**
  17009. * Gets the current list of size gradients.
  17010. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17011. * @returns the list of size gradients
  17012. */
  17013. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17014. /**
  17015. * Gets the current list of color remap gradients.
  17016. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17017. * @returns the list of color remap gradients
  17018. */
  17019. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17020. /**
  17021. * Gets the current list of alpha remap gradients.
  17022. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17023. * @returns the list of alpha remap gradients
  17024. */
  17025. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of life time gradients.
  17028. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17029. * @returns the list of life time gradients
  17030. */
  17031. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17032. /**
  17033. * Gets the current list of angular speed gradients.
  17034. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17035. * @returns the list of angular speed gradients
  17036. */
  17037. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17038. /**
  17039. * Gets the current list of velocity gradients.
  17040. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17041. * @returns the list of velocity gradients
  17042. */
  17043. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Gets the current list of start size gradients.
  17046. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17047. * @returns the list of start size gradients
  17048. */
  17049. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17050. /**
  17051. * Gets the current list of emit rate gradients.
  17052. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17053. * @returns the list of emit rate gradients
  17054. */
  17055. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17056. /**
  17057. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17058. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17059. */
  17060. get direction1(): Vector3;
  17061. set direction1(value: Vector3);
  17062. /**
  17063. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17064. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17065. */
  17066. get direction2(): Vector3;
  17067. set direction2(value: Vector3);
  17068. /**
  17069. * 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.
  17070. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17071. */
  17072. get minEmitBox(): Vector3;
  17073. set minEmitBox(value: Vector3);
  17074. /**
  17075. * 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.
  17076. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17077. */
  17078. get maxEmitBox(): Vector3;
  17079. set maxEmitBox(value: Vector3);
  17080. /**
  17081. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17082. */
  17083. color1: Color4;
  17084. /**
  17085. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17086. */
  17087. color2: Color4;
  17088. /**
  17089. * Color the particle will have at the end of its lifetime
  17090. */
  17091. colorDead: Color4;
  17092. /**
  17093. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17094. */
  17095. textureMask: Color4;
  17096. /**
  17097. * The particle emitter type defines the emitter used by the particle system.
  17098. * It can be for example box, sphere, or cone...
  17099. */
  17100. particleEmitterType: IParticleEmitterType;
  17101. /** @hidden */
  17102. _isSubEmitter: boolean;
  17103. /**
  17104. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17105. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17106. */
  17107. billboardMode: number;
  17108. protected _isBillboardBased: boolean;
  17109. /**
  17110. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17111. */
  17112. get isBillboardBased(): boolean;
  17113. set isBillboardBased(value: boolean);
  17114. /**
  17115. * The scene the particle system belongs to.
  17116. */
  17117. protected _scene: Scene;
  17118. /**
  17119. * Local cache of defines for image processing.
  17120. */
  17121. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17122. /**
  17123. * Default configuration related to image processing available in the standard Material.
  17124. */
  17125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17126. /**
  17127. * Gets the image processing configuration used either in this material.
  17128. */
  17129. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17130. /**
  17131. * Sets the Default image processing configuration used either in the this material.
  17132. *
  17133. * If sets to null, the scene one is in use.
  17134. */
  17135. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17136. /**
  17137. * Attaches a new image processing configuration to the Standard Material.
  17138. * @param configuration
  17139. */
  17140. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17141. /** @hidden */
  17142. protected _reset(): void;
  17143. /** @hidden */
  17144. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17145. /**
  17146. * Instantiates a particle system.
  17147. * 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.
  17148. * @param name The name of the particle system
  17149. */
  17150. constructor(name: string);
  17151. /**
  17152. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17153. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17154. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17155. * @returns the emitter
  17156. */
  17157. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17158. /**
  17159. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17160. * @param radius The radius of the hemisphere to emit from
  17161. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17162. * @returns the emitter
  17163. */
  17164. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17165. /**
  17166. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17167. * @param radius The radius of the sphere to emit from
  17168. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17169. * @returns the emitter
  17170. */
  17171. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17172. /**
  17173. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17174. * @param radius The radius of the sphere to emit from
  17175. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17176. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17177. * @returns the emitter
  17178. */
  17179. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17180. /**
  17181. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17182. * @param radius The radius of the emission cylinder
  17183. * @param height The height of the emission cylinder
  17184. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17185. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17186. * @returns the emitter
  17187. */
  17188. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17189. /**
  17190. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17191. * @param radius The radius of the cylinder to emit from
  17192. * @param height The height of the emission cylinder
  17193. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17196. * @returns the emitter
  17197. */
  17198. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17199. /**
  17200. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17201. * @param radius The radius of the cone to emit from
  17202. * @param angle The base angle of the cone
  17203. * @returns the emitter
  17204. */
  17205. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17206. /**
  17207. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17208. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17209. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17210. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17211. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17212. * @returns the emitter
  17213. */
  17214. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17215. }
  17216. }
  17217. declare module BABYLON {
  17218. /**
  17219. * Type of sub emitter
  17220. */
  17221. export enum SubEmitterType {
  17222. /**
  17223. * Attached to the particle over it's lifetime
  17224. */
  17225. ATTACHED = 0,
  17226. /**
  17227. * Created when the particle dies
  17228. */
  17229. END = 1
  17230. }
  17231. /**
  17232. * Sub emitter class used to emit particles from an existing particle
  17233. */
  17234. export class SubEmitter {
  17235. /**
  17236. * the particle system to be used by the sub emitter
  17237. */
  17238. particleSystem: ParticleSystem;
  17239. /**
  17240. * Type of the submitter (Default: END)
  17241. */
  17242. type: SubEmitterType;
  17243. /**
  17244. * 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)
  17245. * Note: This only is supported when using an emitter of type Mesh
  17246. */
  17247. inheritDirection: boolean;
  17248. /**
  17249. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17250. */
  17251. inheritedVelocityAmount: number;
  17252. /**
  17253. * Creates a sub emitter
  17254. * @param particleSystem the particle system to be used by the sub emitter
  17255. */
  17256. constructor(
  17257. /**
  17258. * the particle system to be used by the sub emitter
  17259. */
  17260. particleSystem: ParticleSystem);
  17261. /**
  17262. * Clones the sub emitter
  17263. * @returns the cloned sub emitter
  17264. */
  17265. clone(): SubEmitter;
  17266. /**
  17267. * Serialize current object to a JSON object
  17268. * @returns the serialized object
  17269. */
  17270. serialize(): any;
  17271. /** @hidden */
  17272. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17273. /**
  17274. * Creates a new SubEmitter from a serialized JSON version
  17275. * @param serializationObject defines the JSON object to read from
  17276. * @param scene defines the hosting scene
  17277. * @param rootUrl defines the rootUrl for data loading
  17278. * @returns a new SubEmitter
  17279. */
  17280. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17281. /** Release associated resources */
  17282. dispose(): void;
  17283. }
  17284. }
  17285. declare module BABYLON {
  17286. /** @hidden */
  17287. export var clipPlaneFragmentDeclaration: {
  17288. name: string;
  17289. shader: string;
  17290. };
  17291. }
  17292. declare module BABYLON {
  17293. /** @hidden */
  17294. export var imageProcessingDeclaration: {
  17295. name: string;
  17296. shader: string;
  17297. };
  17298. }
  17299. declare module BABYLON {
  17300. /** @hidden */
  17301. export var imageProcessingFunctions: {
  17302. name: string;
  17303. shader: string;
  17304. };
  17305. }
  17306. declare module BABYLON {
  17307. /** @hidden */
  17308. export var clipPlaneFragment: {
  17309. name: string;
  17310. shader: string;
  17311. };
  17312. }
  17313. declare module BABYLON {
  17314. /** @hidden */
  17315. export var particlesPixelShader: {
  17316. name: string;
  17317. shader: string;
  17318. };
  17319. }
  17320. declare module BABYLON {
  17321. /** @hidden */
  17322. export var clipPlaneVertexDeclaration: {
  17323. name: string;
  17324. shader: string;
  17325. };
  17326. }
  17327. declare module BABYLON {
  17328. /** @hidden */
  17329. export var clipPlaneVertex: {
  17330. name: string;
  17331. shader: string;
  17332. };
  17333. }
  17334. declare module BABYLON {
  17335. /** @hidden */
  17336. export var particlesVertexShader: {
  17337. name: string;
  17338. shader: string;
  17339. };
  17340. }
  17341. declare module BABYLON {
  17342. /**
  17343. * This represents a particle system in Babylon.
  17344. * 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.
  17345. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17346. * @example https://doc.babylonjs.com/babylon101/particles
  17347. */
  17348. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17349. /**
  17350. * Billboard mode will only apply to Y axis
  17351. */
  17352. static readonly BILLBOARDMODE_Y: number;
  17353. /**
  17354. * Billboard mode will apply to all axes
  17355. */
  17356. static readonly BILLBOARDMODE_ALL: number;
  17357. /**
  17358. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17359. */
  17360. static readonly BILLBOARDMODE_STRETCHED: number;
  17361. /**
  17362. * This function can be defined to provide custom update for active particles.
  17363. * This function will be called instead of regular update (age, position, color, etc.).
  17364. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17365. */
  17366. updateFunction: (particles: Particle[]) => void;
  17367. private _emitterWorldMatrix;
  17368. /**
  17369. * This function can be defined to specify initial direction for every new particle.
  17370. * It by default use the emitterType defined function
  17371. */
  17372. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17373. /**
  17374. * This function can be defined to specify initial position for every new particle.
  17375. * It by default use the emitterType defined function
  17376. */
  17377. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17378. /**
  17379. * @hidden
  17380. */
  17381. _inheritedVelocityOffset: Vector3;
  17382. /**
  17383. * An event triggered when the system is disposed
  17384. */
  17385. onDisposeObservable: Observable<ParticleSystem>;
  17386. private _onDisposeObserver;
  17387. /**
  17388. * Sets a callback that will be triggered when the system is disposed
  17389. */
  17390. set onDispose(callback: () => void);
  17391. private _particles;
  17392. private _epsilon;
  17393. private _capacity;
  17394. private _stockParticles;
  17395. private _newPartsExcess;
  17396. private _vertexData;
  17397. private _vertexBuffer;
  17398. private _vertexBuffers;
  17399. private _spriteBuffer;
  17400. private _indexBuffer;
  17401. private _effect;
  17402. private _customEffect;
  17403. private _cachedDefines;
  17404. private _scaledColorStep;
  17405. private _colorDiff;
  17406. private _scaledDirection;
  17407. private _scaledGravity;
  17408. private _currentRenderId;
  17409. private _alive;
  17410. private _useInstancing;
  17411. private _started;
  17412. private _stopped;
  17413. private _actualFrame;
  17414. private _scaledUpdateSpeed;
  17415. private _vertexBufferSize;
  17416. /** @hidden */
  17417. _currentEmitRateGradient: Nullable<FactorGradient>;
  17418. /** @hidden */
  17419. _currentEmitRate1: number;
  17420. /** @hidden */
  17421. _currentEmitRate2: number;
  17422. /** @hidden */
  17423. _currentStartSizeGradient: Nullable<FactorGradient>;
  17424. /** @hidden */
  17425. _currentStartSize1: number;
  17426. /** @hidden */
  17427. _currentStartSize2: number;
  17428. private readonly _rawTextureWidth;
  17429. private _rampGradientsTexture;
  17430. private _useRampGradients;
  17431. /** Gets or sets a boolean indicating that ramp gradients must be used
  17432. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17433. */
  17434. get useRampGradients(): boolean;
  17435. set useRampGradients(value: boolean);
  17436. /**
  17437. * 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.
  17438. * 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: [])
  17439. */
  17440. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17441. private _subEmitters;
  17442. /**
  17443. * @hidden
  17444. * If the particle systems emitter should be disposed when the particle system is disposed
  17445. */
  17446. _disposeEmitterOnDispose: boolean;
  17447. /**
  17448. * The current active Sub-systems, this property is used by the root particle system only.
  17449. */
  17450. activeSubSystems: Array<ParticleSystem>;
  17451. private _rootParticleSystem;
  17452. /**
  17453. * Gets the current list of active particles
  17454. */
  17455. get particles(): Particle[];
  17456. /**
  17457. * Returns the string "ParticleSystem"
  17458. * @returns a string containing the class name
  17459. */
  17460. getClassName(): string;
  17461. /**
  17462. * Instantiates a particle system.
  17463. * 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.
  17464. * @param name The name of the particle system
  17465. * @param capacity The max number of particles alive at the same time
  17466. * @param scene The scene the particle system belongs to
  17467. * @param customEffect a custom effect used to change the way particles are rendered by default
  17468. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17469. * @param epsilon Offset used to render the particles
  17470. */
  17471. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17472. private _addFactorGradient;
  17473. private _removeFactorGradient;
  17474. /**
  17475. * Adds a new life time gradient
  17476. * @param gradient defines the gradient to use (between 0 and 1)
  17477. * @param factor defines the life time factor to affect to the specified gradient
  17478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17479. * @returns the current particle system
  17480. */
  17481. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17482. /**
  17483. * Remove a specific life time gradient
  17484. * @param gradient defines the gradient to remove
  17485. * @returns the current particle system
  17486. */
  17487. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17488. /**
  17489. * Adds a new size gradient
  17490. * @param gradient defines the gradient to use (between 0 and 1)
  17491. * @param factor defines the size factor to affect to the specified gradient
  17492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17493. * @returns the current particle system
  17494. */
  17495. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17496. /**
  17497. * Remove a specific size gradient
  17498. * @param gradient defines the gradient to remove
  17499. * @returns the current particle system
  17500. */
  17501. removeSizeGradient(gradient: number): IParticleSystem;
  17502. /**
  17503. * Adds a new color remap gradient
  17504. * @param gradient defines the gradient to use (between 0 and 1)
  17505. * @param min defines the color remap minimal range
  17506. * @param max defines the color remap maximal range
  17507. * @returns the current particle system
  17508. */
  17509. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17510. /**
  17511. * Remove a specific color remap gradient
  17512. * @param gradient defines the gradient to remove
  17513. * @returns the current particle system
  17514. */
  17515. removeColorRemapGradient(gradient: number): IParticleSystem;
  17516. /**
  17517. * Adds a new alpha remap gradient
  17518. * @param gradient defines the gradient to use (between 0 and 1)
  17519. * @param min defines the alpha remap minimal range
  17520. * @param max defines the alpha remap maximal range
  17521. * @returns the current particle system
  17522. */
  17523. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17524. /**
  17525. * Remove a specific alpha remap gradient
  17526. * @param gradient defines the gradient to remove
  17527. * @returns the current particle system
  17528. */
  17529. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17530. /**
  17531. * Adds a new angular speed gradient
  17532. * @param gradient defines the gradient to use (between 0 and 1)
  17533. * @param factor defines the angular speed to affect to the specified gradient
  17534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17535. * @returns the current particle system
  17536. */
  17537. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17538. /**
  17539. * Remove a specific angular speed gradient
  17540. * @param gradient defines the gradient to remove
  17541. * @returns the current particle system
  17542. */
  17543. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17544. /**
  17545. * Adds a new velocity gradient
  17546. * @param gradient defines the gradient to use (between 0 and 1)
  17547. * @param factor defines the velocity to affect to the specified gradient
  17548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17549. * @returns the current particle system
  17550. */
  17551. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17552. /**
  17553. * Remove a specific velocity gradient
  17554. * @param gradient defines the gradient to remove
  17555. * @returns the current particle system
  17556. */
  17557. removeVelocityGradient(gradient: number): IParticleSystem;
  17558. /**
  17559. * Adds a new limit velocity gradient
  17560. * @param gradient defines the gradient to use (between 0 and 1)
  17561. * @param factor defines the limit velocity value to affect to the specified gradient
  17562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17563. * @returns the current particle system
  17564. */
  17565. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17566. /**
  17567. * Remove a specific limit velocity gradient
  17568. * @param gradient defines the gradient to remove
  17569. * @returns the current particle system
  17570. */
  17571. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17572. /**
  17573. * Adds a new drag gradient
  17574. * @param gradient defines the gradient to use (between 0 and 1)
  17575. * @param factor defines the drag value to affect to the specified gradient
  17576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17577. * @returns the current particle system
  17578. */
  17579. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17580. /**
  17581. * Remove a specific drag gradient
  17582. * @param gradient defines the gradient to remove
  17583. * @returns the current particle system
  17584. */
  17585. removeDragGradient(gradient: number): IParticleSystem;
  17586. /**
  17587. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17588. * @param gradient defines the gradient to use (between 0 and 1)
  17589. * @param factor defines the emit rate value to affect to the specified gradient
  17590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17591. * @returns the current particle system
  17592. */
  17593. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17594. /**
  17595. * Remove a specific emit rate gradient
  17596. * @param gradient defines the gradient to remove
  17597. * @returns the current particle system
  17598. */
  17599. removeEmitRateGradient(gradient: number): IParticleSystem;
  17600. /**
  17601. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17602. * @param gradient defines the gradient to use (between 0 and 1)
  17603. * @param factor defines the start size value to affect to the specified gradient
  17604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17605. * @returns the current particle system
  17606. */
  17607. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17608. /**
  17609. * Remove a specific start size gradient
  17610. * @param gradient defines the gradient to remove
  17611. * @returns the current particle system
  17612. */
  17613. removeStartSizeGradient(gradient: number): IParticleSystem;
  17614. private _createRampGradientTexture;
  17615. /**
  17616. * Gets the current list of ramp gradients.
  17617. * You must use addRampGradient and removeRampGradient to udpate this list
  17618. * @returns the list of ramp gradients
  17619. */
  17620. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17621. /**
  17622. * Adds a new ramp gradient used to remap particle colors
  17623. * @param gradient defines the gradient to use (between 0 and 1)
  17624. * @param color defines the color to affect to the specified gradient
  17625. * @returns the current particle system
  17626. */
  17627. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17628. /**
  17629. * Remove a specific ramp gradient
  17630. * @param gradient defines the gradient to remove
  17631. * @returns the current particle system
  17632. */
  17633. removeRampGradient(gradient: number): ParticleSystem;
  17634. /**
  17635. * Adds a new color gradient
  17636. * @param gradient defines the gradient to use (between 0 and 1)
  17637. * @param color1 defines the color to affect to the specified gradient
  17638. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17639. * @returns this particle system
  17640. */
  17641. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17642. /**
  17643. * Remove a specific color gradient
  17644. * @param gradient defines the gradient to remove
  17645. * @returns this particle system
  17646. */
  17647. removeColorGradient(gradient: number): IParticleSystem;
  17648. private _fetchR;
  17649. protected _reset(): void;
  17650. private _resetEffect;
  17651. private _createVertexBuffers;
  17652. private _createIndexBuffer;
  17653. /**
  17654. * Gets the maximum number of particles active at the same time.
  17655. * @returns The max number of active particles.
  17656. */
  17657. getCapacity(): number;
  17658. /**
  17659. * Gets whether there are still active particles in the system.
  17660. * @returns True if it is alive, otherwise false.
  17661. */
  17662. isAlive(): boolean;
  17663. /**
  17664. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17665. * @returns True if it has been started, otherwise false.
  17666. */
  17667. isStarted(): boolean;
  17668. private _prepareSubEmitterInternalArray;
  17669. /**
  17670. * Starts the particle system and begins to emit
  17671. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17672. */
  17673. start(delay?: number): void;
  17674. /**
  17675. * Stops the particle system.
  17676. * @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.
  17677. */
  17678. stop(stopSubEmitters?: boolean): void;
  17679. /**
  17680. * Remove all active particles
  17681. */
  17682. reset(): void;
  17683. /**
  17684. * @hidden (for internal use only)
  17685. */
  17686. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17687. /**
  17688. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17689. * Its lifetime will start back at 0.
  17690. */
  17691. recycleParticle: (particle: Particle) => void;
  17692. private _stopSubEmitters;
  17693. private _createParticle;
  17694. private _removeFromRoot;
  17695. private _emitFromParticle;
  17696. private _update;
  17697. /** @hidden */
  17698. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17699. /** @hidden */
  17700. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17701. /** @hidden */
  17702. private _getEffect;
  17703. /**
  17704. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17705. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17706. */
  17707. animate(preWarmOnly?: boolean): void;
  17708. private _appendParticleVertices;
  17709. /**
  17710. * Rebuilds the particle system.
  17711. */
  17712. rebuild(): void;
  17713. /**
  17714. * Is this system ready to be used/rendered
  17715. * @return true if the system is ready
  17716. */
  17717. isReady(): boolean;
  17718. private _render;
  17719. /**
  17720. * Renders the particle system in its current state.
  17721. * @returns the current number of particles
  17722. */
  17723. render(): number;
  17724. /**
  17725. * Disposes the particle system and free the associated resources
  17726. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17727. */
  17728. dispose(disposeTexture?: boolean): void;
  17729. /**
  17730. * Clones the particle system.
  17731. * @param name The name of the cloned object
  17732. * @param newEmitter The new emitter to use
  17733. * @returns the cloned particle system
  17734. */
  17735. clone(name: string, newEmitter: any): ParticleSystem;
  17736. /**
  17737. * Serializes the particle system to a JSON object.
  17738. * @returns the JSON object
  17739. */
  17740. serialize(): any;
  17741. /** @hidden */
  17742. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17743. /** @hidden */
  17744. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17745. /**
  17746. * Parses a JSON object to create a particle system.
  17747. * @param parsedParticleSystem The JSON object to parse
  17748. * @param scene The scene to create the particle system in
  17749. * @param rootUrl The root url to use to load external dependencies like texture
  17750. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17751. * @returns the Parsed particle system
  17752. */
  17753. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17754. }
  17755. }
  17756. declare module BABYLON {
  17757. /**
  17758. * A particle represents one of the element emitted by a particle system.
  17759. * This is mainly define by its coordinates, direction, velocity and age.
  17760. */
  17761. export class Particle {
  17762. /**
  17763. * The particle system the particle belongs to.
  17764. */
  17765. particleSystem: ParticleSystem;
  17766. private static _Count;
  17767. /**
  17768. * Unique ID of the particle
  17769. */
  17770. id: number;
  17771. /**
  17772. * The world position of the particle in the scene.
  17773. */
  17774. position: Vector3;
  17775. /**
  17776. * The world direction of the particle in the scene.
  17777. */
  17778. direction: Vector3;
  17779. /**
  17780. * The color of the particle.
  17781. */
  17782. color: Color4;
  17783. /**
  17784. * The color change of the particle per step.
  17785. */
  17786. colorStep: Color4;
  17787. /**
  17788. * Defines how long will the life of the particle be.
  17789. */
  17790. lifeTime: number;
  17791. /**
  17792. * The current age of the particle.
  17793. */
  17794. age: number;
  17795. /**
  17796. * The current size of the particle.
  17797. */
  17798. size: number;
  17799. /**
  17800. * The current scale of the particle.
  17801. */
  17802. scale: Vector2;
  17803. /**
  17804. * The current angle of the particle.
  17805. */
  17806. angle: number;
  17807. /**
  17808. * Defines how fast is the angle changing.
  17809. */
  17810. angularSpeed: number;
  17811. /**
  17812. * Defines the cell index used by the particle to be rendered from a sprite.
  17813. */
  17814. cellIndex: number;
  17815. /**
  17816. * The information required to support color remapping
  17817. */
  17818. remapData: Vector4;
  17819. /** @hidden */
  17820. _randomCellOffset?: number;
  17821. /** @hidden */
  17822. _initialDirection: Nullable<Vector3>;
  17823. /** @hidden */
  17824. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17825. /** @hidden */
  17826. _initialStartSpriteCellID: number;
  17827. /** @hidden */
  17828. _initialEndSpriteCellID: number;
  17829. /** @hidden */
  17830. _currentColorGradient: Nullable<ColorGradient>;
  17831. /** @hidden */
  17832. _currentColor1: Color4;
  17833. /** @hidden */
  17834. _currentColor2: Color4;
  17835. /** @hidden */
  17836. _currentSizeGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentSize1: number;
  17839. /** @hidden */
  17840. _currentSize2: number;
  17841. /** @hidden */
  17842. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentAngularSpeed1: number;
  17845. /** @hidden */
  17846. _currentAngularSpeed2: number;
  17847. /** @hidden */
  17848. _currentVelocityGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentVelocity1: number;
  17851. /** @hidden */
  17852. _currentVelocity2: number;
  17853. /** @hidden */
  17854. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17855. /** @hidden */
  17856. _currentLimitVelocity1: number;
  17857. /** @hidden */
  17858. _currentLimitVelocity2: number;
  17859. /** @hidden */
  17860. _currentDragGradient: Nullable<FactorGradient>;
  17861. /** @hidden */
  17862. _currentDrag1: number;
  17863. /** @hidden */
  17864. _currentDrag2: number;
  17865. /** @hidden */
  17866. _randomNoiseCoordinates1: Vector3;
  17867. /** @hidden */
  17868. _randomNoiseCoordinates2: Vector3;
  17869. /**
  17870. * Creates a new instance Particle
  17871. * @param particleSystem the particle system the particle belongs to
  17872. */
  17873. constructor(
  17874. /**
  17875. * The particle system the particle belongs to.
  17876. */
  17877. particleSystem: ParticleSystem);
  17878. private updateCellInfoFromSystem;
  17879. /**
  17880. * Defines how the sprite cell index is updated for the particle
  17881. */
  17882. updateCellIndex(): void;
  17883. /** @hidden */
  17884. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17885. /** @hidden */
  17886. _inheritParticleInfoToSubEmitters(): void;
  17887. /** @hidden */
  17888. _reset(): void;
  17889. /**
  17890. * Copy the properties of particle to another one.
  17891. * @param other the particle to copy the information to.
  17892. */
  17893. copyTo(other: Particle): void;
  17894. }
  17895. }
  17896. declare module BABYLON {
  17897. /**
  17898. * Particle emitter represents a volume emitting particles.
  17899. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17900. */
  17901. export interface IParticleEmitterType {
  17902. /**
  17903. * Called by the particle System when the direction is computed for the created particle.
  17904. * @param worldMatrix is the world matrix of the particle system
  17905. * @param directionToUpdate is the direction vector to update with the result
  17906. * @param particle is the particle we are computed the direction for
  17907. */
  17908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17909. /**
  17910. * Called by the particle System when the position is computed for the created particle.
  17911. * @param worldMatrix is the world matrix of the particle system
  17912. * @param positionToUpdate is the position vector to update with the result
  17913. * @param particle is the particle we are computed the position for
  17914. */
  17915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17916. /**
  17917. * Clones the current emitter and returns a copy of it
  17918. * @returns the new emitter
  17919. */
  17920. clone(): IParticleEmitterType;
  17921. /**
  17922. * Called by the GPUParticleSystem to setup the update shader
  17923. * @param effect defines the update shader
  17924. */
  17925. applyToShader(effect: Effect): void;
  17926. /**
  17927. * Returns a string to use to update the GPU particles update shader
  17928. * @returns the effect defines string
  17929. */
  17930. getEffectDefines(): string;
  17931. /**
  17932. * Returns a string representing the class name
  17933. * @returns a string containing the class name
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Serializes the particle system to a JSON object.
  17938. * @returns the JSON object
  17939. */
  17940. serialize(): any;
  17941. /**
  17942. * Parse properties from a JSON object
  17943. * @param serializationObject defines the JSON object
  17944. */
  17945. parse(serializationObject: any): void;
  17946. }
  17947. }
  17948. declare module BABYLON {
  17949. /**
  17950. * Particle emitter emitting particles from the inside of a box.
  17951. * It emits the particles randomly between 2 given directions.
  17952. */
  17953. export class BoxParticleEmitter implements IParticleEmitterType {
  17954. /**
  17955. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17956. */
  17957. direction1: Vector3;
  17958. /**
  17959. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17960. */
  17961. direction2: Vector3;
  17962. /**
  17963. * 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.
  17964. */
  17965. minEmitBox: Vector3;
  17966. /**
  17967. * 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.
  17968. */
  17969. maxEmitBox: Vector3;
  17970. /**
  17971. * Creates a new instance BoxParticleEmitter
  17972. */
  17973. constructor();
  17974. /**
  17975. * Called by the particle System when the direction is computed for the created particle.
  17976. * @param worldMatrix is the world matrix of the particle system
  17977. * @param directionToUpdate is the direction vector to update with the result
  17978. * @param particle is the particle we are computed the direction for
  17979. */
  17980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17981. /**
  17982. * Called by the particle System when the position is computed for the created particle.
  17983. * @param worldMatrix is the world matrix of the particle system
  17984. * @param positionToUpdate is the position vector to update with the result
  17985. * @param particle is the particle we are computed the position for
  17986. */
  17987. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17988. /**
  17989. * Clones the current emitter and returns a copy of it
  17990. * @returns the new emitter
  17991. */
  17992. clone(): BoxParticleEmitter;
  17993. /**
  17994. * Called by the GPUParticleSystem to setup the update shader
  17995. * @param effect defines the update shader
  17996. */
  17997. applyToShader(effect: Effect): void;
  17998. /**
  17999. * Returns a string to use to update the GPU particles update shader
  18000. * @returns a string containng the defines string
  18001. */
  18002. getEffectDefines(): string;
  18003. /**
  18004. * Returns the string "BoxParticleEmitter"
  18005. * @returns a string containing the class name
  18006. */
  18007. getClassName(): string;
  18008. /**
  18009. * Serializes the particle system to a JSON object.
  18010. * @returns the JSON object
  18011. */
  18012. serialize(): any;
  18013. /**
  18014. * Parse properties from a JSON object
  18015. * @param serializationObject defines the JSON object
  18016. */
  18017. parse(serializationObject: any): void;
  18018. }
  18019. }
  18020. declare module BABYLON {
  18021. /**
  18022. * Particle emitter emitting particles from the inside of a cone.
  18023. * It emits the particles alongside the cone volume from the base to the particle.
  18024. * The emission direction might be randomized.
  18025. */
  18026. export class ConeParticleEmitter implements IParticleEmitterType {
  18027. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18028. directionRandomizer: number;
  18029. private _radius;
  18030. private _angle;
  18031. private _height;
  18032. /**
  18033. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18034. */
  18035. radiusRange: number;
  18036. /**
  18037. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18038. */
  18039. heightRange: number;
  18040. /**
  18041. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18042. */
  18043. emitFromSpawnPointOnly: boolean;
  18044. /**
  18045. * Gets or sets the radius of the emission cone
  18046. */
  18047. get radius(): number;
  18048. set radius(value: number);
  18049. /**
  18050. * Gets or sets the angle of the emission cone
  18051. */
  18052. get angle(): number;
  18053. set angle(value: number);
  18054. private _buildHeight;
  18055. /**
  18056. * Creates a new instance ConeParticleEmitter
  18057. * @param radius the radius of the emission cone (1 by default)
  18058. * @param angle the cone base angle (PI by default)
  18059. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18060. */
  18061. constructor(radius?: number, angle?: number,
  18062. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18063. directionRandomizer?: number);
  18064. /**
  18065. * Called by the particle System when the direction is computed for the created particle.
  18066. * @param worldMatrix is the world matrix of the particle system
  18067. * @param directionToUpdate is the direction vector to update with the result
  18068. * @param particle is the particle we are computed the direction for
  18069. */
  18070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18071. /**
  18072. * Called by the particle System when the position is computed for the created particle.
  18073. * @param worldMatrix is the world matrix of the particle system
  18074. * @param positionToUpdate is the position vector to update with the result
  18075. * @param particle is the particle we are computed the position for
  18076. */
  18077. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18078. /**
  18079. * Clones the current emitter and returns a copy of it
  18080. * @returns the new emitter
  18081. */
  18082. clone(): ConeParticleEmitter;
  18083. /**
  18084. * Called by the GPUParticleSystem to setup the update shader
  18085. * @param effect defines the update shader
  18086. */
  18087. applyToShader(effect: Effect): void;
  18088. /**
  18089. * Returns a string to use to update the GPU particles update shader
  18090. * @returns a string containng the defines string
  18091. */
  18092. getEffectDefines(): string;
  18093. /**
  18094. * Returns the string "ConeParticleEmitter"
  18095. * @returns a string containing the class name
  18096. */
  18097. getClassName(): string;
  18098. /**
  18099. * Serializes the particle system to a JSON object.
  18100. * @returns the JSON object
  18101. */
  18102. serialize(): any;
  18103. /**
  18104. * Parse properties from a JSON object
  18105. * @param serializationObject defines the JSON object
  18106. */
  18107. parse(serializationObject: any): void;
  18108. }
  18109. }
  18110. declare module BABYLON {
  18111. /**
  18112. * Particle emitter emitting particles from the inside of a cylinder.
  18113. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18114. */
  18115. export class CylinderParticleEmitter implements IParticleEmitterType {
  18116. /**
  18117. * The radius of the emission cylinder.
  18118. */
  18119. radius: number;
  18120. /**
  18121. * The height of the emission cylinder.
  18122. */
  18123. height: number;
  18124. /**
  18125. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18126. */
  18127. radiusRange: number;
  18128. /**
  18129. * How much to randomize the particle direction [0-1].
  18130. */
  18131. directionRandomizer: number;
  18132. /**
  18133. * Creates a new instance CylinderParticleEmitter
  18134. * @param radius the radius of the emission cylinder (1 by default)
  18135. * @param height the height of the emission cylinder (1 by default)
  18136. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18138. */
  18139. constructor(
  18140. /**
  18141. * The radius of the emission cylinder.
  18142. */
  18143. radius?: number,
  18144. /**
  18145. * The height of the emission cylinder.
  18146. */
  18147. height?: number,
  18148. /**
  18149. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18150. */
  18151. radiusRange?: number,
  18152. /**
  18153. * How much to randomize the particle direction [0-1].
  18154. */
  18155. directionRandomizer?: number);
  18156. /**
  18157. * Called by the particle System when the direction is computed for the created particle.
  18158. * @param worldMatrix is the world matrix of the particle system
  18159. * @param directionToUpdate is the direction vector to update with the result
  18160. * @param particle is the particle we are computed the direction for
  18161. */
  18162. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18163. /**
  18164. * Called by the particle System when the position is computed for the created particle.
  18165. * @param worldMatrix is the world matrix of the particle system
  18166. * @param positionToUpdate is the position vector to update with the result
  18167. * @param particle is the particle we are computed the position for
  18168. */
  18169. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18170. /**
  18171. * Clones the current emitter and returns a copy of it
  18172. * @returns the new emitter
  18173. */
  18174. clone(): CylinderParticleEmitter;
  18175. /**
  18176. * Called by the GPUParticleSystem to setup the update shader
  18177. * @param effect defines the update shader
  18178. */
  18179. applyToShader(effect: Effect): void;
  18180. /**
  18181. * Returns a string to use to update the GPU particles update shader
  18182. * @returns a string containng the defines string
  18183. */
  18184. getEffectDefines(): string;
  18185. /**
  18186. * Returns the string "CylinderParticleEmitter"
  18187. * @returns a string containing the class name
  18188. */
  18189. getClassName(): string;
  18190. /**
  18191. * Serializes the particle system to a JSON object.
  18192. * @returns the JSON object
  18193. */
  18194. serialize(): any;
  18195. /**
  18196. * Parse properties from a JSON object
  18197. * @param serializationObject defines the JSON object
  18198. */
  18199. parse(serializationObject: any): void;
  18200. }
  18201. /**
  18202. * Particle emitter emitting particles from the inside of a cylinder.
  18203. * It emits the particles randomly between two vectors.
  18204. */
  18205. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18206. /**
  18207. * The min limit of the emission direction.
  18208. */
  18209. direction1: Vector3;
  18210. /**
  18211. * The max limit of the emission direction.
  18212. */
  18213. direction2: Vector3;
  18214. /**
  18215. * Creates a new instance CylinderDirectedParticleEmitter
  18216. * @param radius the radius of the emission cylinder (1 by default)
  18217. * @param height the height of the emission cylinder (1 by default)
  18218. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18219. * @param direction1 the min limit of the emission direction (up vector by default)
  18220. * @param direction2 the max limit of the emission direction (up vector by default)
  18221. */
  18222. constructor(radius?: number, height?: number, radiusRange?: number,
  18223. /**
  18224. * The min limit of the emission direction.
  18225. */
  18226. direction1?: Vector3,
  18227. /**
  18228. * The max limit of the emission direction.
  18229. */
  18230. direction2?: Vector3);
  18231. /**
  18232. * Called by the particle System when the direction is computed for the created particle.
  18233. * @param worldMatrix is the world matrix of the particle system
  18234. * @param directionToUpdate is the direction vector to update with the result
  18235. * @param particle is the particle we are computed the direction for
  18236. */
  18237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18238. /**
  18239. * Clones the current emitter and returns a copy of it
  18240. * @returns the new emitter
  18241. */
  18242. clone(): CylinderDirectedParticleEmitter;
  18243. /**
  18244. * Called by the GPUParticleSystem to setup the update shader
  18245. * @param effect defines the update shader
  18246. */
  18247. applyToShader(effect: Effect): void;
  18248. /**
  18249. * Returns a string to use to update the GPU particles update shader
  18250. * @returns a string containng the defines string
  18251. */
  18252. getEffectDefines(): string;
  18253. /**
  18254. * Returns the string "CylinderDirectedParticleEmitter"
  18255. * @returns a string containing the class name
  18256. */
  18257. getClassName(): string;
  18258. /**
  18259. * Serializes the particle system to a JSON object.
  18260. * @returns the JSON object
  18261. */
  18262. serialize(): any;
  18263. /**
  18264. * Parse properties from a JSON object
  18265. * @param serializationObject defines the JSON object
  18266. */
  18267. parse(serializationObject: any): void;
  18268. }
  18269. }
  18270. declare module BABYLON {
  18271. /**
  18272. * Particle emitter emitting particles from the inside of a hemisphere.
  18273. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18274. */
  18275. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18276. /**
  18277. * The radius of the emission hemisphere.
  18278. */
  18279. radius: number;
  18280. /**
  18281. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18282. */
  18283. radiusRange: number;
  18284. /**
  18285. * How much to randomize the particle direction [0-1].
  18286. */
  18287. directionRandomizer: number;
  18288. /**
  18289. * Creates a new instance HemisphericParticleEmitter
  18290. * @param radius the radius of the emission hemisphere (1 by default)
  18291. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18292. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18293. */
  18294. constructor(
  18295. /**
  18296. * The radius of the emission hemisphere.
  18297. */
  18298. radius?: number,
  18299. /**
  18300. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18301. */
  18302. radiusRange?: number,
  18303. /**
  18304. * How much to randomize the particle direction [0-1].
  18305. */
  18306. directionRandomizer?: number);
  18307. /**
  18308. * Called by the particle System when the direction is computed for the created particle.
  18309. * @param worldMatrix is the world matrix of the particle system
  18310. * @param directionToUpdate is the direction vector to update with the result
  18311. * @param particle is the particle we are computed the direction for
  18312. */
  18313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18314. /**
  18315. * Called by the particle System when the position is computed for the created particle.
  18316. * @param worldMatrix is the world matrix of the particle system
  18317. * @param positionToUpdate is the position vector to update with the result
  18318. * @param particle is the particle we are computed the position for
  18319. */
  18320. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18321. /**
  18322. * Clones the current emitter and returns a copy of it
  18323. * @returns the new emitter
  18324. */
  18325. clone(): HemisphericParticleEmitter;
  18326. /**
  18327. * Called by the GPUParticleSystem to setup the update shader
  18328. * @param effect defines the update shader
  18329. */
  18330. applyToShader(effect: Effect): void;
  18331. /**
  18332. * Returns a string to use to update the GPU particles update shader
  18333. * @returns a string containng the defines string
  18334. */
  18335. getEffectDefines(): string;
  18336. /**
  18337. * Returns the string "HemisphericParticleEmitter"
  18338. * @returns a string containing the class name
  18339. */
  18340. getClassName(): string;
  18341. /**
  18342. * Serializes the particle system to a JSON object.
  18343. * @returns the JSON object
  18344. */
  18345. serialize(): any;
  18346. /**
  18347. * Parse properties from a JSON object
  18348. * @param serializationObject defines the JSON object
  18349. */
  18350. parse(serializationObject: any): void;
  18351. }
  18352. }
  18353. declare module BABYLON {
  18354. /**
  18355. * Particle emitter emitting particles from a point.
  18356. * It emits the particles randomly between 2 given directions.
  18357. */
  18358. export class PointParticleEmitter implements IParticleEmitterType {
  18359. /**
  18360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18361. */
  18362. direction1: Vector3;
  18363. /**
  18364. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18365. */
  18366. direction2: Vector3;
  18367. /**
  18368. * Creates a new instance PointParticleEmitter
  18369. */
  18370. constructor();
  18371. /**
  18372. * Called by the particle System when the direction is computed for the created particle.
  18373. * @param worldMatrix is the world matrix of the particle system
  18374. * @param directionToUpdate is the direction vector to update with the result
  18375. * @param particle is the particle we are computed the direction for
  18376. */
  18377. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18378. /**
  18379. * Called by the particle System when the position is computed for the created particle.
  18380. * @param worldMatrix is the world matrix of the particle system
  18381. * @param positionToUpdate is the position vector to update with the result
  18382. * @param particle is the particle we are computed the position for
  18383. */
  18384. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18385. /**
  18386. * Clones the current emitter and returns a copy of it
  18387. * @returns the new emitter
  18388. */
  18389. clone(): PointParticleEmitter;
  18390. /**
  18391. * Called by the GPUParticleSystem to setup the update shader
  18392. * @param effect defines the update shader
  18393. */
  18394. applyToShader(effect: Effect): void;
  18395. /**
  18396. * Returns a string to use to update the GPU particles update shader
  18397. * @returns a string containng the defines string
  18398. */
  18399. getEffectDefines(): string;
  18400. /**
  18401. * Returns the string "PointParticleEmitter"
  18402. * @returns a string containing the class name
  18403. */
  18404. getClassName(): string;
  18405. /**
  18406. * Serializes the particle system to a JSON object.
  18407. * @returns the JSON object
  18408. */
  18409. serialize(): any;
  18410. /**
  18411. * Parse properties from a JSON object
  18412. * @param serializationObject defines the JSON object
  18413. */
  18414. parse(serializationObject: any): void;
  18415. }
  18416. }
  18417. declare module BABYLON {
  18418. /**
  18419. * Particle emitter emitting particles from the inside of a sphere.
  18420. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18421. */
  18422. export class SphereParticleEmitter implements IParticleEmitterType {
  18423. /**
  18424. * The radius of the emission sphere.
  18425. */
  18426. radius: number;
  18427. /**
  18428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18429. */
  18430. radiusRange: number;
  18431. /**
  18432. * How much to randomize the particle direction [0-1].
  18433. */
  18434. directionRandomizer: number;
  18435. /**
  18436. * Creates a new instance SphereParticleEmitter
  18437. * @param radius the radius of the emission sphere (1 by default)
  18438. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18439. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18440. */
  18441. constructor(
  18442. /**
  18443. * The radius of the emission sphere.
  18444. */
  18445. radius?: number,
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange?: number,
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer?: number);
  18454. /**
  18455. * Called by the particle System when the direction is computed for the created particle.
  18456. * @param worldMatrix is the world matrix of the particle system
  18457. * @param directionToUpdate is the direction vector to update with the result
  18458. * @param particle is the particle we are computed the direction for
  18459. */
  18460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18461. /**
  18462. * Called by the particle System when the position is computed for the created particle.
  18463. * @param worldMatrix is the world matrix of the particle system
  18464. * @param positionToUpdate is the position vector to update with the result
  18465. * @param particle is the particle we are computed the position for
  18466. */
  18467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18468. /**
  18469. * Clones the current emitter and returns a copy of it
  18470. * @returns the new emitter
  18471. */
  18472. clone(): SphereParticleEmitter;
  18473. /**
  18474. * Called by the GPUParticleSystem to setup the update shader
  18475. * @param effect defines the update shader
  18476. */
  18477. applyToShader(effect: Effect): void;
  18478. /**
  18479. * Returns a string to use to update the GPU particles update shader
  18480. * @returns a string containng the defines string
  18481. */
  18482. getEffectDefines(): string;
  18483. /**
  18484. * Returns the string "SphereParticleEmitter"
  18485. * @returns a string containing the class name
  18486. */
  18487. getClassName(): string;
  18488. /**
  18489. * Serializes the particle system to a JSON object.
  18490. * @returns the JSON object
  18491. */
  18492. serialize(): any;
  18493. /**
  18494. * Parse properties from a JSON object
  18495. * @param serializationObject defines the JSON object
  18496. */
  18497. parse(serializationObject: any): void;
  18498. }
  18499. /**
  18500. * Particle emitter emitting particles from the inside of a sphere.
  18501. * It emits the particles randomly between two vectors.
  18502. */
  18503. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18504. /**
  18505. * The min limit of the emission direction.
  18506. */
  18507. direction1: Vector3;
  18508. /**
  18509. * The max limit of the emission direction.
  18510. */
  18511. direction2: Vector3;
  18512. /**
  18513. * Creates a new instance SphereDirectedParticleEmitter
  18514. * @param radius the radius of the emission sphere (1 by default)
  18515. * @param direction1 the min limit of the emission direction (up vector by default)
  18516. * @param direction2 the max limit of the emission direction (up vector by default)
  18517. */
  18518. constructor(radius?: number,
  18519. /**
  18520. * The min limit of the emission direction.
  18521. */
  18522. direction1?: Vector3,
  18523. /**
  18524. * The max limit of the emission direction.
  18525. */
  18526. direction2?: Vector3);
  18527. /**
  18528. * Called by the particle System when the direction is computed for the created particle.
  18529. * @param worldMatrix is the world matrix of the particle system
  18530. * @param directionToUpdate is the direction vector to update with the result
  18531. * @param particle is the particle we are computed the direction for
  18532. */
  18533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18534. /**
  18535. * Clones the current emitter and returns a copy of it
  18536. * @returns the new emitter
  18537. */
  18538. clone(): SphereDirectedParticleEmitter;
  18539. /**
  18540. * Called by the GPUParticleSystem to setup the update shader
  18541. * @param effect defines the update shader
  18542. */
  18543. applyToShader(effect: Effect): void;
  18544. /**
  18545. * Returns a string to use to update the GPU particles update shader
  18546. * @returns a string containng the defines string
  18547. */
  18548. getEffectDefines(): string;
  18549. /**
  18550. * Returns the string "SphereDirectedParticleEmitter"
  18551. * @returns a string containing the class name
  18552. */
  18553. getClassName(): string;
  18554. /**
  18555. * Serializes the particle system to a JSON object.
  18556. * @returns the JSON object
  18557. */
  18558. serialize(): any;
  18559. /**
  18560. * Parse properties from a JSON object
  18561. * @param serializationObject defines the JSON object
  18562. */
  18563. parse(serializationObject: any): void;
  18564. }
  18565. }
  18566. declare module BABYLON {
  18567. /**
  18568. * Interface representing a particle system in Babylon.js.
  18569. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18570. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18571. */
  18572. export interface IParticleSystem {
  18573. /**
  18574. * List of animations used by the particle system.
  18575. */
  18576. animations: Animation[];
  18577. /**
  18578. * The id of the Particle system.
  18579. */
  18580. id: string;
  18581. /**
  18582. * The name of the Particle system.
  18583. */
  18584. name: string;
  18585. /**
  18586. * The emitter represents the Mesh or position we are attaching the particle system to.
  18587. */
  18588. emitter: Nullable<AbstractMesh | Vector3>;
  18589. /**
  18590. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18591. */
  18592. isBillboardBased: boolean;
  18593. /**
  18594. * The rendering group used by the Particle system to chose when to render.
  18595. */
  18596. renderingGroupId: number;
  18597. /**
  18598. * The layer mask we are rendering the particles through.
  18599. */
  18600. layerMask: number;
  18601. /**
  18602. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18603. */
  18604. updateSpeed: number;
  18605. /**
  18606. * The amount of time the particle system is running (depends of the overall update speed).
  18607. */
  18608. targetStopDuration: number;
  18609. /**
  18610. * The texture used to render each particle. (this can be a spritesheet)
  18611. */
  18612. particleTexture: Nullable<Texture>;
  18613. /**
  18614. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18615. */
  18616. blendMode: number;
  18617. /**
  18618. * Minimum life time of emitting particles.
  18619. */
  18620. minLifeTime: number;
  18621. /**
  18622. * Maximum life time of emitting particles.
  18623. */
  18624. maxLifeTime: number;
  18625. /**
  18626. * Minimum Size of emitting particles.
  18627. */
  18628. minSize: number;
  18629. /**
  18630. * Maximum Size of emitting particles.
  18631. */
  18632. maxSize: number;
  18633. /**
  18634. * Minimum scale of emitting particles on X axis.
  18635. */
  18636. minScaleX: number;
  18637. /**
  18638. * Maximum scale of emitting particles on X axis.
  18639. */
  18640. maxScaleX: number;
  18641. /**
  18642. * Minimum scale of emitting particles on Y axis.
  18643. */
  18644. minScaleY: number;
  18645. /**
  18646. * Maximum scale of emitting particles on Y axis.
  18647. */
  18648. maxScaleY: number;
  18649. /**
  18650. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18651. */
  18652. color1: Color4;
  18653. /**
  18654. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18655. */
  18656. color2: Color4;
  18657. /**
  18658. * Color the particle will have at the end of its lifetime.
  18659. */
  18660. colorDead: Color4;
  18661. /**
  18662. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18663. */
  18664. emitRate: number;
  18665. /**
  18666. * You can use gravity if you want to give an orientation to your particles.
  18667. */
  18668. gravity: Vector3;
  18669. /**
  18670. * Minimum power of emitting particles.
  18671. */
  18672. minEmitPower: number;
  18673. /**
  18674. * Maximum power of emitting particles.
  18675. */
  18676. maxEmitPower: number;
  18677. /**
  18678. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18679. */
  18680. minAngularSpeed: number;
  18681. /**
  18682. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18683. */
  18684. maxAngularSpeed: number;
  18685. /**
  18686. * Gets or sets the minimal initial rotation in radians.
  18687. */
  18688. minInitialRotation: number;
  18689. /**
  18690. * Gets or sets the maximal initial rotation in radians.
  18691. */
  18692. maxInitialRotation: number;
  18693. /**
  18694. * The particle emitter type defines the emitter used by the particle system.
  18695. * It can be for example box, sphere, or cone...
  18696. */
  18697. particleEmitterType: Nullable<IParticleEmitterType>;
  18698. /**
  18699. * Defines the delay in milliseconds before starting the system (0 by default)
  18700. */
  18701. startDelay: number;
  18702. /**
  18703. * 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
  18704. */
  18705. preWarmCycles: number;
  18706. /**
  18707. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18708. */
  18709. preWarmStepOffset: number;
  18710. /**
  18711. * 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)
  18712. */
  18713. spriteCellChangeSpeed: number;
  18714. /**
  18715. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18716. */
  18717. startSpriteCellID: number;
  18718. /**
  18719. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18720. */
  18721. endSpriteCellID: number;
  18722. /**
  18723. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18724. */
  18725. spriteCellWidth: number;
  18726. /**
  18727. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18728. */
  18729. spriteCellHeight: number;
  18730. /**
  18731. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18732. */
  18733. spriteRandomStartCell: boolean;
  18734. /**
  18735. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18736. */
  18737. isAnimationSheetEnabled: boolean;
  18738. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18739. translationPivot: Vector2;
  18740. /**
  18741. * Gets or sets a texture used to add random noise to particle positions
  18742. */
  18743. noiseTexture: Nullable<BaseTexture>;
  18744. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18745. noiseStrength: Vector3;
  18746. /**
  18747. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18748. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18749. */
  18750. billboardMode: number;
  18751. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18752. limitVelocityDamping: number;
  18753. /**
  18754. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18755. */
  18756. beginAnimationOnStart: boolean;
  18757. /**
  18758. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18759. */
  18760. beginAnimationFrom: number;
  18761. /**
  18762. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18763. */
  18764. beginAnimationTo: number;
  18765. /**
  18766. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18767. */
  18768. beginAnimationLoop: boolean;
  18769. /**
  18770. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18771. */
  18772. disposeOnStop: boolean;
  18773. /**
  18774. * Gets the maximum number of particles active at the same time.
  18775. * @returns The max number of active particles.
  18776. */
  18777. getCapacity(): number;
  18778. /**
  18779. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18780. * @returns True if it has been started, otherwise false.
  18781. */
  18782. isStarted(): boolean;
  18783. /**
  18784. * Animates the particle system for this frame.
  18785. */
  18786. animate(): void;
  18787. /**
  18788. * Renders the particle system in its current state.
  18789. * @returns the current number of particles
  18790. */
  18791. render(): number;
  18792. /**
  18793. * Dispose the particle system and frees its associated resources.
  18794. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18795. */
  18796. dispose(disposeTexture?: boolean): void;
  18797. /**
  18798. * Clones the particle system.
  18799. * @param name The name of the cloned object
  18800. * @param newEmitter The new emitter to use
  18801. * @returns the cloned particle system
  18802. */
  18803. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18804. /**
  18805. * Serializes the particle system to a JSON object.
  18806. * @returns the JSON object
  18807. */
  18808. serialize(): any;
  18809. /**
  18810. * Rebuild the particle system
  18811. */
  18812. rebuild(): void;
  18813. /**
  18814. * Starts the particle system and begins to emit
  18815. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18816. */
  18817. start(delay?: number): void;
  18818. /**
  18819. * Stops the particle system.
  18820. */
  18821. stop(): void;
  18822. /**
  18823. * Remove all active particles
  18824. */
  18825. reset(): void;
  18826. /**
  18827. * Is this system ready to be used/rendered
  18828. * @return true if the system is ready
  18829. */
  18830. isReady(): boolean;
  18831. /**
  18832. * Adds a new color gradient
  18833. * @param gradient defines the gradient to use (between 0 and 1)
  18834. * @param color1 defines the color to affect to the specified gradient
  18835. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18836. * @returns the current particle system
  18837. */
  18838. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18839. /**
  18840. * Remove a specific color gradient
  18841. * @param gradient defines the gradient to remove
  18842. * @returns the current particle system
  18843. */
  18844. removeColorGradient(gradient: number): IParticleSystem;
  18845. /**
  18846. * Adds a new size gradient
  18847. * @param gradient defines the gradient to use (between 0 and 1)
  18848. * @param factor defines the size factor to affect to the specified gradient
  18849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18850. * @returns the current particle system
  18851. */
  18852. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18853. /**
  18854. * Remove a specific size gradient
  18855. * @param gradient defines the gradient to remove
  18856. * @returns the current particle system
  18857. */
  18858. removeSizeGradient(gradient: number): IParticleSystem;
  18859. /**
  18860. * Gets the current list of color gradients.
  18861. * You must use addColorGradient and removeColorGradient to udpate this list
  18862. * @returns the list of color gradients
  18863. */
  18864. getColorGradients(): Nullable<Array<ColorGradient>>;
  18865. /**
  18866. * Gets the current list of size gradients.
  18867. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18868. * @returns the list of size gradients
  18869. */
  18870. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18871. /**
  18872. * Gets the current list of angular speed gradients.
  18873. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18874. * @returns the list of angular speed gradients
  18875. */
  18876. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18877. /**
  18878. * Adds a new angular speed gradient
  18879. * @param gradient defines the gradient to use (between 0 and 1)
  18880. * @param factor defines the angular speed to affect to the specified gradient
  18881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18882. * @returns the current particle system
  18883. */
  18884. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18885. /**
  18886. * Remove a specific angular speed gradient
  18887. * @param gradient defines the gradient to remove
  18888. * @returns the current particle system
  18889. */
  18890. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18891. /**
  18892. * Gets the current list of velocity gradients.
  18893. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18894. * @returns the list of velocity gradients
  18895. */
  18896. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18897. /**
  18898. * Adds a new velocity gradient
  18899. * @param gradient defines the gradient to use (between 0 and 1)
  18900. * @param factor defines the velocity to affect to the specified gradient
  18901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18902. * @returns the current particle system
  18903. */
  18904. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18905. /**
  18906. * Remove a specific velocity gradient
  18907. * @param gradient defines the gradient to remove
  18908. * @returns the current particle system
  18909. */
  18910. removeVelocityGradient(gradient: number): IParticleSystem;
  18911. /**
  18912. * Gets the current list of limit velocity gradients.
  18913. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18914. * @returns the list of limit velocity gradients
  18915. */
  18916. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18917. /**
  18918. * Adds a new limit velocity gradient
  18919. * @param gradient defines the gradient to use (between 0 and 1)
  18920. * @param factor defines the limit velocity to affect to the specified gradient
  18921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18922. * @returns the current particle system
  18923. */
  18924. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18925. /**
  18926. * Remove a specific limit velocity gradient
  18927. * @param gradient defines the gradient to remove
  18928. * @returns the current particle system
  18929. */
  18930. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18931. /**
  18932. * Adds a new drag gradient
  18933. * @param gradient defines the gradient to use (between 0 and 1)
  18934. * @param factor defines the drag to affect to the specified gradient
  18935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18936. * @returns the current particle system
  18937. */
  18938. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18939. /**
  18940. * Remove a specific drag gradient
  18941. * @param gradient defines the gradient to remove
  18942. * @returns the current particle system
  18943. */
  18944. removeDragGradient(gradient: number): IParticleSystem;
  18945. /**
  18946. * Gets the current list of drag gradients.
  18947. * You must use addDragGradient and removeDragGradient to udpate this list
  18948. * @returns the list of drag gradients
  18949. */
  18950. getDragGradients(): Nullable<Array<FactorGradient>>;
  18951. /**
  18952. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18953. * @param gradient defines the gradient to use (between 0 and 1)
  18954. * @param factor defines the emit rate to affect to the specified gradient
  18955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18956. * @returns the current particle system
  18957. */
  18958. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18959. /**
  18960. * Remove a specific emit rate gradient
  18961. * @param gradient defines the gradient to remove
  18962. * @returns the current particle system
  18963. */
  18964. removeEmitRateGradient(gradient: number): IParticleSystem;
  18965. /**
  18966. * Gets the current list of emit rate gradients.
  18967. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18968. * @returns the list of emit rate gradients
  18969. */
  18970. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18971. /**
  18972. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18973. * @param gradient defines the gradient to use (between 0 and 1)
  18974. * @param factor defines the start size to affect to the specified gradient
  18975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18976. * @returns the current particle system
  18977. */
  18978. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18979. /**
  18980. * Remove a specific start size gradient
  18981. * @param gradient defines the gradient to remove
  18982. * @returns the current particle system
  18983. */
  18984. removeStartSizeGradient(gradient: number): IParticleSystem;
  18985. /**
  18986. * Gets the current list of start size gradients.
  18987. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18988. * @returns the list of start size gradients
  18989. */
  18990. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18991. /**
  18992. * Adds a new life time gradient
  18993. * @param gradient defines the gradient to use (between 0 and 1)
  18994. * @param factor defines the life time factor to affect to the specified gradient
  18995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18996. * @returns the current particle system
  18997. */
  18998. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18999. /**
  19000. * Remove a specific life time gradient
  19001. * @param gradient defines the gradient to remove
  19002. * @returns the current particle system
  19003. */
  19004. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19005. /**
  19006. * Gets the current list of life time gradients.
  19007. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19008. * @returns the list of life time gradients
  19009. */
  19010. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19011. /**
  19012. * Gets the current list of color gradients.
  19013. * You must use addColorGradient and removeColorGradient to udpate this list
  19014. * @returns the list of color gradients
  19015. */
  19016. getColorGradients(): Nullable<Array<ColorGradient>>;
  19017. /**
  19018. * Adds a new ramp gradient used to remap particle colors
  19019. * @param gradient defines the gradient to use (between 0 and 1)
  19020. * @param color defines the color to affect to the specified gradient
  19021. * @returns the current particle system
  19022. */
  19023. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19024. /**
  19025. * Gets the current list of ramp gradients.
  19026. * You must use addRampGradient and removeRampGradient to udpate this list
  19027. * @returns the list of ramp gradients
  19028. */
  19029. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19030. /** Gets or sets a boolean indicating that ramp gradients must be used
  19031. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19032. */
  19033. useRampGradients: boolean;
  19034. /**
  19035. * Adds a new color remap gradient
  19036. * @param gradient defines the gradient to use (between 0 and 1)
  19037. * @param min defines the color remap minimal range
  19038. * @param max defines the color remap maximal range
  19039. * @returns the current particle system
  19040. */
  19041. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19042. /**
  19043. * Gets the current list of color remap gradients.
  19044. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19045. * @returns the list of color remap gradients
  19046. */
  19047. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19048. /**
  19049. * Adds a new alpha remap gradient
  19050. * @param gradient defines the gradient to use (between 0 and 1)
  19051. * @param min defines the alpha remap minimal range
  19052. * @param max defines the alpha remap maximal range
  19053. * @returns the current particle system
  19054. */
  19055. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19056. /**
  19057. * Gets the current list of alpha remap gradients.
  19058. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19059. * @returns the list of alpha remap gradients
  19060. */
  19061. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19062. /**
  19063. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19064. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19065. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19066. * @returns the emitter
  19067. */
  19068. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19069. /**
  19070. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19071. * @param radius The radius of the hemisphere to emit from
  19072. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19073. * @returns the emitter
  19074. */
  19075. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19076. /**
  19077. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19078. * @param radius The radius of the sphere to emit from
  19079. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19080. * @returns the emitter
  19081. */
  19082. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19083. /**
  19084. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19085. * @param radius The radius of the sphere to emit from
  19086. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19087. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19088. * @returns the emitter
  19089. */
  19090. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19091. /**
  19092. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19093. * @param radius The radius of the emission cylinder
  19094. * @param height The height of the emission cylinder
  19095. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19096. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19097. * @returns the emitter
  19098. */
  19099. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19100. /**
  19101. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19102. * @param radius The radius of the cylinder to emit from
  19103. * @param height The height of the emission cylinder
  19104. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19105. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19106. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19107. * @returns the emitter
  19108. */
  19109. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19110. /**
  19111. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19112. * @param radius The radius of the cone to emit from
  19113. * @param angle The base angle of the cone
  19114. * @returns the emitter
  19115. */
  19116. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19117. /**
  19118. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19121. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19122. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19123. * @returns the emitter
  19124. */
  19125. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19126. /**
  19127. * Get hosting scene
  19128. * @returns the scene
  19129. */
  19130. getScene(): Scene;
  19131. }
  19132. }
  19133. declare module BABYLON {
  19134. /**
  19135. * Creates an instance based on a source mesh.
  19136. */
  19137. export class InstancedMesh extends AbstractMesh {
  19138. private _sourceMesh;
  19139. private _currentLOD;
  19140. /** @hidden */
  19141. _indexInSourceMeshInstanceArray: number;
  19142. constructor(name: string, source: Mesh);
  19143. /**
  19144. * Returns the string "InstancedMesh".
  19145. */
  19146. getClassName(): string;
  19147. /** Gets the list of lights affecting that mesh */
  19148. get lightSources(): Light[];
  19149. _resyncLightSources(): void;
  19150. _resyncLightSource(light: Light): void;
  19151. _removeLightSource(light: Light, dispose: boolean): void;
  19152. /**
  19153. * If the source mesh receives shadows
  19154. */
  19155. get receiveShadows(): boolean;
  19156. /**
  19157. * The material of the source mesh
  19158. */
  19159. get material(): Nullable<Material>;
  19160. /**
  19161. * Visibility of the source mesh
  19162. */
  19163. get visibility(): number;
  19164. /**
  19165. * Skeleton of the source mesh
  19166. */
  19167. get skeleton(): Nullable<Skeleton>;
  19168. /**
  19169. * Rendering ground id of the source mesh
  19170. */
  19171. get renderingGroupId(): number;
  19172. set renderingGroupId(value: number);
  19173. /**
  19174. * Returns the total number of vertices (integer).
  19175. */
  19176. getTotalVertices(): number;
  19177. /**
  19178. * Returns a positive integer : the total number of indices in this mesh geometry.
  19179. * @returns the numner of indices or zero if the mesh has no geometry.
  19180. */
  19181. getTotalIndices(): number;
  19182. /**
  19183. * The source mesh of the instance
  19184. */
  19185. get sourceMesh(): Mesh;
  19186. /**
  19187. * Is this node ready to be used/rendered
  19188. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19189. * @return {boolean} is it ready
  19190. */
  19191. isReady(completeCheck?: boolean): boolean;
  19192. /**
  19193. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19194. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19195. * @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.
  19196. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19197. */
  19198. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19199. /**
  19200. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19201. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19202. * The `data` are either a numeric array either a Float32Array.
  19203. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19204. * 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).
  19205. * Note that a new underlying VertexBuffer object is created each call.
  19206. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19207. *
  19208. * Possible `kind` values :
  19209. * - VertexBuffer.PositionKind
  19210. * - VertexBuffer.UVKind
  19211. * - VertexBuffer.UV2Kind
  19212. * - VertexBuffer.UV3Kind
  19213. * - VertexBuffer.UV4Kind
  19214. * - VertexBuffer.UV5Kind
  19215. * - VertexBuffer.UV6Kind
  19216. * - VertexBuffer.ColorKind
  19217. * - VertexBuffer.MatricesIndicesKind
  19218. * - VertexBuffer.MatricesIndicesExtraKind
  19219. * - VertexBuffer.MatricesWeightsKind
  19220. * - VertexBuffer.MatricesWeightsExtraKind
  19221. *
  19222. * Returns the Mesh.
  19223. */
  19224. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19225. /**
  19226. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19227. * If the mesh has no geometry, it is simply returned as it is.
  19228. * The `data` are either a numeric array either a Float32Array.
  19229. * No new underlying VertexBuffer object is created.
  19230. * 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.
  19231. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19232. *
  19233. * Possible `kind` values :
  19234. * - VertexBuffer.PositionKind
  19235. * - VertexBuffer.UVKind
  19236. * - VertexBuffer.UV2Kind
  19237. * - VertexBuffer.UV3Kind
  19238. * - VertexBuffer.UV4Kind
  19239. * - VertexBuffer.UV5Kind
  19240. * - VertexBuffer.UV6Kind
  19241. * - VertexBuffer.ColorKind
  19242. * - VertexBuffer.MatricesIndicesKind
  19243. * - VertexBuffer.MatricesIndicesExtraKind
  19244. * - VertexBuffer.MatricesWeightsKind
  19245. * - VertexBuffer.MatricesWeightsExtraKind
  19246. *
  19247. * Returns the Mesh.
  19248. */
  19249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19250. /**
  19251. * Sets the mesh indices.
  19252. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19253. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19254. * This method creates a new index buffer each call.
  19255. * Returns the Mesh.
  19256. */
  19257. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19258. /**
  19259. * Boolean : True if the mesh owns the requested kind of data.
  19260. */
  19261. isVerticesDataPresent(kind: string): boolean;
  19262. /**
  19263. * Returns an array of indices (IndicesArray).
  19264. */
  19265. getIndices(): Nullable<IndicesArray>;
  19266. get _positions(): Nullable<Vector3[]>;
  19267. /**
  19268. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19269. * This means the mesh underlying bounding box and sphere are recomputed.
  19270. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19271. * @returns the current mesh
  19272. */
  19273. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19274. /** @hidden */
  19275. _preActivate(): InstancedMesh;
  19276. /** @hidden */
  19277. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19278. /** @hidden */
  19279. _postActivate(): void;
  19280. getWorldMatrix(): Matrix;
  19281. get isAnInstance(): boolean;
  19282. /**
  19283. * Returns the current associated LOD AbstractMesh.
  19284. */
  19285. getLOD(camera: Camera): AbstractMesh;
  19286. /** @hidden */
  19287. _syncSubMeshes(): InstancedMesh;
  19288. /** @hidden */
  19289. _generatePointsArray(): boolean;
  19290. /**
  19291. * Creates a new InstancedMesh from the current mesh.
  19292. * - name (string) : the cloned mesh name
  19293. * - newParent (optional Node) : the optional Node to parent the clone to.
  19294. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19295. *
  19296. * Returns the clone.
  19297. */
  19298. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19299. /**
  19300. * Disposes the InstancedMesh.
  19301. * Returns nothing.
  19302. */
  19303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19304. }
  19305. interface Mesh {
  19306. /**
  19307. * Register a custom buffer that will be instanced
  19308. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19309. * @param kind defines the buffer kind
  19310. * @param stride defines the stride in floats
  19311. */
  19312. registerInstancedBuffer(kind: string, stride: number): void;
  19313. /** @hidden */
  19314. _userInstancedBuffersStorage: {
  19315. data: {
  19316. [key: string]: Float32Array;
  19317. };
  19318. sizes: {
  19319. [key: string]: number;
  19320. };
  19321. vertexBuffers: {
  19322. [key: string]: Nullable<VertexBuffer>;
  19323. };
  19324. strides: {
  19325. [key: string]: number;
  19326. };
  19327. };
  19328. }
  19329. interface AbstractMesh {
  19330. /**
  19331. * Object used to store instanced buffers defined by user
  19332. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19333. */
  19334. instancedBuffers: {
  19335. [key: string]: any;
  19336. };
  19337. }
  19338. }
  19339. declare module BABYLON {
  19340. /**
  19341. * Defines the options associated with the creation of a shader material.
  19342. */
  19343. export interface IShaderMaterialOptions {
  19344. /**
  19345. * Does the material work in alpha blend mode
  19346. */
  19347. needAlphaBlending: boolean;
  19348. /**
  19349. * Does the material work in alpha test mode
  19350. */
  19351. needAlphaTesting: boolean;
  19352. /**
  19353. * The list of attribute names used in the shader
  19354. */
  19355. attributes: string[];
  19356. /**
  19357. * The list of unifrom names used in the shader
  19358. */
  19359. uniforms: string[];
  19360. /**
  19361. * The list of UBO names used in the shader
  19362. */
  19363. uniformBuffers: string[];
  19364. /**
  19365. * The list of sampler names used in the shader
  19366. */
  19367. samplers: string[];
  19368. /**
  19369. * The list of defines used in the shader
  19370. */
  19371. defines: string[];
  19372. }
  19373. /**
  19374. * 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.
  19375. *
  19376. * This returned material effects how the mesh will look based on the code in the shaders.
  19377. *
  19378. * @see http://doc.babylonjs.com/how_to/shader_material
  19379. */
  19380. export class ShaderMaterial extends Material {
  19381. private _shaderPath;
  19382. private _options;
  19383. private _textures;
  19384. private _textureArrays;
  19385. private _floats;
  19386. private _ints;
  19387. private _floatsArrays;
  19388. private _colors3;
  19389. private _colors3Arrays;
  19390. private _colors4;
  19391. private _colors4Arrays;
  19392. private _vectors2;
  19393. private _vectors3;
  19394. private _vectors4;
  19395. private _matrices;
  19396. private _matrixArrays;
  19397. private _matrices3x3;
  19398. private _matrices2x2;
  19399. private _vectors2Arrays;
  19400. private _vectors3Arrays;
  19401. private _vectors4Arrays;
  19402. private _cachedWorldViewMatrix;
  19403. private _cachedWorldViewProjectionMatrix;
  19404. private _renderId;
  19405. private _multiview;
  19406. /**
  19407. * Instantiate a new shader material.
  19408. * 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.
  19409. * This returned material effects how the mesh will look based on the code in the shaders.
  19410. * @see http://doc.babylonjs.com/how_to/shader_material
  19411. * @param name Define the name of the material in the scene
  19412. * @param scene Define the scene the material belongs to
  19413. * @param shaderPath Defines the route to the shader code in one of three ways:
  19414. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19415. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19416. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19417. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19418. * @param options Define the options used to create the shader
  19419. */
  19420. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19421. /**
  19422. * Gets the shader path used to define the shader code
  19423. * It can be modified to trigger a new compilation
  19424. */
  19425. get shaderPath(): any;
  19426. /**
  19427. * Sets the shader path used to define the shader code
  19428. * It can be modified to trigger a new compilation
  19429. */
  19430. set shaderPath(shaderPath: any);
  19431. /**
  19432. * Gets the options used to compile the shader.
  19433. * They can be modified to trigger a new compilation
  19434. */
  19435. get options(): IShaderMaterialOptions;
  19436. /**
  19437. * Gets the current class name of the material e.g. "ShaderMaterial"
  19438. * Mainly use in serialization.
  19439. * @returns the class name
  19440. */
  19441. getClassName(): string;
  19442. /**
  19443. * Specifies if the material will require alpha blending
  19444. * @returns a boolean specifying if alpha blending is needed
  19445. */
  19446. needAlphaBlending(): boolean;
  19447. /**
  19448. * Specifies if this material should be rendered in alpha test mode
  19449. * @returns a boolean specifying if an alpha test is needed.
  19450. */
  19451. needAlphaTesting(): boolean;
  19452. private _checkUniform;
  19453. /**
  19454. * Set a texture in the shader.
  19455. * @param name Define the name of the uniform samplers as defined in the shader
  19456. * @param texture Define the texture to bind to this sampler
  19457. * @return the material itself allowing "fluent" like uniform updates
  19458. */
  19459. setTexture(name: string, texture: Texture): ShaderMaterial;
  19460. /**
  19461. * Set a texture array in the shader.
  19462. * @param name Define the name of the uniform sampler array as defined in the shader
  19463. * @param textures Define the list of textures to bind to this sampler
  19464. * @return the material itself allowing "fluent" like uniform updates
  19465. */
  19466. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19467. /**
  19468. * Set a float in the shader.
  19469. * @param name Define the name of the uniform as defined in the shader
  19470. * @param value Define the value to give to the uniform
  19471. * @return the material itself allowing "fluent" like uniform updates
  19472. */
  19473. setFloat(name: string, value: number): ShaderMaterial;
  19474. /**
  19475. * Set a int in the shader.
  19476. * @param name Define the name of the uniform as defined in the shader
  19477. * @param value Define the value to give to the uniform
  19478. * @return the material itself allowing "fluent" like uniform updates
  19479. */
  19480. setInt(name: string, value: number): ShaderMaterial;
  19481. /**
  19482. * Set an array of floats in the shader.
  19483. * @param name Define the name of the uniform as defined in the shader
  19484. * @param value Define the value to give to the uniform
  19485. * @return the material itself allowing "fluent" like uniform updates
  19486. */
  19487. setFloats(name: string, value: number[]): ShaderMaterial;
  19488. /**
  19489. * Set a vec3 in the shader from a Color3.
  19490. * @param name Define the name of the uniform as defined in the shader
  19491. * @param value Define the value to give to the uniform
  19492. * @return the material itself allowing "fluent" like uniform updates
  19493. */
  19494. setColor3(name: string, value: Color3): ShaderMaterial;
  19495. /**
  19496. * Set a vec3 array in the shader from a Color3 array.
  19497. * @param name Define the name of the uniform as defined in the shader
  19498. * @param value Define the value to give to the uniform
  19499. * @return the material itself allowing "fluent" like uniform updates
  19500. */
  19501. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19502. /**
  19503. * Set a vec4 in the shader from a Color4.
  19504. * @param name Define the name of the uniform as defined in the shader
  19505. * @param value Define the value to give to the uniform
  19506. * @return the material itself allowing "fluent" like uniform updates
  19507. */
  19508. setColor4(name: string, value: Color4): ShaderMaterial;
  19509. /**
  19510. * Set a vec4 array in the shader from a Color4 array.
  19511. * @param name Define the name of the uniform as defined in the shader
  19512. * @param value Define the value to give to the uniform
  19513. * @return the material itself allowing "fluent" like uniform updates
  19514. */
  19515. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19516. /**
  19517. * Set a vec2 in the shader from a Vector2.
  19518. * @param name Define the name of the uniform as defined in the shader
  19519. * @param value Define the value to give to the uniform
  19520. * @return the material itself allowing "fluent" like uniform updates
  19521. */
  19522. setVector2(name: string, value: Vector2): ShaderMaterial;
  19523. /**
  19524. * Set a vec3 in the shader from a Vector3.
  19525. * @param name Define the name of the uniform as defined in the shader
  19526. * @param value Define the value to give to the uniform
  19527. * @return the material itself allowing "fluent" like uniform updates
  19528. */
  19529. setVector3(name: string, value: Vector3): ShaderMaterial;
  19530. /**
  19531. * Set a vec4 in the shader from a Vector4.
  19532. * @param name Define the name of the uniform as defined in the shader
  19533. * @param value Define the value to give to the uniform
  19534. * @return the material itself allowing "fluent" like uniform updates
  19535. */
  19536. setVector4(name: string, value: Vector4): ShaderMaterial;
  19537. /**
  19538. * Set a mat4 in the shader from a Matrix.
  19539. * @param name Define the name of the uniform as defined in the shader
  19540. * @param value Define the value to give to the uniform
  19541. * @return the material itself allowing "fluent" like uniform updates
  19542. */
  19543. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19544. /**
  19545. * Set a float32Array in the shader from a matrix array.
  19546. * @param name Define the name of the uniform as defined in the shader
  19547. * @param value Define the value to give to the uniform
  19548. * @return the material itself allowing "fluent" like uniform updates
  19549. */
  19550. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19551. /**
  19552. * Set a mat3 in the shader from a Float32Array.
  19553. * @param name Define the name of the uniform as defined in the shader
  19554. * @param value Define the value to give to the uniform
  19555. * @return the material itself allowing "fluent" like uniform updates
  19556. */
  19557. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19558. /**
  19559. * Set a mat2 in the shader from a Float32Array.
  19560. * @param name Define the name of the uniform as defined in the shader
  19561. * @param value Define the value to give to the uniform
  19562. * @return the material itself allowing "fluent" like uniform updates
  19563. */
  19564. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19565. /**
  19566. * Set a vec2 array in the shader from a number array.
  19567. * @param name Define the name of the uniform as defined in the shader
  19568. * @param value Define the value to give to the uniform
  19569. * @return the material itself allowing "fluent" like uniform updates
  19570. */
  19571. setArray2(name: string, value: number[]): ShaderMaterial;
  19572. /**
  19573. * Set a vec3 array in the shader from a number array.
  19574. * @param name Define the name of the uniform as defined in the shader
  19575. * @param value Define the value to give to the uniform
  19576. * @return the material itself allowing "fluent" like uniform updates
  19577. */
  19578. setArray3(name: string, value: number[]): ShaderMaterial;
  19579. /**
  19580. * Set a vec4 array in the shader from a number array.
  19581. * @param name Define the name of the uniform as defined in the shader
  19582. * @param value Define the value to give to the uniform
  19583. * @return the material itself allowing "fluent" like uniform updates
  19584. */
  19585. setArray4(name: string, value: number[]): ShaderMaterial;
  19586. private _checkCache;
  19587. /**
  19588. * Specifies that the submesh is ready to be used
  19589. * @param mesh defines the mesh to check
  19590. * @param subMesh defines which submesh to check
  19591. * @param useInstances specifies that instances should be used
  19592. * @returns a boolean indicating that the submesh is ready or not
  19593. */
  19594. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19595. /**
  19596. * Checks if the material is ready to render the requested mesh
  19597. * @param mesh Define the mesh to render
  19598. * @param useInstances Define whether or not the material is used with instances
  19599. * @returns true if ready, otherwise false
  19600. */
  19601. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19602. /**
  19603. * Binds the world matrix to the material
  19604. * @param world defines the world transformation matrix
  19605. */
  19606. bindOnlyWorldMatrix(world: Matrix): void;
  19607. /**
  19608. * Binds the material to the mesh
  19609. * @param world defines the world transformation matrix
  19610. * @param mesh defines the mesh to bind the material to
  19611. */
  19612. bind(world: Matrix, mesh?: Mesh): void;
  19613. /**
  19614. * Gets the active textures from the material
  19615. * @returns an array of textures
  19616. */
  19617. getActiveTextures(): BaseTexture[];
  19618. /**
  19619. * Specifies if the material uses a texture
  19620. * @param texture defines the texture to check against the material
  19621. * @returns a boolean specifying if the material uses the texture
  19622. */
  19623. hasTexture(texture: BaseTexture): boolean;
  19624. /**
  19625. * Makes a duplicate of the material, and gives it a new name
  19626. * @param name defines the new name for the duplicated material
  19627. * @returns the cloned material
  19628. */
  19629. clone(name: string): ShaderMaterial;
  19630. /**
  19631. * Disposes the material
  19632. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19633. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19634. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19635. */
  19636. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19637. /**
  19638. * Serializes this material in a JSON representation
  19639. * @returns the serialized material object
  19640. */
  19641. serialize(): any;
  19642. /**
  19643. * Creates a shader material from parsed shader material data
  19644. * @param source defines the JSON represnetation of the material
  19645. * @param scene defines the hosting scene
  19646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19647. * @returns a new material
  19648. */
  19649. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19650. }
  19651. }
  19652. declare module BABYLON {
  19653. /** @hidden */
  19654. export var colorPixelShader: {
  19655. name: string;
  19656. shader: string;
  19657. };
  19658. }
  19659. declare module BABYLON {
  19660. /** @hidden */
  19661. export var colorVertexShader: {
  19662. name: string;
  19663. shader: string;
  19664. };
  19665. }
  19666. declare module BABYLON {
  19667. /**
  19668. * Line mesh
  19669. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19670. */
  19671. export class LinesMesh extends Mesh {
  19672. /**
  19673. * If vertex color should be applied to the mesh
  19674. */
  19675. readonly useVertexColor?: boolean | undefined;
  19676. /**
  19677. * If vertex alpha should be applied to the mesh
  19678. */
  19679. readonly useVertexAlpha?: boolean | undefined;
  19680. /**
  19681. * Color of the line (Default: White)
  19682. */
  19683. color: Color3;
  19684. /**
  19685. * Alpha of the line (Default: 1)
  19686. */
  19687. alpha: number;
  19688. /**
  19689. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19690. * This margin is expressed in world space coordinates, so its value may vary.
  19691. * Default value is 0.1
  19692. */
  19693. intersectionThreshold: number;
  19694. private _colorShader;
  19695. private color4;
  19696. /**
  19697. * Creates a new LinesMesh
  19698. * @param name defines the name
  19699. * @param scene defines the hosting scene
  19700. * @param parent defines the parent mesh if any
  19701. * @param source defines the optional source LinesMesh used to clone data from
  19702. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19703. * When false, achieved by calling a clone(), also passing False.
  19704. * This will make creation of children, recursive.
  19705. * @param useVertexColor defines if this LinesMesh supports vertex color
  19706. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19707. */
  19708. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19709. /**
  19710. * If vertex color should be applied to the mesh
  19711. */
  19712. useVertexColor?: boolean | undefined,
  19713. /**
  19714. * If vertex alpha should be applied to the mesh
  19715. */
  19716. useVertexAlpha?: boolean | undefined);
  19717. private _addClipPlaneDefine;
  19718. private _removeClipPlaneDefine;
  19719. isReady(): boolean;
  19720. /**
  19721. * Returns the string "LineMesh"
  19722. */
  19723. getClassName(): string;
  19724. /**
  19725. * @hidden
  19726. */
  19727. get material(): Material;
  19728. /**
  19729. * @hidden
  19730. */
  19731. set material(value: Material);
  19732. /**
  19733. * @hidden
  19734. */
  19735. get checkCollisions(): boolean;
  19736. /** @hidden */
  19737. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19738. /** @hidden */
  19739. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19740. /**
  19741. * Disposes of the line mesh
  19742. * @param doNotRecurse If children should be disposed
  19743. */
  19744. dispose(doNotRecurse?: boolean): void;
  19745. /**
  19746. * Returns a new LineMesh object cloned from the current one.
  19747. */
  19748. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19749. /**
  19750. * Creates a new InstancedLinesMesh object from the mesh model.
  19751. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19752. * @param name defines the name of the new instance
  19753. * @returns a new InstancedLinesMesh
  19754. */
  19755. createInstance(name: string): InstancedLinesMesh;
  19756. }
  19757. /**
  19758. * Creates an instance based on a source LinesMesh
  19759. */
  19760. export class InstancedLinesMesh extends InstancedMesh {
  19761. /**
  19762. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19763. * This margin is expressed in world space coordinates, so its value may vary.
  19764. * Initilized with the intersectionThreshold value of the source LinesMesh
  19765. */
  19766. intersectionThreshold: number;
  19767. constructor(name: string, source: LinesMesh);
  19768. /**
  19769. * Returns the string "InstancedLinesMesh".
  19770. */
  19771. getClassName(): string;
  19772. }
  19773. }
  19774. declare module BABYLON {
  19775. /** @hidden */
  19776. export var linePixelShader: {
  19777. name: string;
  19778. shader: string;
  19779. };
  19780. }
  19781. declare module BABYLON {
  19782. /** @hidden */
  19783. export var lineVertexShader: {
  19784. name: string;
  19785. shader: string;
  19786. };
  19787. }
  19788. declare module BABYLON {
  19789. interface AbstractMesh {
  19790. /**
  19791. * Gets the edgesRenderer associated with the mesh
  19792. */
  19793. edgesRenderer: Nullable<EdgesRenderer>;
  19794. }
  19795. interface LinesMesh {
  19796. /**
  19797. * Enables the edge rendering mode on the mesh.
  19798. * This mode makes the mesh edges visible
  19799. * @param epsilon defines the maximal distance between two angles to detect a face
  19800. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19801. * @returns the currentAbstractMesh
  19802. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19803. */
  19804. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19805. }
  19806. interface InstancedLinesMesh {
  19807. /**
  19808. * Enables the edge rendering mode on the mesh.
  19809. * This mode makes the mesh edges visible
  19810. * @param epsilon defines the maximal distance between two angles to detect a face
  19811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19812. * @returns the current InstancedLinesMesh
  19813. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19814. */
  19815. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19816. }
  19817. /**
  19818. * Defines the minimum contract an Edges renderer should follow.
  19819. */
  19820. export interface IEdgesRenderer extends IDisposable {
  19821. /**
  19822. * Gets or sets a boolean indicating if the edgesRenderer is active
  19823. */
  19824. isEnabled: boolean;
  19825. /**
  19826. * Renders the edges of the attached mesh,
  19827. */
  19828. render(): void;
  19829. /**
  19830. * Checks wether or not the edges renderer is ready to render.
  19831. * @return true if ready, otherwise false.
  19832. */
  19833. isReady(): boolean;
  19834. }
  19835. /**
  19836. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19837. */
  19838. export class EdgesRenderer implements IEdgesRenderer {
  19839. /**
  19840. * Define the size of the edges with an orthographic camera
  19841. */
  19842. edgesWidthScalerForOrthographic: number;
  19843. /**
  19844. * Define the size of the edges with a perspective camera
  19845. */
  19846. edgesWidthScalerForPerspective: number;
  19847. protected _source: AbstractMesh;
  19848. protected _linesPositions: number[];
  19849. protected _linesNormals: number[];
  19850. protected _linesIndices: number[];
  19851. protected _epsilon: number;
  19852. protected _indicesCount: number;
  19853. protected _lineShader: ShaderMaterial;
  19854. protected _ib: DataBuffer;
  19855. protected _buffers: {
  19856. [key: string]: Nullable<VertexBuffer>;
  19857. };
  19858. protected _checkVerticesInsteadOfIndices: boolean;
  19859. private _meshRebuildObserver;
  19860. private _meshDisposeObserver;
  19861. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19862. isEnabled: boolean;
  19863. /**
  19864. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19865. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19866. * @param source Mesh used to create edges
  19867. * @param epsilon sum of angles in adjacency to check for edge
  19868. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19869. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19870. */
  19871. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19872. protected _prepareRessources(): void;
  19873. /** @hidden */
  19874. _rebuild(): void;
  19875. /**
  19876. * Releases the required resources for the edges renderer
  19877. */
  19878. dispose(): void;
  19879. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19880. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19881. /**
  19882. * Checks if the pair of p0 and p1 is en edge
  19883. * @param faceIndex
  19884. * @param edge
  19885. * @param faceNormals
  19886. * @param p0
  19887. * @param p1
  19888. * @private
  19889. */
  19890. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19891. /**
  19892. * push line into the position, normal and index buffer
  19893. * @protected
  19894. */
  19895. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19896. /**
  19897. * Generates lines edges from adjacencjes
  19898. * @private
  19899. */
  19900. _generateEdgesLines(): void;
  19901. /**
  19902. * Checks wether or not the edges renderer is ready to render.
  19903. * @return true if ready, otherwise false.
  19904. */
  19905. isReady(): boolean;
  19906. /**
  19907. * Renders the edges of the attached mesh,
  19908. */
  19909. render(): void;
  19910. }
  19911. /**
  19912. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19913. */
  19914. export class LineEdgesRenderer extends EdgesRenderer {
  19915. /**
  19916. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19917. * @param source LineMesh used to generate edges
  19918. * @param epsilon not important (specified angle for edge detection)
  19919. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19920. */
  19921. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19922. /**
  19923. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19924. */
  19925. _generateEdgesLines(): void;
  19926. }
  19927. }
  19928. declare module BABYLON {
  19929. /**
  19930. * This represents the object necessary to create a rendering group.
  19931. * This is exclusively used and created by the rendering manager.
  19932. * To modify the behavior, you use the available helpers in your scene or meshes.
  19933. * @hidden
  19934. */
  19935. export class RenderingGroup {
  19936. index: number;
  19937. private static _zeroVector;
  19938. private _scene;
  19939. private _opaqueSubMeshes;
  19940. private _transparentSubMeshes;
  19941. private _alphaTestSubMeshes;
  19942. private _depthOnlySubMeshes;
  19943. private _particleSystems;
  19944. private _spriteManagers;
  19945. private _opaqueSortCompareFn;
  19946. private _alphaTestSortCompareFn;
  19947. private _transparentSortCompareFn;
  19948. private _renderOpaque;
  19949. private _renderAlphaTest;
  19950. private _renderTransparent;
  19951. /** @hidden */
  19952. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19953. onBeforeTransparentRendering: () => void;
  19954. /**
  19955. * Set the opaque sort comparison function.
  19956. * If null the sub meshes will be render in the order they were created
  19957. */
  19958. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19959. /**
  19960. * Set the alpha test sort comparison function.
  19961. * If null the sub meshes will be render in the order they were created
  19962. */
  19963. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19964. /**
  19965. * Set the transparent sort comparison function.
  19966. * If null the sub meshes will be render in the order they were created
  19967. */
  19968. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19969. /**
  19970. * Creates a new rendering group.
  19971. * @param index The rendering group index
  19972. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19973. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19974. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19975. */
  19976. 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>);
  19977. /**
  19978. * Render all the sub meshes contained in the group.
  19979. * @param customRenderFunction Used to override the default render behaviour of the group.
  19980. * @returns true if rendered some submeshes.
  19981. */
  19982. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19983. /**
  19984. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19985. * @param subMeshes The submeshes to render
  19986. */
  19987. private renderOpaqueSorted;
  19988. /**
  19989. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19990. * @param subMeshes The submeshes to render
  19991. */
  19992. private renderAlphaTestSorted;
  19993. /**
  19994. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19995. * @param subMeshes The submeshes to render
  19996. */
  19997. private renderTransparentSorted;
  19998. /**
  19999. * Renders the submeshes in a specified order.
  20000. * @param subMeshes The submeshes to sort before render
  20001. * @param sortCompareFn The comparison function use to sort
  20002. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20003. * @param transparent Specifies to activate blending if true
  20004. */
  20005. private static renderSorted;
  20006. /**
  20007. * Renders the submeshes in the order they were dispatched (no sort applied).
  20008. * @param subMeshes The submeshes to render
  20009. */
  20010. private static renderUnsorted;
  20011. /**
  20012. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20013. * are rendered back to front if in the same alpha index.
  20014. *
  20015. * @param a The first submesh
  20016. * @param b The second submesh
  20017. * @returns The result of the comparison
  20018. */
  20019. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20020. /**
  20021. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20022. * are rendered back to front.
  20023. *
  20024. * @param a The first submesh
  20025. * @param b The second submesh
  20026. * @returns The result of the comparison
  20027. */
  20028. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20029. /**
  20030. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20031. * are rendered front to back (prevent overdraw).
  20032. *
  20033. * @param a The first submesh
  20034. * @param b The second submesh
  20035. * @returns The result of the comparison
  20036. */
  20037. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20038. /**
  20039. * Resets the different lists of submeshes to prepare a new frame.
  20040. */
  20041. prepare(): void;
  20042. dispose(): void;
  20043. /**
  20044. * Inserts the submesh in its correct queue depending on its material.
  20045. * @param subMesh The submesh to dispatch
  20046. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20047. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20048. */
  20049. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20050. dispatchSprites(spriteManager: ISpriteManager): void;
  20051. dispatchParticles(particleSystem: IParticleSystem): void;
  20052. private _renderParticles;
  20053. private _renderSprites;
  20054. }
  20055. }
  20056. declare module BABYLON {
  20057. /**
  20058. * Interface describing the different options available in the rendering manager
  20059. * regarding Auto Clear between groups.
  20060. */
  20061. export interface IRenderingManagerAutoClearSetup {
  20062. /**
  20063. * Defines whether or not autoclear is enable.
  20064. */
  20065. autoClear: boolean;
  20066. /**
  20067. * Defines whether or not to autoclear the depth buffer.
  20068. */
  20069. depth: boolean;
  20070. /**
  20071. * Defines whether or not to autoclear the stencil buffer.
  20072. */
  20073. stencil: boolean;
  20074. }
  20075. /**
  20076. * This class is used by the onRenderingGroupObservable
  20077. */
  20078. export class RenderingGroupInfo {
  20079. /**
  20080. * The Scene that being rendered
  20081. */
  20082. scene: Scene;
  20083. /**
  20084. * The camera currently used for the rendering pass
  20085. */
  20086. camera: Nullable<Camera>;
  20087. /**
  20088. * The ID of the renderingGroup being processed
  20089. */
  20090. renderingGroupId: number;
  20091. }
  20092. /**
  20093. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20094. * It is enable to manage the different groups as well as the different necessary sort functions.
  20095. * This should not be used directly aside of the few static configurations
  20096. */
  20097. export class RenderingManager {
  20098. /**
  20099. * The max id used for rendering groups (not included)
  20100. */
  20101. static MAX_RENDERINGGROUPS: number;
  20102. /**
  20103. * The min id used for rendering groups (included)
  20104. */
  20105. static MIN_RENDERINGGROUPS: number;
  20106. /**
  20107. * Used to globally prevent autoclearing scenes.
  20108. */
  20109. static AUTOCLEAR: boolean;
  20110. /**
  20111. * @hidden
  20112. */
  20113. _useSceneAutoClearSetup: boolean;
  20114. private _scene;
  20115. private _renderingGroups;
  20116. private _depthStencilBufferAlreadyCleaned;
  20117. private _autoClearDepthStencil;
  20118. private _customOpaqueSortCompareFn;
  20119. private _customAlphaTestSortCompareFn;
  20120. private _customTransparentSortCompareFn;
  20121. private _renderingGroupInfo;
  20122. /**
  20123. * Instantiates a new rendering group for a particular scene
  20124. * @param scene Defines the scene the groups belongs to
  20125. */
  20126. constructor(scene: Scene);
  20127. private _clearDepthStencilBuffer;
  20128. /**
  20129. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20130. * @hidden
  20131. */
  20132. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20133. /**
  20134. * Resets the different information of the group to prepare a new frame
  20135. * @hidden
  20136. */
  20137. reset(): void;
  20138. /**
  20139. * Dispose and release the group and its associated resources.
  20140. * @hidden
  20141. */
  20142. dispose(): void;
  20143. /**
  20144. * Clear the info related to rendering groups preventing retention points during dispose.
  20145. */
  20146. freeRenderingGroups(): void;
  20147. private _prepareRenderingGroup;
  20148. /**
  20149. * Add a sprite manager to the rendering manager in order to render it this frame.
  20150. * @param spriteManager Define the sprite manager to render
  20151. */
  20152. dispatchSprites(spriteManager: ISpriteManager): void;
  20153. /**
  20154. * Add a particle system to the rendering manager in order to render it this frame.
  20155. * @param particleSystem Define the particle system to render
  20156. */
  20157. dispatchParticles(particleSystem: IParticleSystem): void;
  20158. /**
  20159. * Add a submesh to the manager in order to render it this frame
  20160. * @param subMesh The submesh to dispatch
  20161. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20162. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20163. */
  20164. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20165. /**
  20166. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20167. * This allowed control for front to back rendering or reversly depending of the special needs.
  20168. *
  20169. * @param renderingGroupId The rendering group id corresponding to its index
  20170. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20171. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20172. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20173. */
  20174. 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;
  20175. /**
  20176. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20177. *
  20178. * @param renderingGroupId The rendering group id corresponding to its index
  20179. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20180. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20181. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20182. */
  20183. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20184. /**
  20185. * Gets the current auto clear configuration for one rendering group of the rendering
  20186. * manager.
  20187. * @param index the rendering group index to get the information for
  20188. * @returns The auto clear setup for the requested rendering group
  20189. */
  20190. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20191. }
  20192. }
  20193. declare module BABYLON {
  20194. /**
  20195. * This Helps creating a texture that will be created from a camera in your scene.
  20196. * It is basically a dynamic texture that could be used to create special effects for instance.
  20197. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20198. */
  20199. export class RenderTargetTexture extends Texture {
  20200. isCube: boolean;
  20201. /**
  20202. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20203. */
  20204. static readonly REFRESHRATE_RENDER_ONCE: number;
  20205. /**
  20206. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20207. */
  20208. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20209. /**
  20210. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20211. * the central point of your effect and can save a lot of performances.
  20212. */
  20213. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20214. /**
  20215. * Use this predicate to dynamically define the list of mesh you want to render.
  20216. * If set, the renderList property will be overwritten.
  20217. */
  20218. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20219. private _renderList;
  20220. /**
  20221. * Use this list to define the list of mesh you want to render.
  20222. */
  20223. get renderList(): Nullable<Array<AbstractMesh>>;
  20224. set renderList(value: Nullable<Array<AbstractMesh>>);
  20225. private _hookArray;
  20226. /**
  20227. * Define if particles should be rendered in your texture.
  20228. */
  20229. renderParticles: boolean;
  20230. /**
  20231. * Define if sprites should be rendered in your texture.
  20232. */
  20233. renderSprites: boolean;
  20234. /**
  20235. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20236. */
  20237. coordinatesMode: number;
  20238. /**
  20239. * Define the camera used to render the texture.
  20240. */
  20241. activeCamera: Nullable<Camera>;
  20242. /**
  20243. * Override the render function of the texture with your own one.
  20244. */
  20245. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20246. /**
  20247. * Define if camera post processes should be use while rendering the texture.
  20248. */
  20249. useCameraPostProcesses: boolean;
  20250. /**
  20251. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20252. */
  20253. ignoreCameraViewport: boolean;
  20254. private _postProcessManager;
  20255. private _postProcesses;
  20256. private _resizeObserver;
  20257. /**
  20258. * An event triggered when the texture is unbind.
  20259. */
  20260. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20261. /**
  20262. * An event triggered when the texture is unbind.
  20263. */
  20264. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20265. private _onAfterUnbindObserver;
  20266. /**
  20267. * Set a after unbind callback in the texture.
  20268. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20269. */
  20270. set onAfterUnbind(callback: () => void);
  20271. /**
  20272. * An event triggered before rendering the texture
  20273. */
  20274. onBeforeRenderObservable: Observable<number>;
  20275. private _onBeforeRenderObserver;
  20276. /**
  20277. * Set a before render callback in the texture.
  20278. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20279. */
  20280. set onBeforeRender(callback: (faceIndex: number) => void);
  20281. /**
  20282. * An event triggered after rendering the texture
  20283. */
  20284. onAfterRenderObservable: Observable<number>;
  20285. private _onAfterRenderObserver;
  20286. /**
  20287. * Set a after render callback in the texture.
  20288. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20289. */
  20290. set onAfterRender(callback: (faceIndex: number) => void);
  20291. /**
  20292. * An event triggered after the texture clear
  20293. */
  20294. onClearObservable: Observable<Engine>;
  20295. private _onClearObserver;
  20296. /**
  20297. * Set a clear callback in the texture.
  20298. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20299. */
  20300. set onClear(callback: (Engine: Engine) => void);
  20301. /**
  20302. * An event triggered when the texture is resized.
  20303. */
  20304. onResizeObservable: Observable<RenderTargetTexture>;
  20305. /**
  20306. * Define the clear color of the Render Target if it should be different from the scene.
  20307. */
  20308. clearColor: Color4;
  20309. protected _size: number | {
  20310. width: number;
  20311. height: number;
  20312. };
  20313. protected _initialSizeParameter: number | {
  20314. width: number;
  20315. height: number;
  20316. } | {
  20317. ratio: number;
  20318. };
  20319. protected _sizeRatio: Nullable<number>;
  20320. /** @hidden */
  20321. _generateMipMaps: boolean;
  20322. protected _renderingManager: RenderingManager;
  20323. /** @hidden */
  20324. _waitingRenderList: string[];
  20325. protected _doNotChangeAspectRatio: boolean;
  20326. protected _currentRefreshId: number;
  20327. protected _refreshRate: number;
  20328. protected _textureMatrix: Matrix;
  20329. protected _samples: number;
  20330. protected _renderTargetOptions: RenderTargetCreationOptions;
  20331. /**
  20332. * Gets render target creation options that were used.
  20333. */
  20334. get renderTargetOptions(): RenderTargetCreationOptions;
  20335. protected _engine: Engine;
  20336. protected _onRatioRescale(): void;
  20337. /**
  20338. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20339. * It must define where the camera used to render the texture is set
  20340. */
  20341. boundingBoxPosition: Vector3;
  20342. private _boundingBoxSize;
  20343. /**
  20344. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20345. * When defined, the cubemap will switch to local mode
  20346. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20347. * @example https://www.babylonjs-playground.com/#RNASML
  20348. */
  20349. set boundingBoxSize(value: Vector3);
  20350. get boundingBoxSize(): Vector3;
  20351. /**
  20352. * In case the RTT has been created with a depth texture, get the associated
  20353. * depth texture.
  20354. * Otherwise, return null.
  20355. */
  20356. depthStencilTexture: Nullable<InternalTexture>;
  20357. /**
  20358. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20359. * or used a shadow, depth texture...
  20360. * @param name The friendly name of the texture
  20361. * @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)
  20362. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20363. * @param generateMipMaps True if mip maps need to be generated after render.
  20364. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20365. * @param type The type of the buffer in the RTT (int, half float, float...)
  20366. * @param isCube True if a cube texture needs to be created
  20367. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20368. * @param generateDepthBuffer True to generate a depth buffer
  20369. * @param generateStencilBuffer True to generate a stencil buffer
  20370. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20371. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20372. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20373. */
  20374. constructor(name: string, size: number | {
  20375. width: number;
  20376. height: number;
  20377. } | {
  20378. ratio: number;
  20379. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20380. /**
  20381. * Creates a depth stencil texture.
  20382. * This is only available in WebGL 2 or with the depth texture extension available.
  20383. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20384. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20385. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20386. */
  20387. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20388. private _processSizeParameter;
  20389. /**
  20390. * Define the number of samples to use in case of MSAA.
  20391. * It defaults to one meaning no MSAA has been enabled.
  20392. */
  20393. get samples(): number;
  20394. set samples(value: number);
  20395. /**
  20396. * Resets the refresh counter of the texture and start bak from scratch.
  20397. * Could be useful to regenerate the texture if it is setup to render only once.
  20398. */
  20399. resetRefreshCounter(): void;
  20400. /**
  20401. * Define the refresh rate of the texture or the rendering frequency.
  20402. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20403. */
  20404. get refreshRate(): number;
  20405. set refreshRate(value: number);
  20406. /**
  20407. * Adds a post process to the render target rendering passes.
  20408. * @param postProcess define the post process to add
  20409. */
  20410. addPostProcess(postProcess: PostProcess): void;
  20411. /**
  20412. * Clear all the post processes attached to the render target
  20413. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20414. */
  20415. clearPostProcesses(dispose?: boolean): void;
  20416. /**
  20417. * Remove one of the post process from the list of attached post processes to the texture
  20418. * @param postProcess define the post process to remove from the list
  20419. */
  20420. removePostProcess(postProcess: PostProcess): void;
  20421. /** @hidden */
  20422. _shouldRender(): boolean;
  20423. /**
  20424. * Gets the actual render size of the texture.
  20425. * @returns the width of the render size
  20426. */
  20427. getRenderSize(): number;
  20428. /**
  20429. * Gets the actual render width of the texture.
  20430. * @returns the width of the render size
  20431. */
  20432. getRenderWidth(): number;
  20433. /**
  20434. * Gets the actual render height of the texture.
  20435. * @returns the height of the render size
  20436. */
  20437. getRenderHeight(): number;
  20438. /**
  20439. * Get if the texture can be rescaled or not.
  20440. */
  20441. get canRescale(): boolean;
  20442. /**
  20443. * Resize the texture using a ratio.
  20444. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20445. */
  20446. scale(ratio: number): void;
  20447. /**
  20448. * Get the texture reflection matrix used to rotate/transform the reflection.
  20449. * @returns the reflection matrix
  20450. */
  20451. getReflectionTextureMatrix(): Matrix;
  20452. /**
  20453. * Resize the texture to a new desired size.
  20454. * Be carrefull as it will recreate all the data in the new texture.
  20455. * @param size Define the new size. It can be:
  20456. * - a number for squared texture,
  20457. * - an object containing { width: number, height: number }
  20458. * - or an object containing a ratio { ratio: number }
  20459. */
  20460. resize(size: number | {
  20461. width: number;
  20462. height: number;
  20463. } | {
  20464. ratio: number;
  20465. }): void;
  20466. /**
  20467. * Renders all the objects from the render list into the texture.
  20468. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20469. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20470. */
  20471. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20472. private _bestReflectionRenderTargetDimension;
  20473. /**
  20474. * @hidden
  20475. * @param faceIndex face index to bind to if this is a cubetexture
  20476. */
  20477. _bindFrameBuffer(faceIndex?: number): void;
  20478. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20479. private renderToTarget;
  20480. /**
  20481. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20482. * This allowed control for front to back rendering or reversly depending of the special needs.
  20483. *
  20484. * @param renderingGroupId The rendering group id corresponding to its index
  20485. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20486. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20487. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20488. */
  20489. 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;
  20490. /**
  20491. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20492. *
  20493. * @param renderingGroupId The rendering group id corresponding to its index
  20494. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20495. */
  20496. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20497. /**
  20498. * Clones the texture.
  20499. * @returns the cloned texture
  20500. */
  20501. clone(): RenderTargetTexture;
  20502. /**
  20503. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20504. * @returns The JSON representation of the texture
  20505. */
  20506. serialize(): any;
  20507. /**
  20508. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20509. */
  20510. disposeFramebufferObjects(): void;
  20511. /**
  20512. * Dispose the texture and release its associated resources.
  20513. */
  20514. dispose(): void;
  20515. /** @hidden */
  20516. _rebuild(): void;
  20517. /**
  20518. * Clear the info related to rendering groups preventing retention point in material dispose.
  20519. */
  20520. freeRenderingGroups(): void;
  20521. /**
  20522. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20523. * @returns the view count
  20524. */
  20525. getViewCount(): number;
  20526. }
  20527. }
  20528. declare module BABYLON {
  20529. /**
  20530. * Options for compiling materials.
  20531. */
  20532. export interface IMaterialCompilationOptions {
  20533. /**
  20534. * Defines whether clip planes are enabled.
  20535. */
  20536. clipPlane: boolean;
  20537. /**
  20538. * Defines whether instances are enabled.
  20539. */
  20540. useInstances: boolean;
  20541. }
  20542. /**
  20543. * Base class for the main features of a material in Babylon.js
  20544. */
  20545. export class Material implements IAnimatable {
  20546. /**
  20547. * Returns the triangle fill mode
  20548. */
  20549. static readonly TriangleFillMode: number;
  20550. /**
  20551. * Returns the wireframe mode
  20552. */
  20553. static readonly WireFrameFillMode: number;
  20554. /**
  20555. * Returns the point fill mode
  20556. */
  20557. static readonly PointFillMode: number;
  20558. /**
  20559. * Returns the point list draw mode
  20560. */
  20561. static readonly PointListDrawMode: number;
  20562. /**
  20563. * Returns the line list draw mode
  20564. */
  20565. static readonly LineListDrawMode: number;
  20566. /**
  20567. * Returns the line loop draw mode
  20568. */
  20569. static readonly LineLoopDrawMode: number;
  20570. /**
  20571. * Returns the line strip draw mode
  20572. */
  20573. static readonly LineStripDrawMode: number;
  20574. /**
  20575. * Returns the triangle strip draw mode
  20576. */
  20577. static readonly TriangleStripDrawMode: number;
  20578. /**
  20579. * Returns the triangle fan draw mode
  20580. */
  20581. static readonly TriangleFanDrawMode: number;
  20582. /**
  20583. * Stores the clock-wise side orientation
  20584. */
  20585. static readonly ClockWiseSideOrientation: number;
  20586. /**
  20587. * Stores the counter clock-wise side orientation
  20588. */
  20589. static readonly CounterClockWiseSideOrientation: number;
  20590. /**
  20591. * The dirty texture flag value
  20592. */
  20593. static readonly TextureDirtyFlag: number;
  20594. /**
  20595. * The dirty light flag value
  20596. */
  20597. static readonly LightDirtyFlag: number;
  20598. /**
  20599. * The dirty fresnel flag value
  20600. */
  20601. static readonly FresnelDirtyFlag: number;
  20602. /**
  20603. * The dirty attribute flag value
  20604. */
  20605. static readonly AttributesDirtyFlag: number;
  20606. /**
  20607. * The dirty misc flag value
  20608. */
  20609. static readonly MiscDirtyFlag: number;
  20610. /**
  20611. * The all dirty flag value
  20612. */
  20613. static readonly AllDirtyFlag: number;
  20614. /**
  20615. * The ID of the material
  20616. */
  20617. id: string;
  20618. /**
  20619. * Gets or sets the unique id of the material
  20620. */
  20621. uniqueId: number;
  20622. /**
  20623. * The name of the material
  20624. */
  20625. name: string;
  20626. /**
  20627. * Gets or sets user defined metadata
  20628. */
  20629. metadata: any;
  20630. /**
  20631. * For internal use only. Please do not use.
  20632. */
  20633. reservedDataStore: any;
  20634. /**
  20635. * Specifies if the ready state should be checked on each call
  20636. */
  20637. checkReadyOnEveryCall: boolean;
  20638. /**
  20639. * Specifies if the ready state should be checked once
  20640. */
  20641. checkReadyOnlyOnce: boolean;
  20642. /**
  20643. * The state of the material
  20644. */
  20645. state: string;
  20646. /**
  20647. * The alpha value of the material
  20648. */
  20649. protected _alpha: number;
  20650. /**
  20651. * List of inspectable custom properties (used by the Inspector)
  20652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20653. */
  20654. inspectableCustomProperties: IInspectable[];
  20655. /**
  20656. * Sets the alpha value of the material
  20657. */
  20658. set alpha(value: number);
  20659. /**
  20660. * Gets the alpha value of the material
  20661. */
  20662. get alpha(): number;
  20663. /**
  20664. * Specifies if back face culling is enabled
  20665. */
  20666. protected _backFaceCulling: boolean;
  20667. /**
  20668. * Sets the back-face culling state
  20669. */
  20670. set backFaceCulling(value: boolean);
  20671. /**
  20672. * Gets the back-face culling state
  20673. */
  20674. get backFaceCulling(): boolean;
  20675. /**
  20676. * Stores the value for side orientation
  20677. */
  20678. sideOrientation: number;
  20679. /**
  20680. * Callback triggered when the material is compiled
  20681. */
  20682. onCompiled: Nullable<(effect: Effect) => void>;
  20683. /**
  20684. * Callback triggered when an error occurs
  20685. */
  20686. onError: Nullable<(effect: Effect, errors: string) => void>;
  20687. /**
  20688. * Callback triggered to get the render target textures
  20689. */
  20690. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20691. /**
  20692. * Gets a boolean indicating that current material needs to register RTT
  20693. */
  20694. get hasRenderTargetTextures(): boolean;
  20695. /**
  20696. * Specifies if the material should be serialized
  20697. */
  20698. doNotSerialize: boolean;
  20699. /**
  20700. * @hidden
  20701. */
  20702. _storeEffectOnSubMeshes: boolean;
  20703. /**
  20704. * Stores the animations for the material
  20705. */
  20706. animations: Nullable<Array<Animation>>;
  20707. /**
  20708. * An event triggered when the material is disposed
  20709. */
  20710. onDisposeObservable: Observable<Material>;
  20711. /**
  20712. * An observer which watches for dispose events
  20713. */
  20714. private _onDisposeObserver;
  20715. private _onUnBindObservable;
  20716. /**
  20717. * Called during a dispose event
  20718. */
  20719. set onDispose(callback: () => void);
  20720. private _onBindObservable;
  20721. /**
  20722. * An event triggered when the material is bound
  20723. */
  20724. get onBindObservable(): Observable<AbstractMesh>;
  20725. /**
  20726. * An observer which watches for bind events
  20727. */
  20728. private _onBindObserver;
  20729. /**
  20730. * Called during a bind event
  20731. */
  20732. set onBind(callback: (Mesh: AbstractMesh) => void);
  20733. /**
  20734. * An event triggered when the material is unbound
  20735. */
  20736. get onUnBindObservable(): Observable<Material>;
  20737. /**
  20738. * Stores the value of the alpha mode
  20739. */
  20740. private _alphaMode;
  20741. /**
  20742. * Sets the value of the alpha mode.
  20743. *
  20744. * | Value | Type | Description |
  20745. * | --- | --- | --- |
  20746. * | 0 | ALPHA_DISABLE | |
  20747. * | 1 | ALPHA_ADD | |
  20748. * | 2 | ALPHA_COMBINE | |
  20749. * | 3 | ALPHA_SUBTRACT | |
  20750. * | 4 | ALPHA_MULTIPLY | |
  20751. * | 5 | ALPHA_MAXIMIZED | |
  20752. * | 6 | ALPHA_ONEONE | |
  20753. * | 7 | ALPHA_PREMULTIPLIED | |
  20754. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20755. * | 9 | ALPHA_INTERPOLATE | |
  20756. * | 10 | ALPHA_SCREENMODE | |
  20757. *
  20758. */
  20759. set alphaMode(value: number);
  20760. /**
  20761. * Gets the value of the alpha mode
  20762. */
  20763. get alphaMode(): number;
  20764. /**
  20765. * Stores the state of the need depth pre-pass value
  20766. */
  20767. private _needDepthPrePass;
  20768. /**
  20769. * Sets the need depth pre-pass value
  20770. */
  20771. set needDepthPrePass(value: boolean);
  20772. /**
  20773. * Gets the depth pre-pass value
  20774. */
  20775. get needDepthPrePass(): boolean;
  20776. /**
  20777. * Specifies if depth writing should be disabled
  20778. */
  20779. disableDepthWrite: boolean;
  20780. /**
  20781. * Specifies if depth writing should be forced
  20782. */
  20783. forceDepthWrite: boolean;
  20784. /**
  20785. * Specifies the depth function that should be used. 0 means the default engine function
  20786. */
  20787. depthFunction: number;
  20788. /**
  20789. * Specifies if there should be a separate pass for culling
  20790. */
  20791. separateCullingPass: boolean;
  20792. /**
  20793. * Stores the state specifing if fog should be enabled
  20794. */
  20795. private _fogEnabled;
  20796. /**
  20797. * Sets the state for enabling fog
  20798. */
  20799. set fogEnabled(value: boolean);
  20800. /**
  20801. * Gets the value of the fog enabled state
  20802. */
  20803. get fogEnabled(): boolean;
  20804. /**
  20805. * Stores the size of points
  20806. */
  20807. pointSize: number;
  20808. /**
  20809. * Stores the z offset value
  20810. */
  20811. zOffset: number;
  20812. /**
  20813. * Gets a value specifying if wireframe mode is enabled
  20814. */
  20815. get wireframe(): boolean;
  20816. /**
  20817. * Sets the state of wireframe mode
  20818. */
  20819. set wireframe(value: boolean);
  20820. /**
  20821. * Gets the value specifying if point clouds are enabled
  20822. */
  20823. get pointsCloud(): boolean;
  20824. /**
  20825. * Sets the state of point cloud mode
  20826. */
  20827. set pointsCloud(value: boolean);
  20828. /**
  20829. * Gets the material fill mode
  20830. */
  20831. get fillMode(): number;
  20832. /**
  20833. * Sets the material fill mode
  20834. */
  20835. set fillMode(value: number);
  20836. /**
  20837. * @hidden
  20838. * Stores the effects for the material
  20839. */
  20840. _effect: Nullable<Effect>;
  20841. /**
  20842. * @hidden
  20843. * Specifies if the material was previously ready
  20844. */
  20845. _wasPreviouslyReady: boolean;
  20846. /**
  20847. * Specifies if uniform buffers should be used
  20848. */
  20849. private _useUBO;
  20850. /**
  20851. * Stores a reference to the scene
  20852. */
  20853. private _scene;
  20854. /**
  20855. * Stores the fill mode state
  20856. */
  20857. private _fillMode;
  20858. /**
  20859. * Specifies if the depth write state should be cached
  20860. */
  20861. private _cachedDepthWriteState;
  20862. /**
  20863. * Specifies if the depth function state should be cached
  20864. */
  20865. private _cachedDepthFunctionState;
  20866. /**
  20867. * Stores the uniform buffer
  20868. */
  20869. protected _uniformBuffer: UniformBuffer;
  20870. /** @hidden */
  20871. _indexInSceneMaterialArray: number;
  20872. /** @hidden */
  20873. meshMap: Nullable<{
  20874. [id: string]: AbstractMesh | undefined;
  20875. }>;
  20876. /**
  20877. * Creates a material instance
  20878. * @param name defines the name of the material
  20879. * @param scene defines the scene to reference
  20880. * @param doNotAdd specifies if the material should be added to the scene
  20881. */
  20882. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20883. /**
  20884. * Returns a string representation of the current material
  20885. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20886. * @returns a string with material information
  20887. */
  20888. toString(fullDetails?: boolean): string;
  20889. /**
  20890. * Gets the class name of the material
  20891. * @returns a string with the class name of the material
  20892. */
  20893. getClassName(): string;
  20894. /**
  20895. * Specifies if updates for the material been locked
  20896. */
  20897. get isFrozen(): boolean;
  20898. /**
  20899. * Locks updates for the material
  20900. */
  20901. freeze(): void;
  20902. /**
  20903. * Unlocks updates for the material
  20904. */
  20905. unfreeze(): void;
  20906. /**
  20907. * Specifies if the material is ready to be used
  20908. * @param mesh defines the mesh to check
  20909. * @param useInstances specifies if instances should be used
  20910. * @returns a boolean indicating if the material is ready to be used
  20911. */
  20912. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20913. /**
  20914. * Specifies that the submesh is ready to be used
  20915. * @param mesh defines the mesh to check
  20916. * @param subMesh defines which submesh to check
  20917. * @param useInstances specifies that instances should be used
  20918. * @returns a boolean indicating that the submesh is ready or not
  20919. */
  20920. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20921. /**
  20922. * Returns the material effect
  20923. * @returns the effect associated with the material
  20924. */
  20925. getEffect(): Nullable<Effect>;
  20926. /**
  20927. * Returns the current scene
  20928. * @returns a Scene
  20929. */
  20930. getScene(): Scene;
  20931. /**
  20932. * Specifies if the material will require alpha blending
  20933. * @returns a boolean specifying if alpha blending is needed
  20934. */
  20935. needAlphaBlending(): boolean;
  20936. /**
  20937. * Specifies if the mesh will require alpha blending
  20938. * @param mesh defines the mesh to check
  20939. * @returns a boolean specifying if alpha blending is needed for the mesh
  20940. */
  20941. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20942. /**
  20943. * Specifies if this material should be rendered in alpha test mode
  20944. * @returns a boolean specifying if an alpha test is needed.
  20945. */
  20946. needAlphaTesting(): boolean;
  20947. /**
  20948. * Gets the texture used for the alpha test
  20949. * @returns the texture to use for alpha testing
  20950. */
  20951. getAlphaTestTexture(): Nullable<BaseTexture>;
  20952. /**
  20953. * Marks the material to indicate that it needs to be re-calculated
  20954. */
  20955. markDirty(): void;
  20956. /** @hidden */
  20957. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20958. /**
  20959. * Binds the material to the mesh
  20960. * @param world defines the world transformation matrix
  20961. * @param mesh defines the mesh to bind the material to
  20962. */
  20963. bind(world: Matrix, mesh?: Mesh): void;
  20964. /**
  20965. * Binds the submesh to the material
  20966. * @param world defines the world transformation matrix
  20967. * @param mesh defines the mesh containing the submesh
  20968. * @param subMesh defines the submesh to bind the material to
  20969. */
  20970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20971. /**
  20972. * Binds the world matrix to the material
  20973. * @param world defines the world transformation matrix
  20974. */
  20975. bindOnlyWorldMatrix(world: Matrix): void;
  20976. /**
  20977. * Binds the scene's uniform buffer to the effect.
  20978. * @param effect defines the effect to bind to the scene uniform buffer
  20979. * @param sceneUbo defines the uniform buffer storing scene data
  20980. */
  20981. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20982. /**
  20983. * Binds the view matrix to the effect
  20984. * @param effect defines the effect to bind the view matrix to
  20985. */
  20986. bindView(effect: Effect): void;
  20987. /**
  20988. * Binds the view projection matrix to the effect
  20989. * @param effect defines the effect to bind the view projection matrix to
  20990. */
  20991. bindViewProjection(effect: Effect): void;
  20992. /**
  20993. * Specifies if material alpha testing should be turned on for the mesh
  20994. * @param mesh defines the mesh to check
  20995. */
  20996. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20997. /**
  20998. * Processes to execute after binding the material to a mesh
  20999. * @param mesh defines the rendered mesh
  21000. */
  21001. protected _afterBind(mesh?: Mesh): void;
  21002. /**
  21003. * Unbinds the material from the mesh
  21004. */
  21005. unbind(): void;
  21006. /**
  21007. * Gets the active textures from the material
  21008. * @returns an array of textures
  21009. */
  21010. getActiveTextures(): BaseTexture[];
  21011. /**
  21012. * Specifies if the material uses a texture
  21013. * @param texture defines the texture to check against the material
  21014. * @returns a boolean specifying if the material uses the texture
  21015. */
  21016. hasTexture(texture: BaseTexture): boolean;
  21017. /**
  21018. * Makes a duplicate of the material, and gives it a new name
  21019. * @param name defines the new name for the duplicated material
  21020. * @returns the cloned material
  21021. */
  21022. clone(name: string): Nullable<Material>;
  21023. /**
  21024. * Gets the meshes bound to the material
  21025. * @returns an array of meshes bound to the material
  21026. */
  21027. getBindedMeshes(): AbstractMesh[];
  21028. /**
  21029. * Force shader compilation
  21030. * @param mesh defines the mesh associated with this material
  21031. * @param onCompiled defines a function to execute once the material is compiled
  21032. * @param options defines the options to configure the compilation
  21033. * @param onError defines a function to execute if the material fails compiling
  21034. */
  21035. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21036. /**
  21037. * Force shader compilation
  21038. * @param mesh defines the mesh that will use this material
  21039. * @param options defines additional options for compiling the shaders
  21040. * @returns a promise that resolves when the compilation completes
  21041. */
  21042. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21043. private static readonly _AllDirtyCallBack;
  21044. private static readonly _ImageProcessingDirtyCallBack;
  21045. private static readonly _TextureDirtyCallBack;
  21046. private static readonly _FresnelDirtyCallBack;
  21047. private static readonly _MiscDirtyCallBack;
  21048. private static readonly _LightsDirtyCallBack;
  21049. private static readonly _AttributeDirtyCallBack;
  21050. private static _FresnelAndMiscDirtyCallBack;
  21051. private static _TextureAndMiscDirtyCallBack;
  21052. private static readonly _DirtyCallbackArray;
  21053. private static readonly _RunDirtyCallBacks;
  21054. /**
  21055. * Marks a define in the material to indicate that it needs to be re-computed
  21056. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21057. */
  21058. markAsDirty(flag: number): void;
  21059. /**
  21060. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21061. * @param func defines a function which checks material defines against the submeshes
  21062. */
  21063. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21064. /**
  21065. * Indicates that we need to re-calculated for all submeshes
  21066. */
  21067. protected _markAllSubMeshesAsAllDirty(): void;
  21068. /**
  21069. * Indicates that image processing needs to be re-calculated for all submeshes
  21070. */
  21071. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21072. /**
  21073. * Indicates that textures need to be re-calculated for all submeshes
  21074. */
  21075. protected _markAllSubMeshesAsTexturesDirty(): void;
  21076. /**
  21077. * Indicates that fresnel needs to be re-calculated for all submeshes
  21078. */
  21079. protected _markAllSubMeshesAsFresnelDirty(): void;
  21080. /**
  21081. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21082. */
  21083. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21084. /**
  21085. * Indicates that lights need to be re-calculated for all submeshes
  21086. */
  21087. protected _markAllSubMeshesAsLightsDirty(): void;
  21088. /**
  21089. * Indicates that attributes need to be re-calculated for all submeshes
  21090. */
  21091. protected _markAllSubMeshesAsAttributesDirty(): void;
  21092. /**
  21093. * Indicates that misc needs to be re-calculated for all submeshes
  21094. */
  21095. protected _markAllSubMeshesAsMiscDirty(): void;
  21096. /**
  21097. * Indicates that textures and misc need to be re-calculated for all submeshes
  21098. */
  21099. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21100. /**
  21101. * Disposes the material
  21102. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21103. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21104. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21105. */
  21106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21107. /** @hidden */
  21108. private releaseVertexArrayObject;
  21109. /**
  21110. * Serializes this material
  21111. * @returns the serialized material object
  21112. */
  21113. serialize(): any;
  21114. /**
  21115. * Creates a material from parsed material data
  21116. * @param parsedMaterial defines parsed material data
  21117. * @param scene defines the hosting scene
  21118. * @param rootUrl defines the root URL to use to load textures
  21119. * @returns a new material
  21120. */
  21121. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21122. }
  21123. }
  21124. declare module BABYLON {
  21125. /**
  21126. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21127. * separate meshes. This can be use to improve performances.
  21128. * @see http://doc.babylonjs.com/how_to/multi_materials
  21129. */
  21130. export class MultiMaterial extends Material {
  21131. private _subMaterials;
  21132. /**
  21133. * Gets or Sets the list of Materials used within the multi material.
  21134. * They need to be ordered according to the submeshes order in the associated mesh
  21135. */
  21136. get subMaterials(): Nullable<Material>[];
  21137. set subMaterials(value: Nullable<Material>[]);
  21138. /**
  21139. * Function used to align with Node.getChildren()
  21140. * @returns the list of Materials used within the multi material
  21141. */
  21142. getChildren(): Nullable<Material>[];
  21143. /**
  21144. * Instantiates a new Multi Material
  21145. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21146. * separate meshes. This can be use to improve performances.
  21147. * @see http://doc.babylonjs.com/how_to/multi_materials
  21148. * @param name Define the name in the scene
  21149. * @param scene Define the scene the material belongs to
  21150. */
  21151. constructor(name: string, scene: Scene);
  21152. private _hookArray;
  21153. /**
  21154. * Get one of the submaterial by its index in the submaterials array
  21155. * @param index The index to look the sub material at
  21156. * @returns The Material if the index has been defined
  21157. */
  21158. getSubMaterial(index: number): Nullable<Material>;
  21159. /**
  21160. * Get the list of active textures for the whole sub materials list.
  21161. * @returns All the textures that will be used during the rendering
  21162. */
  21163. getActiveTextures(): BaseTexture[];
  21164. /**
  21165. * Gets the current class name of the material e.g. "MultiMaterial"
  21166. * Mainly use in serialization.
  21167. * @returns the class name
  21168. */
  21169. getClassName(): string;
  21170. /**
  21171. * Checks if the material is ready to render the requested sub mesh
  21172. * @param mesh Define the mesh the submesh belongs to
  21173. * @param subMesh Define the sub mesh to look readyness for
  21174. * @param useInstances Define whether or not the material is used with instances
  21175. * @returns true if ready, otherwise false
  21176. */
  21177. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21178. /**
  21179. * Clones the current material and its related sub materials
  21180. * @param name Define the name of the newly cloned material
  21181. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21182. * @returns the cloned material
  21183. */
  21184. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21185. /**
  21186. * Serializes the materials into a JSON representation.
  21187. * @returns the JSON representation
  21188. */
  21189. serialize(): any;
  21190. /**
  21191. * Dispose the material and release its associated resources
  21192. * @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)
  21193. * @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)
  21194. * @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)
  21195. */
  21196. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21197. /**
  21198. * Creates a MultiMaterial from parsed MultiMaterial data.
  21199. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21200. * @param scene defines the hosting scene
  21201. * @returns a new MultiMaterial
  21202. */
  21203. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21204. }
  21205. }
  21206. declare module BABYLON {
  21207. /**
  21208. * Base class for submeshes
  21209. */
  21210. export class BaseSubMesh {
  21211. /** @hidden */
  21212. _materialDefines: Nullable<MaterialDefines>;
  21213. /** @hidden */
  21214. _materialEffect: Nullable<Effect>;
  21215. /**
  21216. * Gets material defines used by the effect associated to the sub mesh
  21217. */
  21218. get materialDefines(): Nullable<MaterialDefines>;
  21219. /**
  21220. * Sets material defines used by the effect associated to the sub mesh
  21221. */
  21222. set materialDefines(defines: Nullable<MaterialDefines>);
  21223. /**
  21224. * Gets associated effect
  21225. */
  21226. get effect(): Nullable<Effect>;
  21227. /**
  21228. * Sets associated effect (effect used to render this submesh)
  21229. * @param effect defines the effect to associate with
  21230. * @param defines defines the set of defines used to compile this effect
  21231. */
  21232. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21233. }
  21234. /**
  21235. * Defines a subdivision inside a mesh
  21236. */
  21237. export class SubMesh extends BaseSubMesh implements ICullable {
  21238. /** the material index to use */
  21239. materialIndex: number;
  21240. /** vertex index start */
  21241. verticesStart: number;
  21242. /** vertices count */
  21243. verticesCount: number;
  21244. /** index start */
  21245. indexStart: number;
  21246. /** indices count */
  21247. indexCount: number;
  21248. /** @hidden */
  21249. _linesIndexCount: number;
  21250. private _mesh;
  21251. private _renderingMesh;
  21252. private _boundingInfo;
  21253. private _linesIndexBuffer;
  21254. /** @hidden */
  21255. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21256. /** @hidden */
  21257. _trianglePlanes: Plane[];
  21258. /** @hidden */
  21259. _lastColliderTransformMatrix: Nullable<Matrix>;
  21260. /** @hidden */
  21261. _renderId: number;
  21262. /** @hidden */
  21263. _alphaIndex: number;
  21264. /** @hidden */
  21265. _distanceToCamera: number;
  21266. /** @hidden */
  21267. _id: number;
  21268. private _currentMaterial;
  21269. /**
  21270. * Add a new submesh to a mesh
  21271. * @param materialIndex defines the material index to use
  21272. * @param verticesStart defines vertex index start
  21273. * @param verticesCount defines vertices count
  21274. * @param indexStart defines index start
  21275. * @param indexCount defines indices count
  21276. * @param mesh defines the parent mesh
  21277. * @param renderingMesh defines an optional rendering mesh
  21278. * @param createBoundingBox defines if bounding box should be created for this submesh
  21279. * @returns the new submesh
  21280. */
  21281. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21282. /**
  21283. * Creates a new submesh
  21284. * @param materialIndex defines the material index to use
  21285. * @param verticesStart defines vertex index start
  21286. * @param verticesCount defines vertices count
  21287. * @param indexStart defines index start
  21288. * @param indexCount defines indices count
  21289. * @param mesh defines the parent mesh
  21290. * @param renderingMesh defines an optional rendering mesh
  21291. * @param createBoundingBox defines if bounding box should be created for this submesh
  21292. */
  21293. constructor(
  21294. /** the material index to use */
  21295. materialIndex: number,
  21296. /** vertex index start */
  21297. verticesStart: number,
  21298. /** vertices count */
  21299. verticesCount: number,
  21300. /** index start */
  21301. indexStart: number,
  21302. /** indices count */
  21303. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21304. /**
  21305. * Returns true if this submesh covers the entire parent mesh
  21306. * @ignorenaming
  21307. */
  21308. get IsGlobal(): boolean;
  21309. /**
  21310. * Returns the submesh BoudingInfo object
  21311. * @returns current bounding info (or mesh's one if the submesh is global)
  21312. */
  21313. getBoundingInfo(): BoundingInfo;
  21314. /**
  21315. * Sets the submesh BoundingInfo
  21316. * @param boundingInfo defines the new bounding info to use
  21317. * @returns the SubMesh
  21318. */
  21319. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21320. /**
  21321. * Returns the mesh of the current submesh
  21322. * @return the parent mesh
  21323. */
  21324. getMesh(): AbstractMesh;
  21325. /**
  21326. * Returns the rendering mesh of the submesh
  21327. * @returns the rendering mesh (could be different from parent mesh)
  21328. */
  21329. getRenderingMesh(): Mesh;
  21330. /**
  21331. * Returns the submesh material
  21332. * @returns null or the current material
  21333. */
  21334. getMaterial(): Nullable<Material>;
  21335. /**
  21336. * Sets a new updated BoundingInfo object to the submesh
  21337. * @param data defines an optional position array to use to determine the bounding info
  21338. * @returns the SubMesh
  21339. */
  21340. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21341. /** @hidden */
  21342. _checkCollision(collider: Collider): boolean;
  21343. /**
  21344. * Updates the submesh BoundingInfo
  21345. * @param world defines the world matrix to use to update the bounding info
  21346. * @returns the submesh
  21347. */
  21348. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21349. /**
  21350. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21351. * @param frustumPlanes defines the frustum planes
  21352. * @returns true if the submesh is intersecting with the frustum
  21353. */
  21354. isInFrustum(frustumPlanes: Plane[]): boolean;
  21355. /**
  21356. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21357. * @param frustumPlanes defines the frustum planes
  21358. * @returns true if the submesh is inside the frustum
  21359. */
  21360. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21361. /**
  21362. * Renders the submesh
  21363. * @param enableAlphaMode defines if alpha needs to be used
  21364. * @returns the submesh
  21365. */
  21366. render(enableAlphaMode: boolean): SubMesh;
  21367. /**
  21368. * @hidden
  21369. */
  21370. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21371. /**
  21372. * Checks if the submesh intersects with a ray
  21373. * @param ray defines the ray to test
  21374. * @returns true is the passed ray intersects the submesh bounding box
  21375. */
  21376. canIntersects(ray: Ray): boolean;
  21377. /**
  21378. * Intersects current submesh with a ray
  21379. * @param ray defines the ray to test
  21380. * @param positions defines mesh's positions array
  21381. * @param indices defines mesh's indices array
  21382. * @param fastCheck defines if only bounding info should be used
  21383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21384. * @returns intersection info or null if no intersection
  21385. */
  21386. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21387. /** @hidden */
  21388. private _intersectLines;
  21389. /** @hidden */
  21390. private _intersectUnIndexedLines;
  21391. /** @hidden */
  21392. private _intersectTriangles;
  21393. /** @hidden */
  21394. private _intersectUnIndexedTriangles;
  21395. /** @hidden */
  21396. _rebuild(): void;
  21397. /**
  21398. * Creates a new submesh from the passed mesh
  21399. * @param newMesh defines the new hosting mesh
  21400. * @param newRenderingMesh defines an optional rendering mesh
  21401. * @returns the new submesh
  21402. */
  21403. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21404. /**
  21405. * Release associated resources
  21406. */
  21407. dispose(): void;
  21408. /**
  21409. * Gets the class name
  21410. * @returns the string "SubMesh".
  21411. */
  21412. getClassName(): string;
  21413. /**
  21414. * Creates a new submesh from indices data
  21415. * @param materialIndex the index of the main mesh material
  21416. * @param startIndex the index where to start the copy in the mesh indices array
  21417. * @param indexCount the number of indices to copy then from the startIndex
  21418. * @param mesh the main mesh to create the submesh from
  21419. * @param renderingMesh the optional rendering mesh
  21420. * @returns a new submesh
  21421. */
  21422. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21423. }
  21424. }
  21425. declare module BABYLON {
  21426. /**
  21427. * Class used to represent data loading progression
  21428. */
  21429. export class SceneLoaderFlags {
  21430. private static _ForceFullSceneLoadingForIncremental;
  21431. private static _ShowLoadingScreen;
  21432. private static _CleanBoneMatrixWeights;
  21433. private static _loggingLevel;
  21434. /**
  21435. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21436. */
  21437. static get ForceFullSceneLoadingForIncremental(): boolean;
  21438. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21439. /**
  21440. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21441. */
  21442. static get ShowLoadingScreen(): boolean;
  21443. static set ShowLoadingScreen(value: boolean);
  21444. /**
  21445. * Defines the current logging level (while loading the scene)
  21446. * @ignorenaming
  21447. */
  21448. static get loggingLevel(): number;
  21449. static set loggingLevel(value: number);
  21450. /**
  21451. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21452. */
  21453. static get CleanBoneMatrixWeights(): boolean;
  21454. static set CleanBoneMatrixWeights(value: boolean);
  21455. }
  21456. }
  21457. declare module BABYLON {
  21458. /**
  21459. * Class used to store geometry data (vertex buffers + index buffer)
  21460. */
  21461. export class Geometry implements IGetSetVerticesData {
  21462. /**
  21463. * Gets or sets the ID of the geometry
  21464. */
  21465. id: string;
  21466. /**
  21467. * Gets or sets the unique ID of the geometry
  21468. */
  21469. uniqueId: number;
  21470. /**
  21471. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21472. */
  21473. delayLoadState: number;
  21474. /**
  21475. * Gets the file containing the data to load when running in delay load state
  21476. */
  21477. delayLoadingFile: Nullable<string>;
  21478. /**
  21479. * Callback called when the geometry is updated
  21480. */
  21481. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21482. private _scene;
  21483. private _engine;
  21484. private _meshes;
  21485. private _totalVertices;
  21486. /** @hidden */
  21487. _indices: IndicesArray;
  21488. /** @hidden */
  21489. _vertexBuffers: {
  21490. [key: string]: VertexBuffer;
  21491. };
  21492. private _isDisposed;
  21493. private _extend;
  21494. private _boundingBias;
  21495. /** @hidden */
  21496. _delayInfo: Array<string>;
  21497. private _indexBuffer;
  21498. private _indexBufferIsUpdatable;
  21499. /** @hidden */
  21500. _boundingInfo: Nullable<BoundingInfo>;
  21501. /** @hidden */
  21502. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21503. /** @hidden */
  21504. _softwareSkinningFrameId: number;
  21505. private _vertexArrayObjects;
  21506. private _updatable;
  21507. /** @hidden */
  21508. _positions: Nullable<Vector3[]>;
  21509. /**
  21510. * 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
  21511. */
  21512. get boundingBias(): Vector2;
  21513. /**
  21514. * 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
  21515. */
  21516. set boundingBias(value: Vector2);
  21517. /**
  21518. * Static function used to attach a new empty geometry to a mesh
  21519. * @param mesh defines the mesh to attach the geometry to
  21520. * @returns the new Geometry
  21521. */
  21522. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21523. /**
  21524. * Creates a new geometry
  21525. * @param id defines the unique ID
  21526. * @param scene defines the hosting scene
  21527. * @param vertexData defines the VertexData used to get geometry data
  21528. * @param updatable defines if geometry must be updatable (false by default)
  21529. * @param mesh defines the mesh that will be associated with the geometry
  21530. */
  21531. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21532. /**
  21533. * Gets the current extend of the geometry
  21534. */
  21535. get extend(): {
  21536. minimum: Vector3;
  21537. maximum: Vector3;
  21538. };
  21539. /**
  21540. * Gets the hosting scene
  21541. * @returns the hosting Scene
  21542. */
  21543. getScene(): Scene;
  21544. /**
  21545. * Gets the hosting engine
  21546. * @returns the hosting Engine
  21547. */
  21548. getEngine(): Engine;
  21549. /**
  21550. * Defines if the geometry is ready to use
  21551. * @returns true if the geometry is ready to be used
  21552. */
  21553. isReady(): boolean;
  21554. /**
  21555. * Gets a value indicating that the geometry should not be serialized
  21556. */
  21557. get doNotSerialize(): boolean;
  21558. /** @hidden */
  21559. _rebuild(): void;
  21560. /**
  21561. * Affects all geometry data in one call
  21562. * @param vertexData defines the geometry data
  21563. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21564. */
  21565. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21566. /**
  21567. * Set specific vertex data
  21568. * @param kind defines the data kind (Position, normal, etc...)
  21569. * @param data defines the vertex data to use
  21570. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21571. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21572. */
  21573. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21574. /**
  21575. * Removes a specific vertex data
  21576. * @param kind defines the data kind (Position, normal, etc...)
  21577. */
  21578. removeVerticesData(kind: string): void;
  21579. /**
  21580. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21581. * @param buffer defines the vertex buffer to use
  21582. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21583. */
  21584. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21585. /**
  21586. * Update a specific vertex buffer
  21587. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21588. * It will do nothing if the buffer is not updatable
  21589. * @param kind defines the data kind (Position, normal, etc...)
  21590. * @param data defines the data to use
  21591. * @param offset defines the offset in the target buffer where to store the data
  21592. * @param useBytes set to true if the offset is in bytes
  21593. */
  21594. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21595. /**
  21596. * Update a specific vertex buffer
  21597. * This function will create a new buffer if the current one is not updatable
  21598. * @param kind defines the data kind (Position, normal, etc...)
  21599. * @param data defines the data to use
  21600. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21601. */
  21602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21603. private _updateBoundingInfo;
  21604. /** @hidden */
  21605. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21606. /**
  21607. * Gets total number of vertices
  21608. * @returns the total number of vertices
  21609. */
  21610. getTotalVertices(): number;
  21611. /**
  21612. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21613. * @param kind defines the data kind (Position, normal, etc...)
  21614. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21615. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21616. * @returns a float array containing vertex data
  21617. */
  21618. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21619. /**
  21620. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21621. * @param kind defines the data kind (Position, normal, etc...)
  21622. * @returns true if the vertex buffer with the specified kind is updatable
  21623. */
  21624. isVertexBufferUpdatable(kind: string): boolean;
  21625. /**
  21626. * Gets a specific vertex buffer
  21627. * @param kind defines the data kind (Position, normal, etc...)
  21628. * @returns a VertexBuffer
  21629. */
  21630. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21631. /**
  21632. * Returns all vertex buffers
  21633. * @return an object holding all vertex buffers indexed by kind
  21634. */
  21635. getVertexBuffers(): Nullable<{
  21636. [key: string]: VertexBuffer;
  21637. }>;
  21638. /**
  21639. * Gets a boolean indicating if specific vertex buffer is present
  21640. * @param kind defines the data kind (Position, normal, etc...)
  21641. * @returns true if data is present
  21642. */
  21643. isVerticesDataPresent(kind: string): boolean;
  21644. /**
  21645. * Gets a list of all attached data kinds (Position, normal, etc...)
  21646. * @returns a list of string containing all kinds
  21647. */
  21648. getVerticesDataKinds(): string[];
  21649. /**
  21650. * Update index buffer
  21651. * @param indices defines the indices to store in the index buffer
  21652. * @param offset defines the offset in the target buffer where to store the data
  21653. * @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)
  21654. */
  21655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21656. /**
  21657. * Creates a new index buffer
  21658. * @param indices defines the indices to store in the index buffer
  21659. * @param totalVertices defines the total number of vertices (could be null)
  21660. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21661. */
  21662. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21663. /**
  21664. * Return the total number of indices
  21665. * @returns the total number of indices
  21666. */
  21667. getTotalIndices(): number;
  21668. /**
  21669. * Gets the index buffer array
  21670. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21671. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21672. * @returns the index buffer array
  21673. */
  21674. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21675. /**
  21676. * Gets the index buffer
  21677. * @return the index buffer
  21678. */
  21679. getIndexBuffer(): Nullable<DataBuffer>;
  21680. /** @hidden */
  21681. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21682. /**
  21683. * Release the associated resources for a specific mesh
  21684. * @param mesh defines the source mesh
  21685. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21686. */
  21687. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21688. /**
  21689. * Apply current geometry to a given mesh
  21690. * @param mesh defines the mesh to apply geometry to
  21691. */
  21692. applyToMesh(mesh: Mesh): void;
  21693. private _updateExtend;
  21694. private _applyToMesh;
  21695. private notifyUpdate;
  21696. /**
  21697. * Load the geometry if it was flagged as delay loaded
  21698. * @param scene defines the hosting scene
  21699. * @param onLoaded defines a callback called when the geometry is loaded
  21700. */
  21701. load(scene: Scene, onLoaded?: () => void): void;
  21702. private _queueLoad;
  21703. /**
  21704. * Invert the geometry to move from a right handed system to a left handed one.
  21705. */
  21706. toLeftHanded(): void;
  21707. /** @hidden */
  21708. _resetPointsArrayCache(): void;
  21709. /** @hidden */
  21710. _generatePointsArray(): boolean;
  21711. /**
  21712. * Gets a value indicating if the geometry is disposed
  21713. * @returns true if the geometry was disposed
  21714. */
  21715. isDisposed(): boolean;
  21716. private _disposeVertexArrayObjects;
  21717. /**
  21718. * Free all associated resources
  21719. */
  21720. dispose(): void;
  21721. /**
  21722. * Clone the current geometry into a new geometry
  21723. * @param id defines the unique ID of the new geometry
  21724. * @returns a new geometry object
  21725. */
  21726. copy(id: string): Geometry;
  21727. /**
  21728. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21729. * @return a JSON representation of the current geometry data (without the vertices data)
  21730. */
  21731. serialize(): any;
  21732. private toNumberArray;
  21733. /**
  21734. * Serialize all vertices data into a JSON oject
  21735. * @returns a JSON representation of the current geometry data
  21736. */
  21737. serializeVerticeData(): any;
  21738. /**
  21739. * Extracts a clone of a mesh geometry
  21740. * @param mesh defines the source mesh
  21741. * @param id defines the unique ID of the new geometry object
  21742. * @returns the new geometry object
  21743. */
  21744. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21745. /**
  21746. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21747. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21748. * Be aware Math.random() could cause collisions, but:
  21749. * "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"
  21750. * @returns a string containing a new GUID
  21751. */
  21752. static RandomId(): string;
  21753. /** @hidden */
  21754. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21755. private static _CleanMatricesWeights;
  21756. /**
  21757. * Create a new geometry from persisted data (Using .babylon file format)
  21758. * @param parsedVertexData defines the persisted data
  21759. * @param scene defines the hosting scene
  21760. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21761. * @returns the new geometry object
  21762. */
  21763. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21764. }
  21765. }
  21766. declare module BABYLON {
  21767. /**
  21768. * Define an interface for all classes that will get and set the data on vertices
  21769. */
  21770. export interface IGetSetVerticesData {
  21771. /**
  21772. * Gets a boolean indicating if specific vertex data is present
  21773. * @param kind defines the vertex data kind to use
  21774. * @returns true is data kind is present
  21775. */
  21776. isVerticesDataPresent(kind: string): boolean;
  21777. /**
  21778. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21779. * @param kind defines the data kind (Position, normal, etc...)
  21780. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21782. * @returns a float array containing vertex data
  21783. */
  21784. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21785. /**
  21786. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21787. * @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.
  21788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21789. * @returns the indices array or an empty array if the mesh has no geometry
  21790. */
  21791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21792. /**
  21793. * Set specific vertex data
  21794. * @param kind defines the data kind (Position, normal, etc...)
  21795. * @param data defines the vertex data to use
  21796. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21797. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21798. */
  21799. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21800. /**
  21801. * Update a specific associated vertex buffer
  21802. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21803. * - VertexBuffer.PositionKind
  21804. * - VertexBuffer.UVKind
  21805. * - VertexBuffer.UV2Kind
  21806. * - VertexBuffer.UV3Kind
  21807. * - VertexBuffer.UV4Kind
  21808. * - VertexBuffer.UV5Kind
  21809. * - VertexBuffer.UV6Kind
  21810. * - VertexBuffer.ColorKind
  21811. * - VertexBuffer.MatricesIndicesKind
  21812. * - VertexBuffer.MatricesIndicesExtraKind
  21813. * - VertexBuffer.MatricesWeightsKind
  21814. * - VertexBuffer.MatricesWeightsExtraKind
  21815. * @param data defines the data source
  21816. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21817. * @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)
  21818. */
  21819. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21820. /**
  21821. * Creates a new index buffer
  21822. * @param indices defines the indices to store in the index buffer
  21823. * @param totalVertices defines the total number of vertices (could be null)
  21824. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21825. */
  21826. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21827. }
  21828. /**
  21829. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21830. */
  21831. export class VertexData {
  21832. /**
  21833. * Mesh side orientation : usually the external or front surface
  21834. */
  21835. static readonly FRONTSIDE: number;
  21836. /**
  21837. * Mesh side orientation : usually the internal or back surface
  21838. */
  21839. static readonly BACKSIDE: number;
  21840. /**
  21841. * Mesh side orientation : both internal and external or front and back surfaces
  21842. */
  21843. static readonly DOUBLESIDE: number;
  21844. /**
  21845. * Mesh side orientation : by default, `FRONTSIDE`
  21846. */
  21847. static readonly DEFAULTSIDE: number;
  21848. /**
  21849. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21850. */
  21851. positions: Nullable<FloatArray>;
  21852. /**
  21853. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21854. */
  21855. normals: Nullable<FloatArray>;
  21856. /**
  21857. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21858. */
  21859. tangents: Nullable<FloatArray>;
  21860. /**
  21861. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21862. */
  21863. uvs: Nullable<FloatArray>;
  21864. /**
  21865. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21866. */
  21867. uvs2: Nullable<FloatArray>;
  21868. /**
  21869. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21870. */
  21871. uvs3: Nullable<FloatArray>;
  21872. /**
  21873. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21874. */
  21875. uvs4: Nullable<FloatArray>;
  21876. /**
  21877. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21878. */
  21879. uvs5: Nullable<FloatArray>;
  21880. /**
  21881. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21882. */
  21883. uvs6: Nullable<FloatArray>;
  21884. /**
  21885. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21886. */
  21887. colors: Nullable<FloatArray>;
  21888. /**
  21889. * 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).
  21890. */
  21891. matricesIndices: Nullable<FloatArray>;
  21892. /**
  21893. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21894. */
  21895. matricesWeights: Nullable<FloatArray>;
  21896. /**
  21897. * An array extending the number of possible indices
  21898. */
  21899. matricesIndicesExtra: Nullable<FloatArray>;
  21900. /**
  21901. * An array extending the number of possible weights when the number of indices is extended
  21902. */
  21903. matricesWeightsExtra: Nullable<FloatArray>;
  21904. /**
  21905. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21906. */
  21907. indices: Nullable<IndicesArray>;
  21908. /**
  21909. * Uses the passed data array to set the set the values for the specified kind of data
  21910. * @param data a linear array of floating numbers
  21911. * @param kind the type of data that is being set, eg positions, colors etc
  21912. */
  21913. set(data: FloatArray, kind: string): void;
  21914. /**
  21915. * Associates the vertexData to the passed Mesh.
  21916. * Sets it as updatable or not (default `false`)
  21917. * @param mesh the mesh the vertexData is applied to
  21918. * @param updatable when used and having the value true allows new data to update the vertexData
  21919. * @returns the VertexData
  21920. */
  21921. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21922. /**
  21923. * Associates the vertexData to the passed Geometry.
  21924. * Sets it as updatable or not (default `false`)
  21925. * @param geometry the geometry the vertexData is applied to
  21926. * @param updatable when used and having the value true allows new data to update the vertexData
  21927. * @returns VertexData
  21928. */
  21929. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21930. /**
  21931. * Updates the associated mesh
  21932. * @param mesh the mesh to be updated
  21933. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21934. * @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
  21935. * @returns VertexData
  21936. */
  21937. updateMesh(mesh: Mesh): VertexData;
  21938. /**
  21939. * Updates the associated geometry
  21940. * @param geometry the geometry to be updated
  21941. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21942. * @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
  21943. * @returns VertexData.
  21944. */
  21945. updateGeometry(geometry: Geometry): VertexData;
  21946. private _applyTo;
  21947. private _update;
  21948. /**
  21949. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21950. * @param matrix the transforming matrix
  21951. * @returns the VertexData
  21952. */
  21953. transform(matrix: Matrix): VertexData;
  21954. /**
  21955. * Merges the passed VertexData into the current one
  21956. * @param other the VertexData to be merged into the current one
  21957. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21958. * @returns the modified VertexData
  21959. */
  21960. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21961. private _mergeElement;
  21962. private _validate;
  21963. /**
  21964. * Serializes the VertexData
  21965. * @returns a serialized object
  21966. */
  21967. serialize(): any;
  21968. /**
  21969. * Extracts the vertexData from a mesh
  21970. * @param mesh the mesh from which to extract the VertexData
  21971. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21972. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21973. * @returns the object VertexData associated to the passed mesh
  21974. */
  21975. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21976. /**
  21977. * Extracts the vertexData from the geometry
  21978. * @param geometry the geometry from which to extract the VertexData
  21979. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21980. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21981. * @returns the object VertexData associated to the passed mesh
  21982. */
  21983. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21984. private static _ExtractFrom;
  21985. /**
  21986. * Creates the VertexData for a Ribbon
  21987. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21988. * * pathArray array of paths, each of which an array of successive Vector3
  21989. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21990. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21991. * * 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
  21992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21993. * * 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)
  21994. * * 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)
  21995. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21996. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21997. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21998. * @returns the VertexData of the ribbon
  21999. */
  22000. static CreateRibbon(options: {
  22001. pathArray: Vector3[][];
  22002. closeArray?: boolean;
  22003. closePath?: boolean;
  22004. offset?: number;
  22005. sideOrientation?: number;
  22006. frontUVs?: Vector4;
  22007. backUVs?: Vector4;
  22008. invertUV?: boolean;
  22009. uvs?: Vector2[];
  22010. colors?: Color4[];
  22011. }): VertexData;
  22012. /**
  22013. * Creates the VertexData for a box
  22014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22015. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22016. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22017. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22018. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22019. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22020. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22022. * * 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)
  22023. * * 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)
  22024. * @returns the VertexData of the box
  22025. */
  22026. static CreateBox(options: {
  22027. size?: number;
  22028. width?: number;
  22029. height?: number;
  22030. depth?: number;
  22031. faceUV?: Vector4[];
  22032. faceColors?: Color4[];
  22033. sideOrientation?: number;
  22034. frontUVs?: Vector4;
  22035. backUVs?: Vector4;
  22036. }): VertexData;
  22037. /**
  22038. * Creates the VertexData for a tiled box
  22039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22040. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22041. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22042. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22044. * @returns the VertexData of the box
  22045. */
  22046. static CreateTiledBox(options: {
  22047. pattern?: number;
  22048. width?: number;
  22049. height?: number;
  22050. depth?: number;
  22051. tileSize?: number;
  22052. tileWidth?: number;
  22053. tileHeight?: number;
  22054. alignHorizontal?: number;
  22055. alignVertical?: number;
  22056. faceUV?: Vector4[];
  22057. faceColors?: Color4[];
  22058. sideOrientation?: number;
  22059. }): VertexData;
  22060. /**
  22061. * Creates the VertexData for a tiled plane
  22062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22063. * * pattern a limited pattern arrangement depending on the number
  22064. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22065. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22066. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22068. * * 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)
  22069. * * 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)
  22070. * @returns the VertexData of the tiled plane
  22071. */
  22072. static CreateTiledPlane(options: {
  22073. pattern?: number;
  22074. tileSize?: number;
  22075. tileWidth?: number;
  22076. tileHeight?: number;
  22077. size?: number;
  22078. width?: number;
  22079. height?: number;
  22080. alignHorizontal?: number;
  22081. alignVertical?: number;
  22082. sideOrientation?: number;
  22083. frontUVs?: Vector4;
  22084. backUVs?: Vector4;
  22085. }): VertexData;
  22086. /**
  22087. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22089. * * segments sets the number of horizontal strips optional, default 32
  22090. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22091. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22092. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22093. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22094. * * 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
  22095. * * 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
  22096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22097. * * 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)
  22098. * * 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)
  22099. * @returns the VertexData of the ellipsoid
  22100. */
  22101. static CreateSphere(options: {
  22102. segments?: number;
  22103. diameter?: number;
  22104. diameterX?: number;
  22105. diameterY?: number;
  22106. diameterZ?: number;
  22107. arc?: number;
  22108. slice?: number;
  22109. sideOrientation?: number;
  22110. frontUVs?: Vector4;
  22111. backUVs?: Vector4;
  22112. }): VertexData;
  22113. /**
  22114. * Creates the VertexData for a cylinder, cone or prism
  22115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22116. * * height sets the height (y direction) of the cylinder, optional, default 2
  22117. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22118. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22119. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22120. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22121. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22122. * * 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
  22123. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22125. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22126. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22128. * * 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)
  22129. * * 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)
  22130. * @returns the VertexData of the cylinder, cone or prism
  22131. */
  22132. static CreateCylinder(options: {
  22133. height?: number;
  22134. diameterTop?: number;
  22135. diameterBottom?: number;
  22136. diameter?: number;
  22137. tessellation?: number;
  22138. subdivisions?: number;
  22139. arc?: number;
  22140. faceColors?: Color4[];
  22141. faceUV?: Vector4[];
  22142. hasRings?: boolean;
  22143. enclose?: boolean;
  22144. sideOrientation?: number;
  22145. frontUVs?: Vector4;
  22146. backUVs?: Vector4;
  22147. }): VertexData;
  22148. /**
  22149. * Creates the VertexData for a torus
  22150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22151. * * diameter the diameter of the torus, optional default 1
  22152. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22153. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22155. * * 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)
  22156. * * 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)
  22157. * @returns the VertexData of the torus
  22158. */
  22159. static CreateTorus(options: {
  22160. diameter?: number;
  22161. thickness?: number;
  22162. tessellation?: number;
  22163. sideOrientation?: number;
  22164. frontUVs?: Vector4;
  22165. backUVs?: Vector4;
  22166. }): VertexData;
  22167. /**
  22168. * Creates the VertexData of the LineSystem
  22169. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22170. * - lines an array of lines, each line being an array of successive Vector3
  22171. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22172. * @returns the VertexData of the LineSystem
  22173. */
  22174. static CreateLineSystem(options: {
  22175. lines: Vector3[][];
  22176. colors?: Nullable<Color4[][]>;
  22177. }): VertexData;
  22178. /**
  22179. * Create the VertexData for a DashedLines
  22180. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22181. * - points an array successive Vector3
  22182. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22183. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22184. * - dashNb the intended total number of dashes, optional, default 200
  22185. * @returns the VertexData for the DashedLines
  22186. */
  22187. static CreateDashedLines(options: {
  22188. points: Vector3[];
  22189. dashSize?: number;
  22190. gapSize?: number;
  22191. dashNb?: number;
  22192. }): VertexData;
  22193. /**
  22194. * Creates the VertexData for a Ground
  22195. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22196. * - width the width (x direction) of the ground, optional, default 1
  22197. * - height the height (z direction) of the ground, optional, default 1
  22198. * - subdivisions the number of subdivisions per side, optional, default 1
  22199. * @returns the VertexData of the Ground
  22200. */
  22201. static CreateGround(options: {
  22202. width?: number;
  22203. height?: number;
  22204. subdivisions?: number;
  22205. subdivisionsX?: number;
  22206. subdivisionsY?: number;
  22207. }): VertexData;
  22208. /**
  22209. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22210. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22211. * * xmin the ground minimum X coordinate, optional, default -1
  22212. * * zmin the ground minimum Z coordinate, optional, default -1
  22213. * * xmax the ground maximum X coordinate, optional, default 1
  22214. * * zmax the ground maximum Z coordinate, optional, default 1
  22215. * * 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}
  22216. * * 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}
  22217. * @returns the VertexData of the TiledGround
  22218. */
  22219. static CreateTiledGround(options: {
  22220. xmin: number;
  22221. zmin: number;
  22222. xmax: number;
  22223. zmax: number;
  22224. subdivisions?: {
  22225. w: number;
  22226. h: number;
  22227. };
  22228. precision?: {
  22229. w: number;
  22230. h: number;
  22231. };
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData of the Ground designed from a heightmap
  22235. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22236. * * width the width (x direction) of the ground
  22237. * * height the height (z direction) of the ground
  22238. * * subdivisions the number of subdivisions per side
  22239. * * minHeight the minimum altitude on the ground, optional, default 0
  22240. * * maxHeight the maximum altitude on the ground, optional default 1
  22241. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22242. * * buffer the array holding the image color data
  22243. * * bufferWidth the width of image
  22244. * * bufferHeight the height of image
  22245. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22246. * @returns the VertexData of the Ground designed from a heightmap
  22247. */
  22248. static CreateGroundFromHeightMap(options: {
  22249. width: number;
  22250. height: number;
  22251. subdivisions: number;
  22252. minHeight: number;
  22253. maxHeight: number;
  22254. colorFilter: Color3;
  22255. buffer: Uint8Array;
  22256. bufferWidth: number;
  22257. bufferHeight: number;
  22258. alphaFilter: number;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a Plane
  22262. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22263. * * size sets the width and height of the plane to the value of size, optional default 1
  22264. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22265. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * @returns the VertexData of the box
  22270. */
  22271. static CreatePlane(options: {
  22272. size?: number;
  22273. width?: number;
  22274. height?: number;
  22275. sideOrientation?: number;
  22276. frontUVs?: Vector4;
  22277. backUVs?: Vector4;
  22278. }): VertexData;
  22279. /**
  22280. * Creates the VertexData of the Disc or regular Polygon
  22281. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22282. * * radius the radius of the disc, optional default 0.5
  22283. * * tessellation the number of polygon sides, optional, default 64
  22284. * * 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
  22285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22286. * * 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)
  22287. * * 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)
  22288. * @returns the VertexData of the box
  22289. */
  22290. static CreateDisc(options: {
  22291. radius?: number;
  22292. tessellation?: number;
  22293. arc?: number;
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22300. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22301. * @param polygon a mesh built from polygonTriangulation.build()
  22302. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22303. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22304. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22305. * @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)
  22306. * @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)
  22307. * @returns the VertexData of the Polygon
  22308. */
  22309. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22310. /**
  22311. * Creates the VertexData of the IcoSphere
  22312. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22313. * * radius the radius of the IcoSphere, optional default 1
  22314. * * radiusX allows stretching in the x direction, optional, default radius
  22315. * * radiusY allows stretching in the y direction, optional, default radius
  22316. * * radiusZ allows stretching in the z direction, optional, default radius
  22317. * * flat when true creates a flat shaded mesh, optional, default true
  22318. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22320. * * 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)
  22321. * * 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)
  22322. * @returns the VertexData of the IcoSphere
  22323. */
  22324. static CreateIcoSphere(options: {
  22325. radius?: number;
  22326. radiusX?: number;
  22327. radiusY?: number;
  22328. radiusZ?: number;
  22329. flat?: boolean;
  22330. subdivisions?: number;
  22331. sideOrientation?: number;
  22332. frontUVs?: Vector4;
  22333. backUVs?: Vector4;
  22334. }): VertexData;
  22335. /**
  22336. * Creates the VertexData for a Polyhedron
  22337. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22338. * * type provided types are:
  22339. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22340. * * 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)
  22341. * * size the size of the IcoSphere, optional default 1
  22342. * * sizeX allows stretching in the x direction, optional, default size
  22343. * * sizeY allows stretching in the y direction, optional, default size
  22344. * * sizeZ allows stretching in the z direction, optional, default size
  22345. * * 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
  22346. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22347. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22348. * * flat when true creates a flat shaded mesh, optional, default true
  22349. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22351. * * 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)
  22352. * * 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)
  22353. * @returns the VertexData of the Polyhedron
  22354. */
  22355. static CreatePolyhedron(options: {
  22356. type?: number;
  22357. size?: number;
  22358. sizeX?: number;
  22359. sizeY?: number;
  22360. sizeZ?: number;
  22361. custom?: any;
  22362. faceUV?: Vector4[];
  22363. faceColors?: Color4[];
  22364. flat?: boolean;
  22365. sideOrientation?: number;
  22366. frontUVs?: Vector4;
  22367. backUVs?: Vector4;
  22368. }): VertexData;
  22369. /**
  22370. * Creates the VertexData for a TorusKnot
  22371. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22372. * * radius the radius of the torus knot, optional, default 2
  22373. * * tube the thickness of the tube, optional, default 0.5
  22374. * * radialSegments the number of sides on each tube segments, optional, default 32
  22375. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22376. * * p the number of windings around the z axis, optional, default 2
  22377. * * q the number of windings around the x axis, optional, default 3
  22378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22379. * * 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)
  22380. * * 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)
  22381. * @returns the VertexData of the Torus Knot
  22382. */
  22383. static CreateTorusKnot(options: {
  22384. radius?: number;
  22385. tube?: number;
  22386. radialSegments?: number;
  22387. tubularSegments?: number;
  22388. p?: number;
  22389. q?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Compute normals for given positions and indices
  22396. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22397. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22398. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22399. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22400. * * facetNormals : optional array of facet normals (vector3)
  22401. * * facetPositions : optional array of facet positions (vector3)
  22402. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22403. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22404. * * bInfo : optional bounding info, required for facetPartitioning computation
  22405. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22406. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22407. * * useRightHandedSystem: optional boolean to for right handed system computation
  22408. * * depthSort : optional boolean to enable the facet depth sort computation
  22409. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22410. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22411. */
  22412. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22413. facetNormals?: any;
  22414. facetPositions?: any;
  22415. facetPartitioning?: any;
  22416. ratio?: number;
  22417. bInfo?: any;
  22418. bbSize?: Vector3;
  22419. subDiv?: any;
  22420. useRightHandedSystem?: boolean;
  22421. depthSort?: boolean;
  22422. distanceTo?: Vector3;
  22423. depthSortedFacets?: any;
  22424. }): void;
  22425. /** @hidden */
  22426. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22427. /**
  22428. * Applies VertexData created from the imported parameters to the geometry
  22429. * @param parsedVertexData the parsed data from an imported file
  22430. * @param geometry the geometry to apply the VertexData to
  22431. */
  22432. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22433. }
  22434. }
  22435. declare module BABYLON {
  22436. /**
  22437. * Defines a target to use with MorphTargetManager
  22438. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22439. */
  22440. export class MorphTarget implements IAnimatable {
  22441. /** defines the name of the target */
  22442. name: string;
  22443. /**
  22444. * Gets or sets the list of animations
  22445. */
  22446. animations: Animation[];
  22447. private _scene;
  22448. private _positions;
  22449. private _normals;
  22450. private _tangents;
  22451. private _uvs;
  22452. private _influence;
  22453. private _uniqueId;
  22454. /**
  22455. * Observable raised when the influence changes
  22456. */
  22457. onInfluenceChanged: Observable<boolean>;
  22458. /** @hidden */
  22459. _onDataLayoutChanged: Observable<void>;
  22460. /**
  22461. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22462. */
  22463. get influence(): number;
  22464. set influence(influence: number);
  22465. /**
  22466. * Gets or sets the id of the morph Target
  22467. */
  22468. id: string;
  22469. private _animationPropertiesOverride;
  22470. /**
  22471. * Gets or sets the animation properties override
  22472. */
  22473. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22474. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22475. /**
  22476. * Creates a new MorphTarget
  22477. * @param name defines the name of the target
  22478. * @param influence defines the influence to use
  22479. * @param scene defines the scene the morphtarget belongs to
  22480. */
  22481. constructor(
  22482. /** defines the name of the target */
  22483. name: string, influence?: number, scene?: Nullable<Scene>);
  22484. /**
  22485. * Gets the unique ID of this manager
  22486. */
  22487. get uniqueId(): number;
  22488. /**
  22489. * Gets a boolean defining if the target contains position data
  22490. */
  22491. get hasPositions(): boolean;
  22492. /**
  22493. * Gets a boolean defining if the target contains normal data
  22494. */
  22495. get hasNormals(): boolean;
  22496. /**
  22497. * Gets a boolean defining if the target contains tangent data
  22498. */
  22499. get hasTangents(): boolean;
  22500. /**
  22501. * Gets a boolean defining if the target contains texture coordinates data
  22502. */
  22503. get hasUVs(): boolean;
  22504. /**
  22505. * Affects position data to this target
  22506. * @param data defines the position data to use
  22507. */
  22508. setPositions(data: Nullable<FloatArray>): void;
  22509. /**
  22510. * Gets the position data stored in this target
  22511. * @returns a FloatArray containing the position data (or null if not present)
  22512. */
  22513. getPositions(): Nullable<FloatArray>;
  22514. /**
  22515. * Affects normal data to this target
  22516. * @param data defines the normal data to use
  22517. */
  22518. setNormals(data: Nullable<FloatArray>): void;
  22519. /**
  22520. * Gets the normal data stored in this target
  22521. * @returns a FloatArray containing the normal data (or null if not present)
  22522. */
  22523. getNormals(): Nullable<FloatArray>;
  22524. /**
  22525. * Affects tangent data to this target
  22526. * @param data defines the tangent data to use
  22527. */
  22528. setTangents(data: Nullable<FloatArray>): void;
  22529. /**
  22530. * Gets the tangent data stored in this target
  22531. * @returns a FloatArray containing the tangent data (or null if not present)
  22532. */
  22533. getTangents(): Nullable<FloatArray>;
  22534. /**
  22535. * Affects texture coordinates data to this target
  22536. * @param data defines the texture coordinates data to use
  22537. */
  22538. setUVs(data: Nullable<FloatArray>): void;
  22539. /**
  22540. * Gets the texture coordinates data stored in this target
  22541. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22542. */
  22543. getUVs(): Nullable<FloatArray>;
  22544. /**
  22545. * Clone the current target
  22546. * @returns a new MorphTarget
  22547. */
  22548. clone(): MorphTarget;
  22549. /**
  22550. * Serializes the current target into a Serialization object
  22551. * @returns the serialized object
  22552. */
  22553. serialize(): any;
  22554. /**
  22555. * Returns the string "MorphTarget"
  22556. * @returns "MorphTarget"
  22557. */
  22558. getClassName(): string;
  22559. /**
  22560. * Creates a new target from serialized data
  22561. * @param serializationObject defines the serialized data to use
  22562. * @returns a new MorphTarget
  22563. */
  22564. static Parse(serializationObject: any): MorphTarget;
  22565. /**
  22566. * Creates a MorphTarget from mesh data
  22567. * @param mesh defines the source mesh
  22568. * @param name defines the name to use for the new target
  22569. * @param influence defines the influence to attach to the target
  22570. * @returns a new MorphTarget
  22571. */
  22572. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22573. }
  22574. }
  22575. declare module BABYLON {
  22576. /**
  22577. * This class is used to deform meshes using morphing between different targets
  22578. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22579. */
  22580. export class MorphTargetManager {
  22581. private _targets;
  22582. private _targetInfluenceChangedObservers;
  22583. private _targetDataLayoutChangedObservers;
  22584. private _activeTargets;
  22585. private _scene;
  22586. private _influences;
  22587. private _supportsNormals;
  22588. private _supportsTangents;
  22589. private _supportsUVs;
  22590. private _vertexCount;
  22591. private _uniqueId;
  22592. private _tempInfluences;
  22593. /**
  22594. * Gets or sets a boolean indicating if normals must be morphed
  22595. */
  22596. enableNormalMorphing: boolean;
  22597. /**
  22598. * Gets or sets a boolean indicating if tangents must be morphed
  22599. */
  22600. enableTangentMorphing: boolean;
  22601. /**
  22602. * Gets or sets a boolean indicating if UV must be morphed
  22603. */
  22604. enableUVMorphing: boolean;
  22605. /**
  22606. * Creates a new MorphTargetManager
  22607. * @param scene defines the current scene
  22608. */
  22609. constructor(scene?: Nullable<Scene>);
  22610. /**
  22611. * Gets the unique ID of this manager
  22612. */
  22613. get uniqueId(): number;
  22614. /**
  22615. * Gets the number of vertices handled by this manager
  22616. */
  22617. get vertexCount(): number;
  22618. /**
  22619. * Gets a boolean indicating if this manager supports morphing of normals
  22620. */
  22621. get supportsNormals(): boolean;
  22622. /**
  22623. * Gets a boolean indicating if this manager supports morphing of tangents
  22624. */
  22625. get supportsTangents(): boolean;
  22626. /**
  22627. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22628. */
  22629. get supportsUVs(): boolean;
  22630. /**
  22631. * Gets the number of targets stored in this manager
  22632. */
  22633. get numTargets(): number;
  22634. /**
  22635. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22636. */
  22637. get numInfluencers(): number;
  22638. /**
  22639. * Gets the list of influences (one per target)
  22640. */
  22641. get influences(): Float32Array;
  22642. /**
  22643. * Gets the active target at specified index. An active target is a target with an influence > 0
  22644. * @param index defines the index to check
  22645. * @returns the requested target
  22646. */
  22647. getActiveTarget(index: number): MorphTarget;
  22648. /**
  22649. * Gets the target at specified index
  22650. * @param index defines the index to check
  22651. * @returns the requested target
  22652. */
  22653. getTarget(index: number): MorphTarget;
  22654. /**
  22655. * Add a new target to this manager
  22656. * @param target defines the target to add
  22657. */
  22658. addTarget(target: MorphTarget): void;
  22659. /**
  22660. * Removes a target from the manager
  22661. * @param target defines the target to remove
  22662. */
  22663. removeTarget(target: MorphTarget): void;
  22664. /**
  22665. * Clone the current manager
  22666. * @returns a new MorphTargetManager
  22667. */
  22668. clone(): MorphTargetManager;
  22669. /**
  22670. * Serializes the current manager into a Serialization object
  22671. * @returns the serialized object
  22672. */
  22673. serialize(): any;
  22674. private _syncActiveTargets;
  22675. /**
  22676. * Syncrhonize the targets with all the meshes using this morph target manager
  22677. */
  22678. synchronize(): void;
  22679. /**
  22680. * Creates a new MorphTargetManager from serialized data
  22681. * @param serializationObject defines the serialized data
  22682. * @param scene defines the hosting scene
  22683. * @returns the new MorphTargetManager
  22684. */
  22685. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22686. }
  22687. }
  22688. declare module BABYLON {
  22689. /**
  22690. * Class used to represent a specific level of detail of a mesh
  22691. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22692. */
  22693. export class MeshLODLevel {
  22694. /** Defines the distance where this level should start being displayed */
  22695. distance: number;
  22696. /** Defines the mesh to use to render this level */
  22697. mesh: Nullable<Mesh>;
  22698. /**
  22699. * Creates a new LOD level
  22700. * @param distance defines the distance where this level should star being displayed
  22701. * @param mesh defines the mesh to use to render this level
  22702. */
  22703. constructor(
  22704. /** Defines the distance where this level should start being displayed */
  22705. distance: number,
  22706. /** Defines the mesh to use to render this level */
  22707. mesh: Nullable<Mesh>);
  22708. }
  22709. }
  22710. declare module BABYLON {
  22711. /**
  22712. * Mesh representing the gorund
  22713. */
  22714. export class GroundMesh extends Mesh {
  22715. /** If octree should be generated */
  22716. generateOctree: boolean;
  22717. private _heightQuads;
  22718. /** @hidden */
  22719. _subdivisionsX: number;
  22720. /** @hidden */
  22721. _subdivisionsY: number;
  22722. /** @hidden */
  22723. _width: number;
  22724. /** @hidden */
  22725. _height: number;
  22726. /** @hidden */
  22727. _minX: number;
  22728. /** @hidden */
  22729. _maxX: number;
  22730. /** @hidden */
  22731. _minZ: number;
  22732. /** @hidden */
  22733. _maxZ: number;
  22734. constructor(name: string, scene: Scene);
  22735. /**
  22736. * "GroundMesh"
  22737. * @returns "GroundMesh"
  22738. */
  22739. getClassName(): string;
  22740. /**
  22741. * The minimum of x and y subdivisions
  22742. */
  22743. get subdivisions(): number;
  22744. /**
  22745. * X subdivisions
  22746. */
  22747. get subdivisionsX(): number;
  22748. /**
  22749. * Y subdivisions
  22750. */
  22751. get subdivisionsY(): number;
  22752. /**
  22753. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22754. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22755. * @param chunksCount the number of subdivisions for x and y
  22756. * @param octreeBlocksSize (Default: 32)
  22757. */
  22758. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22759. /**
  22760. * Returns a height (y) value in the Worl system :
  22761. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22762. * @param x x coordinate
  22763. * @param z z coordinate
  22764. * @returns the ground y position if (x, z) are outside the ground surface.
  22765. */
  22766. getHeightAtCoordinates(x: number, z: number): number;
  22767. /**
  22768. * Returns a normalized vector (Vector3) orthogonal to the ground
  22769. * at the ground coordinates (x, z) expressed in the World system.
  22770. * @param x x coordinate
  22771. * @param z z coordinate
  22772. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22773. */
  22774. getNormalAtCoordinates(x: number, z: number): Vector3;
  22775. /**
  22776. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22777. * at the ground coordinates (x, z) expressed in the World system.
  22778. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22779. * @param x x coordinate
  22780. * @param z z coordinate
  22781. * @param ref vector to store the result
  22782. * @returns the GroundMesh.
  22783. */
  22784. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22785. /**
  22786. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22787. * if the ground has been updated.
  22788. * This can be used in the render loop.
  22789. * @returns the GroundMesh.
  22790. */
  22791. updateCoordinateHeights(): GroundMesh;
  22792. private _getFacetAt;
  22793. private _initHeightQuads;
  22794. private _computeHeightQuads;
  22795. /**
  22796. * Serializes this ground mesh
  22797. * @param serializationObject object to write serialization to
  22798. */
  22799. serialize(serializationObject: any): void;
  22800. /**
  22801. * Parses a serialized ground mesh
  22802. * @param parsedMesh the serialized mesh
  22803. * @param scene the scene to create the ground mesh in
  22804. * @returns the created ground mesh
  22805. */
  22806. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22807. }
  22808. }
  22809. declare module BABYLON {
  22810. /**
  22811. * Interface for Physics-Joint data
  22812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22813. */
  22814. export interface PhysicsJointData {
  22815. /**
  22816. * The main pivot of the joint
  22817. */
  22818. mainPivot?: Vector3;
  22819. /**
  22820. * The connected pivot of the joint
  22821. */
  22822. connectedPivot?: Vector3;
  22823. /**
  22824. * The main axis of the joint
  22825. */
  22826. mainAxis?: Vector3;
  22827. /**
  22828. * The connected axis of the joint
  22829. */
  22830. connectedAxis?: Vector3;
  22831. /**
  22832. * The collision of the joint
  22833. */
  22834. collision?: boolean;
  22835. /**
  22836. * Native Oimo/Cannon/Energy data
  22837. */
  22838. nativeParams?: any;
  22839. }
  22840. /**
  22841. * This is a holder class for the physics joint created by the physics plugin
  22842. * It holds a set of functions to control the underlying joint
  22843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22844. */
  22845. export class PhysicsJoint {
  22846. /**
  22847. * The type of the physics joint
  22848. */
  22849. type: number;
  22850. /**
  22851. * The data for the physics joint
  22852. */
  22853. jointData: PhysicsJointData;
  22854. private _physicsJoint;
  22855. protected _physicsPlugin: IPhysicsEnginePlugin;
  22856. /**
  22857. * Initializes the physics joint
  22858. * @param type The type of the physics joint
  22859. * @param jointData The data for the physics joint
  22860. */
  22861. constructor(
  22862. /**
  22863. * The type of the physics joint
  22864. */
  22865. type: number,
  22866. /**
  22867. * The data for the physics joint
  22868. */
  22869. jointData: PhysicsJointData);
  22870. /**
  22871. * Gets the physics joint
  22872. */
  22873. get physicsJoint(): any;
  22874. /**
  22875. * Sets the physics joint
  22876. */
  22877. set physicsJoint(newJoint: any);
  22878. /**
  22879. * Sets the physics plugin
  22880. */
  22881. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22882. /**
  22883. * Execute a function that is physics-plugin specific.
  22884. * @param {Function} func the function that will be executed.
  22885. * It accepts two parameters: the physics world and the physics joint
  22886. */
  22887. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22888. /**
  22889. * Distance-Joint type
  22890. */
  22891. static DistanceJoint: number;
  22892. /**
  22893. * Hinge-Joint type
  22894. */
  22895. static HingeJoint: number;
  22896. /**
  22897. * Ball-and-Socket joint type
  22898. */
  22899. static BallAndSocketJoint: number;
  22900. /**
  22901. * Wheel-Joint type
  22902. */
  22903. static WheelJoint: number;
  22904. /**
  22905. * Slider-Joint type
  22906. */
  22907. static SliderJoint: number;
  22908. /**
  22909. * Prismatic-Joint type
  22910. */
  22911. static PrismaticJoint: number;
  22912. /**
  22913. * Universal-Joint type
  22914. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22915. */
  22916. static UniversalJoint: number;
  22917. /**
  22918. * Hinge-Joint 2 type
  22919. */
  22920. static Hinge2Joint: number;
  22921. /**
  22922. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22923. */
  22924. static PointToPointJoint: number;
  22925. /**
  22926. * Spring-Joint type
  22927. */
  22928. static SpringJoint: number;
  22929. /**
  22930. * Lock-Joint type
  22931. */
  22932. static LockJoint: number;
  22933. }
  22934. /**
  22935. * A class representing a physics distance joint
  22936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22937. */
  22938. export class DistanceJoint extends PhysicsJoint {
  22939. /**
  22940. *
  22941. * @param jointData The data for the Distance-Joint
  22942. */
  22943. constructor(jointData: DistanceJointData);
  22944. /**
  22945. * Update the predefined distance.
  22946. * @param maxDistance The maximum preferred distance
  22947. * @param minDistance The minimum preferred distance
  22948. */
  22949. updateDistance(maxDistance: number, minDistance?: number): void;
  22950. }
  22951. /**
  22952. * Represents a Motor-Enabled Joint
  22953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22954. */
  22955. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22956. /**
  22957. * Initializes the Motor-Enabled Joint
  22958. * @param type The type of the joint
  22959. * @param jointData The physica joint data for the joint
  22960. */
  22961. constructor(type: number, jointData: PhysicsJointData);
  22962. /**
  22963. * Set the motor values.
  22964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22965. * @param force the force to apply
  22966. * @param maxForce max force for this motor.
  22967. */
  22968. setMotor(force?: number, maxForce?: number): void;
  22969. /**
  22970. * Set the motor's limits.
  22971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22972. * @param upperLimit The upper limit of the motor
  22973. * @param lowerLimit The lower limit of the motor
  22974. */
  22975. setLimit(upperLimit: number, lowerLimit?: number): void;
  22976. }
  22977. /**
  22978. * This class represents a single physics Hinge-Joint
  22979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22980. */
  22981. export class HingeJoint extends MotorEnabledJoint {
  22982. /**
  22983. * Initializes the Hinge-Joint
  22984. * @param jointData The joint data for the Hinge-Joint
  22985. */
  22986. constructor(jointData: PhysicsJointData);
  22987. /**
  22988. * Set the motor values.
  22989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22990. * @param {number} force the force to apply
  22991. * @param {number} maxForce max force for this motor.
  22992. */
  22993. setMotor(force?: number, maxForce?: number): void;
  22994. /**
  22995. * Set the motor's limits.
  22996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22997. * @param upperLimit The upper limit of the motor
  22998. * @param lowerLimit The lower limit of the motor
  22999. */
  23000. setLimit(upperLimit: number, lowerLimit?: number): void;
  23001. }
  23002. /**
  23003. * This class represents a dual hinge physics joint (same as wheel joint)
  23004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23005. */
  23006. export class Hinge2Joint extends MotorEnabledJoint {
  23007. /**
  23008. * Initializes the Hinge2-Joint
  23009. * @param jointData The joint data for the Hinge2-Joint
  23010. */
  23011. constructor(jointData: PhysicsJointData);
  23012. /**
  23013. * Set the motor values.
  23014. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23015. * @param {number} targetSpeed the speed the motor is to reach
  23016. * @param {number} maxForce max force for this motor.
  23017. * @param {motorIndex} the motor's index, 0 or 1.
  23018. */
  23019. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23020. /**
  23021. * Set the motor limits.
  23022. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23023. * @param {number} upperLimit the upper limit
  23024. * @param {number} lowerLimit lower limit
  23025. * @param {motorIndex} the motor's index, 0 or 1.
  23026. */
  23027. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23028. }
  23029. /**
  23030. * Interface for a motor enabled joint
  23031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23032. */
  23033. export interface IMotorEnabledJoint {
  23034. /**
  23035. * Physics joint
  23036. */
  23037. physicsJoint: any;
  23038. /**
  23039. * Sets the motor of the motor-enabled joint
  23040. * @param force The force of the motor
  23041. * @param maxForce The maximum force of the motor
  23042. * @param motorIndex The index of the motor
  23043. */
  23044. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23045. /**
  23046. * Sets the limit of the motor
  23047. * @param upperLimit The upper limit of the motor
  23048. * @param lowerLimit The lower limit of the motor
  23049. * @param motorIndex The index of the motor
  23050. */
  23051. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23052. }
  23053. /**
  23054. * Joint data for a Distance-Joint
  23055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23056. */
  23057. export interface DistanceJointData extends PhysicsJointData {
  23058. /**
  23059. * Max distance the 2 joint objects can be apart
  23060. */
  23061. maxDistance: number;
  23062. }
  23063. /**
  23064. * Joint data from a spring joint
  23065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23066. */
  23067. export interface SpringJointData extends PhysicsJointData {
  23068. /**
  23069. * Length of the spring
  23070. */
  23071. length: number;
  23072. /**
  23073. * Stiffness of the spring
  23074. */
  23075. stiffness: number;
  23076. /**
  23077. * Damping of the spring
  23078. */
  23079. damping: number;
  23080. /** this callback will be called when applying the force to the impostors. */
  23081. forceApplicationCallback: () => void;
  23082. }
  23083. }
  23084. declare module BABYLON {
  23085. /**
  23086. * Holds the data for the raycast result
  23087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23088. */
  23089. export class PhysicsRaycastResult {
  23090. private _hasHit;
  23091. private _hitDistance;
  23092. private _hitNormalWorld;
  23093. private _hitPointWorld;
  23094. private _rayFromWorld;
  23095. private _rayToWorld;
  23096. /**
  23097. * Gets if there was a hit
  23098. */
  23099. get hasHit(): boolean;
  23100. /**
  23101. * Gets the distance from the hit
  23102. */
  23103. get hitDistance(): number;
  23104. /**
  23105. * Gets the hit normal/direction in the world
  23106. */
  23107. get hitNormalWorld(): Vector3;
  23108. /**
  23109. * Gets the hit point in the world
  23110. */
  23111. get hitPointWorld(): Vector3;
  23112. /**
  23113. * Gets the ray "start point" of the ray in the world
  23114. */
  23115. get rayFromWorld(): Vector3;
  23116. /**
  23117. * Gets the ray "end point" of the ray in the world
  23118. */
  23119. get rayToWorld(): Vector3;
  23120. /**
  23121. * Sets the hit data (normal & point in world space)
  23122. * @param hitNormalWorld defines the normal in world space
  23123. * @param hitPointWorld defines the point in world space
  23124. */
  23125. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23126. /**
  23127. * Sets the distance from the start point to the hit point
  23128. * @param distance
  23129. */
  23130. setHitDistance(distance: number): void;
  23131. /**
  23132. * Calculates the distance manually
  23133. */
  23134. calculateHitDistance(): void;
  23135. /**
  23136. * Resets all the values to default
  23137. * @param from The from point on world space
  23138. * @param to The to point on world space
  23139. */
  23140. reset(from?: Vector3, to?: Vector3): void;
  23141. }
  23142. /**
  23143. * Interface for the size containing width and height
  23144. */
  23145. interface IXYZ {
  23146. /**
  23147. * X
  23148. */
  23149. x: number;
  23150. /**
  23151. * Y
  23152. */
  23153. y: number;
  23154. /**
  23155. * Z
  23156. */
  23157. z: number;
  23158. }
  23159. }
  23160. declare module BABYLON {
  23161. /**
  23162. * Interface used to describe a physics joint
  23163. */
  23164. export interface PhysicsImpostorJoint {
  23165. /** Defines the main impostor to which the joint is linked */
  23166. mainImpostor: PhysicsImpostor;
  23167. /** Defines the impostor that is connected to the main impostor using this joint */
  23168. connectedImpostor: PhysicsImpostor;
  23169. /** Defines the joint itself */
  23170. joint: PhysicsJoint;
  23171. }
  23172. /** @hidden */
  23173. export interface IPhysicsEnginePlugin {
  23174. world: any;
  23175. name: string;
  23176. setGravity(gravity: Vector3): void;
  23177. setTimeStep(timeStep: number): void;
  23178. getTimeStep(): number;
  23179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23180. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23181. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23182. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23183. removePhysicsBody(impostor: PhysicsImpostor): void;
  23184. generateJoint(joint: PhysicsImpostorJoint): void;
  23185. removeJoint(joint: PhysicsImpostorJoint): void;
  23186. isSupported(): boolean;
  23187. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23189. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23190. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23191. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23192. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23193. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23194. getBodyMass(impostor: PhysicsImpostor): number;
  23195. getBodyFriction(impostor: PhysicsImpostor): number;
  23196. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23197. getBodyRestitution(impostor: PhysicsImpostor): number;
  23198. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23199. getBodyPressure?(impostor: PhysicsImpostor): number;
  23200. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23201. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23202. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23203. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23204. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23205. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23206. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23207. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23208. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23209. sleepBody(impostor: PhysicsImpostor): void;
  23210. wakeUpBody(impostor: PhysicsImpostor): void;
  23211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23212. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23213. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23214. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23215. getRadius(impostor: PhysicsImpostor): number;
  23216. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23217. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23218. dispose(): void;
  23219. }
  23220. /**
  23221. * Interface used to define a physics engine
  23222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23223. */
  23224. export interface IPhysicsEngine {
  23225. /**
  23226. * Gets the gravity vector used by the simulation
  23227. */
  23228. gravity: Vector3;
  23229. /**
  23230. * Sets the gravity vector used by the simulation
  23231. * @param gravity defines the gravity vector to use
  23232. */
  23233. setGravity(gravity: Vector3): void;
  23234. /**
  23235. * Set the time step of the physics engine.
  23236. * Default is 1/60.
  23237. * To slow it down, enter 1/600 for example.
  23238. * To speed it up, 1/30
  23239. * @param newTimeStep the new timestep to apply to this world.
  23240. */
  23241. setTimeStep(newTimeStep: number): void;
  23242. /**
  23243. * Get the time step of the physics engine.
  23244. * @returns the current time step
  23245. */
  23246. getTimeStep(): number;
  23247. /**
  23248. * Set the sub time step of the physics engine.
  23249. * Default is 0 meaning there is no sub steps
  23250. * To increase physics resolution precision, set a small value (like 1 ms)
  23251. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23252. */
  23253. setSubTimeStep(subTimeStep: number): void;
  23254. /**
  23255. * Get the sub time step of the physics engine.
  23256. * @returns the current sub time step
  23257. */
  23258. getSubTimeStep(): number;
  23259. /**
  23260. * Release all resources
  23261. */
  23262. dispose(): void;
  23263. /**
  23264. * Gets the name of the current physics plugin
  23265. * @returns the name of the plugin
  23266. */
  23267. getPhysicsPluginName(): string;
  23268. /**
  23269. * Adding a new impostor for the impostor tracking.
  23270. * This will be done by the impostor itself.
  23271. * @param impostor the impostor to add
  23272. */
  23273. addImpostor(impostor: PhysicsImpostor): void;
  23274. /**
  23275. * Remove an impostor from the engine.
  23276. * This impostor and its mesh will not longer be updated by the physics engine.
  23277. * @param impostor the impostor to remove
  23278. */
  23279. removeImpostor(impostor: PhysicsImpostor): void;
  23280. /**
  23281. * Add a joint to the physics engine
  23282. * @param mainImpostor defines the main impostor to which the joint is added.
  23283. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23284. * @param joint defines the joint that will connect both impostors.
  23285. */
  23286. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23287. /**
  23288. * Removes a joint from the simulation
  23289. * @param mainImpostor defines the impostor used with the joint
  23290. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23291. * @param joint defines the joint to remove
  23292. */
  23293. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23294. /**
  23295. * Gets the current plugin used to run the simulation
  23296. * @returns current plugin
  23297. */
  23298. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23299. /**
  23300. * Gets the list of physic impostors
  23301. * @returns an array of PhysicsImpostor
  23302. */
  23303. getImpostors(): Array<PhysicsImpostor>;
  23304. /**
  23305. * Gets the impostor for a physics enabled object
  23306. * @param object defines the object impersonated by the impostor
  23307. * @returns the PhysicsImpostor or null if not found
  23308. */
  23309. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23310. /**
  23311. * Gets the impostor for a physics body object
  23312. * @param body defines physics body used by the impostor
  23313. * @returns the PhysicsImpostor or null if not found
  23314. */
  23315. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23316. /**
  23317. * Does a raycast in the physics world
  23318. * @param from when should the ray start?
  23319. * @param to when should the ray end?
  23320. * @returns PhysicsRaycastResult
  23321. */
  23322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23323. /**
  23324. * Called by the scene. No need to call it.
  23325. * @param delta defines the timespam between frames
  23326. */
  23327. _step(delta: number): void;
  23328. }
  23329. }
  23330. declare module BABYLON {
  23331. /**
  23332. * The interface for the physics imposter parameters
  23333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23334. */
  23335. export interface PhysicsImpostorParameters {
  23336. /**
  23337. * The mass of the physics imposter
  23338. */
  23339. mass: number;
  23340. /**
  23341. * The friction of the physics imposter
  23342. */
  23343. friction?: number;
  23344. /**
  23345. * The coefficient of restitution of the physics imposter
  23346. */
  23347. restitution?: number;
  23348. /**
  23349. * The native options of the physics imposter
  23350. */
  23351. nativeOptions?: any;
  23352. /**
  23353. * Specifies if the parent should be ignored
  23354. */
  23355. ignoreParent?: boolean;
  23356. /**
  23357. * Specifies if bi-directional transformations should be disabled
  23358. */
  23359. disableBidirectionalTransformation?: boolean;
  23360. /**
  23361. * The pressure inside the physics imposter, soft object only
  23362. */
  23363. pressure?: number;
  23364. /**
  23365. * The stiffness the physics imposter, soft object only
  23366. */
  23367. stiffness?: number;
  23368. /**
  23369. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23370. */
  23371. velocityIterations?: number;
  23372. /**
  23373. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23374. */
  23375. positionIterations?: number;
  23376. /**
  23377. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23378. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23379. * Add to fix multiple points
  23380. */
  23381. fixedPoints?: number;
  23382. /**
  23383. * The collision margin around a soft object
  23384. */
  23385. margin?: number;
  23386. /**
  23387. * The collision margin around a soft object
  23388. */
  23389. damping?: number;
  23390. /**
  23391. * The path for a rope based on an extrusion
  23392. */
  23393. path?: any;
  23394. /**
  23395. * The shape of an extrusion used for a rope based on an extrusion
  23396. */
  23397. shape?: any;
  23398. }
  23399. /**
  23400. * Interface for a physics-enabled object
  23401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23402. */
  23403. export interface IPhysicsEnabledObject {
  23404. /**
  23405. * The position of the physics-enabled object
  23406. */
  23407. position: Vector3;
  23408. /**
  23409. * The rotation of the physics-enabled object
  23410. */
  23411. rotationQuaternion: Nullable<Quaternion>;
  23412. /**
  23413. * The scale of the physics-enabled object
  23414. */
  23415. scaling: Vector3;
  23416. /**
  23417. * The rotation of the physics-enabled object
  23418. */
  23419. rotation?: Vector3;
  23420. /**
  23421. * The parent of the physics-enabled object
  23422. */
  23423. parent?: any;
  23424. /**
  23425. * The bounding info of the physics-enabled object
  23426. * @returns The bounding info of the physics-enabled object
  23427. */
  23428. getBoundingInfo(): BoundingInfo;
  23429. /**
  23430. * Computes the world matrix
  23431. * @param force Specifies if the world matrix should be computed by force
  23432. * @returns A world matrix
  23433. */
  23434. computeWorldMatrix(force: boolean): Matrix;
  23435. /**
  23436. * Gets the world matrix
  23437. * @returns A world matrix
  23438. */
  23439. getWorldMatrix?(): Matrix;
  23440. /**
  23441. * Gets the child meshes
  23442. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23443. * @returns An array of abstract meshes
  23444. */
  23445. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23446. /**
  23447. * Gets the vertex data
  23448. * @param kind The type of vertex data
  23449. * @returns A nullable array of numbers, or a float32 array
  23450. */
  23451. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23452. /**
  23453. * Gets the indices from the mesh
  23454. * @returns A nullable array of index arrays
  23455. */
  23456. getIndices?(): Nullable<IndicesArray>;
  23457. /**
  23458. * Gets the scene from the mesh
  23459. * @returns the indices array or null
  23460. */
  23461. getScene?(): Scene;
  23462. /**
  23463. * Gets the absolute position from the mesh
  23464. * @returns the absolute position
  23465. */
  23466. getAbsolutePosition(): Vector3;
  23467. /**
  23468. * Gets the absolute pivot point from the mesh
  23469. * @returns the absolute pivot point
  23470. */
  23471. getAbsolutePivotPoint(): Vector3;
  23472. /**
  23473. * Rotates the mesh
  23474. * @param axis The axis of rotation
  23475. * @param amount The amount of rotation
  23476. * @param space The space of the rotation
  23477. * @returns The rotation transform node
  23478. */
  23479. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23480. /**
  23481. * Translates the mesh
  23482. * @param axis The axis of translation
  23483. * @param distance The distance of translation
  23484. * @param space The space of the translation
  23485. * @returns The transform node
  23486. */
  23487. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23488. /**
  23489. * Sets the absolute position of the mesh
  23490. * @param absolutePosition The absolute position of the mesh
  23491. * @returns The transform node
  23492. */
  23493. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23494. /**
  23495. * Gets the class name of the mesh
  23496. * @returns The class name
  23497. */
  23498. getClassName(): string;
  23499. }
  23500. /**
  23501. * Represents a physics imposter
  23502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23503. */
  23504. export class PhysicsImpostor {
  23505. /**
  23506. * The physics-enabled object used as the physics imposter
  23507. */
  23508. object: IPhysicsEnabledObject;
  23509. /**
  23510. * The type of the physics imposter
  23511. */
  23512. type: number;
  23513. private _options;
  23514. private _scene?;
  23515. /**
  23516. * The default object size of the imposter
  23517. */
  23518. static DEFAULT_OBJECT_SIZE: Vector3;
  23519. /**
  23520. * The identity quaternion of the imposter
  23521. */
  23522. static IDENTITY_QUATERNION: Quaternion;
  23523. /** @hidden */
  23524. _pluginData: any;
  23525. private _physicsEngine;
  23526. private _physicsBody;
  23527. private _bodyUpdateRequired;
  23528. private _onBeforePhysicsStepCallbacks;
  23529. private _onAfterPhysicsStepCallbacks;
  23530. /** @hidden */
  23531. _onPhysicsCollideCallbacks: Array<{
  23532. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23533. otherImpostors: Array<PhysicsImpostor>;
  23534. }>;
  23535. private _deltaPosition;
  23536. private _deltaRotation;
  23537. private _deltaRotationConjugated;
  23538. /** @hidden */
  23539. _isFromLine: boolean;
  23540. private _parent;
  23541. private _isDisposed;
  23542. private static _tmpVecs;
  23543. private static _tmpQuat;
  23544. /**
  23545. * Specifies if the physics imposter is disposed
  23546. */
  23547. get isDisposed(): boolean;
  23548. /**
  23549. * Gets the mass of the physics imposter
  23550. */
  23551. get mass(): number;
  23552. set mass(value: number);
  23553. /**
  23554. * Gets the coefficient of friction
  23555. */
  23556. get friction(): number;
  23557. /**
  23558. * Sets the coefficient of friction
  23559. */
  23560. set friction(value: number);
  23561. /**
  23562. * Gets the coefficient of restitution
  23563. */
  23564. get restitution(): number;
  23565. /**
  23566. * Sets the coefficient of restitution
  23567. */
  23568. set restitution(value: number);
  23569. /**
  23570. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23571. */
  23572. get pressure(): number;
  23573. /**
  23574. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23575. */
  23576. set pressure(value: number);
  23577. /**
  23578. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23579. */
  23580. get stiffness(): number;
  23581. /**
  23582. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23583. */
  23584. set stiffness(value: number);
  23585. /**
  23586. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23587. */
  23588. get velocityIterations(): number;
  23589. /**
  23590. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23591. */
  23592. set velocityIterations(value: number);
  23593. /**
  23594. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23595. */
  23596. get positionIterations(): number;
  23597. /**
  23598. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23599. */
  23600. set positionIterations(value: number);
  23601. /**
  23602. * The unique id of the physics imposter
  23603. * set by the physics engine when adding this impostor to the array
  23604. */
  23605. uniqueId: number;
  23606. /**
  23607. * @hidden
  23608. */
  23609. soft: boolean;
  23610. /**
  23611. * @hidden
  23612. */
  23613. segments: number;
  23614. private _joints;
  23615. /**
  23616. * Initializes the physics imposter
  23617. * @param object The physics-enabled object used as the physics imposter
  23618. * @param type The type of the physics imposter
  23619. * @param _options The options for the physics imposter
  23620. * @param _scene The Babylon scene
  23621. */
  23622. constructor(
  23623. /**
  23624. * The physics-enabled object used as the physics imposter
  23625. */
  23626. object: IPhysicsEnabledObject,
  23627. /**
  23628. * The type of the physics imposter
  23629. */
  23630. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23631. /**
  23632. * This function will completly initialize this impostor.
  23633. * It will create a new body - but only if this mesh has no parent.
  23634. * If it has, this impostor will not be used other than to define the impostor
  23635. * of the child mesh.
  23636. * @hidden
  23637. */
  23638. _init(): void;
  23639. private _getPhysicsParent;
  23640. /**
  23641. * Should a new body be generated.
  23642. * @returns boolean specifying if body initialization is required
  23643. */
  23644. isBodyInitRequired(): boolean;
  23645. /**
  23646. * Sets the updated scaling
  23647. * @param updated Specifies if the scaling is updated
  23648. */
  23649. setScalingUpdated(): void;
  23650. /**
  23651. * Force a regeneration of this or the parent's impostor's body.
  23652. * Use under cautious - This will remove all joints already implemented.
  23653. */
  23654. forceUpdate(): void;
  23655. /**
  23656. * Gets the body that holds this impostor. Either its own, or its parent.
  23657. */
  23658. get physicsBody(): any;
  23659. /**
  23660. * Get the parent of the physics imposter
  23661. * @returns Physics imposter or null
  23662. */
  23663. get parent(): Nullable<PhysicsImpostor>;
  23664. /**
  23665. * Sets the parent of the physics imposter
  23666. */
  23667. set parent(value: Nullable<PhysicsImpostor>);
  23668. /**
  23669. * Set the physics body. Used mainly by the physics engine/plugin
  23670. */
  23671. set physicsBody(physicsBody: any);
  23672. /**
  23673. * Resets the update flags
  23674. */
  23675. resetUpdateFlags(): void;
  23676. /**
  23677. * Gets the object extend size
  23678. * @returns the object extend size
  23679. */
  23680. getObjectExtendSize(): Vector3;
  23681. /**
  23682. * Gets the object center
  23683. * @returns The object center
  23684. */
  23685. getObjectCenter(): Vector3;
  23686. /**
  23687. * Get a specific parametes from the options parameter
  23688. * @param paramName The object parameter name
  23689. * @returns The object parameter
  23690. */
  23691. getParam(paramName: string): any;
  23692. /**
  23693. * Sets a specific parameter in the options given to the physics plugin
  23694. * @param paramName The parameter name
  23695. * @param value The value of the parameter
  23696. */
  23697. setParam(paramName: string, value: number): void;
  23698. /**
  23699. * Specifically change the body's mass option. Won't recreate the physics body object
  23700. * @param mass The mass of the physics imposter
  23701. */
  23702. setMass(mass: number): void;
  23703. /**
  23704. * Gets the linear velocity
  23705. * @returns linear velocity or null
  23706. */
  23707. getLinearVelocity(): Nullable<Vector3>;
  23708. /**
  23709. * Sets the linear velocity
  23710. * @param velocity linear velocity or null
  23711. */
  23712. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23713. /**
  23714. * Gets the angular velocity
  23715. * @returns angular velocity or null
  23716. */
  23717. getAngularVelocity(): Nullable<Vector3>;
  23718. /**
  23719. * Sets the angular velocity
  23720. * @param velocity The velocity or null
  23721. */
  23722. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23723. /**
  23724. * Execute a function with the physics plugin native code
  23725. * Provide a function the will have two variables - the world object and the physics body object
  23726. * @param func The function to execute with the physics plugin native code
  23727. */
  23728. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23729. /**
  23730. * Register a function that will be executed before the physics world is stepping forward
  23731. * @param func The function to execute before the physics world is stepped forward
  23732. */
  23733. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23734. /**
  23735. * Unregister a function that will be executed before the physics world is stepping forward
  23736. * @param func The function to execute before the physics world is stepped forward
  23737. */
  23738. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23739. /**
  23740. * Register a function that will be executed after the physics step
  23741. * @param func The function to execute after physics step
  23742. */
  23743. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23744. /**
  23745. * Unregisters a function that will be executed after the physics step
  23746. * @param func The function to execute after physics step
  23747. */
  23748. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23749. /**
  23750. * register a function that will be executed when this impostor collides against a different body
  23751. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23752. * @param func Callback that is executed on collision
  23753. */
  23754. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23755. /**
  23756. * Unregisters the physics imposter on contact
  23757. * @param collideAgainst The physics object to collide against
  23758. * @param func Callback to execute on collision
  23759. */
  23760. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23761. private _tmpQuat;
  23762. private _tmpQuat2;
  23763. /**
  23764. * Get the parent rotation
  23765. * @returns The parent rotation
  23766. */
  23767. getParentsRotation(): Quaternion;
  23768. /**
  23769. * this function is executed by the physics engine.
  23770. */
  23771. beforeStep: () => void;
  23772. /**
  23773. * this function is executed by the physics engine
  23774. */
  23775. afterStep: () => void;
  23776. /**
  23777. * Legacy collision detection event support
  23778. */
  23779. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23780. /**
  23781. * event and body object due to cannon's event-based architecture.
  23782. */
  23783. onCollide: (e: {
  23784. body: any;
  23785. }) => void;
  23786. /**
  23787. * Apply a force
  23788. * @param force The force to apply
  23789. * @param contactPoint The contact point for the force
  23790. * @returns The physics imposter
  23791. */
  23792. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23793. /**
  23794. * Apply an impulse
  23795. * @param force The impulse force
  23796. * @param contactPoint The contact point for the impulse force
  23797. * @returns The physics imposter
  23798. */
  23799. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23800. /**
  23801. * A help function to create a joint
  23802. * @param otherImpostor A physics imposter used to create a joint
  23803. * @param jointType The type of joint
  23804. * @param jointData The data for the joint
  23805. * @returns The physics imposter
  23806. */
  23807. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23808. /**
  23809. * Add a joint to this impostor with a different impostor
  23810. * @param otherImpostor A physics imposter used to add a joint
  23811. * @param joint The joint to add
  23812. * @returns The physics imposter
  23813. */
  23814. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23815. /**
  23816. * Add an anchor to a cloth impostor
  23817. * @param otherImpostor rigid impostor to anchor to
  23818. * @param width ratio across width from 0 to 1
  23819. * @param height ratio up height from 0 to 1
  23820. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23821. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23822. * @returns impostor the soft imposter
  23823. */
  23824. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23825. /**
  23826. * Add a hook to a rope impostor
  23827. * @param otherImpostor rigid impostor to anchor to
  23828. * @param length ratio across rope from 0 to 1
  23829. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23830. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23831. * @returns impostor the rope imposter
  23832. */
  23833. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23834. /**
  23835. * Will keep this body still, in a sleep mode.
  23836. * @returns the physics imposter
  23837. */
  23838. sleep(): PhysicsImpostor;
  23839. /**
  23840. * Wake the body up.
  23841. * @returns The physics imposter
  23842. */
  23843. wakeUp(): PhysicsImpostor;
  23844. /**
  23845. * Clones the physics imposter
  23846. * @param newObject The physics imposter clones to this physics-enabled object
  23847. * @returns A nullable physics imposter
  23848. */
  23849. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23850. /**
  23851. * Disposes the physics imposter
  23852. */
  23853. dispose(): void;
  23854. /**
  23855. * Sets the delta position
  23856. * @param position The delta position amount
  23857. */
  23858. setDeltaPosition(position: Vector3): void;
  23859. /**
  23860. * Sets the delta rotation
  23861. * @param rotation The delta rotation amount
  23862. */
  23863. setDeltaRotation(rotation: Quaternion): void;
  23864. /**
  23865. * Gets the box size of the physics imposter and stores the result in the input parameter
  23866. * @param result Stores the box size
  23867. * @returns The physics imposter
  23868. */
  23869. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23870. /**
  23871. * Gets the radius of the physics imposter
  23872. * @returns Radius of the physics imposter
  23873. */
  23874. getRadius(): number;
  23875. /**
  23876. * Sync a bone with this impostor
  23877. * @param bone The bone to sync to the impostor.
  23878. * @param boneMesh The mesh that the bone is influencing.
  23879. * @param jointPivot The pivot of the joint / bone in local space.
  23880. * @param distToJoint Optional distance from the impostor to the joint.
  23881. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23882. */
  23883. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23884. /**
  23885. * Sync impostor to a bone
  23886. * @param bone The bone that the impostor will be synced to.
  23887. * @param boneMesh The mesh that the bone is influencing.
  23888. * @param jointPivot The pivot of the joint / bone in local space.
  23889. * @param distToJoint Optional distance from the impostor to the joint.
  23890. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23891. * @param boneAxis Optional vector3 axis the bone is aligned with
  23892. */
  23893. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23894. /**
  23895. * No-Imposter type
  23896. */
  23897. static NoImpostor: number;
  23898. /**
  23899. * Sphere-Imposter type
  23900. */
  23901. static SphereImpostor: number;
  23902. /**
  23903. * Box-Imposter type
  23904. */
  23905. static BoxImpostor: number;
  23906. /**
  23907. * Plane-Imposter type
  23908. */
  23909. static PlaneImpostor: number;
  23910. /**
  23911. * Mesh-imposter type
  23912. */
  23913. static MeshImpostor: number;
  23914. /**
  23915. * Capsule-Impostor type (Ammo.js plugin only)
  23916. */
  23917. static CapsuleImpostor: number;
  23918. /**
  23919. * Cylinder-Imposter type
  23920. */
  23921. static CylinderImpostor: number;
  23922. /**
  23923. * Particle-Imposter type
  23924. */
  23925. static ParticleImpostor: number;
  23926. /**
  23927. * Heightmap-Imposter type
  23928. */
  23929. static HeightmapImpostor: number;
  23930. /**
  23931. * ConvexHull-Impostor type (Ammo.js plugin only)
  23932. */
  23933. static ConvexHullImpostor: number;
  23934. /**
  23935. * Custom-Imposter type (Ammo.js plugin only)
  23936. */
  23937. static CustomImpostor: number;
  23938. /**
  23939. * Rope-Imposter type
  23940. */
  23941. static RopeImpostor: number;
  23942. /**
  23943. * Cloth-Imposter type
  23944. */
  23945. static ClothImpostor: number;
  23946. /**
  23947. * Softbody-Imposter type
  23948. */
  23949. static SoftbodyImpostor: number;
  23950. }
  23951. }
  23952. declare module BABYLON {
  23953. /**
  23954. * @hidden
  23955. **/
  23956. export class _CreationDataStorage {
  23957. closePath?: boolean;
  23958. closeArray?: boolean;
  23959. idx: number[];
  23960. dashSize: number;
  23961. gapSize: number;
  23962. path3D: Path3D;
  23963. pathArray: Vector3[][];
  23964. arc: number;
  23965. radius: number;
  23966. cap: number;
  23967. tessellation: number;
  23968. }
  23969. /**
  23970. * @hidden
  23971. **/
  23972. class _InstanceDataStorage {
  23973. visibleInstances: any;
  23974. batchCache: _InstancesBatch;
  23975. instancesBufferSize: number;
  23976. instancesBuffer: Nullable<Buffer>;
  23977. instancesData: Float32Array;
  23978. overridenInstanceCount: number;
  23979. isFrozen: boolean;
  23980. previousBatch: Nullable<_InstancesBatch>;
  23981. hardwareInstancedRendering: boolean;
  23982. sideOrientation: number;
  23983. manualUpdate: boolean;
  23984. }
  23985. /**
  23986. * @hidden
  23987. **/
  23988. export class _InstancesBatch {
  23989. mustReturn: boolean;
  23990. visibleInstances: Nullable<InstancedMesh[]>[];
  23991. renderSelf: boolean[];
  23992. hardwareInstancedRendering: boolean[];
  23993. }
  23994. /**
  23995. * Class used to represent renderable models
  23996. */
  23997. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23998. /**
  23999. * Mesh side orientation : usually the external or front surface
  24000. */
  24001. static readonly FRONTSIDE: number;
  24002. /**
  24003. * Mesh side orientation : usually the internal or back surface
  24004. */
  24005. static readonly BACKSIDE: number;
  24006. /**
  24007. * Mesh side orientation : both internal and external or front and back surfaces
  24008. */
  24009. static readonly DOUBLESIDE: number;
  24010. /**
  24011. * Mesh side orientation : by default, `FRONTSIDE`
  24012. */
  24013. static readonly DEFAULTSIDE: number;
  24014. /**
  24015. * Mesh cap setting : no cap
  24016. */
  24017. static readonly NO_CAP: number;
  24018. /**
  24019. * Mesh cap setting : one cap at the beginning of the mesh
  24020. */
  24021. static readonly CAP_START: number;
  24022. /**
  24023. * Mesh cap setting : one cap at the end of the mesh
  24024. */
  24025. static readonly CAP_END: number;
  24026. /**
  24027. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24028. */
  24029. static readonly CAP_ALL: number;
  24030. /**
  24031. * Mesh pattern setting : no flip or rotate
  24032. */
  24033. static readonly NO_FLIP: number;
  24034. /**
  24035. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24036. */
  24037. static readonly FLIP_TILE: number;
  24038. /**
  24039. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24040. */
  24041. static readonly ROTATE_TILE: number;
  24042. /**
  24043. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24044. */
  24045. static readonly FLIP_ROW: number;
  24046. /**
  24047. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24048. */
  24049. static readonly ROTATE_ROW: number;
  24050. /**
  24051. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24052. */
  24053. static readonly FLIP_N_ROTATE_TILE: number;
  24054. /**
  24055. * Mesh pattern setting : rotate pattern and rotate
  24056. */
  24057. static readonly FLIP_N_ROTATE_ROW: number;
  24058. /**
  24059. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24060. */
  24061. static readonly CENTER: number;
  24062. /**
  24063. * Mesh tile positioning : part tiles on left
  24064. */
  24065. static readonly LEFT: number;
  24066. /**
  24067. * Mesh tile positioning : part tiles on right
  24068. */
  24069. static readonly RIGHT: number;
  24070. /**
  24071. * Mesh tile positioning : part tiles on top
  24072. */
  24073. static readonly TOP: number;
  24074. /**
  24075. * Mesh tile positioning : part tiles on bottom
  24076. */
  24077. static readonly BOTTOM: number;
  24078. /**
  24079. * Gets the default side orientation.
  24080. * @param orientation the orientation to value to attempt to get
  24081. * @returns the default orientation
  24082. * @hidden
  24083. */
  24084. static _GetDefaultSideOrientation(orientation?: number): number;
  24085. private _internalMeshDataInfo;
  24086. /**
  24087. * An event triggered before rendering the mesh
  24088. */
  24089. get onBeforeRenderObservable(): Observable<Mesh>;
  24090. /**
  24091. * An event triggered before binding the mesh
  24092. */
  24093. get onBeforeBindObservable(): Observable<Mesh>;
  24094. /**
  24095. * An event triggered after rendering the mesh
  24096. */
  24097. get onAfterRenderObservable(): Observable<Mesh>;
  24098. /**
  24099. * An event triggered before drawing the mesh
  24100. */
  24101. get onBeforeDrawObservable(): Observable<Mesh>;
  24102. private _onBeforeDrawObserver;
  24103. /**
  24104. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24105. */
  24106. set onBeforeDraw(callback: () => void);
  24107. get hasInstances(): boolean;
  24108. /**
  24109. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24110. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24111. */
  24112. delayLoadState: number;
  24113. /**
  24114. * Gets the list of instances created from this mesh
  24115. * it is not supposed to be modified manually.
  24116. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24117. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24118. */
  24119. instances: InstancedMesh[];
  24120. /**
  24121. * Gets the file containing delay loading data for this mesh
  24122. */
  24123. delayLoadingFile: string;
  24124. /** @hidden */
  24125. _binaryInfo: any;
  24126. /**
  24127. * User defined function used to change how LOD level selection is done
  24128. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24129. */
  24130. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24131. /**
  24132. * Gets or sets the morph target manager
  24133. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24134. */
  24135. get morphTargetManager(): Nullable<MorphTargetManager>;
  24136. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24137. /** @hidden */
  24138. _creationDataStorage: Nullable<_CreationDataStorage>;
  24139. /** @hidden */
  24140. _geometry: Nullable<Geometry>;
  24141. /** @hidden */
  24142. _delayInfo: Array<string>;
  24143. /** @hidden */
  24144. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24145. /** @hidden */
  24146. _instanceDataStorage: _InstanceDataStorage;
  24147. private _effectiveMaterial;
  24148. /** @hidden */
  24149. _shouldGenerateFlatShading: boolean;
  24150. /** @hidden */
  24151. _originalBuilderSideOrientation: number;
  24152. /**
  24153. * Use this property to change the original side orientation defined at construction time
  24154. */
  24155. overrideMaterialSideOrientation: Nullable<number>;
  24156. /**
  24157. * Gets the source mesh (the one used to clone this one from)
  24158. */
  24159. get source(): Nullable<Mesh>;
  24160. /**
  24161. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24162. */
  24163. get isUnIndexed(): boolean;
  24164. set isUnIndexed(value: boolean);
  24165. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24166. get worldMatrixInstancedBuffer(): Float32Array;
  24167. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24168. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24169. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24170. /**
  24171. * @constructor
  24172. * @param name The value used by scene.getMeshByName() to do a lookup.
  24173. * @param scene The scene to add this mesh to.
  24174. * @param parent The parent of this mesh, if it has one
  24175. * @param source An optional Mesh from which geometry is shared, cloned.
  24176. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24177. * When false, achieved by calling a clone(), also passing False.
  24178. * This will make creation of children, recursive.
  24179. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24180. */
  24181. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24182. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24183. doNotInstantiate: boolean;
  24184. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24185. /**
  24186. * Gets the class name
  24187. * @returns the string "Mesh".
  24188. */
  24189. getClassName(): string;
  24190. /** @hidden */
  24191. get _isMesh(): boolean;
  24192. /**
  24193. * Returns a description of this mesh
  24194. * @param fullDetails define if full details about this mesh must be used
  24195. * @returns a descriptive string representing this mesh
  24196. */
  24197. toString(fullDetails?: boolean): string;
  24198. /** @hidden */
  24199. _unBindEffect(): void;
  24200. /**
  24201. * Gets a boolean indicating if this mesh has LOD
  24202. */
  24203. get hasLODLevels(): boolean;
  24204. /**
  24205. * Gets the list of MeshLODLevel associated with the current mesh
  24206. * @returns an array of MeshLODLevel
  24207. */
  24208. getLODLevels(): MeshLODLevel[];
  24209. private _sortLODLevels;
  24210. /**
  24211. * Add a mesh as LOD level triggered at the given distance.
  24212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24213. * @param distance The distance from the center of the object to show this level
  24214. * @param mesh The mesh to be added as LOD level (can be null)
  24215. * @return This mesh (for chaining)
  24216. */
  24217. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24218. /**
  24219. * Returns the LOD level mesh at the passed distance or null if not found.
  24220. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24221. * @param distance The distance from the center of the object to show this level
  24222. * @returns a Mesh or `null`
  24223. */
  24224. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24225. /**
  24226. * Remove a mesh from the LOD array
  24227. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24228. * @param mesh defines the mesh to be removed
  24229. * @return This mesh (for chaining)
  24230. */
  24231. removeLODLevel(mesh: Mesh): Mesh;
  24232. /**
  24233. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24234. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24235. * @param camera defines the camera to use to compute distance
  24236. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24237. * @return This mesh (for chaining)
  24238. */
  24239. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24240. /**
  24241. * Gets the mesh internal Geometry object
  24242. */
  24243. get geometry(): Nullable<Geometry>;
  24244. /**
  24245. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24246. * @returns the total number of vertices
  24247. */
  24248. getTotalVertices(): number;
  24249. /**
  24250. * Returns the content of an associated vertex buffer
  24251. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24252. * - VertexBuffer.PositionKind
  24253. * - VertexBuffer.UVKind
  24254. * - VertexBuffer.UV2Kind
  24255. * - VertexBuffer.UV3Kind
  24256. * - VertexBuffer.UV4Kind
  24257. * - VertexBuffer.UV5Kind
  24258. * - VertexBuffer.UV6Kind
  24259. * - VertexBuffer.ColorKind
  24260. * - VertexBuffer.MatricesIndicesKind
  24261. * - VertexBuffer.MatricesIndicesExtraKind
  24262. * - VertexBuffer.MatricesWeightsKind
  24263. * - VertexBuffer.MatricesWeightsExtraKind
  24264. * @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
  24265. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24266. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24267. */
  24268. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24269. /**
  24270. * Returns the mesh VertexBuffer object from the requested `kind`
  24271. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24272. * - VertexBuffer.PositionKind
  24273. * - VertexBuffer.NormalKind
  24274. * - VertexBuffer.UVKind
  24275. * - VertexBuffer.UV2Kind
  24276. * - VertexBuffer.UV3Kind
  24277. * - VertexBuffer.UV4Kind
  24278. * - VertexBuffer.UV5Kind
  24279. * - VertexBuffer.UV6Kind
  24280. * - VertexBuffer.ColorKind
  24281. * - VertexBuffer.MatricesIndicesKind
  24282. * - VertexBuffer.MatricesIndicesExtraKind
  24283. * - VertexBuffer.MatricesWeightsKind
  24284. * - VertexBuffer.MatricesWeightsExtraKind
  24285. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24286. */
  24287. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24288. /**
  24289. * Tests if a specific vertex buffer is associated with this mesh
  24290. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24291. * - VertexBuffer.PositionKind
  24292. * - VertexBuffer.NormalKind
  24293. * - VertexBuffer.UVKind
  24294. * - VertexBuffer.UV2Kind
  24295. * - VertexBuffer.UV3Kind
  24296. * - VertexBuffer.UV4Kind
  24297. * - VertexBuffer.UV5Kind
  24298. * - VertexBuffer.UV6Kind
  24299. * - VertexBuffer.ColorKind
  24300. * - VertexBuffer.MatricesIndicesKind
  24301. * - VertexBuffer.MatricesIndicesExtraKind
  24302. * - VertexBuffer.MatricesWeightsKind
  24303. * - VertexBuffer.MatricesWeightsExtraKind
  24304. * @returns a boolean
  24305. */
  24306. isVerticesDataPresent(kind: string): boolean;
  24307. /**
  24308. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24309. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24310. * - VertexBuffer.PositionKind
  24311. * - VertexBuffer.UVKind
  24312. * - VertexBuffer.UV2Kind
  24313. * - VertexBuffer.UV3Kind
  24314. * - VertexBuffer.UV4Kind
  24315. * - VertexBuffer.UV5Kind
  24316. * - VertexBuffer.UV6Kind
  24317. * - VertexBuffer.ColorKind
  24318. * - VertexBuffer.MatricesIndicesKind
  24319. * - VertexBuffer.MatricesIndicesExtraKind
  24320. * - VertexBuffer.MatricesWeightsKind
  24321. * - VertexBuffer.MatricesWeightsExtraKind
  24322. * @returns a boolean
  24323. */
  24324. isVertexBufferUpdatable(kind: string): boolean;
  24325. /**
  24326. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24327. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24328. * - VertexBuffer.PositionKind
  24329. * - VertexBuffer.NormalKind
  24330. * - VertexBuffer.UVKind
  24331. * - VertexBuffer.UV2Kind
  24332. * - VertexBuffer.UV3Kind
  24333. * - VertexBuffer.UV4Kind
  24334. * - VertexBuffer.UV5Kind
  24335. * - VertexBuffer.UV6Kind
  24336. * - VertexBuffer.ColorKind
  24337. * - VertexBuffer.MatricesIndicesKind
  24338. * - VertexBuffer.MatricesIndicesExtraKind
  24339. * - VertexBuffer.MatricesWeightsKind
  24340. * - VertexBuffer.MatricesWeightsExtraKind
  24341. * @returns an array of strings
  24342. */
  24343. getVerticesDataKinds(): string[];
  24344. /**
  24345. * Returns a positive integer : the total number of indices in this mesh geometry.
  24346. * @returns the numner of indices or zero if the mesh has no geometry.
  24347. */
  24348. getTotalIndices(): number;
  24349. /**
  24350. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24351. * @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.
  24352. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24353. * @returns the indices array or an empty array if the mesh has no geometry
  24354. */
  24355. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24356. get isBlocked(): boolean;
  24357. /**
  24358. * Determine if the current mesh is ready to be rendered
  24359. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24360. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24361. * @returns true if all associated assets are ready (material, textures, shaders)
  24362. */
  24363. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24364. /**
  24365. * 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.
  24366. */
  24367. get areNormalsFrozen(): boolean;
  24368. /**
  24369. * 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.
  24370. * @returns the current mesh
  24371. */
  24372. freezeNormals(): Mesh;
  24373. /**
  24374. * 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
  24375. * @returns the current mesh
  24376. */
  24377. unfreezeNormals(): Mesh;
  24378. /**
  24379. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24380. */
  24381. set overridenInstanceCount(count: number);
  24382. /** @hidden */
  24383. _preActivate(): Mesh;
  24384. /** @hidden */
  24385. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24386. /** @hidden */
  24387. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24388. /**
  24389. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24390. * This means the mesh underlying bounding box and sphere are recomputed.
  24391. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24392. * @returns the current mesh
  24393. */
  24394. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24395. /** @hidden */
  24396. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24397. /**
  24398. * This function will subdivide the mesh into multiple submeshes
  24399. * @param count defines the expected number of submeshes
  24400. */
  24401. subdivide(count: number): void;
  24402. /**
  24403. * Copy a FloatArray into a specific associated vertex buffer
  24404. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24405. * - VertexBuffer.PositionKind
  24406. * - VertexBuffer.UVKind
  24407. * - VertexBuffer.UV2Kind
  24408. * - VertexBuffer.UV3Kind
  24409. * - VertexBuffer.UV4Kind
  24410. * - VertexBuffer.UV5Kind
  24411. * - VertexBuffer.UV6Kind
  24412. * - VertexBuffer.ColorKind
  24413. * - VertexBuffer.MatricesIndicesKind
  24414. * - VertexBuffer.MatricesIndicesExtraKind
  24415. * - VertexBuffer.MatricesWeightsKind
  24416. * - VertexBuffer.MatricesWeightsExtraKind
  24417. * @param data defines the data source
  24418. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24419. * @param stride defines the data stride size (can be null)
  24420. * @returns the current mesh
  24421. */
  24422. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24423. /**
  24424. * Delete a vertex buffer associated with this mesh
  24425. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24426. * - VertexBuffer.PositionKind
  24427. * - VertexBuffer.UVKind
  24428. * - VertexBuffer.UV2Kind
  24429. * - VertexBuffer.UV3Kind
  24430. * - VertexBuffer.UV4Kind
  24431. * - VertexBuffer.UV5Kind
  24432. * - VertexBuffer.UV6Kind
  24433. * - VertexBuffer.ColorKind
  24434. * - VertexBuffer.MatricesIndicesKind
  24435. * - VertexBuffer.MatricesIndicesExtraKind
  24436. * - VertexBuffer.MatricesWeightsKind
  24437. * - VertexBuffer.MatricesWeightsExtraKind
  24438. */
  24439. removeVerticesData(kind: string): void;
  24440. /**
  24441. * Flags an associated vertex buffer as updatable
  24442. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24443. * - VertexBuffer.PositionKind
  24444. * - VertexBuffer.UVKind
  24445. * - VertexBuffer.UV2Kind
  24446. * - VertexBuffer.UV3Kind
  24447. * - VertexBuffer.UV4Kind
  24448. * - VertexBuffer.UV5Kind
  24449. * - VertexBuffer.UV6Kind
  24450. * - VertexBuffer.ColorKind
  24451. * - VertexBuffer.MatricesIndicesKind
  24452. * - VertexBuffer.MatricesIndicesExtraKind
  24453. * - VertexBuffer.MatricesWeightsKind
  24454. * - VertexBuffer.MatricesWeightsExtraKind
  24455. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24456. */
  24457. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24458. /**
  24459. * Sets the mesh global Vertex Buffer
  24460. * @param buffer defines the buffer to use
  24461. * @returns the current mesh
  24462. */
  24463. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24464. /**
  24465. * Update a specific associated vertex buffer
  24466. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24467. * - VertexBuffer.PositionKind
  24468. * - VertexBuffer.UVKind
  24469. * - VertexBuffer.UV2Kind
  24470. * - VertexBuffer.UV3Kind
  24471. * - VertexBuffer.UV4Kind
  24472. * - VertexBuffer.UV5Kind
  24473. * - VertexBuffer.UV6Kind
  24474. * - VertexBuffer.ColorKind
  24475. * - VertexBuffer.MatricesIndicesKind
  24476. * - VertexBuffer.MatricesIndicesExtraKind
  24477. * - VertexBuffer.MatricesWeightsKind
  24478. * - VertexBuffer.MatricesWeightsExtraKind
  24479. * @param data defines the data source
  24480. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24481. * @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)
  24482. * @returns the current mesh
  24483. */
  24484. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24485. /**
  24486. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24487. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24488. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24489. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24490. * @returns the current mesh
  24491. */
  24492. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24493. /**
  24494. * Creates a un-shared specific occurence of the geometry for the mesh.
  24495. * @returns the current mesh
  24496. */
  24497. makeGeometryUnique(): Mesh;
  24498. /**
  24499. * Set the index buffer of this mesh
  24500. * @param indices defines the source data
  24501. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24502. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24503. * @returns the current mesh
  24504. */
  24505. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24506. /**
  24507. * Update the current index buffer
  24508. * @param indices defines the source data
  24509. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24510. * @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)
  24511. * @returns the current mesh
  24512. */
  24513. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24514. /**
  24515. * Invert the geometry to move from a right handed system to a left handed one.
  24516. * @returns the current mesh
  24517. */
  24518. toLeftHanded(): Mesh;
  24519. /** @hidden */
  24520. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24521. /** @hidden */
  24522. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24523. /**
  24524. * Registers for this mesh a javascript function called just before the rendering process
  24525. * @param func defines the function to call before rendering this mesh
  24526. * @returns the current mesh
  24527. */
  24528. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24529. /**
  24530. * Disposes a previously registered javascript function called before the rendering
  24531. * @param func defines the function to remove
  24532. * @returns the current mesh
  24533. */
  24534. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24535. /**
  24536. * Registers for this mesh a javascript function called just after the rendering is complete
  24537. * @param func defines the function to call after rendering this mesh
  24538. * @returns the current mesh
  24539. */
  24540. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24541. /**
  24542. * Disposes a previously registered javascript function called after the rendering.
  24543. * @param func defines the function to remove
  24544. * @returns the current mesh
  24545. */
  24546. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24547. /** @hidden */
  24548. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24549. /** @hidden */
  24550. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24551. /** @hidden */
  24552. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24553. /** @hidden */
  24554. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24555. /** @hidden */
  24556. _rebuild(): void;
  24557. /** @hidden */
  24558. _freeze(): void;
  24559. /** @hidden */
  24560. _unFreeze(): void;
  24561. /**
  24562. * 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
  24563. * @param subMesh defines the subMesh to render
  24564. * @param enableAlphaMode defines if alpha mode can be changed
  24565. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24566. * @returns the current mesh
  24567. */
  24568. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24569. private _onBeforeDraw;
  24570. /**
  24571. * Renormalize the mesh and patch it up if there are no weights
  24572. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24573. * However in the case of zero weights then we set just a single influence to 1.
  24574. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24575. */
  24576. cleanMatrixWeights(): void;
  24577. private normalizeSkinFourWeights;
  24578. private normalizeSkinWeightsAndExtra;
  24579. /**
  24580. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24581. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24582. * the user know there was an issue with importing the mesh
  24583. * @returns a validation object with skinned, valid and report string
  24584. */
  24585. validateSkinning(): {
  24586. skinned: boolean;
  24587. valid: boolean;
  24588. report: string;
  24589. };
  24590. /** @hidden */
  24591. _checkDelayState(): Mesh;
  24592. private _queueLoad;
  24593. /**
  24594. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24595. * A mesh is in the frustum if its bounding box intersects the frustum
  24596. * @param frustumPlanes defines the frustum to test
  24597. * @returns true if the mesh is in the frustum planes
  24598. */
  24599. isInFrustum(frustumPlanes: Plane[]): boolean;
  24600. /**
  24601. * Sets the mesh material by the material or multiMaterial `id` property
  24602. * @param id is a string identifying the material or the multiMaterial
  24603. * @returns the current mesh
  24604. */
  24605. setMaterialByID(id: string): Mesh;
  24606. /**
  24607. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24608. * @returns an array of IAnimatable
  24609. */
  24610. getAnimatables(): IAnimatable[];
  24611. /**
  24612. * Modifies the mesh geometry according to the passed transformation matrix.
  24613. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24614. * The mesh normals are modified using the same transformation.
  24615. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24616. * @param transform defines the transform matrix to use
  24617. * @see http://doc.babylonjs.com/resources/baking_transformations
  24618. * @returns the current mesh
  24619. */
  24620. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24621. /**
  24622. * Modifies the mesh geometry according to its own current World Matrix.
  24623. * The mesh World Matrix is then reset.
  24624. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24625. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24626. * @see http://doc.babylonjs.com/resources/baking_transformations
  24627. * @returns the current mesh
  24628. */
  24629. bakeCurrentTransformIntoVertices(): Mesh;
  24630. /** @hidden */
  24631. get _positions(): Nullable<Vector3[]>;
  24632. /** @hidden */
  24633. _resetPointsArrayCache(): Mesh;
  24634. /** @hidden */
  24635. _generatePointsArray(): boolean;
  24636. /**
  24637. * Returns a new Mesh object generated from the current mesh properties.
  24638. * This method must not get confused with createInstance()
  24639. * @param name is a string, the name given to the new mesh
  24640. * @param newParent can be any Node object (default `null`)
  24641. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24642. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24643. * @returns a new mesh
  24644. */
  24645. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24646. /**
  24647. * Releases resources associated with this mesh.
  24648. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24649. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24650. */
  24651. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24652. /** @hidden */
  24653. _disposeInstanceSpecificData(): void;
  24654. /**
  24655. * Modifies the mesh geometry according to a displacement map.
  24656. * 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.
  24657. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24658. * @param url is a string, the URL from the image file is to be downloaded.
  24659. * @param minHeight is the lower limit of the displacement.
  24660. * @param maxHeight is the upper limit of the displacement.
  24661. * @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.
  24662. * @param uvOffset is an optional vector2 used to offset UV.
  24663. * @param uvScale is an optional vector2 used to scale UV.
  24664. * @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.
  24665. * @returns the Mesh.
  24666. */
  24667. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24668. /**
  24669. * Modifies the mesh geometry according to a displacementMap buffer.
  24670. * 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.
  24671. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24672. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24673. * @param heightMapWidth is the width of the buffer image.
  24674. * @param heightMapHeight is the height of the buffer image.
  24675. * @param minHeight is the lower limit of the displacement.
  24676. * @param maxHeight is the upper limit of the displacement.
  24677. * @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.
  24678. * @param uvOffset is an optional vector2 used to offset UV.
  24679. * @param uvScale is an optional vector2 used to scale UV.
  24680. * @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.
  24681. * @returns the Mesh.
  24682. */
  24683. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24684. /**
  24685. * Modify the mesh to get a flat shading rendering.
  24686. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24687. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24688. * @returns current mesh
  24689. */
  24690. convertToFlatShadedMesh(): Mesh;
  24691. /**
  24692. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24693. * In other words, more vertices, no more indices and a single bigger VBO.
  24694. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24695. * @returns current mesh
  24696. */
  24697. convertToUnIndexedMesh(): Mesh;
  24698. /**
  24699. * Inverses facet orientations.
  24700. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24701. * @param flipNormals will also inverts the normals
  24702. * @returns current mesh
  24703. */
  24704. flipFaces(flipNormals?: boolean): Mesh;
  24705. /**
  24706. * Increase the number of facets and hence vertices in a mesh
  24707. * Vertex normals are interpolated from existing vertex normals
  24708. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24709. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24710. */
  24711. increaseVertices(numberPerEdge: number): void;
  24712. /**
  24713. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24714. * This will undo any application of covertToFlatShadedMesh
  24715. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24716. */
  24717. forceSharedVertices(): void;
  24718. /** @hidden */
  24719. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24720. /** @hidden */
  24721. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24722. /**
  24723. * Creates a new InstancedMesh object from the mesh model.
  24724. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24725. * @param name defines the name of the new instance
  24726. * @returns a new InstancedMesh
  24727. */
  24728. createInstance(name: string): InstancedMesh;
  24729. /**
  24730. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24731. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24732. * @returns the current mesh
  24733. */
  24734. synchronizeInstances(): Mesh;
  24735. /**
  24736. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24737. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24738. * This should be used together with the simplification to avoid disappearing triangles.
  24739. * @param successCallback an optional success callback to be called after the optimization finished.
  24740. * @returns the current mesh
  24741. */
  24742. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24743. /**
  24744. * Serialize current mesh
  24745. * @param serializationObject defines the object which will receive the serialization data
  24746. */
  24747. serialize(serializationObject: any): void;
  24748. /** @hidden */
  24749. _syncGeometryWithMorphTargetManager(): void;
  24750. /** @hidden */
  24751. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24752. /**
  24753. * Returns a new Mesh object parsed from the source provided.
  24754. * @param parsedMesh is the source
  24755. * @param scene defines the hosting scene
  24756. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24757. * @returns a new Mesh
  24758. */
  24759. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24760. /**
  24761. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24762. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24763. * @param name defines the name of the mesh to create
  24764. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24765. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24766. * @param closePath creates a seam between the first and the last points of each path of the path array
  24767. * @param offset is taken in account only if the `pathArray` is containing a single path
  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. * @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)
  24772. * @returns a new Mesh
  24773. */
  24774. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24775. /**
  24776. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24777. * @param name defines the name of the mesh to create
  24778. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24779. * @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
  24780. * @param scene defines the hosting scene
  24781. * @param updatable defines if the mesh must be flagged as updatable
  24782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24783. * @returns a new Mesh
  24784. */
  24785. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24786. /**
  24787. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24788. * @param name defines the name of the mesh to create
  24789. * @param size sets the size (float) of each box side (default 1)
  24790. * @param scene defines the hosting scene
  24791. * @param updatable defines if the mesh must be flagged as updatable
  24792. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24793. * @returns a new Mesh
  24794. */
  24795. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24796. /**
  24797. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24798. * @param name defines the name of the mesh to create
  24799. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24800. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24801. * @param scene defines the hosting scene
  24802. * @param updatable defines if the mesh must be flagged as updatable
  24803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24804. * @returns a new Mesh
  24805. */
  24806. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24807. /**
  24808. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24809. * @param name defines the name of the mesh to create
  24810. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24811. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24812. * @param scene defines the hosting scene
  24813. * @returns a new Mesh
  24814. */
  24815. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24816. /**
  24817. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24818. * @param name defines the name of the mesh to create
  24819. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24820. * @param diameterTop set the top cap diameter (floats, default 1)
  24821. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24822. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24823. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  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 CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24830. /**
  24831. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  24834. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24835. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24836. * @param scene defines the hosting scene
  24837. * @param updatable defines if the mesh must be flagged as updatable
  24838. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24839. * @returns a new Mesh
  24840. */
  24841. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24842. /**
  24843. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24844. * @param name defines the name of the mesh to create
  24845. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24846. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24847. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24848. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24849. * @param p the number of windings on X axis (positive integers, default 2)
  24850. * @param q the number of windings on Y axis (positive integers, default 3)
  24851. * @param scene defines the hosting scene
  24852. * @param updatable defines if the mesh must be flagged as updatable
  24853. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24854. * @returns a new Mesh
  24855. */
  24856. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24857. /**
  24858. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24859. * @param name defines the name of the mesh to create
  24860. * @param points is an array successive Vector3
  24861. * @param scene defines the hosting scene
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @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).
  24864. * @returns a new Mesh
  24865. */
  24866. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24867. /**
  24868. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24869. * @param name defines the name of the mesh to create
  24870. * @param points is an array successive Vector3
  24871. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24872. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24873. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24874. * @param scene defines the hosting scene
  24875. * @param updatable defines if the mesh must be flagged as updatable
  24876. * @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)
  24877. * @returns a new Mesh
  24878. */
  24879. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24880. /**
  24881. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24882. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24883. * 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.
  24884. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24885. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24886. * Remember you can only change the shape positions, not their number when updating a polygon.
  24887. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24888. * @param name defines the name of the mesh to create
  24889. * @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
  24890. * @param scene defines the hosting scene
  24891. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24892. * @param updatable defines if the mesh must be flagged as updatable
  24893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24894. * @param earcutInjection can be used to inject your own earcut reference
  24895. * @returns a new Mesh
  24896. */
  24897. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24898. /**
  24899. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24900. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24901. * @param name defines the name of the mesh to create
  24902. * @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
  24903. * @param depth defines the height of extrusion
  24904. * @param scene defines the hosting scene
  24905. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24906. * @param updatable defines if the mesh must be flagged as updatable
  24907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24908. * @param earcutInjection can be used to inject your own earcut reference
  24909. * @returns a new Mesh
  24910. */
  24911. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24912. /**
  24913. * Creates an extruded shape mesh.
  24914. * 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
  24915. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24916. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24917. * @param name defines the name of the mesh to create
  24918. * @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
  24919. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24920. * @param scale is the value to scale the shape
  24921. * @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
  24922. * @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
  24923. * @param scene defines the hosting scene
  24924. * @param updatable defines if the mesh must be flagged as updatable
  24925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24926. * @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)
  24927. * @returns a new Mesh
  24928. */
  24929. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24930. /**
  24931. * Creates an custom extruded shape mesh.
  24932. * The custom extrusion is a parametric shape.
  24933. * It has no predefined shape. Its final shape will depend on the input parameters.
  24934. * Please consider using the same method from the MeshBuilder class instead
  24935. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24936. * @param name defines the name of the mesh to create
  24937. * @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
  24938. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24939. * @param scaleFunction is a custom Javascript function called on each path point
  24940. * @param rotationFunction is a custom Javascript function called on each path point
  24941. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24942. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24943. * @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
  24944. * @param scene defines the hosting scene
  24945. * @param updatable defines if the mesh must be flagged as updatable
  24946. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24947. * @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)
  24948. * @returns a new Mesh
  24949. */
  24950. 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;
  24951. /**
  24952. * Creates lathe mesh.
  24953. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24954. * Please consider using the same method from the MeshBuilder class instead
  24955. * @param name defines the name of the mesh to create
  24956. * @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
  24957. * @param radius is the radius value of the lathe
  24958. * @param tessellation is the side number of the lathe.
  24959. * @param scene defines the hosting scene
  24960. * @param updatable defines if the mesh must be flagged as updatable
  24961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24962. * @returns a new Mesh
  24963. */
  24964. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24965. /**
  24966. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24967. * @param name defines the name of the mesh to create
  24968. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24969. * @param scene defines the hosting scene
  24970. * @param updatable defines if the mesh must be flagged as updatable
  24971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24972. * @returns a new Mesh
  24973. */
  24974. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24975. /**
  24976. * Creates a 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 width set the width of the ground
  24980. * @param height set the height of the ground
  24981. * @param subdivisions sets the number of subdivisions per side
  24982. * @param scene defines the hosting scene
  24983. * @param updatable defines if the mesh must be flagged as updatable
  24984. * @returns a new Mesh
  24985. */
  24986. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24987. /**
  24988. * Creates a tiled ground mesh.
  24989. * Please consider using the same method from the MeshBuilder class instead
  24990. * @param name defines the name of the mesh to create
  24991. * @param xmin set the ground minimum X coordinate
  24992. * @param zmin set the ground minimum Y coordinate
  24993. * @param xmax set the ground maximum X coordinate
  24994. * @param zmax set the ground maximum Z coordinate
  24995. * @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
  24996. * @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
  24997. * @param scene defines the hosting scene
  24998. * @param updatable defines if the mesh must be flagged as updatable
  24999. * @returns a new Mesh
  25000. */
  25001. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25002. w: number;
  25003. h: number;
  25004. }, precision: {
  25005. w: number;
  25006. h: number;
  25007. }, scene: Scene, updatable?: boolean): Mesh;
  25008. /**
  25009. * Creates a ground mesh from a height map.
  25010. * Please consider using the same method from the MeshBuilder class instead
  25011. * @see http://doc.babylonjs.com/babylon101/height_map
  25012. * @param name defines the name of the mesh to create
  25013. * @param url sets the URL of the height map image resource
  25014. * @param width set the ground width size
  25015. * @param height set the ground height size
  25016. * @param subdivisions sets the number of subdivision per side
  25017. * @param minHeight is the minimum altitude on the ground
  25018. * @param maxHeight is the maximum altitude on the ground
  25019. * @param scene defines the hosting scene
  25020. * @param updatable defines if the mesh must be flagged as updatable
  25021. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25022. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25023. * @returns a new Mesh
  25024. */
  25025. 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;
  25026. /**
  25027. * Creates a tube mesh.
  25028. * The tube is a parametric shape.
  25029. * It has no predefined shape. Its final shape will depend on the input parameters.
  25030. * Please consider using the same method from the MeshBuilder class instead
  25031. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25032. * @param name defines the name of the mesh to create
  25033. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25034. * @param radius sets the tube radius size
  25035. * @param tessellation is the number of sides on the tubular surface
  25036. * @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
  25037. * @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
  25038. * @param scene defines the hosting scene
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @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)
  25042. * @returns a new Mesh
  25043. */
  25044. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25045. (i: number, distance: number): number;
  25046. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25047. /**
  25048. * Creates a polyhedron mesh.
  25049. * Please consider using the same method from the MeshBuilder class instead.
  25050. * * 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
  25051. * * The parameter `size` (positive float, default 1) sets the polygon size
  25052. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25053. * * 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`
  25054. * * 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
  25055. * * 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)`)
  25056. * * 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
  25057. * * 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
  25058. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25059. * * 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
  25060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25061. * @param name defines the name of the mesh to create
  25062. * @param options defines the options used to create the mesh
  25063. * @param scene defines the hosting scene
  25064. * @returns a new Mesh
  25065. */
  25066. static CreatePolyhedron(name: string, options: {
  25067. type?: number;
  25068. size?: number;
  25069. sizeX?: number;
  25070. sizeY?: number;
  25071. sizeZ?: number;
  25072. custom?: any;
  25073. faceUV?: Vector4[];
  25074. faceColors?: Color4[];
  25075. updatable?: boolean;
  25076. sideOrientation?: number;
  25077. }, scene: Scene): Mesh;
  25078. /**
  25079. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25080. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25081. * * 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`)
  25082. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25083. * * 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
  25084. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25085. * * 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
  25086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25087. * @param name defines the name of the mesh
  25088. * @param options defines the options used to create the mesh
  25089. * @param scene defines the hosting scene
  25090. * @returns a new Mesh
  25091. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25092. */
  25093. static CreateIcoSphere(name: string, options: {
  25094. radius?: number;
  25095. flat?: boolean;
  25096. subdivisions?: number;
  25097. sideOrientation?: number;
  25098. updatable?: boolean;
  25099. }, scene: Scene): Mesh;
  25100. /**
  25101. * Creates a decal mesh.
  25102. * Please consider using the same method from the MeshBuilder class instead.
  25103. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25104. * @param name defines the name of the mesh
  25105. * @param sourceMesh defines the mesh receiving the decal
  25106. * @param position sets the position of the decal in world coordinates
  25107. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25108. * @param size sets the decal scaling
  25109. * @param angle sets the angle to rotate the decal
  25110. * @returns a new Mesh
  25111. */
  25112. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25113. /**
  25114. * Prepare internal position array for software CPU skinning
  25115. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25116. */
  25117. setPositionsForCPUSkinning(): Float32Array;
  25118. /**
  25119. * Prepare internal normal array for software CPU skinning
  25120. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25121. */
  25122. setNormalsForCPUSkinning(): Float32Array;
  25123. /**
  25124. * Updates the vertex buffer by applying transformation from the bones
  25125. * @param skeleton defines the skeleton to apply to current mesh
  25126. * @returns the current mesh
  25127. */
  25128. applySkeleton(skeleton: Skeleton): Mesh;
  25129. /**
  25130. * 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
  25131. * @param meshes defines the list of meshes to scan
  25132. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25133. */
  25134. static MinMax(meshes: AbstractMesh[]): {
  25135. min: Vector3;
  25136. max: Vector3;
  25137. };
  25138. /**
  25139. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25140. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25141. * @returns a vector3
  25142. */
  25143. static Center(meshesOrMinMaxVector: {
  25144. min: Vector3;
  25145. max: Vector3;
  25146. } | AbstractMesh[]): Vector3;
  25147. /**
  25148. * Merge the array of meshes into a single mesh for performance reasons.
  25149. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25150. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25151. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25152. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25153. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25154. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25155. * @returns a new mesh
  25156. */
  25157. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25158. /** @hidden */
  25159. addInstance(instance: InstancedMesh): void;
  25160. /** @hidden */
  25161. removeInstance(instance: InstancedMesh): void;
  25162. }
  25163. }
  25164. declare module BABYLON {
  25165. /**
  25166. * This is the base class of all the camera used in the application.
  25167. * @see http://doc.babylonjs.com/features/cameras
  25168. */
  25169. export class Camera extends Node {
  25170. /** @hidden */
  25171. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25172. /**
  25173. * This is the default projection mode used by the cameras.
  25174. * It helps recreating a feeling of perspective and better appreciate depth.
  25175. * This is the best way to simulate real life cameras.
  25176. */
  25177. static readonly PERSPECTIVE_CAMERA: number;
  25178. /**
  25179. * This helps creating camera with an orthographic mode.
  25180. * 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.
  25181. */
  25182. static readonly ORTHOGRAPHIC_CAMERA: number;
  25183. /**
  25184. * This is the default FOV mode for perspective cameras.
  25185. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25186. */
  25187. static readonly FOVMODE_VERTICAL_FIXED: number;
  25188. /**
  25189. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25190. */
  25191. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25192. /**
  25193. * This specifies ther is no need for a camera rig.
  25194. * Basically only one eye is rendered corresponding to the camera.
  25195. */
  25196. static readonly RIG_MODE_NONE: number;
  25197. /**
  25198. * Simulates a camera Rig with one blue eye and one red eye.
  25199. * This can be use with 3d blue and red glasses.
  25200. */
  25201. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25202. /**
  25203. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25204. */
  25205. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25206. /**
  25207. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25208. */
  25209. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25210. /**
  25211. * Defines that both eyes of the camera will be rendered over under each other.
  25212. */
  25213. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25214. /**
  25215. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25216. */
  25217. static readonly RIG_MODE_VR: number;
  25218. /**
  25219. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25220. */
  25221. static readonly RIG_MODE_WEBVR: number;
  25222. /**
  25223. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25224. */
  25225. static readonly RIG_MODE_CUSTOM: number;
  25226. /**
  25227. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25228. */
  25229. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25230. /**
  25231. * Define the input manager associated with the camera.
  25232. */
  25233. inputs: CameraInputsManager<Camera>;
  25234. /** @hidden */
  25235. _position: Vector3;
  25236. /**
  25237. * Define the current local position of the camera in the scene
  25238. */
  25239. get position(): Vector3;
  25240. set position(newPosition: Vector3);
  25241. /**
  25242. * The vector the camera should consider as up.
  25243. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25244. */
  25245. upVector: Vector3;
  25246. /**
  25247. * Define the current limit on the left side for an orthographic camera
  25248. * In scene unit
  25249. */
  25250. orthoLeft: Nullable<number>;
  25251. /**
  25252. * Define the current limit on the right side for an orthographic camera
  25253. * In scene unit
  25254. */
  25255. orthoRight: Nullable<number>;
  25256. /**
  25257. * Define the current limit on the bottom side for an orthographic camera
  25258. * In scene unit
  25259. */
  25260. orthoBottom: Nullable<number>;
  25261. /**
  25262. * Define the current limit on the top side for an orthographic camera
  25263. * In scene unit
  25264. */
  25265. orthoTop: Nullable<number>;
  25266. /**
  25267. * Field Of View is set in Radians. (default is 0.8)
  25268. */
  25269. fov: number;
  25270. /**
  25271. * Define the minimum distance the camera can see from.
  25272. * This is important to note that the depth buffer are not infinite and the closer it starts
  25273. * the more your scene might encounter depth fighting issue.
  25274. */
  25275. minZ: number;
  25276. /**
  25277. * Define the maximum distance the camera can see to.
  25278. * This is important to note that the depth buffer are not infinite and the further it end
  25279. * the more your scene might encounter depth fighting issue.
  25280. */
  25281. maxZ: number;
  25282. /**
  25283. * Define the default inertia of the camera.
  25284. * This helps giving a smooth feeling to the camera movement.
  25285. */
  25286. inertia: number;
  25287. /**
  25288. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25289. */
  25290. mode: number;
  25291. /**
  25292. * Define wether the camera is intermediate.
  25293. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25294. */
  25295. isIntermediate: boolean;
  25296. /**
  25297. * Define the viewport of the camera.
  25298. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25299. */
  25300. viewport: Viewport;
  25301. /**
  25302. * Restricts the camera to viewing objects with the same layerMask.
  25303. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25304. */
  25305. layerMask: number;
  25306. /**
  25307. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25308. */
  25309. fovMode: number;
  25310. /**
  25311. * Rig mode of the camera.
  25312. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25313. * This is normally controlled byt the camera themselves as internal use.
  25314. */
  25315. cameraRigMode: number;
  25316. /**
  25317. * Defines the distance between both "eyes" in case of a RIG
  25318. */
  25319. interaxialDistance: number;
  25320. /**
  25321. * Defines if stereoscopic rendering is done side by side or over under.
  25322. */
  25323. isStereoscopicSideBySide: boolean;
  25324. /**
  25325. * 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
  25326. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25327. * else in the scene. (Eg. security camera)
  25328. *
  25329. * 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)
  25330. */
  25331. customRenderTargets: RenderTargetTexture[];
  25332. /**
  25333. * When set, the camera will render to this render target instead of the default canvas
  25334. *
  25335. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25336. */
  25337. outputRenderTarget: Nullable<RenderTargetTexture>;
  25338. /**
  25339. * Observable triggered when the camera view matrix has changed.
  25340. */
  25341. onViewMatrixChangedObservable: Observable<Camera>;
  25342. /**
  25343. * Observable triggered when the camera Projection matrix has changed.
  25344. */
  25345. onProjectionMatrixChangedObservable: Observable<Camera>;
  25346. /**
  25347. * Observable triggered when the inputs have been processed.
  25348. */
  25349. onAfterCheckInputsObservable: Observable<Camera>;
  25350. /**
  25351. * Observable triggered when reset has been called and applied to the camera.
  25352. */
  25353. onRestoreStateObservable: Observable<Camera>;
  25354. /** @hidden */
  25355. _cameraRigParams: any;
  25356. /** @hidden */
  25357. _rigCameras: Camera[];
  25358. /** @hidden */
  25359. _rigPostProcess: Nullable<PostProcess>;
  25360. protected _webvrViewMatrix: Matrix;
  25361. /** @hidden */
  25362. _skipRendering: boolean;
  25363. /** @hidden */
  25364. _projectionMatrix: Matrix;
  25365. /** @hidden */
  25366. _postProcesses: Nullable<PostProcess>[];
  25367. /** @hidden */
  25368. _activeMeshes: SmartArray<AbstractMesh>;
  25369. protected _globalPosition: Vector3;
  25370. /** @hidden */
  25371. _computedViewMatrix: Matrix;
  25372. private _doNotComputeProjectionMatrix;
  25373. private _transformMatrix;
  25374. private _frustumPlanes;
  25375. private _refreshFrustumPlanes;
  25376. private _storedFov;
  25377. private _stateStored;
  25378. /**
  25379. * Instantiates a new camera object.
  25380. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25381. * @see http://doc.babylonjs.com/features/cameras
  25382. * @param name Defines the name of the camera in the scene
  25383. * @param position Defines the position of the camera
  25384. * @param scene Defines the scene the camera belongs too
  25385. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25386. */
  25387. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25388. /**
  25389. * Store current camera state (fov, position, etc..)
  25390. * @returns the camera
  25391. */
  25392. storeState(): Camera;
  25393. /**
  25394. * Restores the camera state values if it has been stored. You must call storeState() first
  25395. */
  25396. protected _restoreStateValues(): boolean;
  25397. /**
  25398. * Restored camera state. You must call storeState() first.
  25399. * @returns true if restored and false otherwise
  25400. */
  25401. restoreState(): boolean;
  25402. /**
  25403. * Gets the class name of the camera.
  25404. * @returns the class name
  25405. */
  25406. getClassName(): string;
  25407. /** @hidden */
  25408. readonly _isCamera: boolean;
  25409. /**
  25410. * Gets a string representation of the camera useful for debug purpose.
  25411. * @param fullDetails Defines that a more verboe level of logging is required
  25412. * @returns the string representation
  25413. */
  25414. toString(fullDetails?: boolean): string;
  25415. /**
  25416. * Gets the current world space position of the camera.
  25417. */
  25418. get globalPosition(): Vector3;
  25419. /**
  25420. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25421. * @returns the active meshe list
  25422. */
  25423. getActiveMeshes(): SmartArray<AbstractMesh>;
  25424. /**
  25425. * Check wether a mesh is part of the current active mesh list of the camera
  25426. * @param mesh Defines the mesh to check
  25427. * @returns true if active, false otherwise
  25428. */
  25429. isActiveMesh(mesh: Mesh): boolean;
  25430. /**
  25431. * Is this camera ready to be used/rendered
  25432. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25433. * @return true if the camera is ready
  25434. */
  25435. isReady(completeCheck?: boolean): boolean;
  25436. /** @hidden */
  25437. _initCache(): void;
  25438. /** @hidden */
  25439. _updateCache(ignoreParentClass?: boolean): void;
  25440. /** @hidden */
  25441. _isSynchronized(): boolean;
  25442. /** @hidden */
  25443. _isSynchronizedViewMatrix(): boolean;
  25444. /** @hidden */
  25445. _isSynchronizedProjectionMatrix(): boolean;
  25446. /**
  25447. * Attach the input controls to a specific dom element to get the input from.
  25448. * @param element Defines the element the controls should be listened from
  25449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25450. */
  25451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25452. /**
  25453. * Detach the current controls from the specified dom element.
  25454. * @param element Defines the element to stop listening the inputs from
  25455. */
  25456. detachControl(element: HTMLElement): void;
  25457. /**
  25458. * Update the camera state according to the different inputs gathered during the frame.
  25459. */
  25460. update(): void;
  25461. /** @hidden */
  25462. _checkInputs(): void;
  25463. /** @hidden */
  25464. get rigCameras(): Camera[];
  25465. /**
  25466. * Gets the post process used by the rig cameras
  25467. */
  25468. get rigPostProcess(): Nullable<PostProcess>;
  25469. /**
  25470. * Internal, gets the first post proces.
  25471. * @returns the first post process to be run on this camera.
  25472. */
  25473. _getFirstPostProcess(): Nullable<PostProcess>;
  25474. private _cascadePostProcessesToRigCams;
  25475. /**
  25476. * Attach a post process to the camera.
  25477. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25478. * @param postProcess The post process to attach to the camera
  25479. * @param insertAt The position of the post process in case several of them are in use in the scene
  25480. * @returns the position the post process has been inserted at
  25481. */
  25482. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25483. /**
  25484. * Detach a post process to the camera.
  25485. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25486. * @param postProcess The post process to detach from the camera
  25487. */
  25488. detachPostProcess(postProcess: PostProcess): void;
  25489. /**
  25490. * Gets the current world matrix of the camera
  25491. */
  25492. getWorldMatrix(): Matrix;
  25493. /** @hidden */
  25494. _getViewMatrix(): Matrix;
  25495. /**
  25496. * Gets the current view matrix of the camera.
  25497. * @param force forces the camera to recompute the matrix without looking at the cached state
  25498. * @returns the view matrix
  25499. */
  25500. getViewMatrix(force?: boolean): Matrix;
  25501. /**
  25502. * Freeze the projection matrix.
  25503. * It will prevent the cache check of the camera projection compute and can speed up perf
  25504. * if no parameter of the camera are meant to change
  25505. * @param projection Defines manually a projection if necessary
  25506. */
  25507. freezeProjectionMatrix(projection?: Matrix): void;
  25508. /**
  25509. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25510. */
  25511. unfreezeProjectionMatrix(): void;
  25512. /**
  25513. * Gets the current projection matrix of the camera.
  25514. * @param force forces the camera to recompute the matrix without looking at the cached state
  25515. * @returns the projection matrix
  25516. */
  25517. getProjectionMatrix(force?: boolean): Matrix;
  25518. /**
  25519. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25520. * @returns a Matrix
  25521. */
  25522. getTransformationMatrix(): Matrix;
  25523. private _updateFrustumPlanes;
  25524. /**
  25525. * Checks if a cullable object (mesh...) is in the camera frustum
  25526. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25527. * @param target The object to check
  25528. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25529. * @returns true if the object is in frustum otherwise false
  25530. */
  25531. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25532. /**
  25533. * Checks if a cullable object (mesh...) is in the camera frustum
  25534. * Unlike isInFrustum this cheks the full bounding box
  25535. * @param target The object to check
  25536. * @returns true if the object is in frustum otherwise false
  25537. */
  25538. isCompletelyInFrustum(target: ICullable): boolean;
  25539. /**
  25540. * Gets a ray in the forward direction from the camera.
  25541. * @param length Defines the length of the ray to create
  25542. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25543. * @param origin Defines the start point of the ray which defaults to the camera position
  25544. * @returns the forward ray
  25545. */
  25546. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25547. /**
  25548. * Releases resources associated with this node.
  25549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25551. */
  25552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25553. /** @hidden */
  25554. _isLeftCamera: boolean;
  25555. /**
  25556. * Gets the left camera of a rig setup in case of Rigged Camera
  25557. */
  25558. get isLeftCamera(): boolean;
  25559. /** @hidden */
  25560. _isRightCamera: boolean;
  25561. /**
  25562. * Gets the right camera of a rig setup in case of Rigged Camera
  25563. */
  25564. get isRightCamera(): boolean;
  25565. /**
  25566. * Gets the left camera of a rig setup in case of Rigged Camera
  25567. */
  25568. get leftCamera(): Nullable<FreeCamera>;
  25569. /**
  25570. * Gets the right camera of a rig setup in case of Rigged Camera
  25571. */
  25572. get rightCamera(): Nullable<FreeCamera>;
  25573. /**
  25574. * Gets the left camera target of a rig setup in case of Rigged Camera
  25575. * @returns the target position
  25576. */
  25577. getLeftTarget(): Nullable<Vector3>;
  25578. /**
  25579. * Gets the right camera target of a rig setup in case of Rigged Camera
  25580. * @returns the target position
  25581. */
  25582. getRightTarget(): Nullable<Vector3>;
  25583. /**
  25584. * @hidden
  25585. */
  25586. setCameraRigMode(mode: number, rigParams: any): void;
  25587. /** @hidden */
  25588. static _setStereoscopicRigMode(camera: Camera): void;
  25589. /** @hidden */
  25590. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25591. /** @hidden */
  25592. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25593. /** @hidden */
  25594. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25595. /** @hidden */
  25596. _getVRProjectionMatrix(): Matrix;
  25597. protected _updateCameraRotationMatrix(): void;
  25598. protected _updateWebVRCameraRotationMatrix(): void;
  25599. /**
  25600. * This function MUST be overwritten by the different WebVR cameras available.
  25601. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25602. * @hidden
  25603. */
  25604. _getWebVRProjectionMatrix(): Matrix;
  25605. /**
  25606. * This function MUST be overwritten by the different WebVR cameras available.
  25607. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25608. * @hidden
  25609. */
  25610. _getWebVRViewMatrix(): Matrix;
  25611. /** @hidden */
  25612. setCameraRigParameter(name: string, value: any): void;
  25613. /**
  25614. * needs to be overridden by children so sub has required properties to be copied
  25615. * @hidden
  25616. */
  25617. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25618. /**
  25619. * May need to be overridden by children
  25620. * @hidden
  25621. */
  25622. _updateRigCameras(): void;
  25623. /** @hidden */
  25624. _setupInputs(): void;
  25625. /**
  25626. * Serialiaze the camera setup to a json represention
  25627. * @returns the JSON representation
  25628. */
  25629. serialize(): any;
  25630. /**
  25631. * Clones the current camera.
  25632. * @param name The cloned camera name
  25633. * @returns the cloned camera
  25634. */
  25635. clone(name: string): Camera;
  25636. /**
  25637. * Gets the direction of the camera relative to a given local axis.
  25638. * @param localAxis Defines the reference axis to provide a relative direction.
  25639. * @return the direction
  25640. */
  25641. getDirection(localAxis: Vector3): Vector3;
  25642. /**
  25643. * Returns the current camera absolute rotation
  25644. */
  25645. get absoluteRotation(): Quaternion;
  25646. /**
  25647. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25648. * @param localAxis Defines the reference axis to provide a relative direction.
  25649. * @param result Defines the vector to store the result in
  25650. */
  25651. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25652. /**
  25653. * Gets a camera constructor for a given camera type
  25654. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25655. * @param name The name of the camera the result will be able to instantiate
  25656. * @param scene The scene the result will construct the camera in
  25657. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25658. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25659. * @returns a factory method to construc the camera
  25660. */
  25661. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25662. /**
  25663. * Compute the world matrix of the camera.
  25664. * @returns the camera world matrix
  25665. */
  25666. computeWorldMatrix(): Matrix;
  25667. /**
  25668. * Parse a JSON and creates the camera from the parsed information
  25669. * @param parsedCamera The JSON to parse
  25670. * @param scene The scene to instantiate the camera in
  25671. * @returns the newly constructed camera
  25672. */
  25673. static Parse(parsedCamera: any, scene: Scene): Camera;
  25674. }
  25675. }
  25676. declare module BABYLON {
  25677. /**
  25678. * Class containing static functions to help procedurally build meshes
  25679. */
  25680. export class DiscBuilder {
  25681. /**
  25682. * Creates a plane polygonal mesh. By default, this is a disc
  25683. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25684. * * 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
  25685. * * 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
  25686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25687. * * 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
  25688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25689. * @param name defines the name of the mesh
  25690. * @param options defines the options used to create the mesh
  25691. * @param scene defines the hosting scene
  25692. * @returns the plane polygonal mesh
  25693. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25694. */
  25695. static CreateDisc(name: string, options: {
  25696. radius?: number;
  25697. tessellation?: number;
  25698. arc?: number;
  25699. updatable?: boolean;
  25700. sideOrientation?: number;
  25701. frontUVs?: Vector4;
  25702. backUVs?: Vector4;
  25703. }, scene?: Nullable<Scene>): Mesh;
  25704. }
  25705. }
  25706. declare module BABYLON {
  25707. /**
  25708. * This represents all the required information to add a fresnel effect on a material:
  25709. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25710. */
  25711. export class FresnelParameters {
  25712. private _isEnabled;
  25713. /**
  25714. * Define if the fresnel effect is enable or not.
  25715. */
  25716. get isEnabled(): boolean;
  25717. set isEnabled(value: boolean);
  25718. /**
  25719. * Define the color used on edges (grazing angle)
  25720. */
  25721. leftColor: Color3;
  25722. /**
  25723. * Define the color used on center
  25724. */
  25725. rightColor: Color3;
  25726. /**
  25727. * Define bias applied to computed fresnel term
  25728. */
  25729. bias: number;
  25730. /**
  25731. * Defined the power exponent applied to fresnel term
  25732. */
  25733. power: number;
  25734. /**
  25735. * Clones the current fresnel and its valuues
  25736. * @returns a clone fresnel configuration
  25737. */
  25738. clone(): FresnelParameters;
  25739. /**
  25740. * Serializes the current fresnel parameters to a JSON representation.
  25741. * @return the JSON serialization
  25742. */
  25743. serialize(): any;
  25744. /**
  25745. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25746. * @param parsedFresnelParameters Define the JSON representation
  25747. * @returns the parsed parameters
  25748. */
  25749. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25750. }
  25751. }
  25752. declare module BABYLON {
  25753. /**
  25754. * Base class of materials working in push mode in babylon JS
  25755. * @hidden
  25756. */
  25757. export class PushMaterial extends Material {
  25758. protected _activeEffect: Effect;
  25759. protected _normalMatrix: Matrix;
  25760. /**
  25761. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25762. * This means that the material can keep using a previous shader while a new one is being compiled.
  25763. * This is mostly used when shader parallel compilation is supported (true by default)
  25764. */
  25765. allowShaderHotSwapping: boolean;
  25766. constructor(name: string, scene: Scene);
  25767. getEffect(): Effect;
  25768. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25769. /**
  25770. * Binds the given world matrix to the active effect
  25771. *
  25772. * @param world the matrix to bind
  25773. */
  25774. bindOnlyWorldMatrix(world: Matrix): void;
  25775. /**
  25776. * Binds the given normal matrix to the active effect
  25777. *
  25778. * @param normalMatrix the matrix to bind
  25779. */
  25780. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25781. bind(world: Matrix, mesh?: Mesh): void;
  25782. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25783. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25784. }
  25785. }
  25786. declare module BABYLON {
  25787. /**
  25788. * This groups all the flags used to control the materials channel.
  25789. */
  25790. export class MaterialFlags {
  25791. private static _DiffuseTextureEnabled;
  25792. /**
  25793. * Are diffuse textures enabled in the application.
  25794. */
  25795. static get DiffuseTextureEnabled(): boolean;
  25796. static set DiffuseTextureEnabled(value: boolean);
  25797. private static _AmbientTextureEnabled;
  25798. /**
  25799. * Are ambient textures enabled in the application.
  25800. */
  25801. static get AmbientTextureEnabled(): boolean;
  25802. static set AmbientTextureEnabled(value: boolean);
  25803. private static _OpacityTextureEnabled;
  25804. /**
  25805. * Are opacity textures enabled in the application.
  25806. */
  25807. static get OpacityTextureEnabled(): boolean;
  25808. static set OpacityTextureEnabled(value: boolean);
  25809. private static _ReflectionTextureEnabled;
  25810. /**
  25811. * Are reflection textures enabled in the application.
  25812. */
  25813. static get ReflectionTextureEnabled(): boolean;
  25814. static set ReflectionTextureEnabled(value: boolean);
  25815. private static _EmissiveTextureEnabled;
  25816. /**
  25817. * Are emissive textures enabled in the application.
  25818. */
  25819. static get EmissiveTextureEnabled(): boolean;
  25820. static set EmissiveTextureEnabled(value: boolean);
  25821. private static _SpecularTextureEnabled;
  25822. /**
  25823. * Are specular textures enabled in the application.
  25824. */
  25825. static get SpecularTextureEnabled(): boolean;
  25826. static set SpecularTextureEnabled(value: boolean);
  25827. private static _BumpTextureEnabled;
  25828. /**
  25829. * Are bump textures enabled in the application.
  25830. */
  25831. static get BumpTextureEnabled(): boolean;
  25832. static set BumpTextureEnabled(value: boolean);
  25833. private static _LightmapTextureEnabled;
  25834. /**
  25835. * Are lightmap textures enabled in the application.
  25836. */
  25837. static get LightmapTextureEnabled(): boolean;
  25838. static set LightmapTextureEnabled(value: boolean);
  25839. private static _RefractionTextureEnabled;
  25840. /**
  25841. * Are refraction textures enabled in the application.
  25842. */
  25843. static get RefractionTextureEnabled(): boolean;
  25844. static set RefractionTextureEnabled(value: boolean);
  25845. private static _ColorGradingTextureEnabled;
  25846. /**
  25847. * Are color grading textures enabled in the application.
  25848. */
  25849. static get ColorGradingTextureEnabled(): boolean;
  25850. static set ColorGradingTextureEnabled(value: boolean);
  25851. private static _FresnelEnabled;
  25852. /**
  25853. * Are fresnels enabled in the application.
  25854. */
  25855. static get FresnelEnabled(): boolean;
  25856. static set FresnelEnabled(value: boolean);
  25857. private static _ClearCoatTextureEnabled;
  25858. /**
  25859. * Are clear coat textures enabled in the application.
  25860. */
  25861. static get ClearCoatTextureEnabled(): boolean;
  25862. static set ClearCoatTextureEnabled(value: boolean);
  25863. private static _ClearCoatBumpTextureEnabled;
  25864. /**
  25865. * Are clear coat bump textures enabled in the application.
  25866. */
  25867. static get ClearCoatBumpTextureEnabled(): boolean;
  25868. static set ClearCoatBumpTextureEnabled(value: boolean);
  25869. private static _ClearCoatTintTextureEnabled;
  25870. /**
  25871. * Are clear coat tint textures enabled in the application.
  25872. */
  25873. static get ClearCoatTintTextureEnabled(): boolean;
  25874. static set ClearCoatTintTextureEnabled(value: boolean);
  25875. private static _SheenTextureEnabled;
  25876. /**
  25877. * Are sheen textures enabled in the application.
  25878. */
  25879. static get SheenTextureEnabled(): boolean;
  25880. static set SheenTextureEnabled(value: boolean);
  25881. private static _AnisotropicTextureEnabled;
  25882. /**
  25883. * Are anisotropic textures enabled in the application.
  25884. */
  25885. static get AnisotropicTextureEnabled(): boolean;
  25886. static set AnisotropicTextureEnabled(value: boolean);
  25887. private static _ThicknessTextureEnabled;
  25888. /**
  25889. * Are thickness textures enabled in the application.
  25890. */
  25891. static get ThicknessTextureEnabled(): boolean;
  25892. static set ThicknessTextureEnabled(value: boolean);
  25893. }
  25894. }
  25895. declare module BABYLON {
  25896. /** @hidden */
  25897. export var defaultFragmentDeclaration: {
  25898. name: string;
  25899. shader: string;
  25900. };
  25901. }
  25902. declare module BABYLON {
  25903. /** @hidden */
  25904. export var defaultUboDeclaration: {
  25905. name: string;
  25906. shader: string;
  25907. };
  25908. }
  25909. declare module BABYLON {
  25910. /** @hidden */
  25911. export var lightFragmentDeclaration: {
  25912. name: string;
  25913. shader: string;
  25914. };
  25915. }
  25916. declare module BABYLON {
  25917. /** @hidden */
  25918. export var lightUboDeclaration: {
  25919. name: string;
  25920. shader: string;
  25921. };
  25922. }
  25923. declare module BABYLON {
  25924. /** @hidden */
  25925. export var lightsFragmentFunctions: {
  25926. name: string;
  25927. shader: string;
  25928. };
  25929. }
  25930. declare module BABYLON {
  25931. /** @hidden */
  25932. export var shadowsFragmentFunctions: {
  25933. name: string;
  25934. shader: string;
  25935. };
  25936. }
  25937. declare module BABYLON {
  25938. /** @hidden */
  25939. export var fresnelFunction: {
  25940. name: string;
  25941. shader: string;
  25942. };
  25943. }
  25944. declare module BABYLON {
  25945. /** @hidden */
  25946. export var reflectionFunction: {
  25947. name: string;
  25948. shader: string;
  25949. };
  25950. }
  25951. declare module BABYLON {
  25952. /** @hidden */
  25953. export var bumpFragmentFunctions: {
  25954. name: string;
  25955. shader: string;
  25956. };
  25957. }
  25958. declare module BABYLON {
  25959. /** @hidden */
  25960. export var logDepthDeclaration: {
  25961. name: string;
  25962. shader: string;
  25963. };
  25964. }
  25965. declare module BABYLON {
  25966. /** @hidden */
  25967. export var bumpFragment: {
  25968. name: string;
  25969. shader: string;
  25970. };
  25971. }
  25972. declare module BABYLON {
  25973. /** @hidden */
  25974. export var depthPrePass: {
  25975. name: string;
  25976. shader: string;
  25977. };
  25978. }
  25979. declare module BABYLON {
  25980. /** @hidden */
  25981. export var lightFragment: {
  25982. name: string;
  25983. shader: string;
  25984. };
  25985. }
  25986. declare module BABYLON {
  25987. /** @hidden */
  25988. export var logDepthFragment: {
  25989. name: string;
  25990. shader: string;
  25991. };
  25992. }
  25993. declare module BABYLON {
  25994. /** @hidden */
  25995. export var defaultPixelShader: {
  25996. name: string;
  25997. shader: string;
  25998. };
  25999. }
  26000. declare module BABYLON {
  26001. /** @hidden */
  26002. export var defaultVertexDeclaration: {
  26003. name: string;
  26004. shader: string;
  26005. };
  26006. }
  26007. declare module BABYLON {
  26008. /** @hidden */
  26009. export var bumpVertexDeclaration: {
  26010. name: string;
  26011. shader: string;
  26012. };
  26013. }
  26014. declare module BABYLON {
  26015. /** @hidden */
  26016. export var bumpVertex: {
  26017. name: string;
  26018. shader: string;
  26019. };
  26020. }
  26021. declare module BABYLON {
  26022. /** @hidden */
  26023. export var fogVertex: {
  26024. name: string;
  26025. shader: string;
  26026. };
  26027. }
  26028. declare module BABYLON {
  26029. /** @hidden */
  26030. export var shadowsVertex: {
  26031. name: string;
  26032. shader: string;
  26033. };
  26034. }
  26035. declare module BABYLON {
  26036. /** @hidden */
  26037. export var pointCloudVertex: {
  26038. name: string;
  26039. shader: string;
  26040. };
  26041. }
  26042. declare module BABYLON {
  26043. /** @hidden */
  26044. export var logDepthVertex: {
  26045. name: string;
  26046. shader: string;
  26047. };
  26048. }
  26049. declare module BABYLON {
  26050. /** @hidden */
  26051. export var defaultVertexShader: {
  26052. name: string;
  26053. shader: string;
  26054. };
  26055. }
  26056. declare module BABYLON {
  26057. /** @hidden */
  26058. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26059. MAINUV1: boolean;
  26060. MAINUV2: boolean;
  26061. DIFFUSE: boolean;
  26062. DIFFUSEDIRECTUV: number;
  26063. AMBIENT: boolean;
  26064. AMBIENTDIRECTUV: number;
  26065. OPACITY: boolean;
  26066. OPACITYDIRECTUV: number;
  26067. OPACITYRGB: boolean;
  26068. REFLECTION: boolean;
  26069. EMISSIVE: boolean;
  26070. EMISSIVEDIRECTUV: number;
  26071. SPECULAR: boolean;
  26072. SPECULARDIRECTUV: number;
  26073. BUMP: boolean;
  26074. BUMPDIRECTUV: number;
  26075. PARALLAX: boolean;
  26076. PARALLAXOCCLUSION: boolean;
  26077. SPECULAROVERALPHA: boolean;
  26078. CLIPPLANE: boolean;
  26079. CLIPPLANE2: boolean;
  26080. CLIPPLANE3: boolean;
  26081. CLIPPLANE4: boolean;
  26082. CLIPPLANE5: boolean;
  26083. CLIPPLANE6: boolean;
  26084. ALPHATEST: boolean;
  26085. DEPTHPREPASS: boolean;
  26086. ALPHAFROMDIFFUSE: boolean;
  26087. POINTSIZE: boolean;
  26088. FOG: boolean;
  26089. SPECULARTERM: boolean;
  26090. DIFFUSEFRESNEL: boolean;
  26091. OPACITYFRESNEL: boolean;
  26092. REFLECTIONFRESNEL: boolean;
  26093. REFRACTIONFRESNEL: boolean;
  26094. EMISSIVEFRESNEL: boolean;
  26095. FRESNEL: boolean;
  26096. NORMAL: boolean;
  26097. UV1: boolean;
  26098. UV2: boolean;
  26099. VERTEXCOLOR: boolean;
  26100. VERTEXALPHA: boolean;
  26101. NUM_BONE_INFLUENCERS: number;
  26102. BonesPerMesh: number;
  26103. BONETEXTURE: boolean;
  26104. INSTANCES: boolean;
  26105. GLOSSINESS: boolean;
  26106. ROUGHNESS: boolean;
  26107. EMISSIVEASILLUMINATION: boolean;
  26108. LINKEMISSIVEWITHDIFFUSE: boolean;
  26109. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26110. LIGHTMAP: boolean;
  26111. LIGHTMAPDIRECTUV: number;
  26112. OBJECTSPACE_NORMALMAP: boolean;
  26113. USELIGHTMAPASSHADOWMAP: boolean;
  26114. REFLECTIONMAP_3D: boolean;
  26115. REFLECTIONMAP_SPHERICAL: boolean;
  26116. REFLECTIONMAP_PLANAR: boolean;
  26117. REFLECTIONMAP_CUBIC: boolean;
  26118. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26119. REFLECTIONMAP_PROJECTION: boolean;
  26120. REFLECTIONMAP_SKYBOX: boolean;
  26121. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26122. REFLECTIONMAP_EXPLICIT: boolean;
  26123. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26124. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26125. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26126. INVERTCUBICMAP: boolean;
  26127. LOGARITHMICDEPTH: boolean;
  26128. REFRACTION: boolean;
  26129. REFRACTIONMAP_3D: boolean;
  26130. REFLECTIONOVERALPHA: boolean;
  26131. TWOSIDEDLIGHTING: boolean;
  26132. SHADOWFLOAT: boolean;
  26133. MORPHTARGETS: boolean;
  26134. MORPHTARGETS_NORMAL: boolean;
  26135. MORPHTARGETS_TANGENT: boolean;
  26136. MORPHTARGETS_UV: boolean;
  26137. NUM_MORPH_INFLUENCERS: number;
  26138. NONUNIFORMSCALING: boolean;
  26139. PREMULTIPLYALPHA: boolean;
  26140. IMAGEPROCESSING: boolean;
  26141. VIGNETTE: boolean;
  26142. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26143. VIGNETTEBLENDMODEOPAQUE: boolean;
  26144. TONEMAPPING: boolean;
  26145. TONEMAPPING_ACES: boolean;
  26146. CONTRAST: boolean;
  26147. COLORCURVES: boolean;
  26148. COLORGRADING: boolean;
  26149. COLORGRADING3D: boolean;
  26150. SAMPLER3DGREENDEPTH: boolean;
  26151. SAMPLER3DBGRMAP: boolean;
  26152. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26153. MULTIVIEW: boolean;
  26154. /**
  26155. * If the reflection texture on this material is in linear color space
  26156. * @hidden
  26157. */
  26158. IS_REFLECTION_LINEAR: boolean;
  26159. /**
  26160. * If the refraction texture on this material is in linear color space
  26161. * @hidden
  26162. */
  26163. IS_REFRACTION_LINEAR: boolean;
  26164. EXPOSURE: boolean;
  26165. constructor();
  26166. setReflectionMode(modeToEnable: string): void;
  26167. }
  26168. /**
  26169. * This is the default material used in Babylon. It is the best trade off between quality
  26170. * and performances.
  26171. * @see http://doc.babylonjs.com/babylon101/materials
  26172. */
  26173. export class StandardMaterial extends PushMaterial {
  26174. private _diffuseTexture;
  26175. /**
  26176. * The basic texture of the material as viewed under a light.
  26177. */
  26178. diffuseTexture: Nullable<BaseTexture>;
  26179. private _ambientTexture;
  26180. /**
  26181. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26182. */
  26183. ambientTexture: Nullable<BaseTexture>;
  26184. private _opacityTexture;
  26185. /**
  26186. * Define the transparency of the material from a texture.
  26187. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26188. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26189. */
  26190. opacityTexture: Nullable<BaseTexture>;
  26191. private _reflectionTexture;
  26192. /**
  26193. * Define the texture used to display the reflection.
  26194. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26195. */
  26196. reflectionTexture: Nullable<BaseTexture>;
  26197. private _emissiveTexture;
  26198. /**
  26199. * Define texture of the material as if self lit.
  26200. * This will be mixed in the final result even in the absence of light.
  26201. */
  26202. emissiveTexture: Nullable<BaseTexture>;
  26203. private _specularTexture;
  26204. /**
  26205. * Define how the color and intensity of the highlight given by the light in the material.
  26206. */
  26207. specularTexture: Nullable<BaseTexture>;
  26208. private _bumpTexture;
  26209. /**
  26210. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26211. * 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.
  26212. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26213. */
  26214. bumpTexture: Nullable<BaseTexture>;
  26215. private _lightmapTexture;
  26216. /**
  26217. * Complex lighting can be computationally expensive to compute at runtime.
  26218. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26219. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26220. */
  26221. lightmapTexture: Nullable<BaseTexture>;
  26222. private _refractionTexture;
  26223. /**
  26224. * Define the texture used to display the refraction.
  26225. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26226. */
  26227. refractionTexture: Nullable<BaseTexture>;
  26228. /**
  26229. * The color of the material lit by the environmental background lighting.
  26230. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26231. */
  26232. ambientColor: Color3;
  26233. /**
  26234. * The basic color of the material as viewed under a light.
  26235. */
  26236. diffuseColor: Color3;
  26237. /**
  26238. * Define how the color and intensity of the highlight given by the light in the material.
  26239. */
  26240. specularColor: Color3;
  26241. /**
  26242. * Define the color of the material as if self lit.
  26243. * This will be mixed in the final result even in the absence of light.
  26244. */
  26245. emissiveColor: Color3;
  26246. /**
  26247. * Defines how sharp are the highlights in the material.
  26248. * The bigger the value the sharper giving a more glossy feeling to the result.
  26249. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26250. */
  26251. specularPower: number;
  26252. private _useAlphaFromDiffuseTexture;
  26253. /**
  26254. * Does the transparency come from the diffuse texture alpha channel.
  26255. */
  26256. useAlphaFromDiffuseTexture: boolean;
  26257. private _useEmissiveAsIllumination;
  26258. /**
  26259. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26260. */
  26261. useEmissiveAsIllumination: boolean;
  26262. private _linkEmissiveWithDiffuse;
  26263. /**
  26264. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26265. * the emissive level when the final color is close to one.
  26266. */
  26267. linkEmissiveWithDiffuse: boolean;
  26268. private _useSpecularOverAlpha;
  26269. /**
  26270. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26271. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26272. */
  26273. useSpecularOverAlpha: boolean;
  26274. private _useReflectionOverAlpha;
  26275. /**
  26276. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26277. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26278. */
  26279. useReflectionOverAlpha: boolean;
  26280. private _disableLighting;
  26281. /**
  26282. * Does lights from the scene impacts this material.
  26283. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26284. */
  26285. disableLighting: boolean;
  26286. private _useObjectSpaceNormalMap;
  26287. /**
  26288. * Allows using an object space normal map (instead of tangent space).
  26289. */
  26290. useObjectSpaceNormalMap: boolean;
  26291. private _useParallax;
  26292. /**
  26293. * Is parallax enabled or not.
  26294. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26295. */
  26296. useParallax: boolean;
  26297. private _useParallaxOcclusion;
  26298. /**
  26299. * Is parallax occlusion enabled or not.
  26300. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26301. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26302. */
  26303. useParallaxOcclusion: boolean;
  26304. /**
  26305. * 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.
  26306. */
  26307. parallaxScaleBias: number;
  26308. private _roughness;
  26309. /**
  26310. * Helps to define how blurry the reflections should appears in the material.
  26311. */
  26312. roughness: number;
  26313. /**
  26314. * In case of refraction, define the value of the index of refraction.
  26315. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26316. */
  26317. indexOfRefraction: number;
  26318. /**
  26319. * Invert the refraction texture alongside the y axis.
  26320. * It can be useful with procedural textures or probe for instance.
  26321. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26322. */
  26323. invertRefractionY: boolean;
  26324. /**
  26325. * Defines the alpha limits in alpha test mode.
  26326. */
  26327. alphaCutOff: number;
  26328. private _useLightmapAsShadowmap;
  26329. /**
  26330. * In case of light mapping, define whether the map contains light or shadow informations.
  26331. */
  26332. useLightmapAsShadowmap: boolean;
  26333. private _diffuseFresnelParameters;
  26334. /**
  26335. * Define the diffuse fresnel parameters of the material.
  26336. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26337. */
  26338. diffuseFresnelParameters: FresnelParameters;
  26339. private _opacityFresnelParameters;
  26340. /**
  26341. * Define the opacity fresnel parameters of the material.
  26342. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26343. */
  26344. opacityFresnelParameters: FresnelParameters;
  26345. private _reflectionFresnelParameters;
  26346. /**
  26347. * Define the reflection fresnel parameters of the material.
  26348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26349. */
  26350. reflectionFresnelParameters: FresnelParameters;
  26351. private _refractionFresnelParameters;
  26352. /**
  26353. * Define the refraction fresnel parameters of the material.
  26354. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26355. */
  26356. refractionFresnelParameters: FresnelParameters;
  26357. private _emissiveFresnelParameters;
  26358. /**
  26359. * Define the emissive fresnel parameters of the material.
  26360. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26361. */
  26362. emissiveFresnelParameters: FresnelParameters;
  26363. private _useReflectionFresnelFromSpecular;
  26364. /**
  26365. * If true automatically deducts the fresnels values from the material specularity.
  26366. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26367. */
  26368. useReflectionFresnelFromSpecular: boolean;
  26369. private _useGlossinessFromSpecularMapAlpha;
  26370. /**
  26371. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26372. */
  26373. useGlossinessFromSpecularMapAlpha: boolean;
  26374. private _maxSimultaneousLights;
  26375. /**
  26376. * Defines the maximum number of lights that can be used in the material
  26377. */
  26378. maxSimultaneousLights: number;
  26379. private _invertNormalMapX;
  26380. /**
  26381. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26382. */
  26383. invertNormalMapX: boolean;
  26384. private _invertNormalMapY;
  26385. /**
  26386. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26387. */
  26388. invertNormalMapY: boolean;
  26389. private _twoSidedLighting;
  26390. /**
  26391. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26392. */
  26393. twoSidedLighting: boolean;
  26394. /**
  26395. * Default configuration related to image processing available in the standard Material.
  26396. */
  26397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26398. /**
  26399. * Gets the image processing configuration used either in this material.
  26400. */
  26401. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26402. /**
  26403. * Sets the Default image processing configuration used either in the this material.
  26404. *
  26405. * If sets to null, the scene one is in use.
  26406. */
  26407. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26408. /**
  26409. * Keep track of the image processing observer to allow dispose and replace.
  26410. */
  26411. private _imageProcessingObserver;
  26412. /**
  26413. * Attaches a new image processing configuration to the Standard Material.
  26414. * @param configuration
  26415. */
  26416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26417. /**
  26418. * Gets wether the color curves effect is enabled.
  26419. */
  26420. get cameraColorCurvesEnabled(): boolean;
  26421. /**
  26422. * Sets wether the color curves effect is enabled.
  26423. */
  26424. set cameraColorCurvesEnabled(value: boolean);
  26425. /**
  26426. * Gets wether the color grading effect is enabled.
  26427. */
  26428. get cameraColorGradingEnabled(): boolean;
  26429. /**
  26430. * Gets wether the color grading effect is enabled.
  26431. */
  26432. set cameraColorGradingEnabled(value: boolean);
  26433. /**
  26434. * Gets wether tonemapping is enabled or not.
  26435. */
  26436. get cameraToneMappingEnabled(): boolean;
  26437. /**
  26438. * Sets wether tonemapping is enabled or not
  26439. */
  26440. set cameraToneMappingEnabled(value: boolean);
  26441. /**
  26442. * The camera exposure used on this material.
  26443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26444. * This corresponds to a photographic exposure.
  26445. */
  26446. get cameraExposure(): number;
  26447. /**
  26448. * The camera exposure used on this material.
  26449. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26450. * This corresponds to a photographic exposure.
  26451. */
  26452. set cameraExposure(value: number);
  26453. /**
  26454. * Gets The camera contrast used on this material.
  26455. */
  26456. get cameraContrast(): number;
  26457. /**
  26458. * Sets The camera contrast used on this material.
  26459. */
  26460. set cameraContrast(value: number);
  26461. /**
  26462. * Gets the Color Grading 2D Lookup Texture.
  26463. */
  26464. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26465. /**
  26466. * Sets the Color Grading 2D Lookup Texture.
  26467. */
  26468. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26469. /**
  26470. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26471. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26472. * 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;
  26473. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26474. */
  26475. get cameraColorCurves(): Nullable<ColorCurves>;
  26476. /**
  26477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26479. * 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;
  26480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26481. */
  26482. set cameraColorCurves(value: Nullable<ColorCurves>);
  26483. /**
  26484. * Custom callback helping to override the default shader used in the material.
  26485. */
  26486. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26487. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26488. protected _worldViewProjectionMatrix: Matrix;
  26489. protected _globalAmbientColor: Color3;
  26490. protected _useLogarithmicDepth: boolean;
  26491. protected _rebuildInParallel: boolean;
  26492. /**
  26493. * Instantiates a new standard material.
  26494. * This is the default material used in Babylon. It is the best trade off between quality
  26495. * and performances.
  26496. * @see http://doc.babylonjs.com/babylon101/materials
  26497. * @param name Define the name of the material in the scene
  26498. * @param scene Define the scene the material belong to
  26499. */
  26500. constructor(name: string, scene: Scene);
  26501. /**
  26502. * Gets a boolean indicating that current material needs to register RTT
  26503. */
  26504. get hasRenderTargetTextures(): boolean;
  26505. /**
  26506. * Gets the current class name of the material e.g. "StandardMaterial"
  26507. * Mainly use in serialization.
  26508. * @returns the class name
  26509. */
  26510. getClassName(): string;
  26511. /**
  26512. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26513. * You can try switching to logarithmic depth.
  26514. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26515. */
  26516. get useLogarithmicDepth(): boolean;
  26517. set useLogarithmicDepth(value: boolean);
  26518. /**
  26519. * Specifies if the material will require alpha blending
  26520. * @returns a boolean specifying if alpha blending is needed
  26521. */
  26522. needAlphaBlending(): boolean;
  26523. /**
  26524. * Specifies if this material should be rendered in alpha test mode
  26525. * @returns a boolean specifying if an alpha test is needed.
  26526. */
  26527. needAlphaTesting(): boolean;
  26528. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26529. /**
  26530. * Get the texture used for alpha test purpose.
  26531. * @returns the diffuse texture in case of the standard material.
  26532. */
  26533. getAlphaTestTexture(): Nullable<BaseTexture>;
  26534. /**
  26535. * Get if the submesh is ready to be used and all its information available.
  26536. * Child classes can use it to update shaders
  26537. * @param mesh defines the mesh to check
  26538. * @param subMesh defines which submesh to check
  26539. * @param useInstances specifies that instances should be used
  26540. * @returns a boolean indicating that the submesh is ready or not
  26541. */
  26542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26543. /**
  26544. * Builds the material UBO layouts.
  26545. * Used internally during the effect preparation.
  26546. */
  26547. buildUniformLayout(): void;
  26548. /**
  26549. * Unbinds the material from the mesh
  26550. */
  26551. unbind(): void;
  26552. /**
  26553. * Binds the submesh to this material by preparing the effect and shader to draw
  26554. * @param world defines the world transformation matrix
  26555. * @param mesh defines the mesh containing the submesh
  26556. * @param subMesh defines the submesh to bind the material to
  26557. */
  26558. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26559. /**
  26560. * Get the list of animatables in the material.
  26561. * @returns the list of animatables object used in the material
  26562. */
  26563. getAnimatables(): IAnimatable[];
  26564. /**
  26565. * Gets the active textures from the material
  26566. * @returns an array of textures
  26567. */
  26568. getActiveTextures(): BaseTexture[];
  26569. /**
  26570. * Specifies if the material uses a texture
  26571. * @param texture defines the texture to check against the material
  26572. * @returns a boolean specifying if the material uses the texture
  26573. */
  26574. hasTexture(texture: BaseTexture): boolean;
  26575. /**
  26576. * Disposes the material
  26577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26579. */
  26580. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26581. /**
  26582. * Makes a duplicate of the material, and gives it a new name
  26583. * @param name defines the new name for the duplicated material
  26584. * @returns the cloned material
  26585. */
  26586. clone(name: string): StandardMaterial;
  26587. /**
  26588. * Serializes this material in a JSON representation
  26589. * @returns the serialized material object
  26590. */
  26591. serialize(): any;
  26592. /**
  26593. * Creates a standard material from parsed material data
  26594. * @param source defines the JSON representation of the material
  26595. * @param scene defines the hosting scene
  26596. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26597. * @returns a new standard material
  26598. */
  26599. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26600. /**
  26601. * Are diffuse textures enabled in the application.
  26602. */
  26603. static get DiffuseTextureEnabled(): boolean;
  26604. static set DiffuseTextureEnabled(value: boolean);
  26605. /**
  26606. * Are ambient textures enabled in the application.
  26607. */
  26608. static get AmbientTextureEnabled(): boolean;
  26609. static set AmbientTextureEnabled(value: boolean);
  26610. /**
  26611. * Are opacity textures enabled in the application.
  26612. */
  26613. static get OpacityTextureEnabled(): boolean;
  26614. static set OpacityTextureEnabled(value: boolean);
  26615. /**
  26616. * Are reflection textures enabled in the application.
  26617. */
  26618. static get ReflectionTextureEnabled(): boolean;
  26619. static set ReflectionTextureEnabled(value: boolean);
  26620. /**
  26621. * Are emissive textures enabled in the application.
  26622. */
  26623. static get EmissiveTextureEnabled(): boolean;
  26624. static set EmissiveTextureEnabled(value: boolean);
  26625. /**
  26626. * Are specular textures enabled in the application.
  26627. */
  26628. static get SpecularTextureEnabled(): boolean;
  26629. static set SpecularTextureEnabled(value: boolean);
  26630. /**
  26631. * Are bump textures enabled in the application.
  26632. */
  26633. static get BumpTextureEnabled(): boolean;
  26634. static set BumpTextureEnabled(value: boolean);
  26635. /**
  26636. * Are lightmap textures enabled in the application.
  26637. */
  26638. static get LightmapTextureEnabled(): boolean;
  26639. static set LightmapTextureEnabled(value: boolean);
  26640. /**
  26641. * Are refraction textures enabled in the application.
  26642. */
  26643. static get RefractionTextureEnabled(): boolean;
  26644. static set RefractionTextureEnabled(value: boolean);
  26645. /**
  26646. * Are color grading textures enabled in the application.
  26647. */
  26648. static get ColorGradingTextureEnabled(): boolean;
  26649. static set ColorGradingTextureEnabled(value: boolean);
  26650. /**
  26651. * Are fresnels enabled in the application.
  26652. */
  26653. static get FresnelEnabled(): boolean;
  26654. static set FresnelEnabled(value: boolean);
  26655. }
  26656. }
  26657. declare module BABYLON {
  26658. /**
  26659. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26660. *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.
  26661. * The SPS is also a particle system. It provides some methods to manage the particles.
  26662. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26663. *
  26664. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26665. */
  26666. export class SolidParticleSystem implements IDisposable {
  26667. /**
  26668. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26669. * Example : var p = SPS.particles[i];
  26670. */
  26671. particles: SolidParticle[];
  26672. /**
  26673. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26674. */
  26675. nbParticles: number;
  26676. /**
  26677. * If the particles must ever face the camera (default false). Useful for planar particles.
  26678. */
  26679. billboard: boolean;
  26680. /**
  26681. * Recompute normals when adding a shape
  26682. */
  26683. recomputeNormals: boolean;
  26684. /**
  26685. * This a counter ofr your own usage. It's not set by any SPS functions.
  26686. */
  26687. counter: number;
  26688. /**
  26689. * The SPS name. This name is also given to the underlying mesh.
  26690. */
  26691. name: string;
  26692. /**
  26693. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26694. */
  26695. mesh: Mesh;
  26696. /**
  26697. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26698. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26699. */
  26700. vars: any;
  26701. /**
  26702. * This array is populated when the SPS is set as 'pickable'.
  26703. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26704. * Each element of this array is an object `{idx: int, faceId: int}`.
  26705. * `idx` is the picked particle index in the `SPS.particles` array
  26706. * `faceId` is the picked face index counted within this particle.
  26707. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26708. */
  26709. pickedParticles: {
  26710. idx: number;
  26711. faceId: number;
  26712. }[];
  26713. /**
  26714. * This array is populated when `enableDepthSort` is set to true.
  26715. * Each element of this array is an instance of the class DepthSortedParticle.
  26716. */
  26717. depthSortedParticles: DepthSortedParticle[];
  26718. /**
  26719. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26720. * @hidden
  26721. */
  26722. _bSphereOnly: boolean;
  26723. /**
  26724. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26725. * @hidden
  26726. */
  26727. _bSphereRadiusFactor: number;
  26728. private _scene;
  26729. private _positions;
  26730. private _indices;
  26731. private _normals;
  26732. private _colors;
  26733. private _uvs;
  26734. private _indices32;
  26735. private _positions32;
  26736. private _normals32;
  26737. private _fixedNormal32;
  26738. private _colors32;
  26739. private _uvs32;
  26740. private _index;
  26741. private _updatable;
  26742. private _pickable;
  26743. private _isVisibilityBoxLocked;
  26744. private _alwaysVisible;
  26745. private _depthSort;
  26746. private _expandable;
  26747. private _shapeCounter;
  26748. private _copy;
  26749. private _color;
  26750. private _computeParticleColor;
  26751. private _computeParticleTexture;
  26752. private _computeParticleRotation;
  26753. private _computeParticleVertex;
  26754. private _computeBoundingBox;
  26755. private _depthSortParticles;
  26756. private _camera;
  26757. private _mustUnrotateFixedNormals;
  26758. private _particlesIntersect;
  26759. private _needs32Bits;
  26760. private _isNotBuilt;
  26761. private _lastParticleId;
  26762. private _idxOfId;
  26763. private _multimaterialEnabled;
  26764. private _useModelMaterial;
  26765. private _indicesByMaterial;
  26766. private _materialIndexes;
  26767. private _depthSortFunction;
  26768. private _materialSortFunction;
  26769. private _materials;
  26770. private _multimaterial;
  26771. private _materialIndexesById;
  26772. private _defaultMaterial;
  26773. private _autoUpdateSubMeshes;
  26774. /**
  26775. * Creates a SPS (Solid Particle System) object.
  26776. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26777. * @param scene (Scene) is the scene in which the SPS is added.
  26778. * @param options defines the options of the sps e.g.
  26779. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26780. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26781. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26782. * * 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.
  26783. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26784. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26785. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26786. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26787. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26788. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26789. */
  26790. constructor(name: string, scene: Scene, options?: {
  26791. updatable?: boolean;
  26792. isPickable?: boolean;
  26793. enableDepthSort?: boolean;
  26794. particleIntersection?: boolean;
  26795. boundingSphereOnly?: boolean;
  26796. bSphereRadiusFactor?: number;
  26797. expandable?: boolean;
  26798. useModelMaterial?: boolean;
  26799. enableMultiMaterial?: boolean;
  26800. });
  26801. /**
  26802. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26803. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26804. * @returns the created mesh
  26805. */
  26806. buildMesh(): Mesh;
  26807. /**
  26808. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26809. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26810. * Thus the particles generated from `digest()` have their property `position` set yet.
  26811. * @param mesh ( Mesh ) is the mesh to be digested
  26812. * @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
  26813. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26814. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26815. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26816. * @returns the current SPS
  26817. */
  26818. digest(mesh: Mesh, options?: {
  26819. facetNb?: number;
  26820. number?: number;
  26821. delta?: number;
  26822. storage?: [];
  26823. }): SolidParticleSystem;
  26824. /**
  26825. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26826. * @hidden
  26827. */
  26828. private _unrotateFixedNormals;
  26829. /**
  26830. * Resets the temporary working copy particle
  26831. * @hidden
  26832. */
  26833. private _resetCopy;
  26834. /**
  26835. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26836. * @param p the current index in the positions array to be updated
  26837. * @param ind the current index in the indices array
  26838. * @param shape a Vector3 array, the shape geometry
  26839. * @param positions the positions array to be updated
  26840. * @param meshInd the shape indices array
  26841. * @param indices the indices array to be updated
  26842. * @param meshUV the shape uv array
  26843. * @param uvs the uv array to be updated
  26844. * @param meshCol the shape color array
  26845. * @param colors the color array to be updated
  26846. * @param meshNor the shape normals array
  26847. * @param normals the normals array to be updated
  26848. * @param idx the particle index
  26849. * @param idxInShape the particle index in its shape
  26850. * @param options the addShape() method passed options
  26851. * @model the particle model
  26852. * @hidden
  26853. */
  26854. private _meshBuilder;
  26855. /**
  26856. * Returns a shape Vector3 array from positions float array
  26857. * @param positions float array
  26858. * @returns a vector3 array
  26859. * @hidden
  26860. */
  26861. private _posToShape;
  26862. /**
  26863. * Returns a shapeUV array from a float uvs (array deep copy)
  26864. * @param uvs as a float array
  26865. * @returns a shapeUV array
  26866. * @hidden
  26867. */
  26868. private _uvsToShapeUV;
  26869. /**
  26870. * Adds a new particle object in the particles array
  26871. * @param idx particle index in particles array
  26872. * @param id particle id
  26873. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26874. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26875. * @param model particle ModelShape object
  26876. * @param shapeId model shape identifier
  26877. * @param idxInShape index of the particle in the current model
  26878. * @param bInfo model bounding info object
  26879. * @param storage target storage array, if any
  26880. * @hidden
  26881. */
  26882. private _addParticle;
  26883. /**
  26884. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26885. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26886. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26887. * @param nb (positive integer) the number of particles to be created from this model
  26888. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26889. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26890. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26891. * @returns the number of shapes in the system
  26892. */
  26893. addShape(mesh: Mesh, nb: number, options?: {
  26894. positionFunction?: any;
  26895. vertexFunction?: any;
  26896. storage?: [];
  26897. }): number;
  26898. /**
  26899. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26900. * @hidden
  26901. */
  26902. private _rebuildParticle;
  26903. /**
  26904. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26905. * @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.
  26906. * @returns the SPS.
  26907. */
  26908. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26909. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26910. * Returns an array with the removed particles.
  26911. * 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.
  26912. * The SPS can't be empty so at least one particle needs to remain in place.
  26913. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26914. * @param start index of the first particle to remove
  26915. * @param end index of the last particle to remove (included)
  26916. * @returns an array populated with the removed particles
  26917. */
  26918. removeParticles(start: number, end: number): SolidParticle[];
  26919. /**
  26920. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26921. * @param solidParticleArray an array populated with Solid Particles objects
  26922. * @returns the SPS
  26923. */
  26924. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26925. /**
  26926. * Creates a new particle and modifies the SPS mesh geometry :
  26927. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26928. * - calls _addParticle() to populate the particle array
  26929. * factorized code from addShape() and insertParticlesFromArray()
  26930. * @param idx particle index in the particles array
  26931. * @param i particle index in its shape
  26932. * @param modelShape particle ModelShape object
  26933. * @param shape shape vertex array
  26934. * @param meshInd shape indices array
  26935. * @param meshUV shape uv array
  26936. * @param meshCol shape color array
  26937. * @param meshNor shape normals array
  26938. * @param bbInfo shape bounding info
  26939. * @param storage target particle storage
  26940. * @options addShape() passed options
  26941. * @hidden
  26942. */
  26943. private _insertNewParticle;
  26944. /**
  26945. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26946. * This method calls `updateParticle()` for each particle of the SPS.
  26947. * For an animated SPS, it is usually called within the render loop.
  26948. * 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.
  26949. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26950. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26951. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26952. * @returns the SPS.
  26953. */
  26954. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26955. /**
  26956. * Disposes the SPS.
  26957. */
  26958. dispose(): void;
  26959. /**
  26960. * Returns a SolidParticle object from its identifier : particle.id
  26961. * @param id (integer) the particle Id
  26962. * @returns the searched particle or null if not found in the SPS.
  26963. */
  26964. getParticleById(id: number): Nullable<SolidParticle>;
  26965. /**
  26966. * Returns a new array populated with the particles having the passed shapeId.
  26967. * @param shapeId (integer) the shape identifier
  26968. * @returns a new solid particle array
  26969. */
  26970. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26971. /**
  26972. * Populates the passed array "ref" with the particles having the passed shapeId.
  26973. * @param shapeId the shape identifier
  26974. * @returns the SPS
  26975. * @param ref
  26976. */
  26977. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26978. /**
  26979. * Computes the required SubMeshes according the materials assigned to the particles.
  26980. * @returns the solid particle system.
  26981. * Does nothing if called before the SPS mesh is built.
  26982. */
  26983. computeSubMeshes(): SolidParticleSystem;
  26984. /**
  26985. * Sorts the solid particles by material when MultiMaterial is enabled.
  26986. * Updates the indices32 array.
  26987. * Updates the indicesByMaterial array.
  26988. * Updates the mesh indices array.
  26989. * @returns the SPS
  26990. * @hidden
  26991. */
  26992. private _sortParticlesByMaterial;
  26993. /**
  26994. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26995. * @hidden
  26996. */
  26997. private _setMaterialIndexesById;
  26998. /**
  26999. * Returns an array with unique values of Materials from the passed array
  27000. * @param array the material array to be checked and filtered
  27001. * @hidden
  27002. */
  27003. private _filterUniqueMaterialId;
  27004. /**
  27005. * Sets a new Standard Material as _defaultMaterial if not already set.
  27006. * @hidden
  27007. */
  27008. private _setDefaultMaterial;
  27009. /**
  27010. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27011. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27012. * @returns the SPS.
  27013. */
  27014. refreshVisibleSize(): SolidParticleSystem;
  27015. /**
  27016. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27017. * @param size the size (float) of the visibility box
  27018. * note : this doesn't lock the SPS mesh bounding box.
  27019. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27020. */
  27021. setVisibilityBox(size: number): void;
  27022. /**
  27023. * Gets whether the SPS as always visible or not
  27024. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27025. */
  27026. get isAlwaysVisible(): boolean;
  27027. /**
  27028. * Sets the SPS as always visible or not
  27029. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27030. */
  27031. set isAlwaysVisible(val: boolean);
  27032. /**
  27033. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27034. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27035. */
  27036. set isVisibilityBoxLocked(val: boolean);
  27037. /**
  27038. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27039. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27040. */
  27041. get isVisibilityBoxLocked(): boolean;
  27042. /**
  27043. * Tells to `setParticles()` to compute the particle rotations or not.
  27044. * Default value : true. The SPS is faster when it's set to false.
  27045. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27046. */
  27047. set computeParticleRotation(val: boolean);
  27048. /**
  27049. * Tells to `setParticles()` to compute the particle colors or not.
  27050. * Default value : true. The SPS is faster when it's set to false.
  27051. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27052. */
  27053. set computeParticleColor(val: boolean);
  27054. set computeParticleTexture(val: boolean);
  27055. /**
  27056. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27057. * Default value : false. The SPS is faster when it's set to false.
  27058. * Note : the particle custom vertex positions aren't stored values.
  27059. */
  27060. set computeParticleVertex(val: boolean);
  27061. /**
  27062. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27063. */
  27064. set computeBoundingBox(val: boolean);
  27065. /**
  27066. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27067. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27068. * Default : `true`
  27069. */
  27070. set depthSortParticles(val: boolean);
  27071. /**
  27072. * Gets if `setParticles()` computes the particle rotations or not.
  27073. * Default value : true. The SPS is faster when it's set to false.
  27074. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27075. */
  27076. get computeParticleRotation(): boolean;
  27077. /**
  27078. * Gets if `setParticles()` computes the particle colors or not.
  27079. * Default value : true. The SPS is faster when it's set to false.
  27080. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27081. */
  27082. get computeParticleColor(): boolean;
  27083. /**
  27084. * Gets if `setParticles()` computes the particle textures or not.
  27085. * Default value : true. The SPS is faster when it's set to false.
  27086. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27087. */
  27088. get computeParticleTexture(): boolean;
  27089. /**
  27090. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27091. * Default value : false. The SPS is faster when it's set to false.
  27092. * Note : the particle custom vertex positions aren't stored values.
  27093. */
  27094. get computeParticleVertex(): boolean;
  27095. /**
  27096. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27097. */
  27098. get computeBoundingBox(): boolean;
  27099. /**
  27100. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27101. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27102. * Default : `true`
  27103. */
  27104. get depthSortParticles(): boolean;
  27105. /**
  27106. * Gets if the SPS is created as expandable at construction time.
  27107. * Default : `false`
  27108. */
  27109. get expandable(): boolean;
  27110. /**
  27111. * Gets if the SPS supports the Multi Materials
  27112. */
  27113. get multimaterialEnabled(): boolean;
  27114. /**
  27115. * Gets if the SPS uses the model materials for its own multimaterial.
  27116. */
  27117. get useModelMaterial(): boolean;
  27118. /**
  27119. * The SPS used material array.
  27120. */
  27121. get materials(): Material[];
  27122. /**
  27123. * Sets the SPS MultiMaterial from the passed materials.
  27124. * Note : the passed array is internally copied and not used then by reference.
  27125. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27126. */
  27127. setMultiMaterial(materials: Material[]): void;
  27128. /**
  27129. * The SPS computed multimaterial object
  27130. */
  27131. get multimaterial(): MultiMaterial;
  27132. set multimaterial(mm: MultiMaterial);
  27133. /**
  27134. * If the subMeshes must be updated on the next call to setParticles()
  27135. */
  27136. get autoUpdateSubMeshes(): boolean;
  27137. set autoUpdateSubMeshes(val: boolean);
  27138. /**
  27139. * This function does nothing. It may be overwritten to set all the particle first values.
  27140. * The SPS doesn't call this function, you may have to call it by your own.
  27141. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27142. */
  27143. initParticles(): void;
  27144. /**
  27145. * This function does nothing. It may be overwritten to recycle a particle.
  27146. * The SPS doesn't call this function, you may have to call it by your own.
  27147. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27148. * @param particle The particle to recycle
  27149. * @returns the recycled particle
  27150. */
  27151. recycleParticle(particle: SolidParticle): SolidParticle;
  27152. /**
  27153. * Updates a particle : this function should be overwritten by the user.
  27154. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27156. * @example : just set a particle position or velocity and recycle conditions
  27157. * @param particle The particle to update
  27158. * @returns the updated particle
  27159. */
  27160. updateParticle(particle: SolidParticle): SolidParticle;
  27161. /**
  27162. * Updates a vertex of a particle : it can be overwritten by the user.
  27163. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27164. * @param particle the current particle
  27165. * @param vertex the current index of the current particle
  27166. * @param pt the index of the current vertex in the particle shape
  27167. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27168. * @example : just set a vertex particle position
  27169. * @returns the updated vertex
  27170. */
  27171. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27172. /**
  27173. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27174. * This does nothing and may be overwritten by the user.
  27175. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27176. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27177. * @param update the boolean update value actually passed to setParticles()
  27178. */
  27179. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27180. /**
  27181. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27182. * This will be passed three parameters.
  27183. * This does nothing and may be overwritten by the user.
  27184. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27185. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27186. * @param update the boolean update value actually passed to setParticles()
  27187. */
  27188. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27189. }
  27190. }
  27191. declare module BABYLON {
  27192. /**
  27193. * Represents one particle of a solid particle system.
  27194. */
  27195. export class SolidParticle {
  27196. /**
  27197. * particle global index
  27198. */
  27199. idx: number;
  27200. /**
  27201. * particle identifier
  27202. */
  27203. id: number;
  27204. /**
  27205. * The color of the particle
  27206. */
  27207. color: Nullable<Color4>;
  27208. /**
  27209. * The world space position of the particle.
  27210. */
  27211. position: Vector3;
  27212. /**
  27213. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27214. */
  27215. rotation: Vector3;
  27216. /**
  27217. * The world space rotation quaternion of the particle.
  27218. */
  27219. rotationQuaternion: Nullable<Quaternion>;
  27220. /**
  27221. * The scaling of the particle.
  27222. */
  27223. scaling: Vector3;
  27224. /**
  27225. * The uvs of the particle.
  27226. */
  27227. uvs: Vector4;
  27228. /**
  27229. * The current speed of the particle.
  27230. */
  27231. velocity: Vector3;
  27232. /**
  27233. * The pivot point in the particle local space.
  27234. */
  27235. pivot: Vector3;
  27236. /**
  27237. * Must the particle be translated from its pivot point in its local space ?
  27238. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27239. * Default : false
  27240. */
  27241. translateFromPivot: boolean;
  27242. /**
  27243. * Is the particle active or not ?
  27244. */
  27245. alive: boolean;
  27246. /**
  27247. * Is the particle visible or not ?
  27248. */
  27249. isVisible: boolean;
  27250. /**
  27251. * Index of this particle in the global "positions" array (Internal use)
  27252. * @hidden
  27253. */
  27254. _pos: number;
  27255. /**
  27256. * @hidden Index of this particle in the global "indices" array (Internal use)
  27257. */
  27258. _ind: number;
  27259. /**
  27260. * @hidden ModelShape of this particle (Internal use)
  27261. */
  27262. _model: ModelShape;
  27263. /**
  27264. * ModelShape id of this particle
  27265. */
  27266. shapeId: number;
  27267. /**
  27268. * Index of the particle in its shape id
  27269. */
  27270. idxInShape: number;
  27271. /**
  27272. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27273. */
  27274. _modelBoundingInfo: BoundingInfo;
  27275. /**
  27276. * @hidden Particle BoundingInfo object (Internal use)
  27277. */
  27278. _boundingInfo: BoundingInfo;
  27279. /**
  27280. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27281. */
  27282. _sps: SolidParticleSystem;
  27283. /**
  27284. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27285. */
  27286. _stillInvisible: boolean;
  27287. /**
  27288. * @hidden Last computed particle rotation matrix
  27289. */
  27290. _rotationMatrix: number[];
  27291. /**
  27292. * Parent particle Id, if any.
  27293. * Default null.
  27294. */
  27295. parentId: Nullable<number>;
  27296. /**
  27297. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27298. */
  27299. materialIndex: Nullable<number>;
  27300. /**
  27301. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27302. * The possible values are :
  27303. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27304. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27306. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27307. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27308. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27309. * */
  27310. cullingStrategy: number;
  27311. /**
  27312. * @hidden Internal global position in the SPS.
  27313. */
  27314. _globalPosition: Vector3;
  27315. /**
  27316. * Creates a Solid Particle object.
  27317. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27318. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27319. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27320. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27321. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27322. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27323. * @param shapeId (integer) is the model shape identifier in the SPS.
  27324. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27325. * @param sps defines the sps it is associated to
  27326. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27327. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27328. */
  27329. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27330. /**
  27331. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27332. * @param target the particle target
  27333. * @returns the current particle
  27334. */
  27335. copyToRef(target: SolidParticle): SolidParticle;
  27336. /**
  27337. * Legacy support, changed scale to scaling
  27338. */
  27339. get scale(): Vector3;
  27340. /**
  27341. * Legacy support, changed scale to scaling
  27342. */
  27343. set scale(scale: Vector3);
  27344. /**
  27345. * Legacy support, changed quaternion to rotationQuaternion
  27346. */
  27347. get quaternion(): Nullable<Quaternion>;
  27348. /**
  27349. * Legacy support, changed quaternion to rotationQuaternion
  27350. */
  27351. set quaternion(q: Nullable<Quaternion>);
  27352. /**
  27353. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27354. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27355. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27356. * @returns true if it intersects
  27357. */
  27358. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27359. /**
  27360. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27361. * A particle is in the frustum if its bounding box intersects the frustum
  27362. * @param frustumPlanes defines the frustum to test
  27363. * @returns true if the particle is in the frustum planes
  27364. */
  27365. isInFrustum(frustumPlanes: Plane[]): boolean;
  27366. /**
  27367. * get the rotation matrix of the particle
  27368. * @hidden
  27369. */
  27370. getRotationMatrix(m: Matrix): void;
  27371. }
  27372. /**
  27373. * Represents the shape of the model used by one particle of a solid particle system.
  27374. * SPS internal tool, don't use it manually.
  27375. */
  27376. export class ModelShape {
  27377. /**
  27378. * The shape id
  27379. * @hidden
  27380. */
  27381. shapeID: number;
  27382. /**
  27383. * flat array of model positions (internal use)
  27384. * @hidden
  27385. */
  27386. _shape: Vector3[];
  27387. /**
  27388. * flat array of model UVs (internal use)
  27389. * @hidden
  27390. */
  27391. _shapeUV: number[];
  27392. /**
  27393. * color array of the model
  27394. * @hidden
  27395. */
  27396. _shapeColors: number[];
  27397. /**
  27398. * indices array of the model
  27399. * @hidden
  27400. */
  27401. _indices: number[];
  27402. /**
  27403. * normals array of the model
  27404. * @hidden
  27405. */
  27406. _normals: number[];
  27407. /**
  27408. * length of the shape in the model indices array (internal use)
  27409. * @hidden
  27410. */
  27411. _indicesLength: number;
  27412. /**
  27413. * Custom position function (internal use)
  27414. * @hidden
  27415. */
  27416. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27417. /**
  27418. * Custom vertex function (internal use)
  27419. * @hidden
  27420. */
  27421. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27422. /**
  27423. * Model material (internal use)
  27424. * @hidden
  27425. */
  27426. _material: Nullable<Material>;
  27427. /**
  27428. * 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.
  27429. * SPS internal tool, don't use it manually.
  27430. * @hidden
  27431. */
  27432. 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>);
  27433. }
  27434. /**
  27435. * Represents a Depth Sorted Particle in the solid particle system.
  27436. * @hidden
  27437. */
  27438. export class DepthSortedParticle {
  27439. /**
  27440. * Index of the particle in the "indices" array
  27441. */
  27442. ind: number;
  27443. /**
  27444. * Length of the particle shape in the "indices" array
  27445. */
  27446. indicesLength: number;
  27447. /**
  27448. * Squared distance from the particle to the camera
  27449. */
  27450. sqDistance: number;
  27451. /**
  27452. * Material index when used with MultiMaterials
  27453. */
  27454. materialIndex: number;
  27455. /**
  27456. * Creates a new sorted particle
  27457. * @param materialIndex
  27458. */
  27459. constructor(ind: number, indLength: number, materialIndex: number);
  27460. }
  27461. }
  27462. declare module BABYLON {
  27463. /**
  27464. * @hidden
  27465. */
  27466. export class _MeshCollisionData {
  27467. _checkCollisions: boolean;
  27468. _collisionMask: number;
  27469. _collisionGroup: number;
  27470. _collider: Nullable<Collider>;
  27471. _oldPositionForCollisions: Vector3;
  27472. _diffPositionForCollisions: Vector3;
  27473. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27474. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27475. }
  27476. }
  27477. declare module BABYLON {
  27478. /** @hidden */
  27479. class _FacetDataStorage {
  27480. facetPositions: Vector3[];
  27481. facetNormals: Vector3[];
  27482. facetPartitioning: number[][];
  27483. facetNb: number;
  27484. partitioningSubdivisions: number;
  27485. partitioningBBoxRatio: number;
  27486. facetDataEnabled: boolean;
  27487. facetParameters: any;
  27488. bbSize: Vector3;
  27489. subDiv: {
  27490. max: number;
  27491. X: number;
  27492. Y: number;
  27493. Z: number;
  27494. };
  27495. facetDepthSort: boolean;
  27496. facetDepthSortEnabled: boolean;
  27497. depthSortedIndices: IndicesArray;
  27498. depthSortedFacets: {
  27499. ind: number;
  27500. sqDistance: number;
  27501. }[];
  27502. facetDepthSortFunction: (f1: {
  27503. ind: number;
  27504. sqDistance: number;
  27505. }, f2: {
  27506. ind: number;
  27507. sqDistance: number;
  27508. }) => number;
  27509. facetDepthSortFrom: Vector3;
  27510. facetDepthSortOrigin: Vector3;
  27511. invertedMatrix: Matrix;
  27512. }
  27513. /**
  27514. * @hidden
  27515. **/
  27516. class _InternalAbstractMeshDataInfo {
  27517. _hasVertexAlpha: boolean;
  27518. _useVertexColors: boolean;
  27519. _numBoneInfluencers: number;
  27520. _applyFog: boolean;
  27521. _receiveShadows: boolean;
  27522. _facetData: _FacetDataStorage;
  27523. _visibility: number;
  27524. _skeleton: Nullable<Skeleton>;
  27525. _layerMask: number;
  27526. _computeBonesUsingShaders: boolean;
  27527. _isActive: boolean;
  27528. _onlyForInstances: boolean;
  27529. _isActiveIntermediate: boolean;
  27530. _onlyForInstancesIntermediate: boolean;
  27531. _actAsRegularMesh: boolean;
  27532. }
  27533. /**
  27534. * Class used to store all common mesh properties
  27535. */
  27536. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27537. /** No occlusion */
  27538. static OCCLUSION_TYPE_NONE: number;
  27539. /** Occlusion set to optimisitic */
  27540. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27541. /** Occlusion set to strict */
  27542. static OCCLUSION_TYPE_STRICT: number;
  27543. /** Use an accurante occlusion algorithm */
  27544. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27545. /** Use a conservative occlusion algorithm */
  27546. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27547. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27548. * Test order :
  27549. * Is the bounding sphere outside the frustum ?
  27550. * If not, are the bounding box vertices outside the frustum ?
  27551. * It not, then the cullable object is in the frustum.
  27552. */
  27553. static readonly CULLINGSTRATEGY_STANDARD: number;
  27554. /** Culling strategy : Bounding Sphere Only.
  27555. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27556. * It's also less accurate than the standard because some not visible objects can still be selected.
  27557. * Test : is the bounding sphere outside the frustum ?
  27558. * If not, then the cullable object is in the frustum.
  27559. */
  27560. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27561. /** Culling strategy : Optimistic Inclusion.
  27562. * This in an inclusion test first, then the standard exclusion test.
  27563. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27564. * 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.
  27565. * Anyway, it's as accurate as the standard strategy.
  27566. * Test :
  27567. * Is the cullable object bounding sphere center in the frustum ?
  27568. * If not, apply the default culling strategy.
  27569. */
  27570. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27571. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27572. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27573. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27574. * 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.
  27575. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27576. * Test :
  27577. * Is the cullable object bounding sphere center in the frustum ?
  27578. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27579. */
  27580. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27581. /**
  27582. * No billboard
  27583. */
  27584. static get BILLBOARDMODE_NONE(): number;
  27585. /** Billboard on X axis */
  27586. static get BILLBOARDMODE_X(): number;
  27587. /** Billboard on Y axis */
  27588. static get BILLBOARDMODE_Y(): number;
  27589. /** Billboard on Z axis */
  27590. static get BILLBOARDMODE_Z(): number;
  27591. /** Billboard on all axes */
  27592. static get BILLBOARDMODE_ALL(): number;
  27593. /** Billboard on using position instead of orientation */
  27594. static get BILLBOARDMODE_USE_POSITION(): number;
  27595. /** @hidden */
  27596. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27597. /**
  27598. * The culling strategy to use to check whether the mesh must be rendered or not.
  27599. * This value can be changed at any time and will be used on the next render mesh selection.
  27600. * The possible values are :
  27601. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27602. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27603. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27604. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27605. * Please read each static variable documentation to get details about the culling process.
  27606. * */
  27607. cullingStrategy: number;
  27608. /**
  27609. * Gets the number of facets in the mesh
  27610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27611. */
  27612. get facetNb(): number;
  27613. /**
  27614. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27616. */
  27617. get partitioningSubdivisions(): number;
  27618. set partitioningSubdivisions(nb: number);
  27619. /**
  27620. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27621. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27623. */
  27624. get partitioningBBoxRatio(): number;
  27625. set partitioningBBoxRatio(ratio: number);
  27626. /**
  27627. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27628. * Works only for updatable meshes.
  27629. * Doesn't work with multi-materials
  27630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27631. */
  27632. get mustDepthSortFacets(): boolean;
  27633. set mustDepthSortFacets(sort: boolean);
  27634. /**
  27635. * The location (Vector3) where the facet depth sort must be computed from.
  27636. * By default, the active camera position.
  27637. * Used only when facet depth sort is enabled
  27638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27639. */
  27640. get facetDepthSortFrom(): Vector3;
  27641. set facetDepthSortFrom(location: Vector3);
  27642. /**
  27643. * gets a boolean indicating if facetData is enabled
  27644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27645. */
  27646. get isFacetDataEnabled(): boolean;
  27647. /** @hidden */
  27648. _updateNonUniformScalingState(value: boolean): boolean;
  27649. /**
  27650. * An event triggered when this mesh collides with another one
  27651. */
  27652. onCollideObservable: Observable<AbstractMesh>;
  27653. /** Set a function to call when this mesh collides with another one */
  27654. set onCollide(callback: () => void);
  27655. /**
  27656. * An event triggered when the collision's position changes
  27657. */
  27658. onCollisionPositionChangeObservable: Observable<Vector3>;
  27659. /** Set a function to call when the collision's position changes */
  27660. set onCollisionPositionChange(callback: () => void);
  27661. /**
  27662. * An event triggered when material is changed
  27663. */
  27664. onMaterialChangedObservable: Observable<AbstractMesh>;
  27665. /**
  27666. * Gets or sets the orientation for POV movement & rotation
  27667. */
  27668. definedFacingForward: boolean;
  27669. /** @hidden */
  27670. _occlusionQuery: Nullable<WebGLQuery>;
  27671. /** @hidden */
  27672. _renderingGroup: Nullable<RenderingGroup>;
  27673. /**
  27674. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27675. */
  27676. get visibility(): number;
  27677. /**
  27678. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27679. */
  27680. set visibility(value: number);
  27681. /** Gets or sets the alpha index used to sort transparent meshes
  27682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27683. */
  27684. alphaIndex: number;
  27685. /**
  27686. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27687. */
  27688. isVisible: boolean;
  27689. /**
  27690. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27691. */
  27692. isPickable: boolean;
  27693. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27694. showSubMeshesBoundingBox: boolean;
  27695. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27696. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27697. */
  27698. isBlocker: boolean;
  27699. /**
  27700. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27701. */
  27702. enablePointerMoveEvents: boolean;
  27703. /**
  27704. * Specifies the rendering group id for this mesh (0 by default)
  27705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27706. */
  27707. renderingGroupId: number;
  27708. private _material;
  27709. /** Gets or sets current material */
  27710. get material(): Nullable<Material>;
  27711. set material(value: Nullable<Material>);
  27712. /**
  27713. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27714. * @see http://doc.babylonjs.com/babylon101/shadows
  27715. */
  27716. get receiveShadows(): boolean;
  27717. set receiveShadows(value: boolean);
  27718. /** Defines color to use when rendering outline */
  27719. outlineColor: Color3;
  27720. /** Define width to use when rendering outline */
  27721. outlineWidth: number;
  27722. /** Defines color to use when rendering overlay */
  27723. overlayColor: Color3;
  27724. /** Defines alpha to use when rendering overlay */
  27725. overlayAlpha: number;
  27726. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27727. get hasVertexAlpha(): boolean;
  27728. set hasVertexAlpha(value: boolean);
  27729. /** 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) */
  27730. get useVertexColors(): boolean;
  27731. set useVertexColors(value: boolean);
  27732. /**
  27733. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27734. */
  27735. get computeBonesUsingShaders(): boolean;
  27736. set computeBonesUsingShaders(value: boolean);
  27737. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27738. get numBoneInfluencers(): number;
  27739. set numBoneInfluencers(value: number);
  27740. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27741. get applyFog(): boolean;
  27742. set applyFog(value: boolean);
  27743. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27744. useOctreeForRenderingSelection: boolean;
  27745. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27746. useOctreeForPicking: boolean;
  27747. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27748. useOctreeForCollisions: boolean;
  27749. /**
  27750. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27751. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27752. */
  27753. get layerMask(): number;
  27754. set layerMask(value: number);
  27755. /**
  27756. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27757. */
  27758. alwaysSelectAsActiveMesh: boolean;
  27759. /**
  27760. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27761. */
  27762. doNotSyncBoundingInfo: boolean;
  27763. /**
  27764. * Gets or sets the current action manager
  27765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27766. */
  27767. actionManager: Nullable<AbstractActionManager>;
  27768. private _meshCollisionData;
  27769. /**
  27770. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27772. */
  27773. ellipsoid: Vector3;
  27774. /**
  27775. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27777. */
  27778. ellipsoidOffset: Vector3;
  27779. /**
  27780. * Gets or sets a collision mask used to mask collisions (default is -1).
  27781. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27782. */
  27783. get collisionMask(): number;
  27784. set collisionMask(mask: number);
  27785. /**
  27786. * Gets or sets the current collision group mask (-1 by default).
  27787. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27788. */
  27789. get collisionGroup(): number;
  27790. set collisionGroup(mask: number);
  27791. /**
  27792. * Defines edge width used when edgesRenderer is enabled
  27793. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27794. */
  27795. edgesWidth: number;
  27796. /**
  27797. * Defines edge color used when edgesRenderer is enabled
  27798. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27799. */
  27800. edgesColor: Color4;
  27801. /** @hidden */
  27802. _edgesRenderer: Nullable<IEdgesRenderer>;
  27803. /** @hidden */
  27804. _masterMesh: Nullable<AbstractMesh>;
  27805. /** @hidden */
  27806. _boundingInfo: Nullable<BoundingInfo>;
  27807. /** @hidden */
  27808. _renderId: number;
  27809. /**
  27810. * Gets or sets the list of subMeshes
  27811. * @see http://doc.babylonjs.com/how_to/multi_materials
  27812. */
  27813. subMeshes: SubMesh[];
  27814. /** @hidden */
  27815. _intersectionsInProgress: AbstractMesh[];
  27816. /** @hidden */
  27817. _unIndexed: boolean;
  27818. /** @hidden */
  27819. _lightSources: Light[];
  27820. /** Gets the list of lights affecting that mesh */
  27821. get lightSources(): Light[];
  27822. /** @hidden */
  27823. get _positions(): Nullable<Vector3[]>;
  27824. /** @hidden */
  27825. _waitingData: {
  27826. lods: Nullable<any>;
  27827. actions: Nullable<any>;
  27828. freezeWorldMatrix: Nullable<boolean>;
  27829. };
  27830. /** @hidden */
  27831. _bonesTransformMatrices: Nullable<Float32Array>;
  27832. /** @hidden */
  27833. _transformMatrixTexture: Nullable<RawTexture>;
  27834. /**
  27835. * Gets or sets a skeleton to apply skining transformations
  27836. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27837. */
  27838. set skeleton(value: Nullable<Skeleton>);
  27839. get skeleton(): Nullable<Skeleton>;
  27840. /**
  27841. * An event triggered when the mesh is rebuilt.
  27842. */
  27843. onRebuildObservable: Observable<AbstractMesh>;
  27844. /**
  27845. * Creates a new AbstractMesh
  27846. * @param name defines the name of the mesh
  27847. * @param scene defines the hosting scene
  27848. */
  27849. constructor(name: string, scene?: Nullable<Scene>);
  27850. /**
  27851. * Returns the string "AbstractMesh"
  27852. * @returns "AbstractMesh"
  27853. */
  27854. getClassName(): string;
  27855. /**
  27856. * Gets a string representation of the current mesh
  27857. * @param fullDetails defines a boolean indicating if full details must be included
  27858. * @returns a string representation of the current mesh
  27859. */
  27860. toString(fullDetails?: boolean): string;
  27861. /**
  27862. * @hidden
  27863. */
  27864. protected _getEffectiveParent(): Nullable<Node>;
  27865. /** @hidden */
  27866. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27867. /** @hidden */
  27868. _rebuild(): void;
  27869. /** @hidden */
  27870. _resyncLightSources(): void;
  27871. /** @hidden */
  27872. _resyncLightSource(light: Light): void;
  27873. /** @hidden */
  27874. _unBindEffect(): void;
  27875. /** @hidden */
  27876. _removeLightSource(light: Light, dispose: boolean): void;
  27877. private _markSubMeshesAsDirty;
  27878. /** @hidden */
  27879. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27880. /** @hidden */
  27881. _markSubMeshesAsAttributesDirty(): void;
  27882. /** @hidden */
  27883. _markSubMeshesAsMiscDirty(): void;
  27884. /**
  27885. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27886. */
  27887. get scaling(): Vector3;
  27888. set scaling(newScaling: Vector3);
  27889. /**
  27890. * Returns true if the mesh is blocked. Implemented by child classes
  27891. */
  27892. get isBlocked(): boolean;
  27893. /**
  27894. * Returns the mesh itself by default. Implemented by child classes
  27895. * @param camera defines the camera to use to pick the right LOD level
  27896. * @returns the currentAbstractMesh
  27897. */
  27898. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27899. /**
  27900. * Returns 0 by default. Implemented by child classes
  27901. * @returns an integer
  27902. */
  27903. getTotalVertices(): number;
  27904. /**
  27905. * Returns a positive integer : the total number of indices in this mesh geometry.
  27906. * @returns the numner of indices or zero if the mesh has no geometry.
  27907. */
  27908. getTotalIndices(): number;
  27909. /**
  27910. * Returns null by default. Implemented by child classes
  27911. * @returns null
  27912. */
  27913. getIndices(): Nullable<IndicesArray>;
  27914. /**
  27915. * Returns the array of the requested vertex data kind. Implemented by child classes
  27916. * @param kind defines the vertex data kind to use
  27917. * @returns null
  27918. */
  27919. getVerticesData(kind: string): Nullable<FloatArray>;
  27920. /**
  27921. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27922. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27923. * Note that a new underlying VertexBuffer object is created each call.
  27924. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27925. * @param kind defines vertex data kind:
  27926. * * VertexBuffer.PositionKind
  27927. * * VertexBuffer.UVKind
  27928. * * VertexBuffer.UV2Kind
  27929. * * VertexBuffer.UV3Kind
  27930. * * VertexBuffer.UV4Kind
  27931. * * VertexBuffer.UV5Kind
  27932. * * VertexBuffer.UV6Kind
  27933. * * VertexBuffer.ColorKind
  27934. * * VertexBuffer.MatricesIndicesKind
  27935. * * VertexBuffer.MatricesIndicesExtraKind
  27936. * * VertexBuffer.MatricesWeightsKind
  27937. * * VertexBuffer.MatricesWeightsExtraKind
  27938. * @param data defines the data source
  27939. * @param updatable defines if the data must be flagged as updatable (or static)
  27940. * @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
  27941. * @returns the current mesh
  27942. */
  27943. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27944. /**
  27945. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27946. * If the mesh has no geometry, it is simply returned as it is.
  27947. * @param kind defines vertex data kind:
  27948. * * VertexBuffer.PositionKind
  27949. * * VertexBuffer.UVKind
  27950. * * VertexBuffer.UV2Kind
  27951. * * VertexBuffer.UV3Kind
  27952. * * VertexBuffer.UV4Kind
  27953. * * VertexBuffer.UV5Kind
  27954. * * VertexBuffer.UV6Kind
  27955. * * VertexBuffer.ColorKind
  27956. * * VertexBuffer.MatricesIndicesKind
  27957. * * VertexBuffer.MatricesIndicesExtraKind
  27958. * * VertexBuffer.MatricesWeightsKind
  27959. * * VertexBuffer.MatricesWeightsExtraKind
  27960. * @param data defines the data source
  27961. * @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
  27962. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27963. * @returns the current mesh
  27964. */
  27965. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27966. /**
  27967. * Sets the mesh indices,
  27968. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27969. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27970. * @param totalVertices Defines the total number of vertices
  27971. * @returns the current mesh
  27972. */
  27973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27974. /**
  27975. * Gets a boolean indicating if specific vertex data is present
  27976. * @param kind defines the vertex data kind to use
  27977. * @returns true is data kind is present
  27978. */
  27979. isVerticesDataPresent(kind: string): boolean;
  27980. /**
  27981. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27982. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27983. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27984. * @returns a BoundingInfo
  27985. */
  27986. getBoundingInfo(): BoundingInfo;
  27987. /**
  27988. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27989. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27990. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27991. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27992. * @returns the current mesh
  27993. */
  27994. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27995. /**
  27996. * Overwrite the current bounding info
  27997. * @param boundingInfo defines the new bounding info
  27998. * @returns the current mesh
  27999. */
  28000. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28001. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28002. get useBones(): boolean;
  28003. /** @hidden */
  28004. _preActivate(): void;
  28005. /** @hidden */
  28006. _preActivateForIntermediateRendering(renderId: number): void;
  28007. /** @hidden */
  28008. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28009. /** @hidden */
  28010. _postActivate(): void;
  28011. /** @hidden */
  28012. _freeze(): void;
  28013. /** @hidden */
  28014. _unFreeze(): void;
  28015. /**
  28016. * Gets the current world matrix
  28017. * @returns a Matrix
  28018. */
  28019. getWorldMatrix(): Matrix;
  28020. /** @hidden */
  28021. _getWorldMatrixDeterminant(): number;
  28022. /**
  28023. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28024. */
  28025. get isAnInstance(): boolean;
  28026. /**
  28027. * Gets a boolean indicating if this mesh has instances
  28028. */
  28029. get hasInstances(): boolean;
  28030. /**
  28031. * Perform relative position change from the point of view of behind the front of the mesh.
  28032. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28033. * Supports definition of mesh facing forward or backward
  28034. * @param amountRight defines the distance on the right axis
  28035. * @param amountUp defines the distance on the up axis
  28036. * @param amountForward defines the distance on the forward axis
  28037. * @returns the current mesh
  28038. */
  28039. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28040. /**
  28041. * Calculate relative position change from the point of view of behind the front of the mesh.
  28042. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28043. * Supports definition of mesh facing forward or backward
  28044. * @param amountRight defines the distance on the right axis
  28045. * @param amountUp defines the distance on the up axis
  28046. * @param amountForward defines the distance on the forward axis
  28047. * @returns the new displacement vector
  28048. */
  28049. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28050. /**
  28051. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28052. * Supports definition of mesh facing forward or backward
  28053. * @param flipBack defines the flip
  28054. * @param twirlClockwise defines the twirl
  28055. * @param tiltRight defines the tilt
  28056. * @returns the current mesh
  28057. */
  28058. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28059. /**
  28060. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28061. * Supports definition of mesh facing forward or backward.
  28062. * @param flipBack defines the flip
  28063. * @param twirlClockwise defines the twirl
  28064. * @param tiltRight defines the tilt
  28065. * @returns the new rotation vector
  28066. */
  28067. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28068. /**
  28069. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28070. * This means the mesh underlying bounding box and sphere are recomputed.
  28071. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28072. * @returns the current mesh
  28073. */
  28074. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28075. /** @hidden */
  28076. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28077. /** @hidden */
  28078. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28079. /** @hidden */
  28080. _updateBoundingInfo(): AbstractMesh;
  28081. /** @hidden */
  28082. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28083. /** @hidden */
  28084. protected _afterComputeWorldMatrix(): void;
  28085. /** @hidden */
  28086. get _effectiveMesh(): AbstractMesh;
  28087. /**
  28088. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28089. * A mesh is in the frustum if its bounding box intersects the frustum
  28090. * @param frustumPlanes defines the frustum to test
  28091. * @returns true if the mesh is in the frustum planes
  28092. */
  28093. isInFrustum(frustumPlanes: Plane[]): boolean;
  28094. /**
  28095. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28096. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28097. * @param frustumPlanes defines the frustum to test
  28098. * @returns true if the mesh is completely in the frustum planes
  28099. */
  28100. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28101. /**
  28102. * True if the mesh intersects another mesh or a SolidParticle object
  28103. * @param mesh defines a target mesh or SolidParticle to test
  28104. * @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)
  28105. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28106. * @returns true if there is an intersection
  28107. */
  28108. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28109. /**
  28110. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28111. * @param point defines the point to test
  28112. * @returns true if there is an intersection
  28113. */
  28114. intersectsPoint(point: Vector3): boolean;
  28115. /**
  28116. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28118. */
  28119. get checkCollisions(): boolean;
  28120. set checkCollisions(collisionEnabled: boolean);
  28121. /**
  28122. * Gets Collider object used to compute collisions (not physics)
  28123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28124. */
  28125. get collider(): Nullable<Collider>;
  28126. /**
  28127. * Move the mesh using collision engine
  28128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28129. * @param displacement defines the requested displacement vector
  28130. * @returns the current mesh
  28131. */
  28132. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28133. private _onCollisionPositionChange;
  28134. /** @hidden */
  28135. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28136. /** @hidden */
  28137. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28138. /** @hidden */
  28139. _checkCollision(collider: Collider): AbstractMesh;
  28140. /** @hidden */
  28141. _generatePointsArray(): boolean;
  28142. /**
  28143. * Checks if the passed Ray intersects with the mesh
  28144. * @param ray defines the ray to use
  28145. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28146. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28147. * @returns the picking info
  28148. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28149. */
  28150. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28151. /**
  28152. * Clones the current mesh
  28153. * @param name defines the mesh name
  28154. * @param newParent defines the new mesh parent
  28155. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28156. * @returns the new mesh
  28157. */
  28158. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28159. /**
  28160. * Disposes all the submeshes of the current meshnp
  28161. * @returns the current mesh
  28162. */
  28163. releaseSubMeshes(): AbstractMesh;
  28164. /**
  28165. * Releases resources associated with this abstract mesh.
  28166. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28167. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28168. */
  28169. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28170. /**
  28171. * Adds the passed mesh as a child to the current mesh
  28172. * @param mesh defines the child mesh
  28173. * @returns the current mesh
  28174. */
  28175. addChild(mesh: AbstractMesh): AbstractMesh;
  28176. /**
  28177. * Removes the passed mesh from the current mesh children list
  28178. * @param mesh defines the child mesh
  28179. * @returns the current mesh
  28180. */
  28181. removeChild(mesh: AbstractMesh): AbstractMesh;
  28182. /** @hidden */
  28183. private _initFacetData;
  28184. /**
  28185. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28186. * This method can be called within the render loop.
  28187. * 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
  28188. * @returns the current mesh
  28189. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28190. */
  28191. updateFacetData(): AbstractMesh;
  28192. /**
  28193. * Returns the facetLocalNormals array.
  28194. * The normals are expressed in the mesh local spac
  28195. * @returns an array of Vector3
  28196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28197. */
  28198. getFacetLocalNormals(): Vector3[];
  28199. /**
  28200. * Returns the facetLocalPositions array.
  28201. * The facet positions are expressed in the mesh local space
  28202. * @returns an array of Vector3
  28203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28204. */
  28205. getFacetLocalPositions(): Vector3[];
  28206. /**
  28207. * Returns the facetLocalPartioning array
  28208. * @returns an array of array of numbers
  28209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28210. */
  28211. getFacetLocalPartitioning(): number[][];
  28212. /**
  28213. * Returns the i-th facet position in the world system.
  28214. * This method allocates a new Vector3 per call
  28215. * @param i defines the facet index
  28216. * @returns a new Vector3
  28217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28218. */
  28219. getFacetPosition(i: number): Vector3;
  28220. /**
  28221. * Sets the reference Vector3 with the i-th facet position in the world system
  28222. * @param i defines the facet index
  28223. * @param ref defines the target vector
  28224. * @returns the current mesh
  28225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28226. */
  28227. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28228. /**
  28229. * Returns the i-th facet normal in the world system.
  28230. * This method allocates a new Vector3 per call
  28231. * @param i defines the facet index
  28232. * @returns a new Vector3
  28233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28234. */
  28235. getFacetNormal(i: number): Vector3;
  28236. /**
  28237. * Sets the reference Vector3 with the i-th facet normal in the world system
  28238. * @param i defines the facet index
  28239. * @param ref defines the target vector
  28240. * @returns the current mesh
  28241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28242. */
  28243. getFacetNormalToRef(i: number, ref: Vector3): this;
  28244. /**
  28245. * 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)
  28246. * @param x defines x coordinate
  28247. * @param y defines y coordinate
  28248. * @param z defines z coordinate
  28249. * @returns the array of facet indexes
  28250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28251. */
  28252. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28253. /**
  28254. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28255. * @param projected sets as the (x,y,z) world 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. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28265. /**
  28266. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28267. * @param projected sets as the (x,y,z) local projection on the facet
  28268. * @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
  28269. * @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
  28270. * @param x defines x coordinate
  28271. * @param y defines y coordinate
  28272. * @param z defines z coordinate
  28273. * @returns the face index if found (or null instead)
  28274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28275. */
  28276. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28277. /**
  28278. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28279. * @returns the parameters
  28280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28281. */
  28282. getFacetDataParameters(): any;
  28283. /**
  28284. * Disables the feature FacetData and frees the related memory
  28285. * @returns the current mesh
  28286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28287. */
  28288. disableFacetData(): AbstractMesh;
  28289. /**
  28290. * Updates the AbstractMesh indices array
  28291. * @param indices defines the data source
  28292. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28293. * @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)
  28294. * @returns the current mesh
  28295. */
  28296. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28297. /**
  28298. * Creates new normals data for the mesh
  28299. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28300. * @returns the current mesh
  28301. */
  28302. createNormals(updatable: boolean): AbstractMesh;
  28303. /**
  28304. * Align the mesh with a normal
  28305. * @param normal defines the normal to use
  28306. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28307. * @returns the current mesh
  28308. */
  28309. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28310. /** @hidden */
  28311. _checkOcclusionQuery(): boolean;
  28312. /**
  28313. * Disables the mesh edge rendering mode
  28314. * @returns the currentAbstractMesh
  28315. */
  28316. disableEdgesRendering(): AbstractMesh;
  28317. /**
  28318. * Enables the edge rendering mode on the mesh.
  28319. * This mode makes the mesh edges visible
  28320. * @param epsilon defines the maximal distance between two angles to detect a face
  28321. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28322. * @returns the currentAbstractMesh
  28323. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28324. */
  28325. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28326. }
  28327. }
  28328. declare module BABYLON {
  28329. /**
  28330. * Interface used to define ActionEvent
  28331. */
  28332. export interface IActionEvent {
  28333. /** The mesh or sprite that triggered the action */
  28334. source: any;
  28335. /** The X mouse cursor position at the time of the event */
  28336. pointerX: number;
  28337. /** The Y mouse cursor position at the time of the event */
  28338. pointerY: number;
  28339. /** The mesh that is currently pointed at (can be null) */
  28340. meshUnderPointer: Nullable<AbstractMesh>;
  28341. /** the original (browser) event that triggered the ActionEvent */
  28342. sourceEvent?: any;
  28343. /** additional data for the event */
  28344. additionalData?: any;
  28345. }
  28346. /**
  28347. * ActionEvent is the event being sent when an action is triggered.
  28348. */
  28349. export class ActionEvent implements IActionEvent {
  28350. /** The mesh or sprite that triggered the action */
  28351. source: any;
  28352. /** The X mouse cursor position at the time of the event */
  28353. pointerX: number;
  28354. /** The Y mouse cursor position at the time of the event */
  28355. pointerY: number;
  28356. /** The mesh that is currently pointed at (can be null) */
  28357. meshUnderPointer: Nullable<AbstractMesh>;
  28358. /** the original (browser) event that triggered the ActionEvent */
  28359. sourceEvent?: any;
  28360. /** additional data for the event */
  28361. additionalData?: any;
  28362. /**
  28363. * Creates a new ActionEvent
  28364. * @param source The mesh or sprite that triggered the action
  28365. * @param pointerX The X mouse cursor position at the time of the event
  28366. * @param pointerY The Y mouse cursor position at the time of the event
  28367. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28368. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28369. * @param additionalData additional data for the event
  28370. */
  28371. constructor(
  28372. /** The mesh or sprite that triggered the action */
  28373. source: any,
  28374. /** The X mouse cursor position at the time of the event */
  28375. pointerX: number,
  28376. /** The Y mouse cursor position at the time of the event */
  28377. pointerY: number,
  28378. /** The mesh that is currently pointed at (can be null) */
  28379. meshUnderPointer: Nullable<AbstractMesh>,
  28380. /** the original (browser) event that triggered the ActionEvent */
  28381. sourceEvent?: any,
  28382. /** additional data for the event */
  28383. additionalData?: any);
  28384. /**
  28385. * Helper function to auto-create an ActionEvent from a source mesh.
  28386. * @param source The source mesh that triggered the event
  28387. * @param evt The original (browser) event
  28388. * @param additionalData additional data for the event
  28389. * @returns the new ActionEvent
  28390. */
  28391. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28392. /**
  28393. * Helper function to auto-create an ActionEvent from a source sprite
  28394. * @param source The source sprite that triggered the event
  28395. * @param scene Scene associated with the sprite
  28396. * @param evt The original (browser) event
  28397. * @param additionalData additional data for the event
  28398. * @returns the new ActionEvent
  28399. */
  28400. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28401. /**
  28402. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28403. * @param scene the scene where the event occurred
  28404. * @param evt The original (browser) event
  28405. * @returns the new ActionEvent
  28406. */
  28407. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28408. /**
  28409. * Helper function to auto-create an ActionEvent from a primitive
  28410. * @param prim defines the target primitive
  28411. * @param pointerPos defines the pointer position
  28412. * @param evt The original (browser) event
  28413. * @param additionalData additional data for the event
  28414. * @returns the new ActionEvent
  28415. */
  28416. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28417. }
  28418. }
  28419. declare module BABYLON {
  28420. /**
  28421. * Abstract class used to decouple action Manager from scene and meshes.
  28422. * Do not instantiate.
  28423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28424. */
  28425. export abstract class AbstractActionManager implements IDisposable {
  28426. /** Gets the list of active triggers */
  28427. static Triggers: {
  28428. [key: string]: number;
  28429. };
  28430. /** Gets the cursor to use when hovering items */
  28431. hoverCursor: string;
  28432. /** Gets the list of actions */
  28433. actions: IAction[];
  28434. /**
  28435. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28436. */
  28437. isRecursive: boolean;
  28438. /**
  28439. * Releases all associated resources
  28440. */
  28441. abstract dispose(): void;
  28442. /**
  28443. * Does this action manager has pointer triggers
  28444. */
  28445. abstract get hasPointerTriggers(): boolean;
  28446. /**
  28447. * Does this action manager has pick triggers
  28448. */
  28449. abstract get hasPickTriggers(): boolean;
  28450. /**
  28451. * Process a specific trigger
  28452. * @param trigger defines the trigger to process
  28453. * @param evt defines the event details to be processed
  28454. */
  28455. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28456. /**
  28457. * Does this action manager handles actions of any of the given triggers
  28458. * @param triggers defines the triggers to be tested
  28459. * @return a boolean indicating whether one (or more) of the triggers is handled
  28460. */
  28461. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28462. /**
  28463. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28464. * speed.
  28465. * @param triggerA defines the trigger to be tested
  28466. * @param triggerB defines the trigger to be tested
  28467. * @return a boolean indicating whether one (or more) of the triggers is handled
  28468. */
  28469. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28470. /**
  28471. * Does this action manager handles actions of a given trigger
  28472. * @param trigger defines the trigger to be tested
  28473. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28474. * @return whether the trigger is handled
  28475. */
  28476. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28477. /**
  28478. * Serialize this manager to a JSON object
  28479. * @param name defines the property name to store this manager
  28480. * @returns a JSON representation of this manager
  28481. */
  28482. abstract serialize(name: string): any;
  28483. /**
  28484. * Registers an action to this action manager
  28485. * @param action defines the action to be registered
  28486. * @return the action amended (prepared) after registration
  28487. */
  28488. abstract registerAction(action: IAction): Nullable<IAction>;
  28489. /**
  28490. * Unregisters an action to this action manager
  28491. * @param action defines the action to be unregistered
  28492. * @return a boolean indicating whether the action has been unregistered
  28493. */
  28494. abstract unregisterAction(action: IAction): Boolean;
  28495. /**
  28496. * Does exist one action manager with at least one trigger
  28497. **/
  28498. static get HasTriggers(): boolean;
  28499. /**
  28500. * Does exist one action manager with at least one pick trigger
  28501. **/
  28502. static get HasPickTriggers(): boolean;
  28503. /**
  28504. * Does exist one action manager that handles actions of a given trigger
  28505. * @param trigger defines the trigger to be tested
  28506. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28507. **/
  28508. static HasSpecificTrigger(trigger: number): boolean;
  28509. }
  28510. }
  28511. declare module BABYLON {
  28512. /**
  28513. * Defines how a node can be built from a string name.
  28514. */
  28515. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28516. /**
  28517. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28518. */
  28519. export class Node implements IBehaviorAware<Node> {
  28520. /** @hidden */
  28521. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28522. private static _NodeConstructors;
  28523. /**
  28524. * Add a new node constructor
  28525. * @param type defines the type name of the node to construct
  28526. * @param constructorFunc defines the constructor function
  28527. */
  28528. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28529. /**
  28530. * Returns a node constructor based on type name
  28531. * @param type defines the type name
  28532. * @param name defines the new node name
  28533. * @param scene defines the hosting scene
  28534. * @param options defines optional options to transmit to constructors
  28535. * @returns the new constructor or null
  28536. */
  28537. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28538. /**
  28539. * Gets or sets the name of the node
  28540. */
  28541. name: string;
  28542. /**
  28543. * Gets or sets the id of the node
  28544. */
  28545. id: string;
  28546. /**
  28547. * Gets or sets the unique id of the node
  28548. */
  28549. uniqueId: number;
  28550. /**
  28551. * Gets or sets a string used to store user defined state for the node
  28552. */
  28553. state: string;
  28554. /**
  28555. * Gets or sets an object used to store user defined information for the node
  28556. */
  28557. metadata: any;
  28558. /**
  28559. * For internal use only. Please do not use.
  28560. */
  28561. reservedDataStore: any;
  28562. /**
  28563. * List of inspectable custom properties (used by the Inspector)
  28564. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28565. */
  28566. inspectableCustomProperties: IInspectable[];
  28567. private _doNotSerialize;
  28568. /**
  28569. * Gets or sets a boolean used to define if the node must be serialized
  28570. */
  28571. get doNotSerialize(): boolean;
  28572. set doNotSerialize(value: boolean);
  28573. /** @hidden */
  28574. _isDisposed: boolean;
  28575. /**
  28576. * Gets a list of Animations associated with the node
  28577. */
  28578. animations: Animation[];
  28579. protected _ranges: {
  28580. [name: string]: Nullable<AnimationRange>;
  28581. };
  28582. /**
  28583. * Callback raised when the node is ready to be used
  28584. */
  28585. onReady: Nullable<(node: Node) => void>;
  28586. private _isEnabled;
  28587. private _isParentEnabled;
  28588. private _isReady;
  28589. /** @hidden */
  28590. _currentRenderId: number;
  28591. private _parentUpdateId;
  28592. /** @hidden */
  28593. _childUpdateId: number;
  28594. /** @hidden */
  28595. _waitingParentId: Nullable<string>;
  28596. /** @hidden */
  28597. _scene: Scene;
  28598. /** @hidden */
  28599. _cache: any;
  28600. private _parentNode;
  28601. private _children;
  28602. /** @hidden */
  28603. _worldMatrix: Matrix;
  28604. /** @hidden */
  28605. _worldMatrixDeterminant: number;
  28606. /** @hidden */
  28607. _worldMatrixDeterminantIsDirty: boolean;
  28608. /** @hidden */
  28609. private _sceneRootNodesIndex;
  28610. /**
  28611. * Gets a boolean indicating if the node has been disposed
  28612. * @returns true if the node was disposed
  28613. */
  28614. isDisposed(): boolean;
  28615. /**
  28616. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28617. * @see https://doc.babylonjs.com/how_to/parenting
  28618. */
  28619. set parent(parent: Nullable<Node>);
  28620. get parent(): Nullable<Node>;
  28621. /** @hidden */
  28622. _addToSceneRootNodes(): void;
  28623. /** @hidden */
  28624. _removeFromSceneRootNodes(): void;
  28625. private _animationPropertiesOverride;
  28626. /**
  28627. * Gets or sets the animation properties override
  28628. */
  28629. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28630. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28631. /**
  28632. * Gets a string idenfifying the name of the class
  28633. * @returns "Node" string
  28634. */
  28635. getClassName(): string;
  28636. /** @hidden */
  28637. readonly _isNode: boolean;
  28638. /**
  28639. * An event triggered when the mesh is disposed
  28640. */
  28641. onDisposeObservable: Observable<Node>;
  28642. private _onDisposeObserver;
  28643. /**
  28644. * Sets a callback that will be raised when the node will be disposed
  28645. */
  28646. set onDispose(callback: () => void);
  28647. /**
  28648. * Creates a new Node
  28649. * @param name the name and id to be given to this node
  28650. * @param scene the scene this node will be added to
  28651. */
  28652. constructor(name: string, scene?: Nullable<Scene>);
  28653. /**
  28654. * Gets the scene of the node
  28655. * @returns a scene
  28656. */
  28657. getScene(): Scene;
  28658. /**
  28659. * Gets the engine of the node
  28660. * @returns a Engine
  28661. */
  28662. getEngine(): Engine;
  28663. private _behaviors;
  28664. /**
  28665. * Attach a behavior to the node
  28666. * @see http://doc.babylonjs.com/features/behaviour
  28667. * @param behavior defines the behavior to attach
  28668. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28669. * @returns the current Node
  28670. */
  28671. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28672. /**
  28673. * Remove an attached behavior
  28674. * @see http://doc.babylonjs.com/features/behaviour
  28675. * @param behavior defines the behavior to attach
  28676. * @returns the current Node
  28677. */
  28678. removeBehavior(behavior: Behavior<Node>): Node;
  28679. /**
  28680. * Gets the list of attached behaviors
  28681. * @see http://doc.babylonjs.com/features/behaviour
  28682. */
  28683. get behaviors(): Behavior<Node>[];
  28684. /**
  28685. * Gets an attached behavior by name
  28686. * @param name defines the name of the behavior to look for
  28687. * @see http://doc.babylonjs.com/features/behaviour
  28688. * @returns null if behavior was not found else the requested behavior
  28689. */
  28690. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28691. /**
  28692. * Returns the latest update of the World matrix
  28693. * @returns a Matrix
  28694. */
  28695. getWorldMatrix(): Matrix;
  28696. /** @hidden */
  28697. _getWorldMatrixDeterminant(): number;
  28698. /**
  28699. * Returns directly the latest state of the mesh World matrix.
  28700. * A Matrix is returned.
  28701. */
  28702. get worldMatrixFromCache(): Matrix;
  28703. /** @hidden */
  28704. _initCache(): void;
  28705. /** @hidden */
  28706. updateCache(force?: boolean): void;
  28707. /** @hidden */
  28708. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28709. /** @hidden */
  28710. _updateCache(ignoreParentClass?: boolean): void;
  28711. /** @hidden */
  28712. _isSynchronized(): boolean;
  28713. /** @hidden */
  28714. _markSyncedWithParent(): void;
  28715. /** @hidden */
  28716. isSynchronizedWithParent(): boolean;
  28717. /** @hidden */
  28718. isSynchronized(): boolean;
  28719. /**
  28720. * Is this node ready to be used/rendered
  28721. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28722. * @return true if the node is ready
  28723. */
  28724. isReady(completeCheck?: boolean): boolean;
  28725. /**
  28726. * Is this node enabled?
  28727. * 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
  28728. * @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
  28729. * @return whether this node (and its parent) is enabled
  28730. */
  28731. isEnabled(checkAncestors?: boolean): boolean;
  28732. /** @hidden */
  28733. protected _syncParentEnabledState(): void;
  28734. /**
  28735. * Set the enabled state of this node
  28736. * @param value defines the new enabled state
  28737. */
  28738. setEnabled(value: boolean): void;
  28739. /**
  28740. * Is this node a descendant of the given node?
  28741. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28742. * @param ancestor defines the parent node to inspect
  28743. * @returns a boolean indicating if this node is a descendant of the given node
  28744. */
  28745. isDescendantOf(ancestor: Node): boolean;
  28746. /** @hidden */
  28747. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28748. /**
  28749. * Will return all nodes that have this node as ascendant
  28750. * @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
  28751. * @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
  28752. * @return all children nodes of all types
  28753. */
  28754. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28755. /**
  28756. * Get all child-meshes of this node
  28757. * @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)
  28758. * @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
  28759. * @returns an array of AbstractMesh
  28760. */
  28761. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28762. /**
  28763. * Get all direct children of this node
  28764. * @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
  28765. * @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)
  28766. * @returns an array of Node
  28767. */
  28768. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28769. /** @hidden */
  28770. _setReady(state: boolean): void;
  28771. /**
  28772. * Get an animation by name
  28773. * @param name defines the name of the animation to look for
  28774. * @returns null if not found else the requested animation
  28775. */
  28776. getAnimationByName(name: string): Nullable<Animation>;
  28777. /**
  28778. * Creates an animation range for this node
  28779. * @param name defines the name of the range
  28780. * @param from defines the starting key
  28781. * @param to defines the end key
  28782. */
  28783. createAnimationRange(name: string, from: number, to: number): void;
  28784. /**
  28785. * Delete a specific animation range
  28786. * @param name defines the name of the range to delete
  28787. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28788. */
  28789. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28790. /**
  28791. * Get an animation range by name
  28792. * @param name defines the name of the animation range to look for
  28793. * @returns null if not found else the requested animation range
  28794. */
  28795. getAnimationRange(name: string): Nullable<AnimationRange>;
  28796. /**
  28797. * Gets the list of all animation ranges defined on this node
  28798. * @returns an array
  28799. */
  28800. getAnimationRanges(): Nullable<AnimationRange>[];
  28801. /**
  28802. * Will start the animation sequence
  28803. * @param name defines the range frames for animation sequence
  28804. * @param loop defines if the animation should loop (false by default)
  28805. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28806. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28807. * @returns the object created for this animation. If range does not exist, it will return null
  28808. */
  28809. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28810. /**
  28811. * Serialize animation ranges into a JSON compatible object
  28812. * @returns serialization object
  28813. */
  28814. serializeAnimationRanges(): any;
  28815. /**
  28816. * Computes the world matrix of the node
  28817. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28818. * @returns the world matrix
  28819. */
  28820. computeWorldMatrix(force?: boolean): Matrix;
  28821. /**
  28822. * Releases resources associated with this node.
  28823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28825. */
  28826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28827. /**
  28828. * Parse animation range data from a serialization object and store them into a given node
  28829. * @param node defines where to store the animation ranges
  28830. * @param parsedNode defines the serialization object to read data from
  28831. * @param scene defines the hosting scene
  28832. */
  28833. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28834. /**
  28835. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28836. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28837. * @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
  28838. * @returns the new bounding vectors
  28839. */
  28840. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28841. min: Vector3;
  28842. max: Vector3;
  28843. };
  28844. }
  28845. }
  28846. declare module BABYLON {
  28847. /**
  28848. * @hidden
  28849. */
  28850. export class _IAnimationState {
  28851. key: number;
  28852. repeatCount: number;
  28853. workValue?: any;
  28854. loopMode?: number;
  28855. offsetValue?: any;
  28856. highLimitValue?: any;
  28857. }
  28858. /**
  28859. * Class used to store any kind of animation
  28860. */
  28861. export class Animation {
  28862. /**Name of the animation */
  28863. name: string;
  28864. /**Property to animate */
  28865. targetProperty: string;
  28866. /**The frames per second of the animation */
  28867. framePerSecond: number;
  28868. /**The data type of the animation */
  28869. dataType: number;
  28870. /**The loop mode of the animation */
  28871. loopMode?: number | undefined;
  28872. /**Specifies if blending should be enabled */
  28873. enableBlending?: boolean | undefined;
  28874. /**
  28875. * Use matrix interpolation instead of using direct key value when animating matrices
  28876. */
  28877. static AllowMatricesInterpolation: boolean;
  28878. /**
  28879. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28880. */
  28881. static AllowMatrixDecomposeForInterpolation: boolean;
  28882. /**
  28883. * Stores the key frames of the animation
  28884. */
  28885. private _keys;
  28886. /**
  28887. * Stores the easing function of the animation
  28888. */
  28889. private _easingFunction;
  28890. /**
  28891. * @hidden Internal use only
  28892. */
  28893. _runtimeAnimations: RuntimeAnimation[];
  28894. /**
  28895. * The set of event that will be linked to this animation
  28896. */
  28897. private _events;
  28898. /**
  28899. * Stores an array of target property paths
  28900. */
  28901. targetPropertyPath: string[];
  28902. /**
  28903. * Stores the blending speed of the animation
  28904. */
  28905. blendingSpeed: number;
  28906. /**
  28907. * Stores the animation ranges for the animation
  28908. */
  28909. private _ranges;
  28910. /**
  28911. * @hidden Internal use
  28912. */
  28913. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28914. /**
  28915. * Sets up an animation
  28916. * @param property The property to animate
  28917. * @param animationType The animation type to apply
  28918. * @param framePerSecond The frames per second of the animation
  28919. * @param easingFunction The easing function used in the animation
  28920. * @returns The created animation
  28921. */
  28922. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28923. /**
  28924. * Create and start an animation on a node
  28925. * @param name defines the name of the global animation that will be run on all nodes
  28926. * @param node defines the root node where the animation will take place
  28927. * @param targetProperty defines property to animate
  28928. * @param framePerSecond defines the number of frame per second yo use
  28929. * @param totalFrame defines the number of frames in total
  28930. * @param from defines the initial value
  28931. * @param to defines the final value
  28932. * @param loopMode defines which loop mode you want to use (off by default)
  28933. * @param easingFunction defines the easing function to use (linear by default)
  28934. * @param onAnimationEnd defines the callback to call when animation end
  28935. * @returns the animatable created for this animation
  28936. */
  28937. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28938. /**
  28939. * Create and start an animation on a node and its descendants
  28940. * @param name defines the name of the global animation that will be run on all nodes
  28941. * @param node defines the root node where the animation will take place
  28942. * @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
  28943. * @param targetProperty defines property to animate
  28944. * @param framePerSecond defines the number of frame per second to use
  28945. * @param totalFrame defines the number of frames in total
  28946. * @param from defines the initial value
  28947. * @param to defines the final value
  28948. * @param loopMode defines which loop mode you want to use (off by default)
  28949. * @param easingFunction defines the easing function to use (linear by default)
  28950. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28951. * @returns the list of animatables created for all nodes
  28952. * @example https://www.babylonjs-playground.com/#MH0VLI
  28953. */
  28954. 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[]>;
  28955. /**
  28956. * Creates a new animation, merges it with the existing animations and starts it
  28957. * @param name Name of the animation
  28958. * @param node Node which contains the scene that begins the animations
  28959. * @param targetProperty Specifies which property to animate
  28960. * @param framePerSecond The frames per second of the animation
  28961. * @param totalFrame The total number of frames
  28962. * @param from The frame at the beginning of the animation
  28963. * @param to The frame at the end of the animation
  28964. * @param loopMode Specifies the loop mode of the animation
  28965. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28966. * @param onAnimationEnd Callback to run once the animation is complete
  28967. * @returns Nullable animation
  28968. */
  28969. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28970. /**
  28971. * Transition property of an host to the target Value
  28972. * @param property The property to transition
  28973. * @param targetValue The target Value of the property
  28974. * @param host The object where the property to animate belongs
  28975. * @param scene Scene used to run the animation
  28976. * @param frameRate Framerate (in frame/s) to use
  28977. * @param transition The transition type we want to use
  28978. * @param duration The duration of the animation, in milliseconds
  28979. * @param onAnimationEnd Callback trigger at the end of the animation
  28980. * @returns Nullable animation
  28981. */
  28982. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28983. /**
  28984. * Return the array of runtime animations currently using this animation
  28985. */
  28986. get runtimeAnimations(): RuntimeAnimation[];
  28987. /**
  28988. * Specifies if any of the runtime animations are currently running
  28989. */
  28990. get hasRunningRuntimeAnimations(): boolean;
  28991. /**
  28992. * Initializes the animation
  28993. * @param name Name of the animation
  28994. * @param targetProperty Property to animate
  28995. * @param framePerSecond The frames per second of the animation
  28996. * @param dataType The data type of the animation
  28997. * @param loopMode The loop mode of the animation
  28998. * @param enableBlending Specifies if blending should be enabled
  28999. */
  29000. constructor(
  29001. /**Name of the animation */
  29002. name: string,
  29003. /**Property to animate */
  29004. targetProperty: string,
  29005. /**The frames per second of the animation */
  29006. framePerSecond: number,
  29007. /**The data type of the animation */
  29008. dataType: number,
  29009. /**The loop mode of the animation */
  29010. loopMode?: number | undefined,
  29011. /**Specifies if blending should be enabled */
  29012. enableBlending?: boolean | undefined);
  29013. /**
  29014. * Converts the animation to a string
  29015. * @param fullDetails support for multiple levels of logging within scene loading
  29016. * @returns String form of the animation
  29017. */
  29018. toString(fullDetails?: boolean): string;
  29019. /**
  29020. * Add an event to this animation
  29021. * @param event Event to add
  29022. */
  29023. addEvent(event: AnimationEvent): void;
  29024. /**
  29025. * Remove all events found at the given frame
  29026. * @param frame The frame to remove events from
  29027. */
  29028. removeEvents(frame: number): void;
  29029. /**
  29030. * Retrieves all the events from the animation
  29031. * @returns Events from the animation
  29032. */
  29033. getEvents(): AnimationEvent[];
  29034. /**
  29035. * Creates an animation range
  29036. * @param name Name of the animation range
  29037. * @param from Starting frame of the animation range
  29038. * @param to Ending frame of the animation
  29039. */
  29040. createRange(name: string, from: number, to: number): void;
  29041. /**
  29042. * Deletes an animation range by name
  29043. * @param name Name of the animation range to delete
  29044. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29045. */
  29046. deleteRange(name: string, deleteFrames?: boolean): void;
  29047. /**
  29048. * Gets the animation range by name, or null if not defined
  29049. * @param name Name of the animation range
  29050. * @returns Nullable animation range
  29051. */
  29052. getRange(name: string): Nullable<AnimationRange>;
  29053. /**
  29054. * Gets the key frames from the animation
  29055. * @returns The key frames of the animation
  29056. */
  29057. getKeys(): Array<IAnimationKey>;
  29058. /**
  29059. * Gets the highest frame rate of the animation
  29060. * @returns Highest frame rate of the animation
  29061. */
  29062. getHighestFrame(): number;
  29063. /**
  29064. * Gets the easing function of the animation
  29065. * @returns Easing function of the animation
  29066. */
  29067. getEasingFunction(): IEasingFunction;
  29068. /**
  29069. * Sets the easing function of the animation
  29070. * @param easingFunction A custom mathematical formula for animation
  29071. */
  29072. setEasingFunction(easingFunction: EasingFunction): void;
  29073. /**
  29074. * Interpolates a scalar linearly
  29075. * @param startValue Start value of the animation curve
  29076. * @param endValue End value of the animation curve
  29077. * @param gradient Scalar amount to interpolate
  29078. * @returns Interpolated scalar value
  29079. */
  29080. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29081. /**
  29082. * Interpolates a scalar cubically
  29083. * @param startValue Start value of the animation curve
  29084. * @param outTangent End tangent of the animation
  29085. * @param endValue End value of the animation curve
  29086. * @param inTangent Start tangent of the animation curve
  29087. * @param gradient Scalar amount to interpolate
  29088. * @returns Interpolated scalar value
  29089. */
  29090. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29091. /**
  29092. * Interpolates a quaternion using a spherical linear interpolation
  29093. * @param startValue Start value of the animation curve
  29094. * @param endValue End value of the animation curve
  29095. * @param gradient Scalar amount to interpolate
  29096. * @returns Interpolated quaternion value
  29097. */
  29098. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29099. /**
  29100. * Interpolates a quaternion cubically
  29101. * @param startValue Start value of the animation curve
  29102. * @param outTangent End tangent of the animation curve
  29103. * @param endValue End value of the animation curve
  29104. * @param inTangent Start tangent of the animation curve
  29105. * @param gradient Scalar amount to interpolate
  29106. * @returns Interpolated quaternion value
  29107. */
  29108. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29109. /**
  29110. * Interpolates a Vector3 linearl
  29111. * @param startValue Start value of the animation curve
  29112. * @param endValue End value of the animation curve
  29113. * @param gradient Scalar amount to interpolate
  29114. * @returns Interpolated scalar value
  29115. */
  29116. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29117. /**
  29118. * Interpolates a Vector3 cubically
  29119. * @param startValue Start value of the animation curve
  29120. * @param outTangent End tangent of the animation
  29121. * @param endValue End value of the animation curve
  29122. * @param inTangent Start tangent of the animation curve
  29123. * @param gradient Scalar amount to interpolate
  29124. * @returns InterpolatedVector3 value
  29125. */
  29126. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29127. /**
  29128. * Interpolates a Vector2 linearly
  29129. * @param startValue Start value of the animation curve
  29130. * @param endValue End value of the animation curve
  29131. * @param gradient Scalar amount to interpolate
  29132. * @returns Interpolated Vector2 value
  29133. */
  29134. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29135. /**
  29136. * Interpolates a Vector2 cubically
  29137. * @param startValue Start value of the animation curve
  29138. * @param outTangent End tangent of the animation
  29139. * @param endValue End value of the animation curve
  29140. * @param inTangent Start tangent of the animation curve
  29141. * @param gradient Scalar amount to interpolate
  29142. * @returns Interpolated Vector2 value
  29143. */
  29144. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29145. /**
  29146. * Interpolates a size linearly
  29147. * @param startValue Start value of the animation curve
  29148. * @param endValue End value of the animation curve
  29149. * @param gradient Scalar amount to interpolate
  29150. * @returns Interpolated Size value
  29151. */
  29152. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29153. /**
  29154. * Interpolates a Color3 linearly
  29155. * @param startValue Start value of the animation curve
  29156. * @param endValue End value of the animation curve
  29157. * @param gradient Scalar amount to interpolate
  29158. * @returns Interpolated Color3 value
  29159. */
  29160. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29161. /**
  29162. * Interpolates a Color4 linearly
  29163. * @param startValue Start value of the animation curve
  29164. * @param endValue End value of the animation curve
  29165. * @param gradient Scalar amount to interpolate
  29166. * @returns Interpolated Color3 value
  29167. */
  29168. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29169. /**
  29170. * @hidden Internal use only
  29171. */
  29172. _getKeyValue(value: any): any;
  29173. /**
  29174. * @hidden Internal use only
  29175. */
  29176. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29177. /**
  29178. * Defines the function to use to interpolate matrices
  29179. * @param startValue defines the start matrix
  29180. * @param endValue defines the end matrix
  29181. * @param gradient defines the gradient between both matrices
  29182. * @param result defines an optional target matrix where to store the interpolation
  29183. * @returns the interpolated matrix
  29184. */
  29185. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29186. /**
  29187. * Makes a copy of the animation
  29188. * @returns Cloned animation
  29189. */
  29190. clone(): Animation;
  29191. /**
  29192. * Sets the key frames of the animation
  29193. * @param values The animation key frames to set
  29194. */
  29195. setKeys(values: Array<IAnimationKey>): void;
  29196. /**
  29197. * Serializes the animation to an object
  29198. * @returns Serialized object
  29199. */
  29200. serialize(): any;
  29201. /**
  29202. * Float animation type
  29203. */
  29204. static readonly ANIMATIONTYPE_FLOAT: number;
  29205. /**
  29206. * Vector3 animation type
  29207. */
  29208. static readonly ANIMATIONTYPE_VECTOR3: number;
  29209. /**
  29210. * Quaternion animation type
  29211. */
  29212. static readonly ANIMATIONTYPE_QUATERNION: number;
  29213. /**
  29214. * Matrix animation type
  29215. */
  29216. static readonly ANIMATIONTYPE_MATRIX: number;
  29217. /**
  29218. * Color3 animation type
  29219. */
  29220. static readonly ANIMATIONTYPE_COLOR3: number;
  29221. /**
  29222. * Color3 animation type
  29223. */
  29224. static readonly ANIMATIONTYPE_COLOR4: number;
  29225. /**
  29226. * Vector2 animation type
  29227. */
  29228. static readonly ANIMATIONTYPE_VECTOR2: number;
  29229. /**
  29230. * Size animation type
  29231. */
  29232. static readonly ANIMATIONTYPE_SIZE: number;
  29233. /**
  29234. * Relative Loop Mode
  29235. */
  29236. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29237. /**
  29238. * Cycle Loop Mode
  29239. */
  29240. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29241. /**
  29242. * Constant Loop Mode
  29243. */
  29244. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29245. /** @hidden */
  29246. static _UniversalLerp(left: any, right: any, amount: number): any;
  29247. /**
  29248. * Parses an animation object and creates an animation
  29249. * @param parsedAnimation Parsed animation object
  29250. * @returns Animation object
  29251. */
  29252. static Parse(parsedAnimation: any): Animation;
  29253. /**
  29254. * Appends the serialized animations from the source animations
  29255. * @param source Source containing the animations
  29256. * @param destination Target to store the animations
  29257. */
  29258. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29259. }
  29260. }
  29261. declare module BABYLON {
  29262. /**
  29263. * Interface containing an array of animations
  29264. */
  29265. export interface IAnimatable {
  29266. /**
  29267. * Array of animations
  29268. */
  29269. animations: Nullable<Array<Animation>>;
  29270. }
  29271. }
  29272. declare module BABYLON {
  29273. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29274. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29275. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29276. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29277. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29278. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29279. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29280. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29281. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29282. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29283. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29284. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29285. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29286. /**
  29287. * Decorator used to define property that can be serialized as reference to a camera
  29288. * @param sourceName defines the name of the property to decorate
  29289. */
  29290. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29291. /**
  29292. * Class used to help serialization objects
  29293. */
  29294. export class SerializationHelper {
  29295. /** @hidden */
  29296. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29297. /** @hidden */
  29298. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29299. /** @hidden */
  29300. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29301. /** @hidden */
  29302. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29303. /**
  29304. * Appends the serialized animations from the source animations
  29305. * @param source Source containing the animations
  29306. * @param destination Target to store the animations
  29307. */
  29308. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29309. /**
  29310. * Static function used to serialized a specific entity
  29311. * @param entity defines the entity to serialize
  29312. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29313. * @returns a JSON compatible object representing the serialization of the entity
  29314. */
  29315. static Serialize<T>(entity: T, serializationObject?: any): any;
  29316. /**
  29317. * Creates a new entity from a serialization data object
  29318. * @param creationFunction defines a function used to instanciated the new entity
  29319. * @param source defines the source serialization data
  29320. * @param scene defines the hosting scene
  29321. * @param rootUrl defines the root url for resources
  29322. * @returns a new entity
  29323. */
  29324. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29325. /**
  29326. * Clones an object
  29327. * @param creationFunction defines the function used to instanciate the new object
  29328. * @param source defines the source object
  29329. * @returns the cloned object
  29330. */
  29331. static Clone<T>(creationFunction: () => T, source: T): T;
  29332. /**
  29333. * Instanciates a new object based on a source one (some data will be shared between both object)
  29334. * @param creationFunction defines the function used to instanciate the new object
  29335. * @param source defines the source object
  29336. * @returns the new object
  29337. */
  29338. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29339. }
  29340. }
  29341. declare module BABYLON {
  29342. /**
  29343. * Class used to manipulate GUIDs
  29344. */
  29345. export class GUID {
  29346. /**
  29347. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29348. * Be aware Math.random() could cause collisions, but:
  29349. * "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"
  29350. * @returns a pseudo random id
  29351. */
  29352. static RandomId(): string;
  29353. }
  29354. }
  29355. declare module BABYLON {
  29356. /**
  29357. * Base class of all the textures in babylon.
  29358. * It groups all the common properties the materials, post process, lights... might need
  29359. * in order to make a correct use of the texture.
  29360. */
  29361. export class BaseTexture implements IAnimatable {
  29362. /**
  29363. * Default anisotropic filtering level for the application.
  29364. * It is set to 4 as a good tradeoff between perf and quality.
  29365. */
  29366. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29367. /**
  29368. * Gets or sets the unique id of the texture
  29369. */
  29370. uniqueId: number;
  29371. /**
  29372. * Define the name of the texture.
  29373. */
  29374. name: string;
  29375. /**
  29376. * Gets or sets an object used to store user defined information.
  29377. */
  29378. metadata: any;
  29379. /**
  29380. * For internal use only. Please do not use.
  29381. */
  29382. reservedDataStore: any;
  29383. private _hasAlpha;
  29384. /**
  29385. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29386. */
  29387. set hasAlpha(value: boolean);
  29388. get hasAlpha(): boolean;
  29389. /**
  29390. * Defines if the alpha value should be determined via the rgb values.
  29391. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29392. */
  29393. getAlphaFromRGB: boolean;
  29394. /**
  29395. * Intensity or strength of the texture.
  29396. * It is commonly used by materials to fine tune the intensity of the texture
  29397. */
  29398. level: number;
  29399. /**
  29400. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29401. * This is part of the texture as textures usually maps to one uv set.
  29402. */
  29403. coordinatesIndex: number;
  29404. private _coordinatesMode;
  29405. /**
  29406. * How a texture is mapped.
  29407. *
  29408. * | Value | Type | Description |
  29409. * | ----- | ----------------------------------- | ----------- |
  29410. * | 0 | EXPLICIT_MODE | |
  29411. * | 1 | SPHERICAL_MODE | |
  29412. * | 2 | PLANAR_MODE | |
  29413. * | 3 | CUBIC_MODE | |
  29414. * | 4 | PROJECTION_MODE | |
  29415. * | 5 | SKYBOX_MODE | |
  29416. * | 6 | INVCUBIC_MODE | |
  29417. * | 7 | EQUIRECTANGULAR_MODE | |
  29418. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29419. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29420. */
  29421. set coordinatesMode(value: number);
  29422. get coordinatesMode(): number;
  29423. /**
  29424. * | Value | Type | Description |
  29425. * | ----- | ------------------ | ----------- |
  29426. * | 0 | CLAMP_ADDRESSMODE | |
  29427. * | 1 | WRAP_ADDRESSMODE | |
  29428. * | 2 | MIRROR_ADDRESSMODE | |
  29429. */
  29430. wrapU: number;
  29431. /**
  29432. * | Value | Type | Description |
  29433. * | ----- | ------------------ | ----------- |
  29434. * | 0 | CLAMP_ADDRESSMODE | |
  29435. * | 1 | WRAP_ADDRESSMODE | |
  29436. * | 2 | MIRROR_ADDRESSMODE | |
  29437. */
  29438. wrapV: number;
  29439. /**
  29440. * | Value | Type | Description |
  29441. * | ----- | ------------------ | ----------- |
  29442. * | 0 | CLAMP_ADDRESSMODE | |
  29443. * | 1 | WRAP_ADDRESSMODE | |
  29444. * | 2 | MIRROR_ADDRESSMODE | |
  29445. */
  29446. wrapR: number;
  29447. /**
  29448. * With compliant hardware and browser (supporting anisotropic filtering)
  29449. * this defines the level of anisotropic filtering in the texture.
  29450. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29451. */
  29452. anisotropicFilteringLevel: number;
  29453. /**
  29454. * Define if the texture is a cube texture or if false a 2d texture.
  29455. */
  29456. get isCube(): boolean;
  29457. set isCube(value: boolean);
  29458. /**
  29459. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29460. */
  29461. get is3D(): boolean;
  29462. set is3D(value: boolean);
  29463. /**
  29464. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29465. */
  29466. get is2DArray(): boolean;
  29467. set is2DArray(value: boolean);
  29468. /**
  29469. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29470. * HDR texture are usually stored in linear space.
  29471. * This only impacts the PBR and Background materials
  29472. */
  29473. gammaSpace: boolean;
  29474. /**
  29475. * Gets or sets whether or not the texture contains RGBD data.
  29476. */
  29477. get isRGBD(): boolean;
  29478. set isRGBD(value: boolean);
  29479. /**
  29480. * Is Z inverted in the texture (useful in a cube texture).
  29481. */
  29482. invertZ: boolean;
  29483. /**
  29484. * Are mip maps generated for this texture or not.
  29485. */
  29486. get noMipmap(): boolean;
  29487. /**
  29488. * @hidden
  29489. */
  29490. lodLevelInAlpha: boolean;
  29491. /**
  29492. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29493. */
  29494. get lodGenerationOffset(): number;
  29495. set lodGenerationOffset(value: number);
  29496. /**
  29497. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29498. */
  29499. get lodGenerationScale(): number;
  29500. set lodGenerationScale(value: number);
  29501. /**
  29502. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29503. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29504. * average roughness values.
  29505. */
  29506. get linearSpecularLOD(): boolean;
  29507. set linearSpecularLOD(value: boolean);
  29508. /**
  29509. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29510. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29511. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29512. */
  29513. get irradianceTexture(): Nullable<BaseTexture>;
  29514. set irradianceTexture(value: Nullable<BaseTexture>);
  29515. /**
  29516. * Define if the texture is a render target.
  29517. */
  29518. isRenderTarget: boolean;
  29519. /**
  29520. * Define the unique id of the texture in the scene.
  29521. */
  29522. get uid(): string;
  29523. /**
  29524. * Return a string representation of the texture.
  29525. * @returns the texture as a string
  29526. */
  29527. toString(): string;
  29528. /**
  29529. * Get the class name of the texture.
  29530. * @returns "BaseTexture"
  29531. */
  29532. getClassName(): string;
  29533. /**
  29534. * Define the list of animation attached to the texture.
  29535. */
  29536. animations: Animation[];
  29537. /**
  29538. * An event triggered when the texture is disposed.
  29539. */
  29540. onDisposeObservable: Observable<BaseTexture>;
  29541. private _onDisposeObserver;
  29542. /**
  29543. * Callback triggered when the texture has been disposed.
  29544. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29545. */
  29546. set onDispose(callback: () => void);
  29547. /**
  29548. * Define the current state of the loading sequence when in delayed load mode.
  29549. */
  29550. delayLoadState: number;
  29551. private _scene;
  29552. /** @hidden */
  29553. _texture: Nullable<InternalTexture>;
  29554. private _uid;
  29555. /**
  29556. * Define if the texture is preventinga material to render or not.
  29557. * If not and the texture is not ready, the engine will use a default black texture instead.
  29558. */
  29559. get isBlocking(): boolean;
  29560. /**
  29561. * Instantiates a new BaseTexture.
  29562. * Base class of all the textures in babylon.
  29563. * It groups all the common properties the materials, post process, lights... might need
  29564. * in order to make a correct use of the texture.
  29565. * @param scene Define the scene the texture blongs to
  29566. */
  29567. constructor(scene: Nullable<Scene>);
  29568. /**
  29569. * Get the scene the texture belongs to.
  29570. * @returns the scene or null if undefined
  29571. */
  29572. getScene(): Nullable<Scene>;
  29573. /**
  29574. * Get the texture transform matrix used to offset tile the texture for istance.
  29575. * @returns the transformation matrix
  29576. */
  29577. getTextureMatrix(): Matrix;
  29578. /**
  29579. * Get the texture reflection matrix used to rotate/transform the reflection.
  29580. * @returns the reflection matrix
  29581. */
  29582. getReflectionTextureMatrix(): Matrix;
  29583. /**
  29584. * Get the underlying lower level texture from Babylon.
  29585. * @returns the insternal texture
  29586. */
  29587. getInternalTexture(): Nullable<InternalTexture>;
  29588. /**
  29589. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29590. * @returns true if ready or not blocking
  29591. */
  29592. isReadyOrNotBlocking(): boolean;
  29593. /**
  29594. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29595. * @returns true if fully ready
  29596. */
  29597. isReady(): boolean;
  29598. private _cachedSize;
  29599. /**
  29600. * Get the size of the texture.
  29601. * @returns the texture size.
  29602. */
  29603. getSize(): ISize;
  29604. /**
  29605. * Get the base size of the texture.
  29606. * It can be different from the size if the texture has been resized for POT for instance
  29607. * @returns the base size
  29608. */
  29609. getBaseSize(): ISize;
  29610. /**
  29611. * Update the sampling mode of the texture.
  29612. * Default is Trilinear mode.
  29613. *
  29614. * | Value | Type | Description |
  29615. * | ----- | ------------------ | ----------- |
  29616. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29617. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29618. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29619. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29620. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29621. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29622. * | 7 | NEAREST_LINEAR | |
  29623. * | 8 | NEAREST_NEAREST | |
  29624. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29625. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29626. * | 11 | LINEAR_LINEAR | |
  29627. * | 12 | LINEAR_NEAREST | |
  29628. *
  29629. * > _mag_: magnification filter (close to the viewer)
  29630. * > _min_: minification filter (far from the viewer)
  29631. * > _mip_: filter used between mip map levels
  29632. *@param samplingMode Define the new sampling mode of the texture
  29633. */
  29634. updateSamplingMode(samplingMode: number): void;
  29635. /**
  29636. * Scales the texture if is `canRescale()`
  29637. * @param ratio the resize factor we want to use to rescale
  29638. */
  29639. scale(ratio: number): void;
  29640. /**
  29641. * Get if the texture can rescale.
  29642. */
  29643. get canRescale(): boolean;
  29644. /** @hidden */
  29645. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29646. /** @hidden */
  29647. _rebuild(): void;
  29648. /**
  29649. * Triggers the load sequence in delayed load mode.
  29650. */
  29651. delayLoad(): void;
  29652. /**
  29653. * Clones the texture.
  29654. * @returns the cloned texture
  29655. */
  29656. clone(): Nullable<BaseTexture>;
  29657. /**
  29658. * Get the texture underlying type (INT, FLOAT...)
  29659. */
  29660. get textureType(): number;
  29661. /**
  29662. * Get the texture underlying format (RGB, RGBA...)
  29663. */
  29664. get textureFormat(): number;
  29665. /**
  29666. * Indicates that textures need to be re-calculated for all materials
  29667. */
  29668. protected _markAllSubMeshesAsTexturesDirty(): void;
  29669. /**
  29670. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29671. * This will returns an RGBA array buffer containing either in values (0-255) or
  29672. * float values (0-1) depending of the underlying buffer type.
  29673. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29674. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29675. * @param buffer defines a user defined buffer to fill with data (can be null)
  29676. * @returns The Array buffer containing the pixels data.
  29677. */
  29678. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29679. /**
  29680. * Release and destroy the underlying lower level texture aka internalTexture.
  29681. */
  29682. releaseInternalTexture(): void;
  29683. /** @hidden */
  29684. get _lodTextureHigh(): Nullable<BaseTexture>;
  29685. /** @hidden */
  29686. get _lodTextureMid(): Nullable<BaseTexture>;
  29687. /** @hidden */
  29688. get _lodTextureLow(): Nullable<BaseTexture>;
  29689. /**
  29690. * Dispose the texture and release its associated resources.
  29691. */
  29692. dispose(): void;
  29693. /**
  29694. * Serialize the texture into a JSON representation that can be parsed later on.
  29695. * @returns the JSON representation of the texture
  29696. */
  29697. serialize(): any;
  29698. /**
  29699. * Helper function to be called back once a list of texture contains only ready textures.
  29700. * @param textures Define the list of textures to wait for
  29701. * @param callback Define the callback triggered once the entire list will be ready
  29702. */
  29703. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29704. }
  29705. }
  29706. declare module BABYLON {
  29707. /**
  29708. * Options to be used when creating an effect.
  29709. */
  29710. export interface IEffectCreationOptions {
  29711. /**
  29712. * Atrributes that will be used in the shader.
  29713. */
  29714. attributes: string[];
  29715. /**
  29716. * Uniform varible names that will be set in the shader.
  29717. */
  29718. uniformsNames: string[];
  29719. /**
  29720. * Uniform buffer variable names that will be set in the shader.
  29721. */
  29722. uniformBuffersNames: string[];
  29723. /**
  29724. * Sampler texture variable names that will be set in the shader.
  29725. */
  29726. samplers: string[];
  29727. /**
  29728. * Define statements that will be set in the shader.
  29729. */
  29730. defines: any;
  29731. /**
  29732. * Possible fallbacks for this effect to improve performance when needed.
  29733. */
  29734. fallbacks: Nullable<IEffectFallbacks>;
  29735. /**
  29736. * Callback that will be called when the shader is compiled.
  29737. */
  29738. onCompiled: Nullable<(effect: Effect) => void>;
  29739. /**
  29740. * Callback that will be called if an error occurs during shader compilation.
  29741. */
  29742. onError: Nullable<(effect: Effect, errors: string) => void>;
  29743. /**
  29744. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29745. */
  29746. indexParameters?: any;
  29747. /**
  29748. * Max number of lights that can be used in the shader.
  29749. */
  29750. maxSimultaneousLights?: number;
  29751. /**
  29752. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29753. */
  29754. transformFeedbackVaryings?: Nullable<string[]>;
  29755. }
  29756. /**
  29757. * Effect containing vertex and fragment shader that can be executed on an object.
  29758. */
  29759. export class Effect implements IDisposable {
  29760. /**
  29761. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29762. */
  29763. static ShadersRepository: string;
  29764. /**
  29765. * Name of the effect.
  29766. */
  29767. name: any;
  29768. /**
  29769. * String container all the define statements that should be set on the shader.
  29770. */
  29771. defines: string;
  29772. /**
  29773. * Callback that will be called when the shader is compiled.
  29774. */
  29775. onCompiled: Nullable<(effect: Effect) => void>;
  29776. /**
  29777. * Callback that will be called if an error occurs during shader compilation.
  29778. */
  29779. onError: Nullable<(effect: Effect, errors: string) => void>;
  29780. /**
  29781. * Callback that will be called when effect is bound.
  29782. */
  29783. onBind: Nullable<(effect: Effect) => void>;
  29784. /**
  29785. * Unique ID of the effect.
  29786. */
  29787. uniqueId: number;
  29788. /**
  29789. * Observable that will be called when the shader is compiled.
  29790. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29791. */
  29792. onCompileObservable: Observable<Effect>;
  29793. /**
  29794. * Observable that will be called if an error occurs during shader compilation.
  29795. */
  29796. onErrorObservable: Observable<Effect>;
  29797. /** @hidden */
  29798. _onBindObservable: Nullable<Observable<Effect>>;
  29799. /**
  29800. * Observable that will be called when effect is bound.
  29801. */
  29802. get onBindObservable(): Observable<Effect>;
  29803. /** @hidden */
  29804. _bonesComputationForcedToCPU: boolean;
  29805. private static _uniqueIdSeed;
  29806. private _engine;
  29807. private _uniformBuffersNames;
  29808. private _uniformsNames;
  29809. private _samplerList;
  29810. private _samplers;
  29811. private _isReady;
  29812. private _compilationError;
  29813. private _allFallbacksProcessed;
  29814. private _attributesNames;
  29815. private _attributes;
  29816. private _attributeLocationByName;
  29817. private _uniforms;
  29818. /**
  29819. * Key for the effect.
  29820. * @hidden
  29821. */
  29822. _key: string;
  29823. private _indexParameters;
  29824. private _fallbacks;
  29825. private _vertexSourceCode;
  29826. private _fragmentSourceCode;
  29827. private _vertexSourceCodeOverride;
  29828. private _fragmentSourceCodeOverride;
  29829. private _transformFeedbackVaryings;
  29830. /**
  29831. * Compiled shader to webGL program.
  29832. * @hidden
  29833. */
  29834. _pipelineContext: Nullable<IPipelineContext>;
  29835. private _valueCache;
  29836. private static _baseCache;
  29837. /**
  29838. * Instantiates an effect.
  29839. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29840. * @param baseName Name of the effect.
  29841. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29842. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29843. * @param samplers List of sampler variables that will be passed to the shader.
  29844. * @param engine Engine to be used to render the effect
  29845. * @param defines Define statements to be added to the shader.
  29846. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29847. * @param onCompiled Callback that will be called when the shader is compiled.
  29848. * @param onError Callback that will be called if an error occurs during shader compilation.
  29849. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29850. */
  29851. 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);
  29852. private _useFinalCode;
  29853. /**
  29854. * Unique key for this effect
  29855. */
  29856. get key(): string;
  29857. /**
  29858. * If the effect has been compiled and prepared.
  29859. * @returns if the effect is compiled and prepared.
  29860. */
  29861. isReady(): boolean;
  29862. private _isReadyInternal;
  29863. /**
  29864. * The engine the effect was initialized with.
  29865. * @returns the engine.
  29866. */
  29867. getEngine(): Engine;
  29868. /**
  29869. * The pipeline context for this effect
  29870. * @returns the associated pipeline context
  29871. */
  29872. getPipelineContext(): Nullable<IPipelineContext>;
  29873. /**
  29874. * The set of names of attribute variables for the shader.
  29875. * @returns An array of attribute names.
  29876. */
  29877. getAttributesNames(): string[];
  29878. /**
  29879. * Returns the attribute at the given index.
  29880. * @param index The index of the attribute.
  29881. * @returns The location of the attribute.
  29882. */
  29883. getAttributeLocation(index: number): number;
  29884. /**
  29885. * Returns the attribute based on the name of the variable.
  29886. * @param name of the attribute to look up.
  29887. * @returns the attribute location.
  29888. */
  29889. getAttributeLocationByName(name: string): number;
  29890. /**
  29891. * The number of attributes.
  29892. * @returns the numnber of attributes.
  29893. */
  29894. getAttributesCount(): number;
  29895. /**
  29896. * Gets the index of a uniform variable.
  29897. * @param uniformName of the uniform to look up.
  29898. * @returns the index.
  29899. */
  29900. getUniformIndex(uniformName: string): number;
  29901. /**
  29902. * Returns the attribute based on the name of the variable.
  29903. * @param uniformName of the uniform to look up.
  29904. * @returns the location of the uniform.
  29905. */
  29906. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29907. /**
  29908. * Returns an array of sampler variable names
  29909. * @returns The array of sampler variable neames.
  29910. */
  29911. getSamplers(): string[];
  29912. /**
  29913. * The error from the last compilation.
  29914. * @returns the error string.
  29915. */
  29916. getCompilationError(): string;
  29917. /**
  29918. * Gets a boolean indicating that all fallbacks were used during compilation
  29919. * @returns true if all fallbacks were used
  29920. */
  29921. allFallbacksProcessed(): boolean;
  29922. /**
  29923. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29924. * @param func The callback to be used.
  29925. */
  29926. executeWhenCompiled(func: (effect: Effect) => void): void;
  29927. private _checkIsReady;
  29928. private _loadShader;
  29929. /**
  29930. * Recompiles the webGL program
  29931. * @param vertexSourceCode The source code for the vertex shader.
  29932. * @param fragmentSourceCode The source code for the fragment shader.
  29933. * @param onCompiled Callback called when completed.
  29934. * @param onError Callback called on error.
  29935. * @hidden
  29936. */
  29937. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29938. /**
  29939. * Prepares the effect
  29940. * @hidden
  29941. */
  29942. _prepareEffect(): void;
  29943. private _processCompilationErrors;
  29944. /**
  29945. * Checks if the effect is supported. (Must be called after compilation)
  29946. */
  29947. get isSupported(): boolean;
  29948. /**
  29949. * Binds a texture to the engine to be used as output of the shader.
  29950. * @param channel Name of the output variable.
  29951. * @param texture Texture to bind.
  29952. * @hidden
  29953. */
  29954. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29955. /**
  29956. * Sets a texture on the engine to be used in the shader.
  29957. * @param channel Name of the sampler variable.
  29958. * @param texture Texture to set.
  29959. */
  29960. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29961. /**
  29962. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29963. * @param channel Name of the sampler variable.
  29964. * @param texture Texture to set.
  29965. */
  29966. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29967. /**
  29968. * Sets an array of textures on the engine to be used in the shader.
  29969. * @param channel Name of the variable.
  29970. * @param textures Textures to set.
  29971. */
  29972. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29973. /**
  29974. * 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)
  29975. * @param channel Name of the sampler variable.
  29976. * @param postProcess Post process to get the input texture from.
  29977. */
  29978. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29979. /**
  29980. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29981. * 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)
  29982. * @param channel Name of the sampler variable.
  29983. * @param postProcess Post process to get the output texture from.
  29984. */
  29985. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29986. /** @hidden */
  29987. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29988. /** @hidden */
  29989. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29990. /** @hidden */
  29991. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29992. /** @hidden */
  29993. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29994. /**
  29995. * Binds a buffer to a uniform.
  29996. * @param buffer Buffer to bind.
  29997. * @param name Name of the uniform variable to bind to.
  29998. */
  29999. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30000. /**
  30001. * Binds block to a uniform.
  30002. * @param blockName Name of the block to bind.
  30003. * @param index Index to bind.
  30004. */
  30005. bindUniformBlock(blockName: string, index: number): void;
  30006. /**
  30007. * Sets an interger value on a uniform variable.
  30008. * @param uniformName Name of the variable.
  30009. * @param value Value to be set.
  30010. * @returns this effect.
  30011. */
  30012. setInt(uniformName: string, value: number): Effect;
  30013. /**
  30014. * Sets an int array on a uniform variable.
  30015. * @param uniformName Name of the variable.
  30016. * @param array array to be set.
  30017. * @returns this effect.
  30018. */
  30019. setIntArray(uniformName: string, array: Int32Array): Effect;
  30020. /**
  30021. * 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)
  30022. * @param uniformName Name of the variable.
  30023. * @param array array to be set.
  30024. * @returns this effect.
  30025. */
  30026. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30027. /**
  30028. * 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)
  30029. * @param uniformName Name of the variable.
  30030. * @param array array to be set.
  30031. * @returns this effect.
  30032. */
  30033. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30034. /**
  30035. * 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)
  30036. * @param uniformName Name of the variable.
  30037. * @param array array to be set.
  30038. * @returns this effect.
  30039. */
  30040. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30041. /**
  30042. * Sets an float array on a uniform variable.
  30043. * @param uniformName Name of the variable.
  30044. * @param array array to be set.
  30045. * @returns this effect.
  30046. */
  30047. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30048. /**
  30049. * 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)
  30050. * @param uniformName Name of the variable.
  30051. * @param array array to be set.
  30052. * @returns this effect.
  30053. */
  30054. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30055. /**
  30056. * 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)
  30057. * @param uniformName Name of the variable.
  30058. * @param array array to be set.
  30059. * @returns this effect.
  30060. */
  30061. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30062. /**
  30063. * 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)
  30064. * @param uniformName Name of the variable.
  30065. * @param array array to be set.
  30066. * @returns this effect.
  30067. */
  30068. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30069. /**
  30070. * Sets an array on a uniform variable.
  30071. * @param uniformName Name of the variable.
  30072. * @param array array to be set.
  30073. * @returns this effect.
  30074. */
  30075. setArray(uniformName: string, array: number[]): Effect;
  30076. /**
  30077. * 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)
  30078. * @param uniformName Name of the variable.
  30079. * @param array array to be set.
  30080. * @returns this effect.
  30081. */
  30082. setArray2(uniformName: string, array: number[]): Effect;
  30083. /**
  30084. * 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)
  30085. * @param uniformName Name of the variable.
  30086. * @param array array to be set.
  30087. * @returns this effect.
  30088. */
  30089. setArray3(uniformName: string, array: number[]): Effect;
  30090. /**
  30091. * 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)
  30092. * @param uniformName Name of the variable.
  30093. * @param array array to be set.
  30094. * @returns this effect.
  30095. */
  30096. setArray4(uniformName: string, array: number[]): Effect;
  30097. /**
  30098. * Sets matrices on a uniform variable.
  30099. * @param uniformName Name of the variable.
  30100. * @param matrices matrices to be set.
  30101. * @returns this effect.
  30102. */
  30103. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30104. /**
  30105. * Sets matrix on a uniform variable.
  30106. * @param uniformName Name of the variable.
  30107. * @param matrix matrix to be set.
  30108. * @returns this effect.
  30109. */
  30110. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30111. /**
  30112. * 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)
  30113. * @param uniformName Name of the variable.
  30114. * @param matrix matrix to be set.
  30115. * @returns this effect.
  30116. */
  30117. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30118. /**
  30119. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30120. * @param uniformName Name of the variable.
  30121. * @param matrix matrix to be set.
  30122. * @returns this effect.
  30123. */
  30124. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30125. /**
  30126. * Sets a float on a uniform variable.
  30127. * @param uniformName Name of the variable.
  30128. * @param value value to be set.
  30129. * @returns this effect.
  30130. */
  30131. setFloat(uniformName: string, value: number): Effect;
  30132. /**
  30133. * Sets a boolean on a uniform variable.
  30134. * @param uniformName Name of the variable.
  30135. * @param bool value to be set.
  30136. * @returns this effect.
  30137. */
  30138. setBool(uniformName: string, bool: boolean): Effect;
  30139. /**
  30140. * Sets a Vector2 on a uniform variable.
  30141. * @param uniformName Name of the variable.
  30142. * @param vector2 vector2 to be set.
  30143. * @returns this effect.
  30144. */
  30145. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30146. /**
  30147. * Sets a float2 on a uniform variable.
  30148. * @param uniformName Name of the variable.
  30149. * @param x First float in float2.
  30150. * @param y Second float in float2.
  30151. * @returns this effect.
  30152. */
  30153. setFloat2(uniformName: string, x: number, y: number): Effect;
  30154. /**
  30155. * Sets a Vector3 on a uniform variable.
  30156. * @param uniformName Name of the variable.
  30157. * @param vector3 Value to be set.
  30158. * @returns this effect.
  30159. */
  30160. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30161. /**
  30162. * Sets a float3 on a uniform variable.
  30163. * @param uniformName Name of the variable.
  30164. * @param x First float in float3.
  30165. * @param y Second float in float3.
  30166. * @param z Third float in float3.
  30167. * @returns this effect.
  30168. */
  30169. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30170. /**
  30171. * Sets a Vector4 on a uniform variable.
  30172. * @param uniformName Name of the variable.
  30173. * @param vector4 Value to be set.
  30174. * @returns this effect.
  30175. */
  30176. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30177. /**
  30178. * Sets a float4 on a uniform variable.
  30179. * @param uniformName Name of the variable.
  30180. * @param x First float in float4.
  30181. * @param y Second float in float4.
  30182. * @param z Third float in float4.
  30183. * @param w Fourth float in float4.
  30184. * @returns this effect.
  30185. */
  30186. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30187. /**
  30188. * Sets a Color3 on a uniform variable.
  30189. * @param uniformName Name of the variable.
  30190. * @param color3 Value to be set.
  30191. * @returns this effect.
  30192. */
  30193. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30194. /**
  30195. * Sets a Color4 on a uniform variable.
  30196. * @param uniformName Name of the variable.
  30197. * @param color3 Value to be set.
  30198. * @param alpha Alpha value to be set.
  30199. * @returns this effect.
  30200. */
  30201. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30202. /**
  30203. * Sets a Color4 on a uniform variable
  30204. * @param uniformName defines the name of the variable
  30205. * @param color4 defines the value to be set
  30206. * @returns this effect.
  30207. */
  30208. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30209. /** Release all associated resources */
  30210. dispose(): void;
  30211. /**
  30212. * This function will add a new shader to the shader store
  30213. * @param name the name of the shader
  30214. * @param pixelShader optional pixel shader content
  30215. * @param vertexShader optional vertex shader content
  30216. */
  30217. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30218. /**
  30219. * Store of each shader (The can be looked up using effect.key)
  30220. */
  30221. static ShadersStore: {
  30222. [key: string]: string;
  30223. };
  30224. /**
  30225. * Store of each included file for a shader (The can be looked up using effect.key)
  30226. */
  30227. static IncludesShadersStore: {
  30228. [key: string]: string;
  30229. };
  30230. /**
  30231. * Resets the cache of effects.
  30232. */
  30233. static ResetCache(): void;
  30234. }
  30235. }
  30236. declare module BABYLON {
  30237. /**
  30238. * Interface used to describe the capabilities of the engine relatively to the current browser
  30239. */
  30240. export interface EngineCapabilities {
  30241. /** Maximum textures units per fragment shader */
  30242. maxTexturesImageUnits: number;
  30243. /** Maximum texture units per vertex shader */
  30244. maxVertexTextureImageUnits: number;
  30245. /** Maximum textures units in the entire pipeline */
  30246. maxCombinedTexturesImageUnits: number;
  30247. /** Maximum texture size */
  30248. maxTextureSize: number;
  30249. /** Maximum texture samples */
  30250. maxSamples?: number;
  30251. /** Maximum cube texture size */
  30252. maxCubemapTextureSize: number;
  30253. /** Maximum render texture size */
  30254. maxRenderTextureSize: number;
  30255. /** Maximum number of vertex attributes */
  30256. maxVertexAttribs: number;
  30257. /** Maximum number of varyings */
  30258. maxVaryingVectors: number;
  30259. /** Maximum number of uniforms per vertex shader */
  30260. maxVertexUniformVectors: number;
  30261. /** Maximum number of uniforms per fragment shader */
  30262. maxFragmentUniformVectors: number;
  30263. /** Defines if standard derivates (dx/dy) are supported */
  30264. standardDerivatives: boolean;
  30265. /** Defines if s3tc texture compression is supported */
  30266. s3tc?: WEBGL_compressed_texture_s3tc;
  30267. /** Defines if pvrtc texture compression is supported */
  30268. pvrtc: any;
  30269. /** Defines if etc1 texture compression is supported */
  30270. etc1: any;
  30271. /** Defines if etc2 texture compression is supported */
  30272. etc2: any;
  30273. /** Defines if astc texture compression is supported */
  30274. astc: any;
  30275. /** Defines if float textures are supported */
  30276. textureFloat: boolean;
  30277. /** Defines if vertex array objects are supported */
  30278. vertexArrayObject: boolean;
  30279. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30280. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30281. /** Gets the maximum level of anisotropy supported */
  30282. maxAnisotropy: number;
  30283. /** Defines if instancing is supported */
  30284. instancedArrays: boolean;
  30285. /** Defines if 32 bits indices are supported */
  30286. uintIndices: boolean;
  30287. /** Defines if high precision shaders are supported */
  30288. highPrecisionShaderSupported: boolean;
  30289. /** Defines if depth reading in the fragment shader is supported */
  30290. fragmentDepthSupported: boolean;
  30291. /** Defines if float texture linear filtering is supported*/
  30292. textureFloatLinearFiltering: boolean;
  30293. /** Defines if rendering to float textures is supported */
  30294. textureFloatRender: boolean;
  30295. /** Defines if half float textures are supported*/
  30296. textureHalfFloat: boolean;
  30297. /** Defines if half float texture linear filtering is supported*/
  30298. textureHalfFloatLinearFiltering: boolean;
  30299. /** Defines if rendering to half float textures is supported */
  30300. textureHalfFloatRender: boolean;
  30301. /** Defines if textureLOD shader command is supported */
  30302. textureLOD: boolean;
  30303. /** Defines if draw buffers extension is supported */
  30304. drawBuffersExtension: boolean;
  30305. /** Defines if depth textures are supported */
  30306. depthTextureExtension: boolean;
  30307. /** Defines if float color buffer are supported */
  30308. colorBufferFloat: boolean;
  30309. /** Gets disjoint timer query extension (null if not supported) */
  30310. timerQuery?: EXT_disjoint_timer_query;
  30311. /** Defines if timestamp can be used with timer query */
  30312. canUseTimestampForTimerQuery: boolean;
  30313. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30314. multiview?: any;
  30315. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30316. oculusMultiview?: any;
  30317. /** Function used to let the system compiles shaders in background */
  30318. parallelShaderCompile?: {
  30319. COMPLETION_STATUS_KHR: number;
  30320. };
  30321. /** Max number of texture samples for MSAA */
  30322. maxMSAASamples: number;
  30323. /** Defines if the blend min max extension is supported */
  30324. blendMinMax: boolean;
  30325. }
  30326. }
  30327. declare module BABYLON {
  30328. /**
  30329. * @hidden
  30330. **/
  30331. export class DepthCullingState {
  30332. private _isDepthTestDirty;
  30333. private _isDepthMaskDirty;
  30334. private _isDepthFuncDirty;
  30335. private _isCullFaceDirty;
  30336. private _isCullDirty;
  30337. private _isZOffsetDirty;
  30338. private _isFrontFaceDirty;
  30339. private _depthTest;
  30340. private _depthMask;
  30341. private _depthFunc;
  30342. private _cull;
  30343. private _cullFace;
  30344. private _zOffset;
  30345. private _frontFace;
  30346. /**
  30347. * Initializes the state.
  30348. */
  30349. constructor();
  30350. get isDirty(): boolean;
  30351. get zOffset(): number;
  30352. set zOffset(value: number);
  30353. get cullFace(): Nullable<number>;
  30354. set cullFace(value: Nullable<number>);
  30355. get cull(): Nullable<boolean>;
  30356. set cull(value: Nullable<boolean>);
  30357. get depthFunc(): Nullable<number>;
  30358. set depthFunc(value: Nullable<number>);
  30359. get depthMask(): boolean;
  30360. set depthMask(value: boolean);
  30361. get depthTest(): boolean;
  30362. set depthTest(value: boolean);
  30363. get frontFace(): Nullable<number>;
  30364. set frontFace(value: Nullable<number>);
  30365. reset(): void;
  30366. apply(gl: WebGLRenderingContext): void;
  30367. }
  30368. }
  30369. declare module BABYLON {
  30370. /**
  30371. * @hidden
  30372. **/
  30373. export class StencilState {
  30374. /** 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 */
  30375. static readonly ALWAYS: number;
  30376. /** Passed to stencilOperation to specify that stencil value must be kept */
  30377. static readonly KEEP: number;
  30378. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30379. static readonly REPLACE: number;
  30380. private _isStencilTestDirty;
  30381. private _isStencilMaskDirty;
  30382. private _isStencilFuncDirty;
  30383. private _isStencilOpDirty;
  30384. private _stencilTest;
  30385. private _stencilMask;
  30386. private _stencilFunc;
  30387. private _stencilFuncRef;
  30388. private _stencilFuncMask;
  30389. private _stencilOpStencilFail;
  30390. private _stencilOpDepthFail;
  30391. private _stencilOpStencilDepthPass;
  30392. get isDirty(): boolean;
  30393. get stencilFunc(): number;
  30394. set stencilFunc(value: number);
  30395. get stencilFuncRef(): number;
  30396. set stencilFuncRef(value: number);
  30397. get stencilFuncMask(): number;
  30398. set stencilFuncMask(value: number);
  30399. get stencilOpStencilFail(): number;
  30400. set stencilOpStencilFail(value: number);
  30401. get stencilOpDepthFail(): number;
  30402. set stencilOpDepthFail(value: number);
  30403. get stencilOpStencilDepthPass(): number;
  30404. set stencilOpStencilDepthPass(value: number);
  30405. get stencilMask(): number;
  30406. set stencilMask(value: number);
  30407. get stencilTest(): boolean;
  30408. set stencilTest(value: boolean);
  30409. constructor();
  30410. reset(): void;
  30411. apply(gl: WebGLRenderingContext): void;
  30412. }
  30413. }
  30414. declare module BABYLON {
  30415. /**
  30416. * @hidden
  30417. **/
  30418. export class AlphaState {
  30419. private _isAlphaBlendDirty;
  30420. private _isBlendFunctionParametersDirty;
  30421. private _isBlendEquationParametersDirty;
  30422. private _isBlendConstantsDirty;
  30423. private _alphaBlend;
  30424. private _blendFunctionParameters;
  30425. private _blendEquationParameters;
  30426. private _blendConstants;
  30427. /**
  30428. * Initializes the state.
  30429. */
  30430. constructor();
  30431. get isDirty(): boolean;
  30432. get alphaBlend(): boolean;
  30433. set alphaBlend(value: boolean);
  30434. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30435. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30436. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30437. reset(): void;
  30438. apply(gl: WebGLRenderingContext): void;
  30439. }
  30440. }
  30441. declare module BABYLON {
  30442. /** @hidden */
  30443. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30444. attributeProcessor(attribute: string): string;
  30445. varyingProcessor(varying: string, isFragment: boolean): string;
  30446. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30447. }
  30448. }
  30449. declare module BABYLON {
  30450. /**
  30451. * Interface for attribute information associated with buffer instanciation
  30452. */
  30453. export interface InstancingAttributeInfo {
  30454. /**
  30455. * Name of the GLSL attribute
  30456. * if attribute index is not specified, this is used to retrieve the index from the effect
  30457. */
  30458. attributeName: string;
  30459. /**
  30460. * Index/offset of the attribute in the vertex shader
  30461. * if not specified, this will be computes from the name.
  30462. */
  30463. index?: number;
  30464. /**
  30465. * size of the attribute, 1, 2, 3 or 4
  30466. */
  30467. attributeSize: number;
  30468. /**
  30469. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30470. */
  30471. offset: number;
  30472. /**
  30473. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30474. * default to 1
  30475. */
  30476. divisor?: number;
  30477. /**
  30478. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30479. * default is FLOAT
  30480. */
  30481. attributeType?: number;
  30482. /**
  30483. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30484. */
  30485. normalized?: boolean;
  30486. }
  30487. }
  30488. declare module BABYLON {
  30489. interface ThinEngine {
  30490. /**
  30491. * Update a video texture
  30492. * @param texture defines the texture to update
  30493. * @param video defines the video element to use
  30494. * @param invertY defines if data must be stored with Y axis inverted
  30495. */
  30496. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30497. }
  30498. }
  30499. declare module BABYLON {
  30500. /**
  30501. * Settings for finer control over video usage
  30502. */
  30503. export interface VideoTextureSettings {
  30504. /**
  30505. * Applies `autoplay` to video, if specified
  30506. */
  30507. autoPlay?: boolean;
  30508. /**
  30509. * Applies `loop` to video, if specified
  30510. */
  30511. loop?: boolean;
  30512. /**
  30513. * Automatically updates internal texture from video at every frame in the render loop
  30514. */
  30515. autoUpdateTexture: boolean;
  30516. /**
  30517. * Image src displayed during the video loading or until the user interacts with the video.
  30518. */
  30519. poster?: string;
  30520. }
  30521. /**
  30522. * If you want to display a video in your scene, this is the special texture for that.
  30523. * This special texture works similar to other textures, with the exception of a few parameters.
  30524. * @see https://doc.babylonjs.com/how_to/video_texture
  30525. */
  30526. export class VideoTexture extends Texture {
  30527. /**
  30528. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30529. */
  30530. readonly autoUpdateTexture: boolean;
  30531. /**
  30532. * The video instance used by the texture internally
  30533. */
  30534. readonly video: HTMLVideoElement;
  30535. private _onUserActionRequestedObservable;
  30536. /**
  30537. * Event triggerd when a dom action is required by the user to play the video.
  30538. * This happens due to recent changes in browser policies preventing video to auto start.
  30539. */
  30540. get onUserActionRequestedObservable(): Observable<Texture>;
  30541. private _generateMipMaps;
  30542. private _engine;
  30543. private _stillImageCaptured;
  30544. private _displayingPosterTexture;
  30545. private _settings;
  30546. private _createInternalTextureOnEvent;
  30547. private _frameId;
  30548. /**
  30549. * Creates a video texture.
  30550. * If you want to display a video in your scene, this is the special texture for that.
  30551. * This special texture works similar to other textures, with the exception of a few parameters.
  30552. * @see https://doc.babylonjs.com/how_to/video_texture
  30553. * @param name optional name, will detect from video source, if not defined
  30554. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30555. * @param scene is obviously the current scene.
  30556. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30557. * @param invertY is false by default but can be used to invert video on Y axis
  30558. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30559. * @param settings allows finer control over video usage
  30560. */
  30561. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30562. private _getName;
  30563. private _getVideo;
  30564. private _createInternalTexture;
  30565. private reset;
  30566. /**
  30567. * @hidden Internal method to initiate `update`.
  30568. */
  30569. _rebuild(): void;
  30570. /**
  30571. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30572. */
  30573. update(): void;
  30574. /**
  30575. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30576. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30577. */
  30578. updateTexture(isVisible: boolean): void;
  30579. protected _updateInternalTexture: () => void;
  30580. /**
  30581. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30582. * @param url New url.
  30583. */
  30584. updateURL(url: string): void;
  30585. /**
  30586. * Dispose the texture and release its associated resources.
  30587. */
  30588. dispose(): void;
  30589. /**
  30590. * Creates a video texture straight from a stream.
  30591. * @param scene Define the scene the texture should be created in
  30592. * @param stream Define the stream the texture should be created from
  30593. * @returns The created video texture as a promise
  30594. */
  30595. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30596. /**
  30597. * Creates a video texture straight from your WebCam video feed.
  30598. * @param scene Define the scene the texture should be created in
  30599. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30600. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30601. * @returns The created video texture as a promise
  30602. */
  30603. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30604. minWidth: number;
  30605. maxWidth: number;
  30606. minHeight: number;
  30607. maxHeight: number;
  30608. deviceId: string;
  30609. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30610. /**
  30611. * Creates a video texture straight from your WebCam video feed.
  30612. * @param scene Define the scene the texture should be created in
  30613. * @param onReady Define a callback to triggered once the texture will be ready
  30614. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30615. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30616. */
  30617. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30618. minWidth: number;
  30619. maxWidth: number;
  30620. minHeight: number;
  30621. maxHeight: number;
  30622. deviceId: string;
  30623. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30624. }
  30625. }
  30626. declare module BABYLON {
  30627. /**
  30628. * Defines the interface used by objects working like Scene
  30629. * @hidden
  30630. */
  30631. interface ISceneLike {
  30632. _addPendingData(data: any): void;
  30633. _removePendingData(data: any): void;
  30634. offlineProvider: IOfflineProvider;
  30635. }
  30636. /** Interface defining initialization parameters for Engine class */
  30637. export interface EngineOptions extends WebGLContextAttributes {
  30638. /**
  30639. * Defines if the engine should no exceed a specified device ratio
  30640. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30641. */
  30642. limitDeviceRatio?: number;
  30643. /**
  30644. * Defines if webvr should be enabled automatically
  30645. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30646. */
  30647. autoEnableWebVR?: boolean;
  30648. /**
  30649. * Defines if webgl2 should be turned off even if supported
  30650. * @see http://doc.babylonjs.com/features/webgl2
  30651. */
  30652. disableWebGL2Support?: boolean;
  30653. /**
  30654. * Defines if webaudio should be initialized as well
  30655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30656. */
  30657. audioEngine?: boolean;
  30658. /**
  30659. * Defines if animations should run using a deterministic lock step
  30660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30661. */
  30662. deterministicLockstep?: boolean;
  30663. /** Defines the maximum steps to use with deterministic lock step mode */
  30664. lockstepMaxSteps?: number;
  30665. /** Defines the seconds between each deterministic lock step */
  30666. timeStep?: number;
  30667. /**
  30668. * Defines that engine should ignore context lost events
  30669. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30670. */
  30671. doNotHandleContextLost?: boolean;
  30672. /**
  30673. * Defines that engine should ignore modifying touch action attribute and style
  30674. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30675. */
  30676. doNotHandleTouchAction?: boolean;
  30677. /**
  30678. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30679. */
  30680. useHighPrecisionFloats?: boolean;
  30681. }
  30682. /**
  30683. * The base engine class (root of all engines)
  30684. */
  30685. export class ThinEngine {
  30686. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30687. static ExceptionList: ({
  30688. key: string;
  30689. capture: string;
  30690. captureConstraint: number;
  30691. targets: string[];
  30692. } | {
  30693. key: string;
  30694. capture: null;
  30695. captureConstraint: null;
  30696. targets: string[];
  30697. })[];
  30698. /** @hidden */
  30699. static _TextureLoaders: IInternalTextureLoader[];
  30700. /**
  30701. * Returns the current npm package of the sdk
  30702. */
  30703. static get NpmPackage(): string;
  30704. /**
  30705. * Returns the current version of the framework
  30706. */
  30707. static get Version(): string;
  30708. /**
  30709. * Returns a string describing the current engine
  30710. */
  30711. get description(): string;
  30712. /**
  30713. * Gets or sets the epsilon value used by collision engine
  30714. */
  30715. static CollisionsEpsilon: number;
  30716. /**
  30717. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30718. */
  30719. static get ShadersRepository(): string;
  30720. static set ShadersRepository(value: string);
  30721. /**
  30722. * Gets or sets the textures that the engine should not attempt to load as compressed
  30723. */
  30724. protected _excludedCompressedTextures: string[];
  30725. /**
  30726. * Filters the compressed texture formats to only include
  30727. * files that are not included in the skippable list
  30728. *
  30729. * @param url the current extension
  30730. * @param textureFormatInUse the current compressed texture format
  30731. * @returns "format" string
  30732. */
  30733. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30734. /** @hidden */
  30735. _shaderProcessor: IShaderProcessor;
  30736. /**
  30737. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30738. */
  30739. forcePOTTextures: boolean;
  30740. /**
  30741. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30742. */
  30743. isFullscreen: boolean;
  30744. /**
  30745. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30746. */
  30747. cullBackFaces: boolean;
  30748. /**
  30749. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30750. */
  30751. renderEvenInBackground: boolean;
  30752. /**
  30753. * Gets or sets a boolean indicating that cache can be kept between frames
  30754. */
  30755. preventCacheWipeBetweenFrames: boolean;
  30756. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30757. validateShaderPrograms: boolean;
  30758. /**
  30759. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30760. * This can provide greater z depth for distant objects.
  30761. */
  30762. useReverseDepthBuffer: boolean;
  30763. /**
  30764. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30765. */
  30766. disableUniformBuffers: boolean;
  30767. /** @hidden */
  30768. _uniformBuffers: UniformBuffer[];
  30769. /**
  30770. * Gets a boolean indicating that the engine supports uniform buffers
  30771. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30772. */
  30773. get supportsUniformBuffers(): boolean;
  30774. /** @hidden */
  30775. _gl: WebGLRenderingContext;
  30776. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30777. protected _windowIsBackground: boolean;
  30778. protected _webGLVersion: number;
  30779. protected _creationOptions: EngineOptions;
  30780. protected _highPrecisionShadersAllowed: boolean;
  30781. /** @hidden */
  30782. get _shouldUseHighPrecisionShader(): boolean;
  30783. /**
  30784. * Gets a boolean indicating that only power of 2 textures are supported
  30785. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30786. */
  30787. get needPOTTextures(): boolean;
  30788. /** @hidden */
  30789. _badOS: boolean;
  30790. /** @hidden */
  30791. _badDesktopOS: boolean;
  30792. private _hardwareScalingLevel;
  30793. /** @hidden */
  30794. _caps: EngineCapabilities;
  30795. private _isStencilEnable;
  30796. private _glVersion;
  30797. private _glRenderer;
  30798. private _glVendor;
  30799. /** @hidden */
  30800. _videoTextureSupported: boolean;
  30801. protected _renderingQueueLaunched: boolean;
  30802. protected _activeRenderLoops: (() => void)[];
  30803. /**
  30804. * Observable signaled when a context lost event is raised
  30805. */
  30806. onContextLostObservable: Observable<ThinEngine>;
  30807. /**
  30808. * Observable signaled when a context restored event is raised
  30809. */
  30810. onContextRestoredObservable: Observable<ThinEngine>;
  30811. private _onContextLost;
  30812. private _onContextRestored;
  30813. protected _contextWasLost: boolean;
  30814. /** @hidden */
  30815. _doNotHandleContextLost: boolean;
  30816. /**
  30817. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30818. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30819. */
  30820. get doNotHandleContextLost(): boolean;
  30821. set doNotHandleContextLost(value: boolean);
  30822. /**
  30823. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30824. */
  30825. disableVertexArrayObjects: boolean;
  30826. /** @hidden */
  30827. protected _colorWrite: boolean;
  30828. /** @hidden */
  30829. protected _colorWriteChanged: boolean;
  30830. /** @hidden */
  30831. protected _depthCullingState: DepthCullingState;
  30832. /** @hidden */
  30833. protected _stencilState: StencilState;
  30834. /** @hidden */
  30835. _alphaState: AlphaState;
  30836. /** @hidden */
  30837. _alphaMode: number;
  30838. /** @hidden */
  30839. _alphaEquation: number;
  30840. /** @hidden */
  30841. _internalTexturesCache: InternalTexture[];
  30842. /** @hidden */
  30843. protected _activeChannel: number;
  30844. private _currentTextureChannel;
  30845. /** @hidden */
  30846. protected _boundTexturesCache: {
  30847. [key: string]: Nullable<InternalTexture>;
  30848. };
  30849. /** @hidden */
  30850. protected _currentEffect: Nullable<Effect>;
  30851. /** @hidden */
  30852. protected _currentProgram: Nullable<WebGLProgram>;
  30853. private _compiledEffects;
  30854. private _vertexAttribArraysEnabled;
  30855. /** @hidden */
  30856. protected _cachedViewport: Nullable<IViewportLike>;
  30857. private _cachedVertexArrayObject;
  30858. /** @hidden */
  30859. protected _cachedVertexBuffers: any;
  30860. /** @hidden */
  30861. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30862. /** @hidden */
  30863. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30864. /** @hidden */
  30865. _currentRenderTarget: Nullable<InternalTexture>;
  30866. private _uintIndicesCurrentlySet;
  30867. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30868. /** @hidden */
  30869. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30870. private _currentBufferPointers;
  30871. private _currentInstanceLocations;
  30872. private _currentInstanceBuffers;
  30873. private _textureUnits;
  30874. /** @hidden */
  30875. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30876. /** @hidden */
  30877. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30878. /** @hidden */
  30879. _boundRenderFunction: any;
  30880. private _vaoRecordInProgress;
  30881. private _mustWipeVertexAttributes;
  30882. private _emptyTexture;
  30883. private _emptyCubeTexture;
  30884. private _emptyTexture3D;
  30885. private _emptyTexture2DArray;
  30886. /** @hidden */
  30887. _frameHandler: number;
  30888. private _nextFreeTextureSlots;
  30889. private _maxSimultaneousTextures;
  30890. private _activeRequests;
  30891. protected _texturesSupported: string[];
  30892. /** @hidden */
  30893. _textureFormatInUse: Nullable<string>;
  30894. protected get _supportsHardwareTextureRescaling(): boolean;
  30895. /**
  30896. * Gets the list of texture formats supported
  30897. */
  30898. get texturesSupported(): Array<string>;
  30899. /**
  30900. * Gets the list of texture formats in use
  30901. */
  30902. get textureFormatInUse(): Nullable<string>;
  30903. /**
  30904. * Gets the current viewport
  30905. */
  30906. get currentViewport(): Nullable<IViewportLike>;
  30907. /**
  30908. * Gets the default empty texture
  30909. */
  30910. get emptyTexture(): InternalTexture;
  30911. /**
  30912. * Gets the default empty 3D texture
  30913. */
  30914. get emptyTexture3D(): InternalTexture;
  30915. /**
  30916. * Gets the default empty 2D array texture
  30917. */
  30918. get emptyTexture2DArray(): InternalTexture;
  30919. /**
  30920. * Gets the default empty cube texture
  30921. */
  30922. get emptyCubeTexture(): InternalTexture;
  30923. /**
  30924. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30925. */
  30926. readonly premultipliedAlpha: boolean;
  30927. /**
  30928. * Observable event triggered before each texture is initialized
  30929. */
  30930. onBeforeTextureInitObservable: Observable<Texture>;
  30931. /**
  30932. * Creates a new engine
  30933. * @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
  30934. * @param antialias defines enable antialiasing (default: false)
  30935. * @param options defines further options to be sent to the getContext() function
  30936. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30937. */
  30938. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30939. private _rebuildInternalTextures;
  30940. private _rebuildEffects;
  30941. /**
  30942. * Gets a boolean indicating if all created effects are ready
  30943. * @returns true if all effects are ready
  30944. */
  30945. areAllEffectsReady(): boolean;
  30946. protected _rebuildBuffers(): void;
  30947. private _initGLContext;
  30948. /**
  30949. * Gets version of the current webGL context
  30950. */
  30951. get webGLVersion(): number;
  30952. /**
  30953. * Gets a string idenfifying the name of the class
  30954. * @returns "Engine" string
  30955. */
  30956. getClassName(): string;
  30957. /**
  30958. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30959. */
  30960. get isStencilEnable(): boolean;
  30961. /** @hidden */
  30962. _prepareWorkingCanvas(): void;
  30963. /**
  30964. * Reset the texture cache to empty state
  30965. */
  30966. resetTextureCache(): void;
  30967. /**
  30968. * Gets an object containing information about the current webGL context
  30969. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30970. */
  30971. getGlInfo(): {
  30972. vendor: string;
  30973. renderer: string;
  30974. version: string;
  30975. };
  30976. /**
  30977. * Defines the hardware scaling level.
  30978. * By default the hardware scaling level is computed from the window device ratio.
  30979. * 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.
  30980. * @param level defines the level to use
  30981. */
  30982. setHardwareScalingLevel(level: number): void;
  30983. /**
  30984. * Gets the current hardware scaling level.
  30985. * By default the hardware scaling level is computed from the window device ratio.
  30986. * 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.
  30987. * @returns a number indicating the current hardware scaling level
  30988. */
  30989. getHardwareScalingLevel(): number;
  30990. /**
  30991. * Gets the list of loaded textures
  30992. * @returns an array containing all loaded textures
  30993. */
  30994. getLoadedTexturesCache(): InternalTexture[];
  30995. /**
  30996. * Gets the object containing all engine capabilities
  30997. * @returns the EngineCapabilities object
  30998. */
  30999. getCaps(): EngineCapabilities;
  31000. /**
  31001. * stop executing a render loop function and remove it from the execution array
  31002. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31003. */
  31004. stopRenderLoop(renderFunction?: () => void): void;
  31005. /** @hidden */
  31006. _renderLoop(): void;
  31007. /**
  31008. * Gets the HTML canvas attached with the current webGL context
  31009. * @returns a HTML canvas
  31010. */
  31011. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31012. /**
  31013. * Gets host window
  31014. * @returns the host window object
  31015. */
  31016. getHostWindow(): Nullable<Window>;
  31017. /**
  31018. * Gets the current render width
  31019. * @param useScreen defines if screen size must be used (or the current render target if any)
  31020. * @returns a number defining the current render width
  31021. */
  31022. getRenderWidth(useScreen?: boolean): number;
  31023. /**
  31024. * Gets the current render height
  31025. * @param useScreen defines if screen size must be used (or the current render target if any)
  31026. * @returns a number defining the current render height
  31027. */
  31028. getRenderHeight(useScreen?: boolean): number;
  31029. /**
  31030. * Can be used to override the current requestAnimationFrame requester.
  31031. * @hidden
  31032. */
  31033. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31034. /**
  31035. * Register and execute a render loop. The engine can have more than one render function
  31036. * @param renderFunction defines the function to continuously execute
  31037. */
  31038. runRenderLoop(renderFunction: () => void): void;
  31039. /**
  31040. * Clear the current render buffer or the current render target (if any is set up)
  31041. * @param color defines the color to use
  31042. * @param backBuffer defines if the back buffer must be cleared
  31043. * @param depth defines if the depth buffer must be cleared
  31044. * @param stencil defines if the stencil buffer must be cleared
  31045. */
  31046. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31047. private _viewportCached;
  31048. /** @hidden */
  31049. _viewport(x: number, y: number, width: number, height: number): void;
  31050. /**
  31051. * Set the WebGL's viewport
  31052. * @param viewport defines the viewport element to be used
  31053. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31054. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31055. */
  31056. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31057. /**
  31058. * Begin a new frame
  31059. */
  31060. beginFrame(): void;
  31061. /**
  31062. * Enf the current frame
  31063. */
  31064. endFrame(): void;
  31065. /**
  31066. * Resize the view according to the canvas' size
  31067. */
  31068. resize(): void;
  31069. /**
  31070. * Force a specific size of the canvas
  31071. * @param width defines the new canvas' width
  31072. * @param height defines the new canvas' height
  31073. */
  31074. setSize(width: number, height: number): void;
  31075. /**
  31076. * Binds the frame buffer to the specified texture.
  31077. * @param texture The texture to render to or null for the default canvas
  31078. * @param faceIndex The face of the texture to render to in case of cube texture
  31079. * @param requiredWidth The width of the target to render to
  31080. * @param requiredHeight The height of the target to render to
  31081. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31082. * @param depthStencilTexture The depth stencil texture to use to render
  31083. * @param lodLevel defines le lod level to bind to the frame buffer
  31084. */
  31085. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31086. /** @hidden */
  31087. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31088. /**
  31089. * Unbind the current render target texture from the webGL context
  31090. * @param texture defines the render target texture to unbind
  31091. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31092. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31093. */
  31094. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31095. /**
  31096. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31097. */
  31098. flushFramebuffer(): void;
  31099. /**
  31100. * Unbind the current render target and bind the default framebuffer
  31101. */
  31102. restoreDefaultFramebuffer(): void;
  31103. /** @hidden */
  31104. protected _resetVertexBufferBinding(): void;
  31105. /**
  31106. * Creates a vertex buffer
  31107. * @param data the data for the vertex buffer
  31108. * @returns the new WebGL static buffer
  31109. */
  31110. createVertexBuffer(data: DataArray): DataBuffer;
  31111. private _createVertexBuffer;
  31112. /**
  31113. * Creates a dynamic vertex buffer
  31114. * @param data the data for the dynamic vertex buffer
  31115. * @returns the new WebGL dynamic buffer
  31116. */
  31117. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31118. protected _resetIndexBufferBinding(): void;
  31119. /**
  31120. * Creates a new index buffer
  31121. * @param indices defines the content of the index buffer
  31122. * @param updatable defines if the index buffer must be updatable
  31123. * @returns a new webGL buffer
  31124. */
  31125. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31126. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31127. /**
  31128. * Bind a webGL buffer to the webGL context
  31129. * @param buffer defines the buffer to bind
  31130. */
  31131. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31132. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31133. private bindBuffer;
  31134. /**
  31135. * update the bound buffer with the given data
  31136. * @param data defines the data to update
  31137. */
  31138. updateArrayBuffer(data: Float32Array): void;
  31139. private _vertexAttribPointer;
  31140. private _bindIndexBufferWithCache;
  31141. private _bindVertexBuffersAttributes;
  31142. /**
  31143. * Records a vertex array object
  31144. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31145. * @param vertexBuffers defines the list of vertex buffers to store
  31146. * @param indexBuffer defines the index buffer to store
  31147. * @param effect defines the effect to store
  31148. * @returns the new vertex array object
  31149. */
  31150. recordVertexArrayObject(vertexBuffers: {
  31151. [key: string]: VertexBuffer;
  31152. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31153. /**
  31154. * Bind a specific vertex array object
  31155. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31156. * @param vertexArrayObject defines the vertex array object to bind
  31157. * @param indexBuffer defines the index buffer to bind
  31158. */
  31159. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31160. /**
  31161. * Bind webGl buffers directly to the webGL context
  31162. * @param vertexBuffer defines the vertex buffer to bind
  31163. * @param indexBuffer defines the index buffer to bind
  31164. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31165. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31166. * @param effect defines the effect associated with the vertex buffer
  31167. */
  31168. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31169. private _unbindVertexArrayObject;
  31170. /**
  31171. * Bind a list of vertex buffers to the webGL context
  31172. * @param vertexBuffers defines the list of vertex buffers to bind
  31173. * @param indexBuffer defines the index buffer to bind
  31174. * @param effect defines the effect associated with the vertex buffers
  31175. */
  31176. bindBuffers(vertexBuffers: {
  31177. [key: string]: Nullable<VertexBuffer>;
  31178. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31179. /**
  31180. * Unbind all instance attributes
  31181. */
  31182. unbindInstanceAttributes(): void;
  31183. /**
  31184. * Release and free the memory of a vertex array object
  31185. * @param vao defines the vertex array object to delete
  31186. */
  31187. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31188. /** @hidden */
  31189. _releaseBuffer(buffer: DataBuffer): boolean;
  31190. protected _deleteBuffer(buffer: DataBuffer): void;
  31191. /**
  31192. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31193. * @param instancesBuffer defines the webGL buffer to update and bind
  31194. * @param data defines the data to store in the buffer
  31195. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31196. */
  31197. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31198. /**
  31199. * Bind the content of a webGL buffer used with instanciation
  31200. * @param instancesBuffer defines the webGL buffer to bind
  31201. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31202. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31203. */
  31204. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31205. /**
  31206. * Disable the instance attribute corresponding to the name in parameter
  31207. * @param name defines the name of the attribute to disable
  31208. */
  31209. disableInstanceAttributeByName(name: string): void;
  31210. /**
  31211. * Disable the instance attribute corresponding to the location in parameter
  31212. * @param attributeLocation defines the attribute location of the attribute to disable
  31213. */
  31214. disableInstanceAttribute(attributeLocation: number): void;
  31215. /**
  31216. * Disable the attribute corresponding to the location in parameter
  31217. * @param attributeLocation defines the attribute location of the attribute to disable
  31218. */
  31219. disableAttributeByIndex(attributeLocation: number): void;
  31220. /**
  31221. * Send a draw order
  31222. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31223. * @param indexStart defines the starting index
  31224. * @param indexCount defines the number of index to draw
  31225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31226. */
  31227. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31228. /**
  31229. * Draw a list of points
  31230. * @param verticesStart defines the index of first vertex to draw
  31231. * @param verticesCount defines the count of vertices to draw
  31232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31233. */
  31234. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31235. /**
  31236. * Draw a list of unindexed primitives
  31237. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31238. * @param verticesStart defines the index of first vertex to draw
  31239. * @param verticesCount defines the count of vertices to draw
  31240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31241. */
  31242. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31243. /**
  31244. * Draw a list of indexed primitives
  31245. * @param fillMode defines the primitive to use
  31246. * @param indexStart defines the starting index
  31247. * @param indexCount defines the number of index to draw
  31248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31249. */
  31250. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31251. /**
  31252. * Draw a list of unindexed primitives
  31253. * @param fillMode defines the primitive to use
  31254. * @param verticesStart defines the index of first vertex to draw
  31255. * @param verticesCount defines the count of vertices to draw
  31256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31257. */
  31258. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31259. private _drawMode;
  31260. /** @hidden */
  31261. protected _reportDrawCall(): void;
  31262. /** @hidden */
  31263. _releaseEffect(effect: Effect): void;
  31264. /** @hidden */
  31265. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31266. /**
  31267. * Create a new effect (used to store vertex/fragment shaders)
  31268. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31269. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31270. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31271. * @param samplers defines an array of string used to represent textures
  31272. * @param defines defines the string containing the defines to use to compile the shaders
  31273. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31274. * @param onCompiled defines a function to call when the effect creation is successful
  31275. * @param onError defines a function to call when the effect creation has failed
  31276. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31277. * @returns the new Effect
  31278. */
  31279. 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;
  31280. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31281. private _compileShader;
  31282. private _compileRawShader;
  31283. /**
  31284. * Directly creates a webGL program
  31285. * @param pipelineContext defines the pipeline context to attach to
  31286. * @param vertexCode defines the vertex shader code to use
  31287. * @param fragmentCode defines the fragment shader code to use
  31288. * @param context defines the webGL context to use (if not set, the current one will be used)
  31289. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31290. * @returns the new webGL program
  31291. */
  31292. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31293. /**
  31294. * Creates a webGL program
  31295. * @param pipelineContext defines the pipeline context to attach to
  31296. * @param vertexCode defines the vertex shader code to use
  31297. * @param fragmentCode defines the fragment shader code to use
  31298. * @param defines defines the string containing the defines to use to compile the shaders
  31299. * @param context defines the webGL context to use (if not set, the current one will be used)
  31300. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31301. * @returns the new webGL program
  31302. */
  31303. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31304. /**
  31305. * Creates a new pipeline context
  31306. * @returns the new pipeline
  31307. */
  31308. createPipelineContext(): IPipelineContext;
  31309. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31310. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31311. /** @hidden */
  31312. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31313. /** @hidden */
  31314. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31315. /** @hidden */
  31316. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31317. /**
  31318. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31319. * @param pipelineContext defines the pipeline context to use
  31320. * @param uniformsNames defines the list of uniform names
  31321. * @returns an array of webGL uniform locations
  31322. */
  31323. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31324. /**
  31325. * Gets the lsit of active attributes for a given webGL program
  31326. * @param pipelineContext defines the pipeline context to use
  31327. * @param attributesNames defines the list of attribute names to get
  31328. * @returns an array of indices indicating the offset of each attribute
  31329. */
  31330. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31331. /**
  31332. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31333. * @param effect defines the effect to activate
  31334. */
  31335. enableEffect(effect: Nullable<Effect>): void;
  31336. /**
  31337. * Set the value of an uniform to a number (int)
  31338. * @param uniform defines the webGL uniform location where to store the value
  31339. * @param value defines the int number to store
  31340. */
  31341. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31342. /**
  31343. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31348. /**
  31349. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31354. /**
  31355. * Set the value of an uniform to an array of int32 (stored as vec3)
  31356. * @param uniform defines the webGL uniform location where to store the value
  31357. * @param array defines the array of int32 to store
  31358. */
  31359. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31360. /**
  31361. * Set the value of an uniform to an array of int32 (stored as vec4)
  31362. * @param uniform defines the webGL uniform location where to store the value
  31363. * @param array defines the array of int32 to store
  31364. */
  31365. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31366. /**
  31367. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31372. /**
  31373. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31378. /**
  31379. * Set the value of an uniform to an array of number (stored as vec3)
  31380. * @param uniform defines the webGL uniform location where to store the value
  31381. * @param array defines the array of number to store
  31382. */
  31383. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31384. /**
  31385. * Set the value of an uniform to an array of number (stored as vec4)
  31386. * @param uniform defines the webGL uniform location where to store the value
  31387. * @param array defines the array of number to store
  31388. */
  31389. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31390. /**
  31391. * Set the value of an uniform to an array of float32 (stored as matrices)
  31392. * @param uniform defines the webGL uniform location where to store the value
  31393. * @param matrices defines the array of float32 to store
  31394. */
  31395. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31396. /**
  31397. * Set the value of an uniform to a matrix (3x3)
  31398. * @param uniform defines the webGL uniform location where to store the value
  31399. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31400. */
  31401. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31402. /**
  31403. * Set the value of an uniform to a matrix (2x2)
  31404. * @param uniform defines the webGL uniform location where to store the value
  31405. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31406. */
  31407. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31408. /**
  31409. * Set the value of an uniform to a number (float)
  31410. * @param uniform defines the webGL uniform location where to store the value
  31411. * @param value defines the float number to store
  31412. */
  31413. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31414. /**
  31415. * Set the value of an uniform to a vec2
  31416. * @param uniform defines the webGL uniform location where to store the value
  31417. * @param x defines the 1st component of the value
  31418. * @param y defines the 2nd component of the value
  31419. */
  31420. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31421. /**
  31422. * Set the value of an uniform to a vec3
  31423. * @param uniform defines the webGL uniform location where to store the value
  31424. * @param x defines the 1st component of the value
  31425. * @param y defines the 2nd component of the value
  31426. * @param z defines the 3rd component of the value
  31427. */
  31428. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31429. /**
  31430. * Set the value of an uniform to a vec4
  31431. * @param uniform defines the webGL uniform location where to store the value
  31432. * @param x defines the 1st component of the value
  31433. * @param y defines the 2nd component of the value
  31434. * @param z defines the 3rd component of the value
  31435. * @param w defines the 4th component of the value
  31436. */
  31437. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31438. /**
  31439. * Apply all cached states (depth, culling, stencil and alpha)
  31440. */
  31441. applyStates(): void;
  31442. /**
  31443. * Enable or disable color writing
  31444. * @param enable defines the state to set
  31445. */
  31446. setColorWrite(enable: boolean): void;
  31447. /**
  31448. * Gets a boolean indicating if color writing is enabled
  31449. * @returns the current color writing state
  31450. */
  31451. getColorWrite(): boolean;
  31452. /**
  31453. * Gets the depth culling state manager
  31454. */
  31455. get depthCullingState(): DepthCullingState;
  31456. /**
  31457. * Gets the alpha state manager
  31458. */
  31459. get alphaState(): AlphaState;
  31460. /**
  31461. * Gets the stencil state manager
  31462. */
  31463. get stencilState(): StencilState;
  31464. /**
  31465. * Clears the list of texture accessible through engine.
  31466. * This can help preventing texture load conflict due to name collision.
  31467. */
  31468. clearInternalTexturesCache(): void;
  31469. /**
  31470. * Force the entire cache to be cleared
  31471. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31472. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31473. */
  31474. wipeCaches(bruteForce?: boolean): void;
  31475. /** @hidden */
  31476. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31477. min: number;
  31478. mag: number;
  31479. };
  31480. /** @hidden */
  31481. _createTexture(): WebGLTexture;
  31482. /**
  31483. * Usually called from Texture.ts.
  31484. * Passed information to create a WebGLTexture
  31485. * @param urlArg defines a value which contains one of the following:
  31486. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31487. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31488. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31489. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31490. * @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)
  31491. * @param scene needed for loading to the correct scene
  31492. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31493. * @param onLoad optional callback to be called upon successful completion
  31494. * @param onError optional callback to be called upon failure
  31495. * @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
  31496. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31497. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31498. * @param forcedExtension defines the extension to use to pick the right loader
  31499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31500. * @param mimeType defines an optional mime type
  31501. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31502. */
  31503. 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;
  31504. /**
  31505. * Loads an image as an HTMLImageElement.
  31506. * @param input url string, ArrayBuffer, or Blob to load
  31507. * @param onLoad callback called when the image successfully loads
  31508. * @param onError callback called when the image fails to load
  31509. * @param offlineProvider offline provider for caching
  31510. * @param mimeType optional mime type
  31511. * @returns the HTMLImageElement of the loaded image
  31512. * @hidden
  31513. */
  31514. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31515. /**
  31516. * @hidden
  31517. */
  31518. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31519. /**
  31520. * Creates a raw texture
  31521. * @param data defines the data to store in the texture
  31522. * @param width defines the width of the texture
  31523. * @param height defines the height of the texture
  31524. * @param format defines the format of the data
  31525. * @param generateMipMaps defines if the engine should generate the mip levels
  31526. * @param invertY defines if data must be stored with Y axis inverted
  31527. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31528. * @param compression defines the compression used (null by default)
  31529. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31530. * @returns the raw texture inside an InternalTexture
  31531. */
  31532. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31533. /**
  31534. * Creates a new raw cube texture
  31535. * @param data defines the array of data to use to create each face
  31536. * @param size defines the size of the textures
  31537. * @param format defines the format of the data
  31538. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31539. * @param generateMipMaps defines if the engine should generate the mip levels
  31540. * @param invertY defines if data must be stored with Y axis inverted
  31541. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31542. * @param compression defines the compression used (null by default)
  31543. * @returns the cube texture as an InternalTexture
  31544. */
  31545. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31546. /**
  31547. * Creates a new raw 3D texture
  31548. * @param data defines the data used to create the texture
  31549. * @param width defines the width of the texture
  31550. * @param height defines the height of the texture
  31551. * @param depth defines the depth of the texture
  31552. * @param format defines the format of the texture
  31553. * @param generateMipMaps defines if the engine must generate mip levels
  31554. * @param invertY defines if data must be stored with Y axis inverted
  31555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31556. * @param compression defines the compressed used (can be null)
  31557. * @param textureType defines the compressed used (can be null)
  31558. * @returns a new raw 3D texture (stored in an InternalTexture)
  31559. */
  31560. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31561. /**
  31562. * Creates a new raw 2D array texture
  31563. * @param data defines the data used to create the texture
  31564. * @param width defines the width of the texture
  31565. * @param height defines the height of the texture
  31566. * @param depth defines the number of layers of the texture
  31567. * @param format defines the format of the texture
  31568. * @param generateMipMaps defines if the engine must generate mip levels
  31569. * @param invertY defines if data must be stored with Y axis inverted
  31570. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31571. * @param compression defines the compressed used (can be null)
  31572. * @param textureType defines the compressed used (can be null)
  31573. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31574. */
  31575. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31576. private _unpackFlipYCached;
  31577. /**
  31578. * In case you are sharing the context with other applications, it might
  31579. * be interested to not cache the unpack flip y state to ensure a consistent
  31580. * value would be set.
  31581. */
  31582. enableUnpackFlipYCached: boolean;
  31583. /** @hidden */
  31584. _unpackFlipY(value: boolean): void;
  31585. /** @hidden */
  31586. _getUnpackAlignement(): number;
  31587. private _getTextureTarget;
  31588. /**
  31589. * Update the sampling mode of a given texture
  31590. * @param samplingMode defines the required sampling mode
  31591. * @param texture defines the texture to update
  31592. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31593. */
  31594. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31595. /**
  31596. * Update the sampling mode of a given texture
  31597. * @param texture defines the texture to update
  31598. * @param wrapU defines the texture wrap mode of the u coordinates
  31599. * @param wrapV defines the texture wrap mode of the v coordinates
  31600. * @param wrapR defines the texture wrap mode of the r coordinates
  31601. */
  31602. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31603. /** @hidden */
  31604. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31605. width: number;
  31606. height: number;
  31607. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31608. /** @hidden */
  31609. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31610. /** @hidden */
  31611. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31612. /** @hidden */
  31613. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31614. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31615. private _prepareWebGLTexture;
  31616. /** @hidden */
  31617. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31618. private _getDepthStencilBuffer;
  31619. /** @hidden */
  31620. _releaseFramebufferObjects(texture: InternalTexture): void;
  31621. /** @hidden */
  31622. _releaseTexture(texture: InternalTexture): void;
  31623. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31624. protected _setProgram(program: WebGLProgram): void;
  31625. protected _boundUniforms: {
  31626. [key: number]: WebGLUniformLocation;
  31627. };
  31628. /**
  31629. * Binds an effect to the webGL context
  31630. * @param effect defines the effect to bind
  31631. */
  31632. bindSamplers(effect: Effect): void;
  31633. private _activateCurrentTexture;
  31634. /** @hidden */
  31635. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31636. /** @hidden */
  31637. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31638. /**
  31639. * Unbind all textures from the webGL context
  31640. */
  31641. unbindAllTextures(): void;
  31642. /**
  31643. * Sets a texture to the according uniform.
  31644. * @param channel The texture channel
  31645. * @param uniform The uniform to set
  31646. * @param texture The texture to apply
  31647. */
  31648. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31649. private _bindSamplerUniformToChannel;
  31650. private _getTextureWrapMode;
  31651. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31652. /**
  31653. * Sets an array of texture to the webGL context
  31654. * @param channel defines the channel where the texture array must be set
  31655. * @param uniform defines the associated uniform location
  31656. * @param textures defines the array of textures to bind
  31657. */
  31658. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31659. /** @hidden */
  31660. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31661. private _setTextureParameterFloat;
  31662. private _setTextureParameterInteger;
  31663. /**
  31664. * Unbind all vertex attributes from the webGL context
  31665. */
  31666. unbindAllAttributes(): void;
  31667. /**
  31668. * 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
  31669. */
  31670. releaseEffects(): void;
  31671. /**
  31672. * Dispose and release all associated resources
  31673. */
  31674. dispose(): void;
  31675. /**
  31676. * Attach a new callback raised when context lost event is fired
  31677. * @param callback defines the callback to call
  31678. */
  31679. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31680. /**
  31681. * Attach a new callback raised when context restored event is fired
  31682. * @param callback defines the callback to call
  31683. */
  31684. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31685. /**
  31686. * Get the current error code of the webGL context
  31687. * @returns the error code
  31688. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31689. */
  31690. getError(): number;
  31691. private _canRenderToFloatFramebuffer;
  31692. private _canRenderToHalfFloatFramebuffer;
  31693. private _canRenderToFramebuffer;
  31694. /** @hidden */
  31695. _getWebGLTextureType(type: number): number;
  31696. /** @hidden */
  31697. _getInternalFormat(format: number): number;
  31698. /** @hidden */
  31699. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31700. /** @hidden */
  31701. _getRGBAMultiSampleBufferFormat(type: number): number;
  31702. /** @hidden */
  31703. _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;
  31704. /**
  31705. * Loads a file from a url
  31706. * @param url url to load
  31707. * @param onSuccess callback called when the file successfully loads
  31708. * @param onProgress callback called while file is loading (if the server supports this mode)
  31709. * @param offlineProvider defines the offline provider for caching
  31710. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31711. * @param onError callback called when the file fails to load
  31712. * @returns a file request object
  31713. * @hidden
  31714. */
  31715. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  31716. /**
  31717. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31718. * @param x defines the x coordinate of the rectangle where pixels must be read
  31719. * @param y defines the y coordinate of the rectangle where pixels must be read
  31720. * @param width defines the width of the rectangle where pixels must be read
  31721. * @param height defines the height of the rectangle where pixels must be read
  31722. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31723. * @returns a Uint8Array containing RGBA colors
  31724. */
  31725. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31726. private static _isSupported;
  31727. /**
  31728. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31729. * @returns true if the engine can be created
  31730. * @ignorenaming
  31731. */
  31732. static isSupported(): boolean;
  31733. /**
  31734. * Find the next highest power of two.
  31735. * @param x Number to start search from.
  31736. * @return Next highest power of two.
  31737. */
  31738. static CeilingPOT(x: number): number;
  31739. /**
  31740. * Find the next lowest power of two.
  31741. * @param x Number to start search from.
  31742. * @return Next lowest power of two.
  31743. */
  31744. static FloorPOT(x: number): number;
  31745. /**
  31746. * Find the nearest power of two.
  31747. * @param x Number to start search from.
  31748. * @return Next nearest power of two.
  31749. */
  31750. static NearestPOT(x: number): number;
  31751. /**
  31752. * Get the closest exponent of two
  31753. * @param value defines the value to approximate
  31754. * @param max defines the maximum value to return
  31755. * @param mode defines how to define the closest value
  31756. * @returns closest exponent of two of the given value
  31757. */
  31758. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31759. /**
  31760. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31761. * @param func - the function to be called
  31762. * @param requester - the object that will request the next frame. Falls back to window.
  31763. * @returns frame number
  31764. */
  31765. static QueueNewFrame(func: () => void, requester?: any): number;
  31766. /**
  31767. * Gets host document
  31768. * @returns the host document object
  31769. */
  31770. getHostDocument(): Nullable<Document>;
  31771. }
  31772. }
  31773. declare module BABYLON {
  31774. /**
  31775. * Class representing spherical harmonics coefficients to the 3rd degree
  31776. */
  31777. export class SphericalHarmonics {
  31778. /**
  31779. * Defines whether or not the harmonics have been prescaled for rendering.
  31780. */
  31781. preScaled: boolean;
  31782. /**
  31783. * The l0,0 coefficients of the spherical harmonics
  31784. */
  31785. l00: Vector3;
  31786. /**
  31787. * The l1,-1 coefficients of the spherical harmonics
  31788. */
  31789. l1_1: Vector3;
  31790. /**
  31791. * The l1,0 coefficients of the spherical harmonics
  31792. */
  31793. l10: Vector3;
  31794. /**
  31795. * The l1,1 coefficients of the spherical harmonics
  31796. */
  31797. l11: Vector3;
  31798. /**
  31799. * The l2,-2 coefficients of the spherical harmonics
  31800. */
  31801. l2_2: Vector3;
  31802. /**
  31803. * The l2,-1 coefficients of the spherical harmonics
  31804. */
  31805. l2_1: Vector3;
  31806. /**
  31807. * The l2,0 coefficients of the spherical harmonics
  31808. */
  31809. l20: Vector3;
  31810. /**
  31811. * The l2,1 coefficients of the spherical harmonics
  31812. */
  31813. l21: Vector3;
  31814. /**
  31815. * The l2,2 coefficients of the spherical harmonics
  31816. */
  31817. l22: Vector3;
  31818. /**
  31819. * Adds a light to the spherical harmonics
  31820. * @param direction the direction of the light
  31821. * @param color the color of the light
  31822. * @param deltaSolidAngle the delta solid angle of the light
  31823. */
  31824. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31825. /**
  31826. * Scales the spherical harmonics by the given amount
  31827. * @param scale the amount to scale
  31828. */
  31829. scaleInPlace(scale: number): void;
  31830. /**
  31831. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31832. *
  31833. * ```
  31834. * E_lm = A_l * L_lm
  31835. * ```
  31836. *
  31837. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31838. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31839. * the scaling factors are given in equation 9.
  31840. */
  31841. convertIncidentRadianceToIrradiance(): void;
  31842. /**
  31843. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31844. *
  31845. * ```
  31846. * L = (1/pi) * E * rho
  31847. * ```
  31848. *
  31849. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31850. */
  31851. convertIrradianceToLambertianRadiance(): void;
  31852. /**
  31853. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31854. * required operations at run time.
  31855. *
  31856. * This is simply done by scaling back the SH with Ylm constants parameter.
  31857. * The trigonometric part being applied by the shader at run time.
  31858. */
  31859. preScaleForRendering(): void;
  31860. /**
  31861. * Constructs a spherical harmonics from an array.
  31862. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31863. * @returns the spherical harmonics
  31864. */
  31865. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31866. /**
  31867. * Gets the spherical harmonics from polynomial
  31868. * @param polynomial the spherical polynomial
  31869. * @returns the spherical harmonics
  31870. */
  31871. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31872. }
  31873. /**
  31874. * Class representing spherical polynomial coefficients to the 3rd degree
  31875. */
  31876. export class SphericalPolynomial {
  31877. private _harmonics;
  31878. /**
  31879. * The spherical harmonics used to create the polynomials.
  31880. */
  31881. get preScaledHarmonics(): SphericalHarmonics;
  31882. /**
  31883. * The x coefficients of the spherical polynomial
  31884. */
  31885. x: Vector3;
  31886. /**
  31887. * The y coefficients of the spherical polynomial
  31888. */
  31889. y: Vector3;
  31890. /**
  31891. * The z coefficients of the spherical polynomial
  31892. */
  31893. z: Vector3;
  31894. /**
  31895. * The xx coefficients of the spherical polynomial
  31896. */
  31897. xx: Vector3;
  31898. /**
  31899. * The yy coefficients of the spherical polynomial
  31900. */
  31901. yy: Vector3;
  31902. /**
  31903. * The zz coefficients of the spherical polynomial
  31904. */
  31905. zz: Vector3;
  31906. /**
  31907. * The xy coefficients of the spherical polynomial
  31908. */
  31909. xy: Vector3;
  31910. /**
  31911. * The yz coefficients of the spherical polynomial
  31912. */
  31913. yz: Vector3;
  31914. /**
  31915. * The zx coefficients of the spherical polynomial
  31916. */
  31917. zx: Vector3;
  31918. /**
  31919. * Adds an ambient color to the spherical polynomial
  31920. * @param color the color to add
  31921. */
  31922. addAmbient(color: Color3): void;
  31923. /**
  31924. * Scales the spherical polynomial by the given amount
  31925. * @param scale the amount to scale
  31926. */
  31927. scaleInPlace(scale: number): void;
  31928. /**
  31929. * Gets the spherical polynomial from harmonics
  31930. * @param harmonics the spherical harmonics
  31931. * @returns the spherical polynomial
  31932. */
  31933. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31934. /**
  31935. * Constructs a spherical polynomial from an array.
  31936. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31937. * @returns the spherical polynomial
  31938. */
  31939. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31940. }
  31941. }
  31942. declare module BABYLON {
  31943. /**
  31944. * Defines the source of the internal texture
  31945. */
  31946. export enum InternalTextureSource {
  31947. /**
  31948. * The source of the texture data is unknown
  31949. */
  31950. Unknown = 0,
  31951. /**
  31952. * Texture data comes from an URL
  31953. */
  31954. Url = 1,
  31955. /**
  31956. * Texture data is only used for temporary storage
  31957. */
  31958. Temp = 2,
  31959. /**
  31960. * Texture data comes from raw data (ArrayBuffer)
  31961. */
  31962. Raw = 3,
  31963. /**
  31964. * Texture content is dynamic (video or dynamic texture)
  31965. */
  31966. Dynamic = 4,
  31967. /**
  31968. * Texture content is generated by rendering to it
  31969. */
  31970. RenderTarget = 5,
  31971. /**
  31972. * Texture content is part of a multi render target process
  31973. */
  31974. MultiRenderTarget = 6,
  31975. /**
  31976. * Texture data comes from a cube data file
  31977. */
  31978. Cube = 7,
  31979. /**
  31980. * Texture data comes from a raw cube data
  31981. */
  31982. CubeRaw = 8,
  31983. /**
  31984. * Texture data come from a prefiltered cube data file
  31985. */
  31986. CubePrefiltered = 9,
  31987. /**
  31988. * Texture content is raw 3D data
  31989. */
  31990. Raw3D = 10,
  31991. /**
  31992. * Texture content is raw 2D array data
  31993. */
  31994. Raw2DArray = 11,
  31995. /**
  31996. * Texture content is a depth texture
  31997. */
  31998. Depth = 12,
  31999. /**
  32000. * Texture data comes from a raw cube data encoded with RGBD
  32001. */
  32002. CubeRawRGBD = 13
  32003. }
  32004. /**
  32005. * Class used to store data associated with WebGL texture data for the engine
  32006. * This class should not be used directly
  32007. */
  32008. export class InternalTexture {
  32009. /** @hidden */
  32010. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32011. /**
  32012. * Defines if the texture is ready
  32013. */
  32014. isReady: boolean;
  32015. /**
  32016. * Defines if the texture is a cube texture
  32017. */
  32018. isCube: boolean;
  32019. /**
  32020. * Defines if the texture contains 3D data
  32021. */
  32022. is3D: boolean;
  32023. /**
  32024. * Defines if the texture contains 2D array data
  32025. */
  32026. is2DArray: boolean;
  32027. /**
  32028. * Defines if the texture contains multiview data
  32029. */
  32030. isMultiview: boolean;
  32031. /**
  32032. * Gets the URL used to load this texture
  32033. */
  32034. url: string;
  32035. /**
  32036. * Gets the sampling mode of the texture
  32037. */
  32038. samplingMode: number;
  32039. /**
  32040. * Gets a boolean indicating if the texture needs mipmaps generation
  32041. */
  32042. generateMipMaps: boolean;
  32043. /**
  32044. * Gets the number of samples used by the texture (WebGL2+ only)
  32045. */
  32046. samples: number;
  32047. /**
  32048. * Gets the type of the texture (int, float...)
  32049. */
  32050. type: number;
  32051. /**
  32052. * Gets the format of the texture (RGB, RGBA...)
  32053. */
  32054. format: number;
  32055. /**
  32056. * Observable called when the texture is loaded
  32057. */
  32058. onLoadedObservable: Observable<InternalTexture>;
  32059. /**
  32060. * Gets the width of the texture
  32061. */
  32062. width: number;
  32063. /**
  32064. * Gets the height of the texture
  32065. */
  32066. height: number;
  32067. /**
  32068. * Gets the depth of the texture
  32069. */
  32070. depth: number;
  32071. /**
  32072. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32073. */
  32074. baseWidth: number;
  32075. /**
  32076. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32077. */
  32078. baseHeight: number;
  32079. /**
  32080. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32081. */
  32082. baseDepth: number;
  32083. /**
  32084. * Gets a boolean indicating if the texture is inverted on Y axis
  32085. */
  32086. invertY: boolean;
  32087. /** @hidden */
  32088. _invertVScale: boolean;
  32089. /** @hidden */
  32090. _associatedChannel: number;
  32091. /** @hidden */
  32092. _source: InternalTextureSource;
  32093. /** @hidden */
  32094. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32095. /** @hidden */
  32096. _bufferView: Nullable<ArrayBufferView>;
  32097. /** @hidden */
  32098. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32099. /** @hidden */
  32100. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32101. /** @hidden */
  32102. _size: number;
  32103. /** @hidden */
  32104. _extension: string;
  32105. /** @hidden */
  32106. _files: Nullable<string[]>;
  32107. /** @hidden */
  32108. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32109. /** @hidden */
  32110. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32111. /** @hidden */
  32112. _framebuffer: Nullable<WebGLFramebuffer>;
  32113. /** @hidden */
  32114. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32115. /** @hidden */
  32116. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32117. /** @hidden */
  32118. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32119. /** @hidden */
  32120. _attachments: Nullable<number[]>;
  32121. /** @hidden */
  32122. _cachedCoordinatesMode: Nullable<number>;
  32123. /** @hidden */
  32124. _cachedWrapU: Nullable<number>;
  32125. /** @hidden */
  32126. _cachedWrapV: Nullable<number>;
  32127. /** @hidden */
  32128. _cachedWrapR: Nullable<number>;
  32129. /** @hidden */
  32130. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32131. /** @hidden */
  32132. _isDisabled: boolean;
  32133. /** @hidden */
  32134. _compression: Nullable<string>;
  32135. /** @hidden */
  32136. _generateStencilBuffer: boolean;
  32137. /** @hidden */
  32138. _generateDepthBuffer: boolean;
  32139. /** @hidden */
  32140. _comparisonFunction: number;
  32141. /** @hidden */
  32142. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32143. /** @hidden */
  32144. _lodGenerationScale: number;
  32145. /** @hidden */
  32146. _lodGenerationOffset: number;
  32147. /** @hidden */
  32148. _colorTextureArray: Nullable<WebGLTexture>;
  32149. /** @hidden */
  32150. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32151. /** @hidden */
  32152. _lodTextureHigh: Nullable<BaseTexture>;
  32153. /** @hidden */
  32154. _lodTextureMid: Nullable<BaseTexture>;
  32155. /** @hidden */
  32156. _lodTextureLow: Nullable<BaseTexture>;
  32157. /** @hidden */
  32158. _isRGBD: boolean;
  32159. /** @hidden */
  32160. _linearSpecularLOD: boolean;
  32161. /** @hidden */
  32162. _irradianceTexture: Nullable<BaseTexture>;
  32163. /** @hidden */
  32164. _webGLTexture: Nullable<WebGLTexture>;
  32165. /** @hidden */
  32166. _references: number;
  32167. private _engine;
  32168. /**
  32169. * Gets the Engine the texture belongs to.
  32170. * @returns The babylon engine
  32171. */
  32172. getEngine(): ThinEngine;
  32173. /**
  32174. * Gets the data source type of the texture
  32175. */
  32176. get source(): InternalTextureSource;
  32177. /**
  32178. * Creates a new InternalTexture
  32179. * @param engine defines the engine to use
  32180. * @param source defines the type of data that will be used
  32181. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32182. */
  32183. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32184. /**
  32185. * Increments the number of references (ie. the number of Texture that point to it)
  32186. */
  32187. incrementReferences(): void;
  32188. /**
  32189. * Change the size of the texture (not the size of the content)
  32190. * @param width defines the new width
  32191. * @param height defines the new height
  32192. * @param depth defines the new depth (1 by default)
  32193. */
  32194. updateSize(width: int, height: int, depth?: int): void;
  32195. /** @hidden */
  32196. _rebuild(): void;
  32197. /** @hidden */
  32198. _swapAndDie(target: InternalTexture): void;
  32199. /**
  32200. * Dispose the current allocated resources
  32201. */
  32202. dispose(): void;
  32203. }
  32204. }
  32205. declare module BABYLON {
  32206. /**
  32207. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32209. */
  32210. export class Analyser {
  32211. /**
  32212. * Gets or sets the smoothing
  32213. * @ignorenaming
  32214. */
  32215. SMOOTHING: number;
  32216. /**
  32217. * Gets or sets the FFT table size
  32218. * @ignorenaming
  32219. */
  32220. FFT_SIZE: number;
  32221. /**
  32222. * Gets or sets the bar graph amplitude
  32223. * @ignorenaming
  32224. */
  32225. BARGRAPHAMPLITUDE: number;
  32226. /**
  32227. * Gets or sets the position of the debug canvas
  32228. * @ignorenaming
  32229. */
  32230. DEBUGCANVASPOS: {
  32231. x: number;
  32232. y: number;
  32233. };
  32234. /**
  32235. * Gets or sets the debug canvas size
  32236. * @ignorenaming
  32237. */
  32238. DEBUGCANVASSIZE: {
  32239. width: number;
  32240. height: number;
  32241. };
  32242. private _byteFreqs;
  32243. private _byteTime;
  32244. private _floatFreqs;
  32245. private _webAudioAnalyser;
  32246. private _debugCanvas;
  32247. private _debugCanvasContext;
  32248. private _scene;
  32249. private _registerFunc;
  32250. private _audioEngine;
  32251. /**
  32252. * Creates a new analyser
  32253. * @param scene defines hosting scene
  32254. */
  32255. constructor(scene: Scene);
  32256. /**
  32257. * Get the number of data values you will have to play with for the visualization
  32258. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32259. * @returns a number
  32260. */
  32261. getFrequencyBinCount(): number;
  32262. /**
  32263. * Gets the current frequency data as a byte array
  32264. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32265. * @returns a Uint8Array
  32266. */
  32267. getByteFrequencyData(): Uint8Array;
  32268. /**
  32269. * Gets the current waveform as a byte array
  32270. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32271. * @returns a Uint8Array
  32272. */
  32273. getByteTimeDomainData(): Uint8Array;
  32274. /**
  32275. * Gets the current frequency data as a float array
  32276. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32277. * @returns a Float32Array
  32278. */
  32279. getFloatFrequencyData(): Float32Array;
  32280. /**
  32281. * Renders the debug canvas
  32282. */
  32283. drawDebugCanvas(): void;
  32284. /**
  32285. * Stops rendering the debug canvas and removes it
  32286. */
  32287. stopDebugCanvas(): void;
  32288. /**
  32289. * Connects two audio nodes
  32290. * @param inputAudioNode defines first node to connect
  32291. * @param outputAudioNode defines second node to connect
  32292. */
  32293. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32294. /**
  32295. * Releases all associated resources
  32296. */
  32297. dispose(): void;
  32298. }
  32299. }
  32300. declare module BABYLON {
  32301. /**
  32302. * This represents an audio engine and it is responsible
  32303. * to play, synchronize and analyse sounds throughout the application.
  32304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32305. */
  32306. export interface IAudioEngine extends IDisposable {
  32307. /**
  32308. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32309. */
  32310. readonly canUseWebAudio: boolean;
  32311. /**
  32312. * Gets the current AudioContext if available.
  32313. */
  32314. readonly audioContext: Nullable<AudioContext>;
  32315. /**
  32316. * The master gain node defines the global audio volume of your audio engine.
  32317. */
  32318. readonly masterGain: GainNode;
  32319. /**
  32320. * Gets whether or not mp3 are supported by your browser.
  32321. */
  32322. readonly isMP3supported: boolean;
  32323. /**
  32324. * Gets whether or not ogg are supported by your browser.
  32325. */
  32326. readonly isOGGsupported: boolean;
  32327. /**
  32328. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32329. * @ignoreNaming
  32330. */
  32331. WarnedWebAudioUnsupported: boolean;
  32332. /**
  32333. * Defines if the audio engine relies on a custom unlocked button.
  32334. * In this case, the embedded button will not be displayed.
  32335. */
  32336. useCustomUnlockedButton: boolean;
  32337. /**
  32338. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32339. */
  32340. readonly unlocked: boolean;
  32341. /**
  32342. * Event raised when audio has been unlocked on the browser.
  32343. */
  32344. onAudioUnlockedObservable: Observable<AudioEngine>;
  32345. /**
  32346. * Event raised when audio has been locked on the browser.
  32347. */
  32348. onAudioLockedObservable: Observable<AudioEngine>;
  32349. /**
  32350. * Flags the audio engine in Locked state.
  32351. * This happens due to new browser policies preventing audio to autoplay.
  32352. */
  32353. lock(): void;
  32354. /**
  32355. * Unlocks the audio engine once a user action has been done on the dom.
  32356. * This is helpful to resume play once browser policies have been satisfied.
  32357. */
  32358. unlock(): void;
  32359. }
  32360. /**
  32361. * This represents the default audio engine used in babylon.
  32362. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32364. */
  32365. export class AudioEngine implements IAudioEngine {
  32366. private _audioContext;
  32367. private _audioContextInitialized;
  32368. private _muteButton;
  32369. private _hostElement;
  32370. /**
  32371. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32372. */
  32373. canUseWebAudio: boolean;
  32374. /**
  32375. * The master gain node defines the global audio volume of your audio engine.
  32376. */
  32377. masterGain: GainNode;
  32378. /**
  32379. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32380. * @ignoreNaming
  32381. */
  32382. WarnedWebAudioUnsupported: boolean;
  32383. /**
  32384. * Gets whether or not mp3 are supported by your browser.
  32385. */
  32386. isMP3supported: boolean;
  32387. /**
  32388. * Gets whether or not ogg are supported by your browser.
  32389. */
  32390. isOGGsupported: boolean;
  32391. /**
  32392. * Gets whether audio has been unlocked on the device.
  32393. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32394. * a user interaction has happened.
  32395. */
  32396. unlocked: boolean;
  32397. /**
  32398. * Defines if the audio engine relies on a custom unlocked button.
  32399. * In this case, the embedded button will not be displayed.
  32400. */
  32401. useCustomUnlockedButton: boolean;
  32402. /**
  32403. * Event raised when audio has been unlocked on the browser.
  32404. */
  32405. onAudioUnlockedObservable: Observable<AudioEngine>;
  32406. /**
  32407. * Event raised when audio has been locked on the browser.
  32408. */
  32409. onAudioLockedObservable: Observable<AudioEngine>;
  32410. /**
  32411. * Gets the current AudioContext if available.
  32412. */
  32413. get audioContext(): Nullable<AudioContext>;
  32414. private _connectedAnalyser;
  32415. /**
  32416. * Instantiates a new audio engine.
  32417. *
  32418. * There should be only one per page as some browsers restrict the number
  32419. * of audio contexts you can create.
  32420. * @param hostElement defines the host element where to display the mute icon if necessary
  32421. */
  32422. constructor(hostElement?: Nullable<HTMLElement>);
  32423. /**
  32424. * Flags the audio engine in Locked state.
  32425. * This happens due to new browser policies preventing audio to autoplay.
  32426. */
  32427. lock(): void;
  32428. /**
  32429. * Unlocks the audio engine once a user action has been done on the dom.
  32430. * This is helpful to resume play once browser policies have been satisfied.
  32431. */
  32432. unlock(): void;
  32433. private _resumeAudioContext;
  32434. private _initializeAudioContext;
  32435. private _tryToRun;
  32436. private _triggerRunningState;
  32437. private _triggerSuspendedState;
  32438. private _displayMuteButton;
  32439. private _moveButtonToTopLeft;
  32440. private _onResize;
  32441. private _hideMuteButton;
  32442. /**
  32443. * Destroy and release the resources associated with the audio ccontext.
  32444. */
  32445. dispose(): void;
  32446. /**
  32447. * Gets the global volume sets on the master gain.
  32448. * @returns the global volume if set or -1 otherwise
  32449. */
  32450. getGlobalVolume(): number;
  32451. /**
  32452. * Sets the global volume of your experience (sets on the master gain).
  32453. * @param newVolume Defines the new global volume of the application
  32454. */
  32455. setGlobalVolume(newVolume: number): void;
  32456. /**
  32457. * Connect the audio engine to an audio analyser allowing some amazing
  32458. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32460. * @param analyser The analyser to connect to the engine
  32461. */
  32462. connectToAnalyser(analyser: Analyser): void;
  32463. }
  32464. }
  32465. declare module BABYLON {
  32466. /**
  32467. * Interface used to present a loading screen while loading a scene
  32468. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32469. */
  32470. export interface ILoadingScreen {
  32471. /**
  32472. * Function called to display the loading screen
  32473. */
  32474. displayLoadingUI: () => void;
  32475. /**
  32476. * Function called to hide the loading screen
  32477. */
  32478. hideLoadingUI: () => void;
  32479. /**
  32480. * Gets or sets the color to use for the background
  32481. */
  32482. loadingUIBackgroundColor: string;
  32483. /**
  32484. * Gets or sets the text to display while loading
  32485. */
  32486. loadingUIText: string;
  32487. }
  32488. /**
  32489. * Class used for the default loading screen
  32490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32491. */
  32492. export class DefaultLoadingScreen implements ILoadingScreen {
  32493. private _renderingCanvas;
  32494. private _loadingText;
  32495. private _loadingDivBackgroundColor;
  32496. private _loadingDiv;
  32497. private _loadingTextDiv;
  32498. /** Gets or sets the logo url to use for the default loading screen */
  32499. static DefaultLogoUrl: string;
  32500. /** Gets or sets the spinner url to use for the default loading screen */
  32501. static DefaultSpinnerUrl: string;
  32502. /**
  32503. * Creates a new default loading screen
  32504. * @param _renderingCanvas defines the canvas used to render the scene
  32505. * @param _loadingText defines the default text to display
  32506. * @param _loadingDivBackgroundColor defines the default background color
  32507. */
  32508. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32509. /**
  32510. * Function called to display the loading screen
  32511. */
  32512. displayLoadingUI(): void;
  32513. /**
  32514. * Function called to hide the loading screen
  32515. */
  32516. hideLoadingUI(): void;
  32517. /**
  32518. * Gets or sets the text to display while loading
  32519. */
  32520. set loadingUIText(text: string);
  32521. get loadingUIText(): string;
  32522. /**
  32523. * Gets or sets the color to use for the background
  32524. */
  32525. get loadingUIBackgroundColor(): string;
  32526. set loadingUIBackgroundColor(color: string);
  32527. private _resizeLoadingUI;
  32528. }
  32529. }
  32530. declare module BABYLON {
  32531. /**
  32532. * Interface for any object that can request an animation frame
  32533. */
  32534. export interface ICustomAnimationFrameRequester {
  32535. /**
  32536. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32537. */
  32538. renderFunction?: Function;
  32539. /**
  32540. * Called to request the next frame to render to
  32541. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32542. */
  32543. requestAnimationFrame: Function;
  32544. /**
  32545. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32546. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32547. */
  32548. requestID?: number;
  32549. }
  32550. }
  32551. declare module BABYLON {
  32552. /**
  32553. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32554. */
  32555. export class PerformanceMonitor {
  32556. private _enabled;
  32557. private _rollingFrameTime;
  32558. private _lastFrameTimeMs;
  32559. /**
  32560. * constructor
  32561. * @param frameSampleSize The number of samples required to saturate the sliding window
  32562. */
  32563. constructor(frameSampleSize?: number);
  32564. /**
  32565. * Samples current frame
  32566. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32567. */
  32568. sampleFrame(timeMs?: number): void;
  32569. /**
  32570. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32571. */
  32572. get averageFrameTime(): number;
  32573. /**
  32574. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32575. */
  32576. get averageFrameTimeVariance(): number;
  32577. /**
  32578. * Returns the frame time of the most recent frame
  32579. */
  32580. get instantaneousFrameTime(): number;
  32581. /**
  32582. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32583. */
  32584. get averageFPS(): number;
  32585. /**
  32586. * Returns the average framerate in frames per second using the most recent frame time
  32587. */
  32588. get instantaneousFPS(): number;
  32589. /**
  32590. * Returns true if enough samples have been taken to completely fill the sliding window
  32591. */
  32592. get isSaturated(): boolean;
  32593. /**
  32594. * Enables contributions to the sliding window sample set
  32595. */
  32596. enable(): void;
  32597. /**
  32598. * Disables contributions to the sliding window sample set
  32599. * Samples will not be interpolated over the disabled period
  32600. */
  32601. disable(): void;
  32602. /**
  32603. * Returns true if sampling is enabled
  32604. */
  32605. get isEnabled(): boolean;
  32606. /**
  32607. * Resets performance monitor
  32608. */
  32609. reset(): void;
  32610. }
  32611. /**
  32612. * RollingAverage
  32613. *
  32614. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32615. */
  32616. export class RollingAverage {
  32617. /**
  32618. * Current average
  32619. */
  32620. average: number;
  32621. /**
  32622. * Current variance
  32623. */
  32624. variance: number;
  32625. protected _samples: Array<number>;
  32626. protected _sampleCount: number;
  32627. protected _pos: number;
  32628. protected _m2: number;
  32629. /**
  32630. * constructor
  32631. * @param length The number of samples required to saturate the sliding window
  32632. */
  32633. constructor(length: number);
  32634. /**
  32635. * Adds a sample to the sample set
  32636. * @param v The sample value
  32637. */
  32638. add(v: number): void;
  32639. /**
  32640. * Returns previously added values or null if outside of history or outside the sliding window domain
  32641. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32642. * @return Value previously recorded with add() or null if outside of range
  32643. */
  32644. history(i: number): number;
  32645. /**
  32646. * Returns true if enough samples have been taken to completely fill the sliding window
  32647. * @return true if sample-set saturated
  32648. */
  32649. isSaturated(): boolean;
  32650. /**
  32651. * Resets the rolling average (equivalent to 0 samples taken so far)
  32652. */
  32653. reset(): void;
  32654. /**
  32655. * Wraps a value around the sample range boundaries
  32656. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32657. * @return Wrapped position in sample range
  32658. */
  32659. protected _wrapPosition(i: number): number;
  32660. }
  32661. }
  32662. declare module BABYLON {
  32663. /**
  32664. * This class is used to track a performance counter which is number based.
  32665. * The user has access to many properties which give statistics of different nature.
  32666. *
  32667. * The implementer can track two kinds of Performance Counter: time and count.
  32668. * 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.
  32669. * 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.
  32670. */
  32671. export class PerfCounter {
  32672. /**
  32673. * Gets or sets a global boolean to turn on and off all the counters
  32674. */
  32675. static Enabled: boolean;
  32676. /**
  32677. * Returns the smallest value ever
  32678. */
  32679. get min(): number;
  32680. /**
  32681. * Returns the biggest value ever
  32682. */
  32683. get max(): number;
  32684. /**
  32685. * Returns the average value since the performance counter is running
  32686. */
  32687. get average(): number;
  32688. /**
  32689. * Returns the average value of the last second the counter was monitored
  32690. */
  32691. get lastSecAverage(): number;
  32692. /**
  32693. * Returns the current value
  32694. */
  32695. get current(): number;
  32696. /**
  32697. * Gets the accumulated total
  32698. */
  32699. get total(): number;
  32700. /**
  32701. * Gets the total value count
  32702. */
  32703. get count(): number;
  32704. /**
  32705. * Creates a new counter
  32706. */
  32707. constructor();
  32708. /**
  32709. * Call this method to start monitoring a new frame.
  32710. * 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.
  32711. */
  32712. fetchNewFrame(): void;
  32713. /**
  32714. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32715. * @param newCount the count value to add to the monitored count
  32716. * @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.
  32717. */
  32718. addCount(newCount: number, fetchResult: boolean): void;
  32719. /**
  32720. * Start monitoring this performance counter
  32721. */
  32722. beginMonitoring(): void;
  32723. /**
  32724. * Compute the time lapsed since the previous beginMonitoring() call.
  32725. * @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
  32726. */
  32727. endMonitoring(newFrame?: boolean): void;
  32728. private _fetchResult;
  32729. private _startMonitoringTime;
  32730. private _min;
  32731. private _max;
  32732. private _average;
  32733. private _current;
  32734. private _totalValueCount;
  32735. private _totalAccumulated;
  32736. private _lastSecAverage;
  32737. private _lastSecAccumulated;
  32738. private _lastSecTime;
  32739. private _lastSecValueCount;
  32740. }
  32741. }
  32742. declare module BABYLON {
  32743. interface ThinEngine {
  32744. /**
  32745. * Sets alpha constants used by some alpha blending modes
  32746. * @param r defines the red component
  32747. * @param g defines the green component
  32748. * @param b defines the blue component
  32749. * @param a defines the alpha component
  32750. */
  32751. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32752. /**
  32753. * Sets the current alpha mode
  32754. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32755. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32756. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32757. */
  32758. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32759. /**
  32760. * Gets the current alpha mode
  32761. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32762. * @returns the current alpha mode
  32763. */
  32764. getAlphaMode(): number;
  32765. /**
  32766. * Sets the current alpha equation
  32767. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32768. */
  32769. setAlphaEquation(equation: number): void;
  32770. /**
  32771. * Gets the current alpha equation.
  32772. * @returns the current alpha equation
  32773. */
  32774. getAlphaEquation(): number;
  32775. }
  32776. }
  32777. declare module BABYLON {
  32778. /**
  32779. * Defines the interface used by display changed events
  32780. */
  32781. export interface IDisplayChangedEventArgs {
  32782. /** Gets the vrDisplay object (if any) */
  32783. vrDisplay: Nullable<any>;
  32784. /** Gets a boolean indicating if webVR is supported */
  32785. vrSupported: boolean;
  32786. }
  32787. /**
  32788. * Defines the interface used by objects containing a viewport (like a camera)
  32789. */
  32790. interface IViewportOwnerLike {
  32791. /**
  32792. * Gets or sets the viewport
  32793. */
  32794. viewport: IViewportLike;
  32795. }
  32796. /**
  32797. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32798. */
  32799. export class Engine extends ThinEngine {
  32800. /** Defines that alpha blending is disabled */
  32801. static readonly ALPHA_DISABLE: number;
  32802. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32803. static readonly ALPHA_ADD: number;
  32804. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32805. static readonly ALPHA_COMBINE: number;
  32806. /** Defines that alpha blending to DEST - SRC * DEST */
  32807. static readonly ALPHA_SUBTRACT: number;
  32808. /** Defines that alpha blending to SRC * DEST */
  32809. static readonly ALPHA_MULTIPLY: number;
  32810. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32811. static readonly ALPHA_MAXIMIZED: number;
  32812. /** Defines that alpha blending to SRC + DEST */
  32813. static readonly ALPHA_ONEONE: number;
  32814. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32815. static readonly ALPHA_PREMULTIPLIED: number;
  32816. /**
  32817. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32818. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32819. */
  32820. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32821. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32822. static readonly ALPHA_INTERPOLATE: number;
  32823. /**
  32824. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32825. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32826. */
  32827. static readonly ALPHA_SCREENMODE: number;
  32828. /** Defines that the ressource is not delayed*/
  32829. static readonly DELAYLOADSTATE_NONE: number;
  32830. /** Defines that the ressource was successfully delay loaded */
  32831. static readonly DELAYLOADSTATE_LOADED: number;
  32832. /** Defines that the ressource is currently delay loading */
  32833. static readonly DELAYLOADSTATE_LOADING: number;
  32834. /** Defines that the ressource is delayed and has not started loading */
  32835. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32836. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32837. static readonly NEVER: number;
  32838. /** 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 */
  32839. static readonly ALWAYS: number;
  32840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32841. static readonly LESS: number;
  32842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32843. static readonly EQUAL: number;
  32844. /** 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 */
  32845. static readonly LEQUAL: number;
  32846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32847. static readonly GREATER: number;
  32848. /** 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 */
  32849. static readonly GEQUAL: number;
  32850. /** 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 */
  32851. static readonly NOTEQUAL: number;
  32852. /** Passed to stencilOperation to specify that stencil value must be kept */
  32853. static readonly KEEP: number;
  32854. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32855. static readonly REPLACE: number;
  32856. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32857. static readonly INCR: number;
  32858. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32859. static readonly DECR: number;
  32860. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32861. static readonly INVERT: number;
  32862. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32863. static readonly INCR_WRAP: number;
  32864. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32865. static readonly DECR_WRAP: number;
  32866. /** Texture is not repeating outside of 0..1 UVs */
  32867. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32868. /** Texture is repeating outside of 0..1 UVs */
  32869. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32870. /** Texture is repeating and mirrored */
  32871. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32872. /** ALPHA */
  32873. static readonly TEXTUREFORMAT_ALPHA: number;
  32874. /** LUMINANCE */
  32875. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32876. /** LUMINANCE_ALPHA */
  32877. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32878. /** RGB */
  32879. static readonly TEXTUREFORMAT_RGB: number;
  32880. /** RGBA */
  32881. static readonly TEXTUREFORMAT_RGBA: number;
  32882. /** RED */
  32883. static readonly TEXTUREFORMAT_RED: number;
  32884. /** RED (2nd reference) */
  32885. static readonly TEXTUREFORMAT_R: number;
  32886. /** RG */
  32887. static readonly TEXTUREFORMAT_RG: number;
  32888. /** RED_INTEGER */
  32889. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32890. /** RED_INTEGER (2nd reference) */
  32891. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32892. /** RG_INTEGER */
  32893. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32894. /** RGB_INTEGER */
  32895. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32896. /** RGBA_INTEGER */
  32897. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32898. /** UNSIGNED_BYTE */
  32899. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32900. /** UNSIGNED_BYTE (2nd reference) */
  32901. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32902. /** FLOAT */
  32903. static readonly TEXTURETYPE_FLOAT: number;
  32904. /** HALF_FLOAT */
  32905. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32906. /** BYTE */
  32907. static readonly TEXTURETYPE_BYTE: number;
  32908. /** SHORT */
  32909. static readonly TEXTURETYPE_SHORT: number;
  32910. /** UNSIGNED_SHORT */
  32911. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32912. /** INT */
  32913. static readonly TEXTURETYPE_INT: number;
  32914. /** UNSIGNED_INT */
  32915. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32916. /** UNSIGNED_SHORT_4_4_4_4 */
  32917. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32918. /** UNSIGNED_SHORT_5_5_5_1 */
  32919. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32920. /** UNSIGNED_SHORT_5_6_5 */
  32921. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32922. /** UNSIGNED_INT_2_10_10_10_REV */
  32923. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32924. /** UNSIGNED_INT_24_8 */
  32925. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32926. /** UNSIGNED_INT_10F_11F_11F_REV */
  32927. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32928. /** UNSIGNED_INT_5_9_9_9_REV */
  32929. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32930. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32931. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32932. /** nearest is mag = nearest and min = nearest and mip = linear */
  32933. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32934. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32935. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32936. /** Trilinear is mag = linear and min = linear and mip = linear */
  32937. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32938. /** nearest is mag = nearest and min = nearest and mip = linear */
  32939. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32941. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32942. /** Trilinear is mag = linear and min = linear and mip = linear */
  32943. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32944. /** mag = nearest and min = nearest and mip = nearest */
  32945. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32946. /** mag = nearest and min = linear and mip = nearest */
  32947. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32948. /** mag = nearest and min = linear and mip = linear */
  32949. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32950. /** mag = nearest and min = linear and mip = none */
  32951. static readonly TEXTURE_NEAREST_LINEAR: number;
  32952. /** mag = nearest and min = nearest and mip = none */
  32953. static readonly TEXTURE_NEAREST_NEAREST: number;
  32954. /** mag = linear and min = nearest and mip = nearest */
  32955. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32956. /** mag = linear and min = nearest and mip = linear */
  32957. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32958. /** mag = linear and min = linear and mip = none */
  32959. static readonly TEXTURE_LINEAR_LINEAR: number;
  32960. /** mag = linear and min = nearest and mip = none */
  32961. static readonly TEXTURE_LINEAR_NEAREST: number;
  32962. /** Explicit coordinates mode */
  32963. static readonly TEXTURE_EXPLICIT_MODE: number;
  32964. /** Spherical coordinates mode */
  32965. static readonly TEXTURE_SPHERICAL_MODE: number;
  32966. /** Planar coordinates mode */
  32967. static readonly TEXTURE_PLANAR_MODE: number;
  32968. /** Cubic coordinates mode */
  32969. static readonly TEXTURE_CUBIC_MODE: number;
  32970. /** Projection coordinates mode */
  32971. static readonly TEXTURE_PROJECTION_MODE: number;
  32972. /** Skybox coordinates mode */
  32973. static readonly TEXTURE_SKYBOX_MODE: number;
  32974. /** Inverse Cubic coordinates mode */
  32975. static readonly TEXTURE_INVCUBIC_MODE: number;
  32976. /** Equirectangular coordinates mode */
  32977. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32978. /** Equirectangular Fixed coordinates mode */
  32979. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32980. /** Equirectangular Fixed Mirrored coordinates mode */
  32981. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32982. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32983. static readonly SCALEMODE_FLOOR: number;
  32984. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32985. static readonly SCALEMODE_NEAREST: number;
  32986. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32987. static readonly SCALEMODE_CEILING: number;
  32988. /**
  32989. * Returns the current npm package of the sdk
  32990. */
  32991. static get NpmPackage(): string;
  32992. /**
  32993. * Returns the current version of the framework
  32994. */
  32995. static get Version(): string;
  32996. /** Gets the list of created engines */
  32997. static get Instances(): Engine[];
  32998. /**
  32999. * Gets the latest created engine
  33000. */
  33001. static get LastCreatedEngine(): Nullable<Engine>;
  33002. /**
  33003. * Gets the latest created scene
  33004. */
  33005. static get LastCreatedScene(): Nullable<Scene>;
  33006. /**
  33007. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33008. * @param flag defines which part of the materials must be marked as dirty
  33009. * @param predicate defines a predicate used to filter which materials should be affected
  33010. */
  33011. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33012. /**
  33013. * Method called to create the default loading screen.
  33014. * This can be overriden in your own app.
  33015. * @param canvas The rendering canvas element
  33016. * @returns The loading screen
  33017. */
  33018. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33019. /**
  33020. * Method called to create the default rescale post process on each engine.
  33021. */
  33022. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33023. /**
  33024. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33025. **/
  33026. enableOfflineSupport: boolean;
  33027. /**
  33028. * 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)
  33029. **/
  33030. disableManifestCheck: boolean;
  33031. /**
  33032. * Gets the list of created scenes
  33033. */
  33034. scenes: Scene[];
  33035. /**
  33036. * Event raised when a new scene is created
  33037. */
  33038. onNewSceneAddedObservable: Observable<Scene>;
  33039. /**
  33040. * Gets the list of created postprocesses
  33041. */
  33042. postProcesses: PostProcess[];
  33043. /**
  33044. * Gets a boolean indicating if the pointer is currently locked
  33045. */
  33046. isPointerLock: boolean;
  33047. /**
  33048. * Observable event triggered each time the rendering canvas is resized
  33049. */
  33050. onResizeObservable: Observable<Engine>;
  33051. /**
  33052. * Observable event triggered each time the canvas loses focus
  33053. */
  33054. onCanvasBlurObservable: Observable<Engine>;
  33055. /**
  33056. * Observable event triggered each time the canvas gains focus
  33057. */
  33058. onCanvasFocusObservable: Observable<Engine>;
  33059. /**
  33060. * Observable event triggered each time the canvas receives pointerout event
  33061. */
  33062. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33063. /**
  33064. * Observable raised when the engine begins a new frame
  33065. */
  33066. onBeginFrameObservable: Observable<Engine>;
  33067. /**
  33068. * If set, will be used to request the next animation frame for the render loop
  33069. */
  33070. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33071. /**
  33072. * Observable raised when the engine ends the current frame
  33073. */
  33074. onEndFrameObservable: Observable<Engine>;
  33075. /**
  33076. * Observable raised when the engine is about to compile a shader
  33077. */
  33078. onBeforeShaderCompilationObservable: Observable<Engine>;
  33079. /**
  33080. * Observable raised when the engine has jsut compiled a shader
  33081. */
  33082. onAfterShaderCompilationObservable: Observable<Engine>;
  33083. /**
  33084. * Gets the audio engine
  33085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33086. * @ignorenaming
  33087. */
  33088. static audioEngine: IAudioEngine;
  33089. /**
  33090. * Default AudioEngine factory responsible of creating the Audio Engine.
  33091. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33092. */
  33093. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33094. /**
  33095. * Default offline support factory responsible of creating a tool used to store data locally.
  33096. * By default, this will create a Database object if the workload has been embedded.
  33097. */
  33098. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33099. private _loadingScreen;
  33100. private _pointerLockRequested;
  33101. private _dummyFramebuffer;
  33102. private _rescalePostProcess;
  33103. private _deterministicLockstep;
  33104. private _lockstepMaxSteps;
  33105. private _timeStep;
  33106. protected get _supportsHardwareTextureRescaling(): boolean;
  33107. private _fps;
  33108. private _deltaTime;
  33109. /** @hidden */
  33110. _drawCalls: PerfCounter;
  33111. /**
  33112. * Turn this value on if you want to pause FPS computation when in background
  33113. */
  33114. disablePerformanceMonitorInBackground: boolean;
  33115. private _performanceMonitor;
  33116. /**
  33117. * Gets the performance monitor attached to this engine
  33118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33119. */
  33120. get performanceMonitor(): PerformanceMonitor;
  33121. private _onFocus;
  33122. private _onBlur;
  33123. private _onCanvasPointerOut;
  33124. private _onCanvasBlur;
  33125. private _onCanvasFocus;
  33126. private _onFullscreenChange;
  33127. private _onPointerLockChange;
  33128. /**
  33129. * Gets the HTML element used to attach event listeners
  33130. * @returns a HTML element
  33131. */
  33132. getInputElement(): Nullable<HTMLElement>;
  33133. /**
  33134. * Creates a new engine
  33135. * @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
  33136. * @param antialias defines enable antialiasing (default: false)
  33137. * @param options defines further options to be sent to the getContext() function
  33138. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33139. */
  33140. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33141. /**
  33142. * Gets current aspect ratio
  33143. * @param viewportOwner defines the camera to use to get the aspect ratio
  33144. * @param useScreen defines if screen size must be used (or the current render target if any)
  33145. * @returns a number defining the aspect ratio
  33146. */
  33147. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33148. /**
  33149. * Gets current screen aspect ratio
  33150. * @returns a number defining the aspect ratio
  33151. */
  33152. getScreenAspectRatio(): number;
  33153. /**
  33154. * Gets the client rect of the HTML canvas attached with the current webGL context
  33155. * @returns a client rectanglee
  33156. */
  33157. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33158. /**
  33159. * Gets the client rect of the HTML element used for events
  33160. * @returns a client rectanglee
  33161. */
  33162. getInputElementClientRect(): Nullable<ClientRect>;
  33163. /**
  33164. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33166. * @returns true if engine is in deterministic lock step mode
  33167. */
  33168. isDeterministicLockStep(): boolean;
  33169. /**
  33170. * Gets the max steps when engine is running in deterministic lock step
  33171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33172. * @returns the max steps
  33173. */
  33174. getLockstepMaxSteps(): number;
  33175. /**
  33176. * Returns the time in ms between steps when using deterministic lock step.
  33177. * @returns time step in (ms)
  33178. */
  33179. getTimeStep(): number;
  33180. /**
  33181. * Force the mipmap generation for the given render target texture
  33182. * @param texture defines the render target texture to use
  33183. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33184. */
  33185. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33186. /** States */
  33187. /**
  33188. * Set various states to the webGL context
  33189. * @param culling defines backface culling state
  33190. * @param zOffset defines the value to apply to zOffset (0 by default)
  33191. * @param force defines if states must be applied even if cache is up to date
  33192. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33193. */
  33194. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33195. /**
  33196. * Set the z offset to apply to current rendering
  33197. * @param value defines the offset to apply
  33198. */
  33199. setZOffset(value: number): void;
  33200. /**
  33201. * Gets the current value of the zOffset
  33202. * @returns the current zOffset state
  33203. */
  33204. getZOffset(): number;
  33205. /**
  33206. * Enable or disable depth buffering
  33207. * @param enable defines the state to set
  33208. */
  33209. setDepthBuffer(enable: boolean): void;
  33210. /**
  33211. * Gets a boolean indicating if depth writing is enabled
  33212. * @returns the current depth writing state
  33213. */
  33214. getDepthWrite(): boolean;
  33215. /**
  33216. * Enable or disable depth writing
  33217. * @param enable defines the state to set
  33218. */
  33219. setDepthWrite(enable: boolean): void;
  33220. /**
  33221. * Gets a boolean indicating if stencil buffer is enabled
  33222. * @returns the current stencil buffer state
  33223. */
  33224. getStencilBuffer(): boolean;
  33225. /**
  33226. * Enable or disable the stencil buffer
  33227. * @param enable defines if the stencil buffer must be enabled or disabled
  33228. */
  33229. setStencilBuffer(enable: boolean): void;
  33230. /**
  33231. * Gets the current stencil mask
  33232. * @returns a number defining the new stencil mask to use
  33233. */
  33234. getStencilMask(): number;
  33235. /**
  33236. * Sets the current stencil mask
  33237. * @param mask defines the new stencil mask to use
  33238. */
  33239. setStencilMask(mask: number): void;
  33240. /**
  33241. * Gets the current stencil function
  33242. * @returns a number defining the stencil function to use
  33243. */
  33244. getStencilFunction(): number;
  33245. /**
  33246. * Gets the current stencil reference value
  33247. * @returns a number defining the stencil reference value to use
  33248. */
  33249. getStencilFunctionReference(): number;
  33250. /**
  33251. * Gets the current stencil mask
  33252. * @returns a number defining the stencil mask to use
  33253. */
  33254. getStencilFunctionMask(): number;
  33255. /**
  33256. * Sets the current stencil function
  33257. * @param stencilFunc defines the new stencil function to use
  33258. */
  33259. setStencilFunction(stencilFunc: number): void;
  33260. /**
  33261. * Sets the current stencil reference
  33262. * @param reference defines the new stencil reference to use
  33263. */
  33264. setStencilFunctionReference(reference: number): void;
  33265. /**
  33266. * Sets the current stencil mask
  33267. * @param mask defines the new stencil mask to use
  33268. */
  33269. setStencilFunctionMask(mask: number): void;
  33270. /**
  33271. * Gets the current stencil operation when stencil fails
  33272. * @returns a number defining stencil operation to use when stencil fails
  33273. */
  33274. getStencilOperationFail(): number;
  33275. /**
  33276. * Gets the current stencil operation when depth fails
  33277. * @returns a number defining stencil operation to use when depth fails
  33278. */
  33279. getStencilOperationDepthFail(): number;
  33280. /**
  33281. * Gets the current stencil operation when stencil passes
  33282. * @returns a number defining stencil operation to use when stencil passes
  33283. */
  33284. getStencilOperationPass(): number;
  33285. /**
  33286. * Sets the stencil operation to use when stencil fails
  33287. * @param operation defines the stencil operation to use when stencil fails
  33288. */
  33289. setStencilOperationFail(operation: number): void;
  33290. /**
  33291. * Sets the stencil operation to use when depth fails
  33292. * @param operation defines the stencil operation to use when depth fails
  33293. */
  33294. setStencilOperationDepthFail(operation: number): void;
  33295. /**
  33296. * Sets the stencil operation to use when stencil passes
  33297. * @param operation defines the stencil operation to use when stencil passes
  33298. */
  33299. setStencilOperationPass(operation: number): void;
  33300. /**
  33301. * Sets a boolean indicating if the dithering state is enabled or disabled
  33302. * @param value defines the dithering state
  33303. */
  33304. setDitheringState(value: boolean): void;
  33305. /**
  33306. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33307. * @param value defines the rasterizer state
  33308. */
  33309. setRasterizerState(value: boolean): void;
  33310. /**
  33311. * Gets the current depth function
  33312. * @returns a number defining the depth function
  33313. */
  33314. getDepthFunction(): Nullable<number>;
  33315. /**
  33316. * Sets the current depth function
  33317. * @param depthFunc defines the function to use
  33318. */
  33319. setDepthFunction(depthFunc: number): void;
  33320. /**
  33321. * Sets the current depth function to GREATER
  33322. */
  33323. setDepthFunctionToGreater(): void;
  33324. /**
  33325. * Sets the current depth function to GEQUAL
  33326. */
  33327. setDepthFunctionToGreaterOrEqual(): void;
  33328. /**
  33329. * Sets the current depth function to LESS
  33330. */
  33331. setDepthFunctionToLess(): void;
  33332. /**
  33333. * Sets the current depth function to LEQUAL
  33334. */
  33335. setDepthFunctionToLessOrEqual(): void;
  33336. private _cachedStencilBuffer;
  33337. private _cachedStencilFunction;
  33338. private _cachedStencilMask;
  33339. private _cachedStencilOperationPass;
  33340. private _cachedStencilOperationFail;
  33341. private _cachedStencilOperationDepthFail;
  33342. private _cachedStencilReference;
  33343. /**
  33344. * Caches the the state of the stencil buffer
  33345. */
  33346. cacheStencilState(): void;
  33347. /**
  33348. * Restores the state of the stencil buffer
  33349. */
  33350. restoreStencilState(): void;
  33351. /**
  33352. * Directly set the WebGL Viewport
  33353. * @param x defines the x coordinate of the viewport (in screen space)
  33354. * @param y defines the y coordinate of the viewport (in screen space)
  33355. * @param width defines the width of the viewport (in screen space)
  33356. * @param height defines the height of the viewport (in screen space)
  33357. * @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
  33358. */
  33359. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33360. /**
  33361. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33362. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33363. * @param y defines the y-coordinate of the corner of the clear rectangle
  33364. * @param width defines the width of the clear rectangle
  33365. * @param height defines the height of the clear rectangle
  33366. * @param clearColor defines the clear color
  33367. */
  33368. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33369. /**
  33370. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33371. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33372. * @param y defines the y-coordinate of the corner of the clear rectangle
  33373. * @param width defines the width of the clear rectangle
  33374. * @param height defines the height of the clear rectangle
  33375. */
  33376. enableScissor(x: number, y: number, width: number, height: number): void;
  33377. /**
  33378. * Disable previously set scissor test rectangle
  33379. */
  33380. disableScissor(): void;
  33381. protected _reportDrawCall(): void;
  33382. /**
  33383. * Initializes a webVR display and starts listening to display change events
  33384. * The onVRDisplayChangedObservable will be notified upon these changes
  33385. * @returns The onVRDisplayChangedObservable
  33386. */
  33387. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33388. /** @hidden */
  33389. _prepareVRComponent(): void;
  33390. /** @hidden */
  33391. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33392. /** @hidden */
  33393. _submitVRFrame(): void;
  33394. /**
  33395. * Call this function to leave webVR mode
  33396. * Will do nothing if webVR is not supported or if there is no webVR device
  33397. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33398. */
  33399. disableVR(): void;
  33400. /**
  33401. * Gets a boolean indicating that the system is in VR mode and is presenting
  33402. * @returns true if VR mode is engaged
  33403. */
  33404. isVRPresenting(): boolean;
  33405. /** @hidden */
  33406. _requestVRFrame(): void;
  33407. /** @hidden */
  33408. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33409. /**
  33410. * Gets the source code of the vertex shader associated with a specific webGL program
  33411. * @param program defines the program to use
  33412. * @returns a string containing the source code of the vertex shader associated with the program
  33413. */
  33414. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33415. /**
  33416. * Gets the source code of the fragment shader associated with a specific webGL program
  33417. * @param program defines the program to use
  33418. * @returns a string containing the source code of the fragment shader associated with the program
  33419. */
  33420. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33421. /**
  33422. * Sets a depth stencil texture from a render target to the according uniform.
  33423. * @param channel The texture channel
  33424. * @param uniform The uniform to set
  33425. * @param texture The render target texture containing the depth stencil texture to apply
  33426. */
  33427. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33428. /**
  33429. * Sets a texture to the webGL context from a postprocess
  33430. * @param channel defines the channel to use
  33431. * @param postProcess defines the source postprocess
  33432. */
  33433. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33434. /**
  33435. * Binds the output of the passed in post process to the texture channel specified
  33436. * @param channel The channel the texture should be bound to
  33437. * @param postProcess The post process which's output should be bound
  33438. */
  33439. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33440. /** @hidden */
  33441. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33442. protected _rebuildBuffers(): void;
  33443. /** @hidden */
  33444. _renderFrame(): void;
  33445. _renderLoop(): void;
  33446. /** @hidden */
  33447. _renderViews(): boolean;
  33448. /**
  33449. * Toggle full screen mode
  33450. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33451. */
  33452. switchFullscreen(requestPointerLock: boolean): void;
  33453. /**
  33454. * Enters full screen mode
  33455. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33456. */
  33457. enterFullscreen(requestPointerLock: boolean): void;
  33458. /**
  33459. * Exits full screen mode
  33460. */
  33461. exitFullscreen(): void;
  33462. /**
  33463. * Enters Pointerlock mode
  33464. */
  33465. enterPointerlock(): void;
  33466. /**
  33467. * Exits Pointerlock mode
  33468. */
  33469. exitPointerlock(): void;
  33470. /**
  33471. * Begin a new frame
  33472. */
  33473. beginFrame(): void;
  33474. /**
  33475. * Enf the current frame
  33476. */
  33477. endFrame(): void;
  33478. resize(): void;
  33479. /**
  33480. * Set the compressed texture format to use, based on the formats you have, and the formats
  33481. * supported by the hardware / browser.
  33482. *
  33483. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33484. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33485. * to API arguments needed to compressed textures. This puts the burden on the container
  33486. * generator to house the arcane code for determining these for current & future formats.
  33487. *
  33488. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33489. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33490. *
  33491. * Note: The result of this call is not taken into account when a texture is base64.
  33492. *
  33493. * @param formatsAvailable defines the list of those format families you have created
  33494. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33495. *
  33496. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33497. * @returns The extension selected.
  33498. */
  33499. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33500. /**
  33501. * Set the compressed texture extensions or file names to skip.
  33502. *
  33503. * @param skippedFiles defines the list of those texture files you want to skip
  33504. * Example: [".dds", ".env", "myfile.png"]
  33505. */
  33506. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33507. /**
  33508. * Force a specific size of the canvas
  33509. * @param width defines the new canvas' width
  33510. * @param height defines the new canvas' height
  33511. */
  33512. setSize(width: number, height: number): void;
  33513. /**
  33514. * Updates a dynamic vertex buffer.
  33515. * @param vertexBuffer the vertex buffer to update
  33516. * @param data the data used to update the vertex buffer
  33517. * @param byteOffset the byte offset of the data
  33518. * @param byteLength the byte length of the data
  33519. */
  33520. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33521. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33522. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33523. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33524. _releaseTexture(texture: InternalTexture): void;
  33525. /**
  33526. * @hidden
  33527. * Rescales a texture
  33528. * @param source input texutre
  33529. * @param destination destination texture
  33530. * @param scene scene to use to render the resize
  33531. * @param internalFormat format to use when resizing
  33532. * @param onComplete callback to be called when resize has completed
  33533. */
  33534. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33535. /**
  33536. * Gets the current framerate
  33537. * @returns a number representing the framerate
  33538. */
  33539. getFps(): number;
  33540. /**
  33541. * Gets the time spent between current and previous frame
  33542. * @returns a number representing the delta time in ms
  33543. */
  33544. getDeltaTime(): number;
  33545. private _measureFps;
  33546. /** @hidden */
  33547. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33548. /**
  33549. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33550. * @param renderTarget The render target to set the frame buffer for
  33551. */
  33552. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33553. /**
  33554. * Update a dynamic index buffer
  33555. * @param indexBuffer defines the target index buffer
  33556. * @param indices defines the data to update
  33557. * @param offset defines the offset in the target index buffer where update should start
  33558. */
  33559. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33560. /**
  33561. * Updates the sample count of a render target texture
  33562. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33563. * @param texture defines the texture to update
  33564. * @param samples defines the sample count to set
  33565. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33566. */
  33567. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33568. /**
  33569. * Updates a depth texture Comparison Mode and Function.
  33570. * If the comparison Function is equal to 0, the mode will be set to none.
  33571. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33572. * @param texture The texture to set the comparison function for
  33573. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33574. */
  33575. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33576. /**
  33577. * Creates a webGL buffer to use with instanciation
  33578. * @param capacity defines the size of the buffer
  33579. * @returns the webGL buffer
  33580. */
  33581. createInstancesBuffer(capacity: number): DataBuffer;
  33582. /**
  33583. * Delete a webGL buffer used with instanciation
  33584. * @param buffer defines the webGL buffer to delete
  33585. */
  33586. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33587. /** @hidden */
  33588. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33589. dispose(): void;
  33590. private _disableTouchAction;
  33591. /**
  33592. * Display the loading screen
  33593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33594. */
  33595. displayLoadingUI(): void;
  33596. /**
  33597. * Hide the loading screen
  33598. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33599. */
  33600. hideLoadingUI(): void;
  33601. /**
  33602. * Gets the current loading screen object
  33603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33604. */
  33605. get loadingScreen(): ILoadingScreen;
  33606. /**
  33607. * Sets the current loading screen object
  33608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33609. */
  33610. set loadingScreen(loadingScreen: ILoadingScreen);
  33611. /**
  33612. * Sets the current loading screen text
  33613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33614. */
  33615. set loadingUIText(text: string);
  33616. /**
  33617. * Sets the current loading screen background color
  33618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33619. */
  33620. set loadingUIBackgroundColor(color: string);
  33621. /** Pointerlock and fullscreen */
  33622. /**
  33623. * Ask the browser to promote the current element to pointerlock mode
  33624. * @param element defines the DOM element to promote
  33625. */
  33626. static _RequestPointerlock(element: HTMLElement): void;
  33627. /**
  33628. * Asks the browser to exit pointerlock mode
  33629. */
  33630. static _ExitPointerlock(): void;
  33631. /**
  33632. * Ask the browser to promote the current element to fullscreen rendering mode
  33633. * @param element defines the DOM element to promote
  33634. */
  33635. static _RequestFullscreen(element: HTMLElement): void;
  33636. /**
  33637. * Asks the browser to exit fullscreen mode
  33638. */
  33639. static _ExitFullscreen(): void;
  33640. }
  33641. }
  33642. declare module BABYLON {
  33643. /**
  33644. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33645. * during the life time of the application.
  33646. */
  33647. export class EngineStore {
  33648. /** Gets the list of created engines */
  33649. static Instances: Engine[];
  33650. /** @hidden */
  33651. static _LastCreatedScene: Nullable<Scene>;
  33652. /**
  33653. * Gets the latest created engine
  33654. */
  33655. static get LastCreatedEngine(): Nullable<Engine>;
  33656. /**
  33657. * Gets the latest created scene
  33658. */
  33659. static get LastCreatedScene(): Nullable<Scene>;
  33660. /**
  33661. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33662. * @ignorenaming
  33663. */
  33664. static UseFallbackTexture: boolean;
  33665. /**
  33666. * Texture content used if a texture cannot loaded
  33667. * @ignorenaming
  33668. */
  33669. static FallbackTexture: string;
  33670. }
  33671. }
  33672. declare module BABYLON {
  33673. /**
  33674. * Helper class that provides a small promise polyfill
  33675. */
  33676. export class PromisePolyfill {
  33677. /**
  33678. * Static function used to check if the polyfill is required
  33679. * If this is the case then the function will inject the polyfill to window.Promise
  33680. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33681. */
  33682. static Apply(force?: boolean): void;
  33683. }
  33684. }
  33685. declare module BABYLON {
  33686. /**
  33687. * Interface for screenshot methods with describe argument called `size` as object with options
  33688. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33689. */
  33690. export interface IScreenshotSize {
  33691. /**
  33692. * number in pixels for canvas height
  33693. */
  33694. height?: number;
  33695. /**
  33696. * multiplier allowing render at a higher or lower resolution
  33697. * If value is defined then height and width will be ignored and taken from camera
  33698. */
  33699. precision?: number;
  33700. /**
  33701. * number in pixels for canvas width
  33702. */
  33703. width?: number;
  33704. }
  33705. }
  33706. declare module BABYLON {
  33707. interface IColor4Like {
  33708. r: float;
  33709. g: float;
  33710. b: float;
  33711. a: float;
  33712. }
  33713. /**
  33714. * Class containing a set of static utilities functions
  33715. */
  33716. export class Tools {
  33717. /**
  33718. * Gets or sets the base URL to use to load assets
  33719. */
  33720. static get BaseUrl(): string;
  33721. static set BaseUrl(value: string);
  33722. /**
  33723. * Enable/Disable Custom HTTP Request Headers globally.
  33724. * default = false
  33725. * @see CustomRequestHeaders
  33726. */
  33727. static UseCustomRequestHeaders: boolean;
  33728. /**
  33729. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33730. * i.e. when loading files, where the server/service expects an Authorization header
  33731. */
  33732. static CustomRequestHeaders: {
  33733. [key: string]: string;
  33734. };
  33735. /**
  33736. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33737. */
  33738. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33739. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33740. /**
  33741. * Default behaviour for cors in the application.
  33742. * It can be a string if the expected behavior is identical in the entire app.
  33743. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33744. */
  33745. static CorsBehavior: string | ((url: string | string[]) => string);
  33746. /**
  33747. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33748. * @ignorenaming
  33749. */
  33750. static get UseFallbackTexture(): boolean;
  33751. static set UseFallbackTexture(value: boolean);
  33752. /**
  33753. * Use this object to register external classes like custom textures or material
  33754. * to allow the laoders to instantiate them
  33755. */
  33756. static get RegisteredExternalClasses(): {
  33757. [key: string]: Object;
  33758. };
  33759. static set RegisteredExternalClasses(classes: {
  33760. [key: string]: Object;
  33761. });
  33762. /**
  33763. * Texture content used if a texture cannot loaded
  33764. * @ignorenaming
  33765. */
  33766. static get fallbackTexture(): string;
  33767. static set fallbackTexture(value: string);
  33768. /**
  33769. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33770. * @param u defines the coordinate on X axis
  33771. * @param v defines the coordinate on Y axis
  33772. * @param width defines the width of the source data
  33773. * @param height defines the height of the source data
  33774. * @param pixels defines the source byte array
  33775. * @param color defines the output color
  33776. */
  33777. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33778. /**
  33779. * Interpolates between a and b via alpha
  33780. * @param a The lower value (returned when alpha = 0)
  33781. * @param b The upper value (returned when alpha = 1)
  33782. * @param alpha The interpolation-factor
  33783. * @return The mixed value
  33784. */
  33785. static Mix(a: number, b: number, alpha: number): number;
  33786. /**
  33787. * Tries to instantiate a new object from a given class name
  33788. * @param className defines the class name to instantiate
  33789. * @returns the new object or null if the system was not able to do the instantiation
  33790. */
  33791. static Instantiate(className: string): any;
  33792. /**
  33793. * Provides a slice function that will work even on IE
  33794. * @param data defines the array to slice
  33795. * @param start defines the start of the data (optional)
  33796. * @param end defines the end of the data (optional)
  33797. * @returns the new sliced array
  33798. */
  33799. static Slice<T>(data: T, start?: number, end?: number): T;
  33800. /**
  33801. * Polyfill for setImmediate
  33802. * @param action defines the action to execute after the current execution block
  33803. */
  33804. static SetImmediate(action: () => void): void;
  33805. /**
  33806. * Function indicating if a number is an exponent of 2
  33807. * @param value defines the value to test
  33808. * @returns true if the value is an exponent of 2
  33809. */
  33810. static IsExponentOfTwo(value: number): boolean;
  33811. private static _tmpFloatArray;
  33812. /**
  33813. * Returns the nearest 32-bit single precision float representation of a Number
  33814. * @param value A Number. If the parameter is of a different type, it will get converted
  33815. * to a number or to NaN if it cannot be converted
  33816. * @returns number
  33817. */
  33818. static FloatRound(value: number): number;
  33819. /**
  33820. * Extracts the filename from a path
  33821. * @param path defines the path to use
  33822. * @returns the filename
  33823. */
  33824. static GetFilename(path: string): string;
  33825. /**
  33826. * Extracts the "folder" part of a path (everything before the filename).
  33827. * @param uri The URI to extract the info from
  33828. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33829. * @returns The "folder" part of the path
  33830. */
  33831. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33832. /**
  33833. * Extracts text content from a DOM element hierarchy
  33834. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33835. */
  33836. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33837. /**
  33838. * Convert an angle in radians to degrees
  33839. * @param angle defines the angle to convert
  33840. * @returns the angle in degrees
  33841. */
  33842. static ToDegrees(angle: number): number;
  33843. /**
  33844. * Convert an angle in degrees to radians
  33845. * @param angle defines the angle to convert
  33846. * @returns the angle in radians
  33847. */
  33848. static ToRadians(angle: number): number;
  33849. /**
  33850. * Returns an array if obj is not an array
  33851. * @param obj defines the object to evaluate as an array
  33852. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33853. * @returns either obj directly if obj is an array or a new array containing obj
  33854. */
  33855. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33856. /**
  33857. * Gets the pointer prefix to use
  33858. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33859. */
  33860. static GetPointerPrefix(): string;
  33861. /**
  33862. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33863. * @param url define the url we are trying
  33864. * @param element define the dom element where to configure the cors policy
  33865. */
  33866. static SetCorsBehavior(url: string | string[], element: {
  33867. crossOrigin: string | null;
  33868. }): void;
  33869. /**
  33870. * Removes unwanted characters from an url
  33871. * @param url defines the url to clean
  33872. * @returns the cleaned url
  33873. */
  33874. static CleanUrl(url: string): string;
  33875. /**
  33876. * Gets or sets a function used to pre-process url before using them to load assets
  33877. */
  33878. static get PreprocessUrl(): (url: string) => string;
  33879. static set PreprocessUrl(processor: (url: string) => string);
  33880. /**
  33881. * Loads an image as an HTMLImageElement.
  33882. * @param input url string, ArrayBuffer, or Blob to load
  33883. * @param onLoad callback called when the image successfully loads
  33884. * @param onError callback called when the image fails to load
  33885. * @param offlineProvider offline provider for caching
  33886. * @param mimeType optional mime type
  33887. * @returns the HTMLImageElement of the loaded image
  33888. */
  33889. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33890. /**
  33891. * Loads a file from a url
  33892. * @param url url string, ArrayBuffer, or Blob to load
  33893. * @param onSuccess callback called when the file successfully loads
  33894. * @param onProgress callback called while file is loading (if the server supports this mode)
  33895. * @param offlineProvider defines the offline provider for caching
  33896. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33897. * @param onError callback called when the file fails to load
  33898. * @returns a file request object
  33899. */
  33900. 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;
  33901. /**
  33902. * Loads a file from a url
  33903. * @param url the file url to load
  33904. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33905. */
  33906. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33907. /**
  33908. * Load a script (identified by an url). When the url returns, the
  33909. * content of this file is added into a new script element, attached to the DOM (body element)
  33910. * @param scriptUrl defines the url of the script to laod
  33911. * @param onSuccess defines the callback called when the script is loaded
  33912. * @param onError defines the callback to call if an error occurs
  33913. * @param scriptId defines the id of the script element
  33914. */
  33915. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33916. /**
  33917. * Load an asynchronous script (identified by an url). When the url returns, the
  33918. * content of this file is added into a new script element, attached to the DOM (body element)
  33919. * @param scriptUrl defines the url of the script to laod
  33920. * @param scriptId defines the id of the script element
  33921. * @returns a promise request object
  33922. */
  33923. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  33924. /**
  33925. * Loads a file from a blob
  33926. * @param fileToLoad defines the blob to use
  33927. * @param callback defines the callback to call when data is loaded
  33928. * @param progressCallback defines the callback to call during loading process
  33929. * @returns a file request object
  33930. */
  33931. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33932. /**
  33933. * Reads a file from a File object
  33934. * @param file defines the file to load
  33935. * @param onSuccess defines the callback to call when data is loaded
  33936. * @param onProgress defines the callback to call during loading process
  33937. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33938. * @param onError defines the callback to call when an error occurs
  33939. * @returns a file request object
  33940. */
  33941. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33942. /**
  33943. * Creates a data url from a given string content
  33944. * @param content defines the content to convert
  33945. * @returns the new data url link
  33946. */
  33947. static FileAsURL(content: string): string;
  33948. /**
  33949. * Format the given number to a specific decimal format
  33950. * @param value defines the number to format
  33951. * @param decimals defines the number of decimals to use
  33952. * @returns the formatted string
  33953. */
  33954. static Format(value: number, decimals?: number): string;
  33955. /**
  33956. * Tries to copy an object by duplicating every property
  33957. * @param source defines the source object
  33958. * @param destination defines the target object
  33959. * @param doNotCopyList defines a list of properties to avoid
  33960. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33961. */
  33962. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33963. /**
  33964. * Gets a boolean indicating if the given object has no own property
  33965. * @param obj defines the object to test
  33966. * @returns true if object has no own property
  33967. */
  33968. static IsEmpty(obj: any): boolean;
  33969. /**
  33970. * Function used to register events at window level
  33971. * @param windowElement defines the Window object to use
  33972. * @param events defines the events to register
  33973. */
  33974. static RegisterTopRootEvents(windowElement: Window, events: {
  33975. name: string;
  33976. handler: Nullable<(e: FocusEvent) => any>;
  33977. }[]): void;
  33978. /**
  33979. * Function used to unregister events from window level
  33980. * @param windowElement defines the Window object to use
  33981. * @param events defines the events to unregister
  33982. */
  33983. static UnregisterTopRootEvents(windowElement: Window, events: {
  33984. name: string;
  33985. handler: Nullable<(e: FocusEvent) => any>;
  33986. }[]): void;
  33987. /**
  33988. * @ignore
  33989. */
  33990. static _ScreenshotCanvas: HTMLCanvasElement;
  33991. /**
  33992. * Dumps the current bound framebuffer
  33993. * @param width defines the rendering width
  33994. * @param height defines the rendering height
  33995. * @param engine defines the hosting engine
  33996. * @param successCallback defines the callback triggered once the data are available
  33997. * @param mimeType defines the mime type of the result
  33998. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33999. */
  34000. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34001. /**
  34002. * Converts the canvas data to blob.
  34003. * This acts as a polyfill for browsers not supporting the to blob function.
  34004. * @param canvas Defines the canvas to extract the data from
  34005. * @param successCallback Defines the callback triggered once the data are available
  34006. * @param mimeType Defines the mime type of the result
  34007. */
  34008. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34009. /**
  34010. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34011. * @param successCallback defines the callback triggered once the data are available
  34012. * @param mimeType defines the mime type of the result
  34013. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34014. */
  34015. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34016. /**
  34017. * Downloads a blob in the browser
  34018. * @param blob defines the blob to download
  34019. * @param fileName defines the name of the downloaded file
  34020. */
  34021. static Download(blob: Blob, fileName: string): void;
  34022. /**
  34023. * Captures a screenshot of the current rendering
  34024. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34025. * @param engine defines the rendering engine
  34026. * @param camera defines the source camera
  34027. * @param size This parameter can be set to a single number or to an object with the
  34028. * following (optional) properties: precision, width, height. If a single number is passed,
  34029. * it will be used for both width and height. If an object is passed, the screenshot size
  34030. * will be derived from the parameters. The precision property is a multiplier allowing
  34031. * rendering at a higher or lower resolution
  34032. * @param successCallback defines the callback receives a single parameter which contains the
  34033. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34034. * src parameter of an <img> to display it
  34035. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34036. * Check your browser for supported MIME types
  34037. */
  34038. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34039. /**
  34040. * Captures a screenshot of the current rendering
  34041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34042. * @param engine defines the rendering engine
  34043. * @param camera defines the source camera
  34044. * @param size This parameter can be set to a single number or to an object with the
  34045. * following (optional) properties: precision, width, height. If a single number is passed,
  34046. * it will be used for both width and height. If an object is passed, the screenshot size
  34047. * will be derived from the parameters. The precision property is a multiplier allowing
  34048. * rendering at a higher or lower resolution
  34049. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34050. * Check your browser for supported MIME types
  34051. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34052. * to the src parameter of an <img> to display it
  34053. */
  34054. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34055. /**
  34056. * Generates an image screenshot from the specified camera.
  34057. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34058. * @param engine The engine to use for rendering
  34059. * @param camera The camera to use for rendering
  34060. * @param size This parameter can be set to a single number or to an object with the
  34061. * following (optional) properties: precision, width, height. If a single number is passed,
  34062. * it will be used for both width and height. If an object is passed, the screenshot size
  34063. * will be derived from the parameters. The precision property is a multiplier allowing
  34064. * rendering at a higher or lower resolution
  34065. * @param successCallback The callback receives a single parameter which contains the
  34066. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34067. * src parameter of an <img> to display it
  34068. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34069. * Check your browser for supported MIME types
  34070. * @param samples Texture samples (default: 1)
  34071. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34072. * @param fileName A name for for the downloaded file.
  34073. */
  34074. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34075. /**
  34076. * Generates an image screenshot from the specified camera.
  34077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34078. * @param engine The engine to use for rendering
  34079. * @param camera The camera to use for rendering
  34080. * @param size This parameter can be set to a single number or to an object with the
  34081. * following (optional) properties: precision, width, height. If a single number is passed,
  34082. * it will be used for both width and height. If an object is passed, the screenshot size
  34083. * will be derived from the parameters. The precision property is a multiplier allowing
  34084. * rendering at a higher or lower resolution
  34085. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34086. * Check your browser for supported MIME types
  34087. * @param samples Texture samples (default: 1)
  34088. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34089. * @param fileName A name for for the downloaded file.
  34090. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34091. * to the src parameter of an <img> to display it
  34092. */
  34093. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34094. /**
  34095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34096. * Be aware Math.random() could cause collisions, but:
  34097. * "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"
  34098. * @returns a pseudo random id
  34099. */
  34100. static RandomId(): string;
  34101. /**
  34102. * Test if the given uri is a base64 string
  34103. * @param uri The uri to test
  34104. * @return True if the uri is a base64 string or false otherwise
  34105. */
  34106. static IsBase64(uri: string): boolean;
  34107. /**
  34108. * Decode the given base64 uri.
  34109. * @param uri The uri to decode
  34110. * @return The decoded base64 data.
  34111. */
  34112. static DecodeBase64(uri: string): ArrayBuffer;
  34113. /**
  34114. * Gets the absolute url.
  34115. * @param url the input url
  34116. * @return the absolute url
  34117. */
  34118. static GetAbsoluteUrl(url: string): string;
  34119. /**
  34120. * No log
  34121. */
  34122. static readonly NoneLogLevel: number;
  34123. /**
  34124. * Only message logs
  34125. */
  34126. static readonly MessageLogLevel: number;
  34127. /**
  34128. * Only warning logs
  34129. */
  34130. static readonly WarningLogLevel: number;
  34131. /**
  34132. * Only error logs
  34133. */
  34134. static readonly ErrorLogLevel: number;
  34135. /**
  34136. * All logs
  34137. */
  34138. static readonly AllLogLevel: number;
  34139. /**
  34140. * Gets a value indicating the number of loading errors
  34141. * @ignorenaming
  34142. */
  34143. static get errorsCount(): number;
  34144. /**
  34145. * Callback called when a new log is added
  34146. */
  34147. static OnNewCacheEntry: (entry: string) => void;
  34148. /**
  34149. * Log a message to the console
  34150. * @param message defines the message to log
  34151. */
  34152. static Log(message: string): void;
  34153. /**
  34154. * Write a warning message to the console
  34155. * @param message defines the message to log
  34156. */
  34157. static Warn(message: string): void;
  34158. /**
  34159. * Write an error message to the console
  34160. * @param message defines the message to log
  34161. */
  34162. static Error(message: string): void;
  34163. /**
  34164. * Gets current log cache (list of logs)
  34165. */
  34166. static get LogCache(): string;
  34167. /**
  34168. * Clears the log cache
  34169. */
  34170. static ClearLogCache(): void;
  34171. /**
  34172. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34173. */
  34174. static set LogLevels(level: number);
  34175. /**
  34176. * Checks if the window object exists
  34177. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34178. */
  34179. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34180. /**
  34181. * No performance log
  34182. */
  34183. static readonly PerformanceNoneLogLevel: number;
  34184. /**
  34185. * Use user marks to log performance
  34186. */
  34187. static readonly PerformanceUserMarkLogLevel: number;
  34188. /**
  34189. * Log performance to the console
  34190. */
  34191. static readonly PerformanceConsoleLogLevel: number;
  34192. private static _performance;
  34193. /**
  34194. * Sets the current performance log level
  34195. */
  34196. static set PerformanceLogLevel(level: number);
  34197. private static _StartPerformanceCounterDisabled;
  34198. private static _EndPerformanceCounterDisabled;
  34199. private static _StartUserMark;
  34200. private static _EndUserMark;
  34201. private static _StartPerformanceConsole;
  34202. private static _EndPerformanceConsole;
  34203. /**
  34204. * Starts a performance counter
  34205. */
  34206. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34207. /**
  34208. * Ends a specific performance coutner
  34209. */
  34210. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34211. /**
  34212. * Gets either window.performance.now() if supported or Date.now() else
  34213. */
  34214. static get Now(): number;
  34215. /**
  34216. * This method will return the name of the class used to create the instance of the given object.
  34217. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34218. * @param object the object to get the class name from
  34219. * @param isType defines if the object is actually a type
  34220. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34221. */
  34222. static GetClassName(object: any, isType?: boolean): string;
  34223. /**
  34224. * Gets the first element of an array satisfying a given predicate
  34225. * @param array defines the array to browse
  34226. * @param predicate defines the predicate to use
  34227. * @returns null if not found or the element
  34228. */
  34229. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34230. /**
  34231. * This method will return the name of the full name of the class, including its owning module (if any).
  34232. * 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).
  34233. * @param object the object to get the class name from
  34234. * @param isType defines if the object is actually a type
  34235. * @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.
  34236. * @ignorenaming
  34237. */
  34238. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34239. /**
  34240. * Returns a promise that resolves after the given amount of time.
  34241. * @param delay Number of milliseconds to delay
  34242. * @returns Promise that resolves after the given amount of time
  34243. */
  34244. static DelayAsync(delay: number): Promise<void>;
  34245. }
  34246. /**
  34247. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34248. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34249. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34250. * @param name The name of the class, case should be preserved
  34251. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34252. */
  34253. export function className(name: string, module?: string): (target: Object) => void;
  34254. /**
  34255. * An implementation of a loop for asynchronous functions.
  34256. */
  34257. export class AsyncLoop {
  34258. /**
  34259. * Defines the number of iterations for the loop
  34260. */
  34261. iterations: number;
  34262. /**
  34263. * Defines the current index of the loop.
  34264. */
  34265. index: number;
  34266. private _done;
  34267. private _fn;
  34268. private _successCallback;
  34269. /**
  34270. * Constructor.
  34271. * @param iterations the number of iterations.
  34272. * @param func the function to run each iteration
  34273. * @param successCallback the callback that will be called upon succesful execution
  34274. * @param offset starting offset.
  34275. */
  34276. constructor(
  34277. /**
  34278. * Defines the number of iterations for the loop
  34279. */
  34280. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34281. /**
  34282. * Execute the next iteration. Must be called after the last iteration was finished.
  34283. */
  34284. executeNext(): void;
  34285. /**
  34286. * Break the loop and run the success callback.
  34287. */
  34288. breakLoop(): void;
  34289. /**
  34290. * Create and run an async loop.
  34291. * @param iterations the number of iterations.
  34292. * @param fn the function to run each iteration
  34293. * @param successCallback the callback that will be called upon succesful execution
  34294. * @param offset starting offset.
  34295. * @returns the created async loop object
  34296. */
  34297. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34298. /**
  34299. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34300. * @param iterations total number of iterations
  34301. * @param syncedIterations number of synchronous iterations in each async iteration.
  34302. * @param fn the function to call each iteration.
  34303. * @param callback a success call back that will be called when iterating stops.
  34304. * @param breakFunction a break condition (optional)
  34305. * @param timeout timeout settings for the setTimeout function. default - 0.
  34306. * @returns the created async loop object
  34307. */
  34308. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34309. }
  34310. }
  34311. declare module BABYLON {
  34312. /**
  34313. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34314. * The underlying implementation relies on an associative array to ensure the best performances.
  34315. * The value can be anything including 'null' but except 'undefined'
  34316. */
  34317. export class StringDictionary<T> {
  34318. /**
  34319. * This will clear this dictionary and copy the content from the 'source' one.
  34320. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34321. * @param source the dictionary to take the content from and copy to this dictionary
  34322. */
  34323. copyFrom(source: StringDictionary<T>): void;
  34324. /**
  34325. * Get a value based from its key
  34326. * @param key the given key to get the matching value from
  34327. * @return the value if found, otherwise undefined is returned
  34328. */
  34329. get(key: string): T | undefined;
  34330. /**
  34331. * Get a value from its key or add it if it doesn't exist.
  34332. * This method will ensure you that a given key/data will be present in the dictionary.
  34333. * @param key the given key to get the matching value from
  34334. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34335. * The factory will only be invoked if there's no data for the given key.
  34336. * @return the value corresponding to the key.
  34337. */
  34338. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34339. /**
  34340. * Get a value from its key if present in the dictionary otherwise add it
  34341. * @param key the key to get the value from
  34342. * @param val if there's no such key/value pair in the dictionary add it with this value
  34343. * @return the value corresponding to the key
  34344. */
  34345. getOrAdd(key: string, val: T): T;
  34346. /**
  34347. * Check if there's a given key in the dictionary
  34348. * @param key the key to check for
  34349. * @return true if the key is present, false otherwise
  34350. */
  34351. contains(key: string): boolean;
  34352. /**
  34353. * Add a new key and its corresponding value
  34354. * @param key the key to add
  34355. * @param value the value corresponding to the key
  34356. * @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
  34357. */
  34358. add(key: string, value: T): boolean;
  34359. /**
  34360. * Update a specific value associated to a key
  34361. * @param key defines the key to use
  34362. * @param value defines the value to store
  34363. * @returns true if the value was updated (or false if the key was not found)
  34364. */
  34365. set(key: string, value: T): boolean;
  34366. /**
  34367. * Get the element of the given key and remove it from the dictionary
  34368. * @param key defines the key to search
  34369. * @returns the value associated with the key or null if not found
  34370. */
  34371. getAndRemove(key: string): Nullable<T>;
  34372. /**
  34373. * Remove a key/value from the dictionary.
  34374. * @param key the key to remove
  34375. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34376. */
  34377. remove(key: string): boolean;
  34378. /**
  34379. * Clear the whole content of the dictionary
  34380. */
  34381. clear(): void;
  34382. /**
  34383. * Gets the current count
  34384. */
  34385. get count(): number;
  34386. /**
  34387. * Execute a callback on each key/val of the dictionary.
  34388. * Note that you can remove any element in this dictionary in the callback implementation
  34389. * @param callback the callback to execute on a given key/value pair
  34390. */
  34391. forEach(callback: (key: string, val: T) => void): void;
  34392. /**
  34393. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34394. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34395. * Note that you can remove any element in this dictionary in the callback implementation
  34396. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34397. * @returns the first item
  34398. */
  34399. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34400. private _count;
  34401. private _data;
  34402. }
  34403. }
  34404. declare module BABYLON {
  34405. /** @hidden */
  34406. export interface ICollisionCoordinator {
  34407. createCollider(): Collider;
  34408. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34409. init(scene: Scene): void;
  34410. }
  34411. /** @hidden */
  34412. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34413. private _scene;
  34414. private _scaledPosition;
  34415. private _scaledVelocity;
  34416. private _finalPosition;
  34417. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34418. createCollider(): Collider;
  34419. init(scene: Scene): void;
  34420. private _collideWithWorld;
  34421. }
  34422. }
  34423. declare module BABYLON {
  34424. /**
  34425. * Class used to manage all inputs for the scene.
  34426. */
  34427. export class InputManager {
  34428. /** The distance in pixel that you have to move to prevent some events */
  34429. static DragMovementThreshold: number;
  34430. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34431. static LongPressDelay: number;
  34432. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34433. static DoubleClickDelay: number;
  34434. /** If you need to check double click without raising a single click at first click, enable this flag */
  34435. static ExclusiveDoubleClickMode: boolean;
  34436. private _wheelEventName;
  34437. private _onPointerMove;
  34438. private _onPointerDown;
  34439. private _onPointerUp;
  34440. private _initClickEvent;
  34441. private _initActionManager;
  34442. private _delayedSimpleClick;
  34443. private _delayedSimpleClickTimeout;
  34444. private _previousDelayedSimpleClickTimeout;
  34445. private _meshPickProceed;
  34446. private _previousButtonPressed;
  34447. private _currentPickResult;
  34448. private _previousPickResult;
  34449. private _totalPointersPressed;
  34450. private _doubleClickOccured;
  34451. private _pointerOverMesh;
  34452. private _pickedDownMesh;
  34453. private _pickedUpMesh;
  34454. private _pointerX;
  34455. private _pointerY;
  34456. private _unTranslatedPointerX;
  34457. private _unTranslatedPointerY;
  34458. private _startingPointerPosition;
  34459. private _previousStartingPointerPosition;
  34460. private _startingPointerTime;
  34461. private _previousStartingPointerTime;
  34462. private _pointerCaptures;
  34463. private _onKeyDown;
  34464. private _onKeyUp;
  34465. private _onCanvasFocusObserver;
  34466. private _onCanvasBlurObserver;
  34467. private _scene;
  34468. /**
  34469. * Creates a new InputManager
  34470. * @param scene defines the hosting scene
  34471. */
  34472. constructor(scene: Scene);
  34473. /**
  34474. * Gets the mesh that is currently under the pointer
  34475. */
  34476. get meshUnderPointer(): Nullable<AbstractMesh>;
  34477. /**
  34478. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34479. */
  34480. get unTranslatedPointer(): Vector2;
  34481. /**
  34482. * Gets or sets the current on-screen X position of the pointer
  34483. */
  34484. get pointerX(): number;
  34485. set pointerX(value: number);
  34486. /**
  34487. * Gets or sets the current on-screen Y position of the pointer
  34488. */
  34489. get pointerY(): number;
  34490. set pointerY(value: number);
  34491. private _updatePointerPosition;
  34492. private _processPointerMove;
  34493. private _setRayOnPointerInfo;
  34494. private _checkPrePointerObservable;
  34495. /**
  34496. * Use this method to simulate a pointer move on a mesh
  34497. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34498. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34499. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34500. */
  34501. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34502. /**
  34503. * Use this method to simulate a pointer down on a mesh
  34504. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34505. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34506. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34507. */
  34508. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34509. private _processPointerDown;
  34510. /** @hidden */
  34511. _isPointerSwiping(): boolean;
  34512. /**
  34513. * Use this method to simulate a pointer up on a mesh
  34514. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34515. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34516. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34517. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34518. */
  34519. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34520. private _processPointerUp;
  34521. /**
  34522. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34523. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34524. * @returns true if the pointer was captured
  34525. */
  34526. isPointerCaptured(pointerId?: number): boolean;
  34527. /**
  34528. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34529. * @param attachUp defines if you want to attach events to pointerup
  34530. * @param attachDown defines if you want to attach events to pointerdown
  34531. * @param attachMove defines if you want to attach events to pointermove
  34532. */
  34533. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34534. /**
  34535. * Detaches all event handlers
  34536. */
  34537. detachControl(): void;
  34538. /**
  34539. * Force the value of meshUnderPointer
  34540. * @param mesh defines the mesh to use
  34541. */
  34542. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34543. /**
  34544. * Gets the mesh under the pointer
  34545. * @returns a Mesh or null if no mesh is under the pointer
  34546. */
  34547. getPointerOverMesh(): Nullable<AbstractMesh>;
  34548. }
  34549. }
  34550. declare module BABYLON {
  34551. /**
  34552. * Helper class used to generate session unique ID
  34553. */
  34554. export class UniqueIdGenerator {
  34555. private static _UniqueIdCounter;
  34556. /**
  34557. * Gets an unique (relatively to the current scene) Id
  34558. */
  34559. static get UniqueId(): number;
  34560. }
  34561. }
  34562. declare module BABYLON {
  34563. /**
  34564. * This class defines the direct association between an animation and a target
  34565. */
  34566. export class TargetedAnimation {
  34567. /**
  34568. * Animation to perform
  34569. */
  34570. animation: Animation;
  34571. /**
  34572. * Target to animate
  34573. */
  34574. target: any;
  34575. /**
  34576. * Serialize the object
  34577. * @returns the JSON object representing the current entity
  34578. */
  34579. serialize(): any;
  34580. }
  34581. /**
  34582. * Use this class to create coordinated animations on multiple targets
  34583. */
  34584. export class AnimationGroup implements IDisposable {
  34585. /** The name of the animation group */
  34586. name: string;
  34587. private _scene;
  34588. private _targetedAnimations;
  34589. private _animatables;
  34590. private _from;
  34591. private _to;
  34592. private _isStarted;
  34593. private _isPaused;
  34594. private _speedRatio;
  34595. private _loopAnimation;
  34596. /**
  34597. * Gets or sets the unique id of the node
  34598. */
  34599. uniqueId: number;
  34600. /**
  34601. * This observable will notify when one animation have ended
  34602. */
  34603. onAnimationEndObservable: Observable<TargetedAnimation>;
  34604. /**
  34605. * Observer raised when one animation loops
  34606. */
  34607. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34608. /**
  34609. * Observer raised when all animations have looped
  34610. */
  34611. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34612. /**
  34613. * This observable will notify when all animations have ended.
  34614. */
  34615. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34616. /**
  34617. * This observable will notify when all animations have paused.
  34618. */
  34619. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34620. /**
  34621. * This observable will notify when all animations are playing.
  34622. */
  34623. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34624. /**
  34625. * Gets the first frame
  34626. */
  34627. get from(): number;
  34628. /**
  34629. * Gets the last frame
  34630. */
  34631. get to(): number;
  34632. /**
  34633. * Define if the animations are started
  34634. */
  34635. get isStarted(): boolean;
  34636. /**
  34637. * Gets a value indicating that the current group is playing
  34638. */
  34639. get isPlaying(): boolean;
  34640. /**
  34641. * Gets or sets the speed ratio to use for all animations
  34642. */
  34643. get speedRatio(): number;
  34644. /**
  34645. * Gets or sets the speed ratio to use for all animations
  34646. */
  34647. set speedRatio(value: number);
  34648. /**
  34649. * Gets or sets if all animations should loop or not
  34650. */
  34651. get loopAnimation(): boolean;
  34652. set loopAnimation(value: boolean);
  34653. /**
  34654. * Gets the targeted animations for this animation group
  34655. */
  34656. get targetedAnimations(): Array<TargetedAnimation>;
  34657. /**
  34658. * returning the list of animatables controlled by this animation group.
  34659. */
  34660. get animatables(): Array<Animatable>;
  34661. /**
  34662. * Instantiates a new Animation Group.
  34663. * This helps managing several animations at once.
  34664. * @see http://doc.babylonjs.com/how_to/group
  34665. * @param name Defines the name of the group
  34666. * @param scene Defines the scene the group belongs to
  34667. */
  34668. constructor(
  34669. /** The name of the animation group */
  34670. name: string, scene?: Nullable<Scene>);
  34671. /**
  34672. * Add an animation (with its target) in the group
  34673. * @param animation defines the animation we want to add
  34674. * @param target defines the target of the animation
  34675. * @returns the TargetedAnimation object
  34676. */
  34677. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34678. /**
  34679. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34680. * It can add constant keys at begin or end
  34681. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34682. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34683. * @returns the animation group
  34684. */
  34685. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34686. private _animationLoopCount;
  34687. private _animationLoopFlags;
  34688. private _processLoop;
  34689. /**
  34690. * Start all animations on given targets
  34691. * @param loop defines if animations must loop
  34692. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34693. * @param from defines the from key (optional)
  34694. * @param to defines the to key (optional)
  34695. * @returns the current animation group
  34696. */
  34697. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34698. /**
  34699. * Pause all animations
  34700. * @returns the animation group
  34701. */
  34702. pause(): AnimationGroup;
  34703. /**
  34704. * Play all animations to initial state
  34705. * This function will start() the animations if they were not started or will restart() them if they were paused
  34706. * @param loop defines if animations must loop
  34707. * @returns the animation group
  34708. */
  34709. play(loop?: boolean): AnimationGroup;
  34710. /**
  34711. * Reset all animations to initial state
  34712. * @returns the animation group
  34713. */
  34714. reset(): AnimationGroup;
  34715. /**
  34716. * Restart animations from key 0
  34717. * @returns the animation group
  34718. */
  34719. restart(): AnimationGroup;
  34720. /**
  34721. * Stop all animations
  34722. * @returns the animation group
  34723. */
  34724. stop(): AnimationGroup;
  34725. /**
  34726. * Set animation weight for all animatables
  34727. * @param weight defines the weight to use
  34728. * @return the animationGroup
  34729. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34730. */
  34731. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34732. /**
  34733. * Synchronize and normalize all animatables with a source animatable
  34734. * @param root defines the root animatable to synchronize with
  34735. * @return the animationGroup
  34736. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34737. */
  34738. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34739. /**
  34740. * Goes to a specific frame in this animation group
  34741. * @param frame the frame number to go to
  34742. * @return the animationGroup
  34743. */
  34744. goToFrame(frame: number): AnimationGroup;
  34745. /**
  34746. * Dispose all associated resources
  34747. */
  34748. dispose(): void;
  34749. private _checkAnimationGroupEnded;
  34750. /**
  34751. * Clone the current animation group and returns a copy
  34752. * @param newName defines the name of the new group
  34753. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34754. * @returns the new aniamtion group
  34755. */
  34756. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34757. /**
  34758. * Serializes the animationGroup to an object
  34759. * @returns Serialized object
  34760. */
  34761. serialize(): any;
  34762. /**
  34763. * Returns a new AnimationGroup object parsed from the source provided.
  34764. * @param parsedAnimationGroup defines the source
  34765. * @param scene defines the scene that will receive the animationGroup
  34766. * @returns a new AnimationGroup
  34767. */
  34768. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34769. /**
  34770. * Returns the string "AnimationGroup"
  34771. * @returns "AnimationGroup"
  34772. */
  34773. getClassName(): string;
  34774. /**
  34775. * Creates a detailled string about the object
  34776. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34777. * @returns a string representing the object
  34778. */
  34779. toString(fullDetails?: boolean): string;
  34780. }
  34781. }
  34782. declare module BABYLON {
  34783. /**
  34784. * Define an interface for all classes that will hold resources
  34785. */
  34786. export interface IDisposable {
  34787. /**
  34788. * Releases all held resources
  34789. */
  34790. dispose(): void;
  34791. }
  34792. /** Interface defining initialization parameters for Scene class */
  34793. export interface SceneOptions {
  34794. /**
  34795. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34796. * It will improve performance when the number of geometries becomes important.
  34797. */
  34798. useGeometryUniqueIdsMap?: boolean;
  34799. /**
  34800. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34801. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34802. */
  34803. useMaterialMeshMap?: boolean;
  34804. /**
  34805. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34806. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34807. */
  34808. useClonedMeshMap?: boolean;
  34809. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34810. virtual?: boolean;
  34811. }
  34812. /**
  34813. * Represents a scene to be rendered by the engine.
  34814. * @see http://doc.babylonjs.com/features/scene
  34815. */
  34816. export class Scene extends AbstractScene implements IAnimatable {
  34817. /** The fog is deactivated */
  34818. static readonly FOGMODE_NONE: number;
  34819. /** The fog density is following an exponential function */
  34820. static readonly FOGMODE_EXP: number;
  34821. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34822. static readonly FOGMODE_EXP2: number;
  34823. /** The fog density is following a linear function. */
  34824. static readonly FOGMODE_LINEAR: number;
  34825. /**
  34826. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34827. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34828. */
  34829. static MinDeltaTime: number;
  34830. /**
  34831. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34833. */
  34834. static MaxDeltaTime: number;
  34835. /**
  34836. * Factory used to create the default material.
  34837. * @param name The name of the material to create
  34838. * @param scene The scene to create the material for
  34839. * @returns The default material
  34840. */
  34841. static DefaultMaterialFactory(scene: Scene): Material;
  34842. /**
  34843. * Factory used to create the a collision coordinator.
  34844. * @returns The collision coordinator
  34845. */
  34846. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34847. /** @hidden */
  34848. _inputManager: InputManager;
  34849. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34850. cameraToUseForPointers: Nullable<Camera>;
  34851. /** @hidden */
  34852. readonly _isScene: boolean;
  34853. /**
  34854. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34855. */
  34856. autoClear: boolean;
  34857. /**
  34858. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34859. */
  34860. autoClearDepthAndStencil: boolean;
  34861. /**
  34862. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34863. */
  34864. clearColor: Color4;
  34865. /**
  34866. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34867. */
  34868. ambientColor: Color3;
  34869. /**
  34870. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34871. * It should only be one of the following (if not the default embedded one):
  34872. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34873. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34874. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34875. * The material properties need to be setup according to the type of texture in use.
  34876. */
  34877. environmentBRDFTexture: BaseTexture;
  34878. /** @hidden */
  34879. protected _environmentTexture: Nullable<BaseTexture>;
  34880. /**
  34881. * Texture used in all pbr material as the reflection texture.
  34882. * As in the majority of the scene they are the same (exception for multi room and so on),
  34883. * this is easier to reference from here than from all the materials.
  34884. */
  34885. get environmentTexture(): Nullable<BaseTexture>;
  34886. /**
  34887. * Texture used in all pbr material as the reflection texture.
  34888. * As in the majority of the scene they are the same (exception for multi room and so on),
  34889. * this is easier to set here than in all the materials.
  34890. */
  34891. set environmentTexture(value: Nullable<BaseTexture>);
  34892. /** @hidden */
  34893. protected _environmentIntensity: number;
  34894. /**
  34895. * Intensity of the environment in all pbr material.
  34896. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34897. * As in the majority of the scene they are the same (exception for multi room and so on),
  34898. * this is easier to reference from here than from all the materials.
  34899. */
  34900. get environmentIntensity(): number;
  34901. /**
  34902. * Intensity of the environment in all pbr material.
  34903. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34904. * As in the majority of the scene they are the same (exception for multi room and so on),
  34905. * this is easier to set here than in all the materials.
  34906. */
  34907. set environmentIntensity(value: number);
  34908. /** @hidden */
  34909. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34910. /**
  34911. * Default image processing configuration used either in the rendering
  34912. * Forward main pass or through the imageProcessingPostProcess if present.
  34913. * As in the majority of the scene they are the same (exception for multi camera),
  34914. * this is easier to reference from here than from all the materials and post process.
  34915. *
  34916. * No setter as we it is a shared configuration, you can set the values instead.
  34917. */
  34918. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34919. private _forceWireframe;
  34920. /**
  34921. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34922. */
  34923. set forceWireframe(value: boolean);
  34924. get forceWireframe(): boolean;
  34925. private _skipFrustumClipping;
  34926. /**
  34927. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  34928. */
  34929. set skipFrustumClipping(value: boolean);
  34930. get skipFrustumClipping(): boolean;
  34931. private _forcePointsCloud;
  34932. /**
  34933. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34934. */
  34935. set forcePointsCloud(value: boolean);
  34936. get forcePointsCloud(): boolean;
  34937. /**
  34938. * Gets or sets the active clipplane 1
  34939. */
  34940. clipPlane: Nullable<Plane>;
  34941. /**
  34942. * Gets or sets the active clipplane 2
  34943. */
  34944. clipPlane2: Nullable<Plane>;
  34945. /**
  34946. * Gets or sets the active clipplane 3
  34947. */
  34948. clipPlane3: Nullable<Plane>;
  34949. /**
  34950. * Gets or sets the active clipplane 4
  34951. */
  34952. clipPlane4: Nullable<Plane>;
  34953. /**
  34954. * Gets or sets the active clipplane 5
  34955. */
  34956. clipPlane5: Nullable<Plane>;
  34957. /**
  34958. * Gets or sets the active clipplane 6
  34959. */
  34960. clipPlane6: Nullable<Plane>;
  34961. /**
  34962. * Gets or sets a boolean indicating if animations are enabled
  34963. */
  34964. animationsEnabled: boolean;
  34965. private _animationPropertiesOverride;
  34966. /**
  34967. * Gets or sets the animation properties override
  34968. */
  34969. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34970. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34971. /**
  34972. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34973. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34974. */
  34975. useConstantAnimationDeltaTime: boolean;
  34976. /**
  34977. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34978. * Please note that it requires to run a ray cast through the scene on every frame
  34979. */
  34980. constantlyUpdateMeshUnderPointer: boolean;
  34981. /**
  34982. * Defines the HTML cursor to use when hovering over interactive elements
  34983. */
  34984. hoverCursor: string;
  34985. /**
  34986. * Defines the HTML default cursor to use (empty by default)
  34987. */
  34988. defaultCursor: string;
  34989. /**
  34990. * Defines wether cursors are handled by the scene.
  34991. */
  34992. doNotHandleCursors: boolean;
  34993. /**
  34994. * This is used to call preventDefault() on pointer down
  34995. * in order to block unwanted artifacts like system double clicks
  34996. */
  34997. preventDefaultOnPointerDown: boolean;
  34998. /**
  34999. * This is used to call preventDefault() on pointer up
  35000. * in order to block unwanted artifacts like system double clicks
  35001. */
  35002. preventDefaultOnPointerUp: boolean;
  35003. /**
  35004. * Gets or sets user defined metadata
  35005. */
  35006. metadata: any;
  35007. /**
  35008. * For internal use only. Please do not use.
  35009. */
  35010. reservedDataStore: any;
  35011. /**
  35012. * Gets the name of the plugin used to load this scene (null by default)
  35013. */
  35014. loadingPluginName: string;
  35015. /**
  35016. * Use this array to add regular expressions used to disable offline support for specific urls
  35017. */
  35018. disableOfflineSupportExceptionRules: RegExp[];
  35019. /**
  35020. * An event triggered when the scene is disposed.
  35021. */
  35022. onDisposeObservable: Observable<Scene>;
  35023. private _onDisposeObserver;
  35024. /** Sets a function to be executed when this scene is disposed. */
  35025. set onDispose(callback: () => void);
  35026. /**
  35027. * An event triggered before rendering the scene (right after animations and physics)
  35028. */
  35029. onBeforeRenderObservable: Observable<Scene>;
  35030. private _onBeforeRenderObserver;
  35031. /** Sets a function to be executed before rendering this scene */
  35032. set beforeRender(callback: Nullable<() => void>);
  35033. /**
  35034. * An event triggered after rendering the scene
  35035. */
  35036. onAfterRenderObservable: Observable<Scene>;
  35037. /**
  35038. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35039. */
  35040. onAfterRenderCameraObservable: Observable<Camera>;
  35041. private _onAfterRenderObserver;
  35042. /** Sets a function to be executed after rendering this scene */
  35043. set afterRender(callback: Nullable<() => void>);
  35044. /**
  35045. * An event triggered before animating the scene
  35046. */
  35047. onBeforeAnimationsObservable: Observable<Scene>;
  35048. /**
  35049. * An event triggered after animations processing
  35050. */
  35051. onAfterAnimationsObservable: Observable<Scene>;
  35052. /**
  35053. * An event triggered before draw calls are ready to be sent
  35054. */
  35055. onBeforeDrawPhaseObservable: Observable<Scene>;
  35056. /**
  35057. * An event triggered after draw calls have been sent
  35058. */
  35059. onAfterDrawPhaseObservable: Observable<Scene>;
  35060. /**
  35061. * An event triggered when the scene is ready
  35062. */
  35063. onReadyObservable: Observable<Scene>;
  35064. /**
  35065. * An event triggered before rendering a camera
  35066. */
  35067. onBeforeCameraRenderObservable: Observable<Camera>;
  35068. private _onBeforeCameraRenderObserver;
  35069. /** Sets a function to be executed before rendering a camera*/
  35070. set beforeCameraRender(callback: () => void);
  35071. /**
  35072. * An event triggered after rendering a camera
  35073. */
  35074. onAfterCameraRenderObservable: Observable<Camera>;
  35075. private _onAfterCameraRenderObserver;
  35076. /** Sets a function to be executed after rendering a camera*/
  35077. set afterCameraRender(callback: () => void);
  35078. /**
  35079. * An event triggered when active meshes evaluation is about to start
  35080. */
  35081. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35082. /**
  35083. * An event triggered when active meshes evaluation is done
  35084. */
  35085. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35086. /**
  35087. * An event triggered when particles rendering is about to start
  35088. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35089. */
  35090. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35091. /**
  35092. * An event triggered when particles rendering is done
  35093. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35094. */
  35095. onAfterParticlesRenderingObservable: Observable<Scene>;
  35096. /**
  35097. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35098. */
  35099. onDataLoadedObservable: Observable<Scene>;
  35100. /**
  35101. * An event triggered when a camera is created
  35102. */
  35103. onNewCameraAddedObservable: Observable<Camera>;
  35104. /**
  35105. * An event triggered when a camera is removed
  35106. */
  35107. onCameraRemovedObservable: Observable<Camera>;
  35108. /**
  35109. * An event triggered when a light is created
  35110. */
  35111. onNewLightAddedObservable: Observable<Light>;
  35112. /**
  35113. * An event triggered when a light is removed
  35114. */
  35115. onLightRemovedObservable: Observable<Light>;
  35116. /**
  35117. * An event triggered when a geometry is created
  35118. */
  35119. onNewGeometryAddedObservable: Observable<Geometry>;
  35120. /**
  35121. * An event triggered when a geometry is removed
  35122. */
  35123. onGeometryRemovedObservable: Observable<Geometry>;
  35124. /**
  35125. * An event triggered when a transform node is created
  35126. */
  35127. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35128. /**
  35129. * An event triggered when a transform node is removed
  35130. */
  35131. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35132. /**
  35133. * An event triggered when a mesh is created
  35134. */
  35135. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35136. /**
  35137. * An event triggered when a mesh is removed
  35138. */
  35139. onMeshRemovedObservable: Observable<AbstractMesh>;
  35140. /**
  35141. * An event triggered when a skeleton is created
  35142. */
  35143. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35144. /**
  35145. * An event triggered when a skeleton is removed
  35146. */
  35147. onSkeletonRemovedObservable: Observable<Skeleton>;
  35148. /**
  35149. * An event triggered when a material is created
  35150. */
  35151. onNewMaterialAddedObservable: Observable<Material>;
  35152. /**
  35153. * An event triggered when a material is removed
  35154. */
  35155. onMaterialRemovedObservable: Observable<Material>;
  35156. /**
  35157. * An event triggered when a texture is created
  35158. */
  35159. onNewTextureAddedObservable: Observable<BaseTexture>;
  35160. /**
  35161. * An event triggered when a texture is removed
  35162. */
  35163. onTextureRemovedObservable: Observable<BaseTexture>;
  35164. /**
  35165. * An event triggered when render targets are about to be rendered
  35166. * Can happen multiple times per frame.
  35167. */
  35168. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35169. /**
  35170. * An event triggered when render targets were rendered.
  35171. * Can happen multiple times per frame.
  35172. */
  35173. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35174. /**
  35175. * An event triggered before calculating deterministic simulation step
  35176. */
  35177. onBeforeStepObservable: Observable<Scene>;
  35178. /**
  35179. * An event triggered after calculating deterministic simulation step
  35180. */
  35181. onAfterStepObservable: Observable<Scene>;
  35182. /**
  35183. * An event triggered when the activeCamera property is updated
  35184. */
  35185. onActiveCameraChanged: Observable<Scene>;
  35186. /**
  35187. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35188. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35189. * 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)
  35190. */
  35191. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35192. /**
  35193. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35194. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35195. * 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)
  35196. */
  35197. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35198. /**
  35199. * This Observable will when a mesh has been imported into the scene.
  35200. */
  35201. onMeshImportedObservable: Observable<AbstractMesh>;
  35202. /**
  35203. * This Observable will when an animation file has been imported into the scene.
  35204. */
  35205. onAnimationFileImportedObservable: Observable<Scene>;
  35206. /**
  35207. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35208. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35209. */
  35210. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35211. /** @hidden */
  35212. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35213. /**
  35214. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35215. */
  35216. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35217. /**
  35218. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35219. */
  35220. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35221. /**
  35222. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35223. */
  35224. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35225. /** Callback called when a pointer move is detected */
  35226. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35227. /** Callback called when a pointer down is detected */
  35228. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35229. /** Callback called when a pointer up is detected */
  35230. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35231. /** Callback called when a pointer pick is detected */
  35232. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35233. /**
  35234. * 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).
  35235. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35236. */
  35237. onPrePointerObservable: Observable<PointerInfoPre>;
  35238. /**
  35239. * Observable event triggered each time an input event is received from the rendering canvas
  35240. */
  35241. onPointerObservable: Observable<PointerInfo>;
  35242. /**
  35243. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35244. */
  35245. get unTranslatedPointer(): Vector2;
  35246. /**
  35247. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35248. */
  35249. static get DragMovementThreshold(): number;
  35250. static set DragMovementThreshold(value: number);
  35251. /**
  35252. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35253. */
  35254. static get LongPressDelay(): number;
  35255. static set LongPressDelay(value: number);
  35256. /**
  35257. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35258. */
  35259. static get DoubleClickDelay(): number;
  35260. static set DoubleClickDelay(value: number);
  35261. /** If you need to check double click without raising a single click at first click, enable this flag */
  35262. static get ExclusiveDoubleClickMode(): boolean;
  35263. static set ExclusiveDoubleClickMode(value: boolean);
  35264. /** @hidden */
  35265. _mirroredCameraPosition: Nullable<Vector3>;
  35266. /**
  35267. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35268. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35269. */
  35270. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35271. /**
  35272. * Observable event triggered each time an keyboard event is received from the hosting window
  35273. */
  35274. onKeyboardObservable: Observable<KeyboardInfo>;
  35275. private _useRightHandedSystem;
  35276. /**
  35277. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35278. */
  35279. set useRightHandedSystem(value: boolean);
  35280. get useRightHandedSystem(): boolean;
  35281. private _timeAccumulator;
  35282. private _currentStepId;
  35283. private _currentInternalStep;
  35284. /**
  35285. * Sets the step Id used by deterministic lock step
  35286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35287. * @param newStepId defines the step Id
  35288. */
  35289. setStepId(newStepId: number): void;
  35290. /**
  35291. * Gets the step Id used by deterministic lock step
  35292. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35293. * @returns the step Id
  35294. */
  35295. getStepId(): number;
  35296. /**
  35297. * Gets the internal step used by deterministic lock step
  35298. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35299. * @returns the internal step
  35300. */
  35301. getInternalStep(): number;
  35302. private _fogEnabled;
  35303. /**
  35304. * Gets or sets a boolean indicating if fog is enabled on this scene
  35305. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35306. * (Default is true)
  35307. */
  35308. set fogEnabled(value: boolean);
  35309. get fogEnabled(): boolean;
  35310. private _fogMode;
  35311. /**
  35312. * Gets or sets the fog mode to use
  35313. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35314. * | mode | value |
  35315. * | --- | --- |
  35316. * | FOGMODE_NONE | 0 |
  35317. * | FOGMODE_EXP | 1 |
  35318. * | FOGMODE_EXP2 | 2 |
  35319. * | FOGMODE_LINEAR | 3 |
  35320. */
  35321. set fogMode(value: number);
  35322. get fogMode(): number;
  35323. /**
  35324. * Gets or sets the fog color to use
  35325. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35326. * (Default is Color3(0.2, 0.2, 0.3))
  35327. */
  35328. fogColor: Color3;
  35329. /**
  35330. * Gets or sets the fog density to use
  35331. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35332. * (Default is 0.1)
  35333. */
  35334. fogDensity: number;
  35335. /**
  35336. * Gets or sets the fog start distance to use
  35337. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35338. * (Default is 0)
  35339. */
  35340. fogStart: number;
  35341. /**
  35342. * Gets or sets the fog end distance to use
  35343. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35344. * (Default is 1000)
  35345. */
  35346. fogEnd: number;
  35347. private _shadowsEnabled;
  35348. /**
  35349. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35350. */
  35351. set shadowsEnabled(value: boolean);
  35352. get shadowsEnabled(): boolean;
  35353. private _lightsEnabled;
  35354. /**
  35355. * Gets or sets a boolean indicating if lights are enabled on this scene
  35356. */
  35357. set lightsEnabled(value: boolean);
  35358. get lightsEnabled(): boolean;
  35359. /** All of the active cameras added to this scene. */
  35360. activeCameras: Camera[];
  35361. /** @hidden */
  35362. _activeCamera: Nullable<Camera>;
  35363. /** Gets or sets the current active camera */
  35364. get activeCamera(): Nullable<Camera>;
  35365. set activeCamera(value: Nullable<Camera>);
  35366. private _defaultMaterial;
  35367. /** The default material used on meshes when no material is affected */
  35368. get defaultMaterial(): Material;
  35369. /** The default material used on meshes when no material is affected */
  35370. set defaultMaterial(value: Material);
  35371. private _texturesEnabled;
  35372. /**
  35373. * Gets or sets a boolean indicating if textures are enabled on this scene
  35374. */
  35375. set texturesEnabled(value: boolean);
  35376. get texturesEnabled(): boolean;
  35377. /**
  35378. * Gets or sets a boolean indicating if particles are enabled on this scene
  35379. */
  35380. particlesEnabled: boolean;
  35381. /**
  35382. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35383. */
  35384. spritesEnabled: boolean;
  35385. private _skeletonsEnabled;
  35386. /**
  35387. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35388. */
  35389. set skeletonsEnabled(value: boolean);
  35390. get skeletonsEnabled(): boolean;
  35391. /**
  35392. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35393. */
  35394. lensFlaresEnabled: boolean;
  35395. /**
  35396. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35398. */
  35399. collisionsEnabled: boolean;
  35400. private _collisionCoordinator;
  35401. /** @hidden */
  35402. get collisionCoordinator(): ICollisionCoordinator;
  35403. /**
  35404. * Defines the gravity applied to this scene (used only for collisions)
  35405. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35406. */
  35407. gravity: Vector3;
  35408. /**
  35409. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35410. */
  35411. postProcessesEnabled: boolean;
  35412. /**
  35413. * The list of postprocesses added to the scene
  35414. */
  35415. postProcesses: PostProcess[];
  35416. /**
  35417. * Gets the current postprocess manager
  35418. */
  35419. postProcessManager: PostProcessManager;
  35420. /**
  35421. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35422. */
  35423. renderTargetsEnabled: boolean;
  35424. /**
  35425. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35426. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35427. */
  35428. dumpNextRenderTargets: boolean;
  35429. /**
  35430. * The list of user defined render targets added to the scene
  35431. */
  35432. customRenderTargets: RenderTargetTexture[];
  35433. /**
  35434. * Defines if texture loading must be delayed
  35435. * If true, textures will only be loaded when they need to be rendered
  35436. */
  35437. useDelayedTextureLoading: boolean;
  35438. /**
  35439. * Gets the list of meshes imported to the scene through SceneLoader
  35440. */
  35441. importedMeshesFiles: String[];
  35442. /**
  35443. * Gets or sets a boolean indicating if probes are enabled on this scene
  35444. */
  35445. probesEnabled: boolean;
  35446. /**
  35447. * Gets or sets the current offline provider to use to store scene data
  35448. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35449. */
  35450. offlineProvider: IOfflineProvider;
  35451. /**
  35452. * Gets or sets the action manager associated with the scene
  35453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35454. */
  35455. actionManager: AbstractActionManager;
  35456. private _meshesForIntersections;
  35457. /**
  35458. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35459. */
  35460. proceduralTexturesEnabled: boolean;
  35461. private _engine;
  35462. private _totalVertices;
  35463. /** @hidden */
  35464. _activeIndices: PerfCounter;
  35465. /** @hidden */
  35466. _activeParticles: PerfCounter;
  35467. /** @hidden */
  35468. _activeBones: PerfCounter;
  35469. private _animationRatio;
  35470. /** @hidden */
  35471. _animationTimeLast: number;
  35472. /** @hidden */
  35473. _animationTime: number;
  35474. /**
  35475. * Gets or sets a general scale for animation speed
  35476. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35477. */
  35478. animationTimeScale: number;
  35479. /** @hidden */
  35480. _cachedMaterial: Nullable<Material>;
  35481. /** @hidden */
  35482. _cachedEffect: Nullable<Effect>;
  35483. /** @hidden */
  35484. _cachedVisibility: Nullable<number>;
  35485. private _renderId;
  35486. private _frameId;
  35487. private _executeWhenReadyTimeoutId;
  35488. private _intermediateRendering;
  35489. private _viewUpdateFlag;
  35490. private _projectionUpdateFlag;
  35491. /** @hidden */
  35492. _toBeDisposed: Nullable<IDisposable>[];
  35493. private _activeRequests;
  35494. /** @hidden */
  35495. _pendingData: any[];
  35496. private _isDisposed;
  35497. /**
  35498. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35499. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35500. */
  35501. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35502. private _activeMeshes;
  35503. private _processedMaterials;
  35504. private _renderTargets;
  35505. /** @hidden */
  35506. _activeParticleSystems: SmartArray<IParticleSystem>;
  35507. private _activeSkeletons;
  35508. private _softwareSkinnedMeshes;
  35509. private _renderingManager;
  35510. /** @hidden */
  35511. _activeAnimatables: Animatable[];
  35512. private _transformMatrix;
  35513. private _sceneUbo;
  35514. /** @hidden */
  35515. _viewMatrix: Matrix;
  35516. private _projectionMatrix;
  35517. /** @hidden */
  35518. _forcedViewPosition: Nullable<Vector3>;
  35519. /** @hidden */
  35520. _frustumPlanes: Plane[];
  35521. /**
  35522. * Gets the list of frustum planes (built from the active camera)
  35523. */
  35524. get frustumPlanes(): Plane[];
  35525. /**
  35526. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35527. * This is useful if there are more lights that the maximum simulteanous authorized
  35528. */
  35529. requireLightSorting: boolean;
  35530. /** @hidden */
  35531. readonly useMaterialMeshMap: boolean;
  35532. /** @hidden */
  35533. readonly useClonedMeshMap: boolean;
  35534. private _externalData;
  35535. private _uid;
  35536. /**
  35537. * @hidden
  35538. * Backing store of defined scene components.
  35539. */
  35540. _components: ISceneComponent[];
  35541. /**
  35542. * @hidden
  35543. * Backing store of defined scene components.
  35544. */
  35545. _serializableComponents: ISceneSerializableComponent[];
  35546. /**
  35547. * List of components to register on the next registration step.
  35548. */
  35549. private _transientComponents;
  35550. /**
  35551. * Registers the transient components if needed.
  35552. */
  35553. private _registerTransientComponents;
  35554. /**
  35555. * @hidden
  35556. * Add a component to the scene.
  35557. * Note that the ccomponent could be registered on th next frame if this is called after
  35558. * the register component stage.
  35559. * @param component Defines the component to add to the scene
  35560. */
  35561. _addComponent(component: ISceneComponent): void;
  35562. /**
  35563. * @hidden
  35564. * Gets a component from the scene.
  35565. * @param name defines the name of the component to retrieve
  35566. * @returns the component or null if not present
  35567. */
  35568. _getComponent(name: string): Nullable<ISceneComponent>;
  35569. /**
  35570. * @hidden
  35571. * Defines the actions happening before camera updates.
  35572. */
  35573. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35574. /**
  35575. * @hidden
  35576. * Defines the actions happening before clear the canvas.
  35577. */
  35578. _beforeClearStage: Stage<SimpleStageAction>;
  35579. /**
  35580. * @hidden
  35581. * Defines the actions when collecting render targets for the frame.
  35582. */
  35583. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35584. /**
  35585. * @hidden
  35586. * Defines the actions happening for one camera in the frame.
  35587. */
  35588. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35589. /**
  35590. * @hidden
  35591. * Defines the actions happening during the per mesh ready checks.
  35592. */
  35593. _isReadyForMeshStage: Stage<MeshStageAction>;
  35594. /**
  35595. * @hidden
  35596. * Defines the actions happening before evaluate active mesh checks.
  35597. */
  35598. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35599. /**
  35600. * @hidden
  35601. * Defines the actions happening during the evaluate sub mesh checks.
  35602. */
  35603. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35604. /**
  35605. * @hidden
  35606. * Defines the actions happening during the active mesh stage.
  35607. */
  35608. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35609. /**
  35610. * @hidden
  35611. * Defines the actions happening during the per camera render target step.
  35612. */
  35613. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35614. /**
  35615. * @hidden
  35616. * Defines the actions happening just before the active camera is drawing.
  35617. */
  35618. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35619. /**
  35620. * @hidden
  35621. * Defines the actions happening just before a render target is drawing.
  35622. */
  35623. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35624. /**
  35625. * @hidden
  35626. * Defines the actions happening just before a rendering group is drawing.
  35627. */
  35628. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35629. /**
  35630. * @hidden
  35631. * Defines the actions happening just before a mesh is drawing.
  35632. */
  35633. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35634. /**
  35635. * @hidden
  35636. * Defines the actions happening just after a mesh has been drawn.
  35637. */
  35638. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35639. /**
  35640. * @hidden
  35641. * Defines the actions happening just after a rendering group has been drawn.
  35642. */
  35643. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35644. /**
  35645. * @hidden
  35646. * Defines the actions happening just after the active camera has been drawn.
  35647. */
  35648. _afterCameraDrawStage: Stage<CameraStageAction>;
  35649. /**
  35650. * @hidden
  35651. * Defines the actions happening just after a render target has been drawn.
  35652. */
  35653. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35654. /**
  35655. * @hidden
  35656. * Defines the actions happening just after rendering all cameras and computing intersections.
  35657. */
  35658. _afterRenderStage: Stage<SimpleStageAction>;
  35659. /**
  35660. * @hidden
  35661. * Defines the actions happening when a pointer move event happens.
  35662. */
  35663. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35664. /**
  35665. * @hidden
  35666. * Defines the actions happening when a pointer down event happens.
  35667. */
  35668. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35669. /**
  35670. * @hidden
  35671. * Defines the actions happening when a pointer up event happens.
  35672. */
  35673. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35674. /**
  35675. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35676. */
  35677. private geometriesByUniqueId;
  35678. /**
  35679. * Creates a new Scene
  35680. * @param engine defines the engine to use to render this scene
  35681. * @param options defines the scene options
  35682. */
  35683. constructor(engine: Engine, options?: SceneOptions);
  35684. /**
  35685. * Gets a string idenfifying the name of the class
  35686. * @returns "Scene" string
  35687. */
  35688. getClassName(): string;
  35689. private _defaultMeshCandidates;
  35690. /**
  35691. * @hidden
  35692. */
  35693. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35694. private _defaultSubMeshCandidates;
  35695. /**
  35696. * @hidden
  35697. */
  35698. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35699. /**
  35700. * Sets the default candidate providers for the scene.
  35701. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35702. * and getCollidingSubMeshCandidates to their default function
  35703. */
  35704. setDefaultCandidateProviders(): void;
  35705. /**
  35706. * Gets the mesh that is currently under the pointer
  35707. */
  35708. get meshUnderPointer(): Nullable<AbstractMesh>;
  35709. /**
  35710. * Gets or sets the current on-screen X position of the pointer
  35711. */
  35712. get pointerX(): number;
  35713. set pointerX(value: number);
  35714. /**
  35715. * Gets or sets the current on-screen Y position of the pointer
  35716. */
  35717. get pointerY(): number;
  35718. set pointerY(value: number);
  35719. /**
  35720. * Gets the cached material (ie. the latest rendered one)
  35721. * @returns the cached material
  35722. */
  35723. getCachedMaterial(): Nullable<Material>;
  35724. /**
  35725. * Gets the cached effect (ie. the latest rendered one)
  35726. * @returns the cached effect
  35727. */
  35728. getCachedEffect(): Nullable<Effect>;
  35729. /**
  35730. * Gets the cached visibility state (ie. the latest rendered one)
  35731. * @returns the cached visibility state
  35732. */
  35733. getCachedVisibility(): Nullable<number>;
  35734. /**
  35735. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35736. * @param material defines the current material
  35737. * @param effect defines the current effect
  35738. * @param visibility defines the current visibility state
  35739. * @returns true if one parameter is not cached
  35740. */
  35741. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35742. /**
  35743. * Gets the engine associated with the scene
  35744. * @returns an Engine
  35745. */
  35746. getEngine(): Engine;
  35747. /**
  35748. * Gets the total number of vertices rendered per frame
  35749. * @returns the total number of vertices rendered per frame
  35750. */
  35751. getTotalVertices(): number;
  35752. /**
  35753. * Gets the performance counter for total vertices
  35754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35755. */
  35756. get totalVerticesPerfCounter(): PerfCounter;
  35757. /**
  35758. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35759. * @returns the total number of active indices rendered per frame
  35760. */
  35761. getActiveIndices(): number;
  35762. /**
  35763. * Gets the performance counter for active indices
  35764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35765. */
  35766. get totalActiveIndicesPerfCounter(): PerfCounter;
  35767. /**
  35768. * Gets the total number of active particles rendered per frame
  35769. * @returns the total number of active particles rendered per frame
  35770. */
  35771. getActiveParticles(): number;
  35772. /**
  35773. * Gets the performance counter for active particles
  35774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35775. */
  35776. get activeParticlesPerfCounter(): PerfCounter;
  35777. /**
  35778. * Gets the total number of active bones rendered per frame
  35779. * @returns the total number of active bones rendered per frame
  35780. */
  35781. getActiveBones(): number;
  35782. /**
  35783. * Gets the performance counter for active bones
  35784. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35785. */
  35786. get activeBonesPerfCounter(): PerfCounter;
  35787. /**
  35788. * Gets the array of active meshes
  35789. * @returns an array of AbstractMesh
  35790. */
  35791. getActiveMeshes(): SmartArray<AbstractMesh>;
  35792. /**
  35793. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35794. * @returns a number
  35795. */
  35796. getAnimationRatio(): number;
  35797. /**
  35798. * Gets an unique Id for the current render phase
  35799. * @returns a number
  35800. */
  35801. getRenderId(): number;
  35802. /**
  35803. * Gets an unique Id for the current frame
  35804. * @returns a number
  35805. */
  35806. getFrameId(): number;
  35807. /** Call this function if you want to manually increment the render Id*/
  35808. incrementRenderId(): void;
  35809. private _createUbo;
  35810. /**
  35811. * Use this method to simulate a pointer move on a mesh
  35812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35815. * @returns the current scene
  35816. */
  35817. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35818. /**
  35819. * Use this method to simulate a pointer down on a mesh
  35820. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35821. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35822. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35823. * @returns the current scene
  35824. */
  35825. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35826. /**
  35827. * Use this method to simulate a pointer up on a mesh
  35828. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35829. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35830. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35831. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35832. * @returns the current scene
  35833. */
  35834. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35835. /**
  35836. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35837. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35838. * @returns true if the pointer was captured
  35839. */
  35840. isPointerCaptured(pointerId?: number): boolean;
  35841. /**
  35842. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35843. * @param attachUp defines if you want to attach events to pointerup
  35844. * @param attachDown defines if you want to attach events to pointerdown
  35845. * @param attachMove defines if you want to attach events to pointermove
  35846. */
  35847. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35848. /** Detaches all event handlers*/
  35849. detachControl(): void;
  35850. /**
  35851. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35852. * Delay loaded resources are not taking in account
  35853. * @return true if all required resources are ready
  35854. */
  35855. isReady(): boolean;
  35856. /** Resets all cached information relative to material (including effect and visibility) */
  35857. resetCachedMaterial(): void;
  35858. /**
  35859. * Registers a function to be called before every frame render
  35860. * @param func defines the function to register
  35861. */
  35862. registerBeforeRender(func: () => void): void;
  35863. /**
  35864. * Unregisters a function called before every frame render
  35865. * @param func defines the function to unregister
  35866. */
  35867. unregisterBeforeRender(func: () => void): void;
  35868. /**
  35869. * Registers a function to be called after every frame render
  35870. * @param func defines the function to register
  35871. */
  35872. registerAfterRender(func: () => void): void;
  35873. /**
  35874. * Unregisters a function called after every frame render
  35875. * @param func defines the function to unregister
  35876. */
  35877. unregisterAfterRender(func: () => void): void;
  35878. private _executeOnceBeforeRender;
  35879. /**
  35880. * The provided function will run before render once and will be disposed afterwards.
  35881. * A timeout delay can be provided so that the function will be executed in N ms.
  35882. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35883. * @param func The function to be executed.
  35884. * @param timeout optional delay in ms
  35885. */
  35886. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35887. /** @hidden */
  35888. _addPendingData(data: any): void;
  35889. /** @hidden */
  35890. _removePendingData(data: any): void;
  35891. /**
  35892. * Returns the number of items waiting to be loaded
  35893. * @returns the number of items waiting to be loaded
  35894. */
  35895. getWaitingItemsCount(): number;
  35896. /**
  35897. * Returns a boolean indicating if the scene is still loading data
  35898. */
  35899. get isLoading(): boolean;
  35900. /**
  35901. * Registers a function to be executed when the scene is ready
  35902. * @param {Function} func - the function to be executed
  35903. */
  35904. executeWhenReady(func: () => void): void;
  35905. /**
  35906. * Returns a promise that resolves when the scene is ready
  35907. * @returns A promise that resolves when the scene is ready
  35908. */
  35909. whenReadyAsync(): Promise<void>;
  35910. /** @hidden */
  35911. _checkIsReady(): void;
  35912. /**
  35913. * Gets all animatable attached to the scene
  35914. */
  35915. get animatables(): Animatable[];
  35916. /**
  35917. * Resets the last animation time frame.
  35918. * Useful to override when animations start running when loading a scene for the first time.
  35919. */
  35920. resetLastAnimationTimeFrame(): void;
  35921. /**
  35922. * Gets the current view matrix
  35923. * @returns a Matrix
  35924. */
  35925. getViewMatrix(): Matrix;
  35926. /**
  35927. * Gets the current projection matrix
  35928. * @returns a Matrix
  35929. */
  35930. getProjectionMatrix(): Matrix;
  35931. /**
  35932. * Gets the current transform matrix
  35933. * @returns a Matrix made of View * Projection
  35934. */
  35935. getTransformMatrix(): Matrix;
  35936. /**
  35937. * Sets the current transform matrix
  35938. * @param viewL defines the View matrix to use
  35939. * @param projectionL defines the Projection matrix to use
  35940. * @param viewR defines the right View matrix to use (if provided)
  35941. * @param projectionR defines the right Projection matrix to use (if provided)
  35942. */
  35943. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35944. /**
  35945. * Gets the uniform buffer used to store scene data
  35946. * @returns a UniformBuffer
  35947. */
  35948. getSceneUniformBuffer(): UniformBuffer;
  35949. /**
  35950. * Gets an unique (relatively to the current scene) Id
  35951. * @returns an unique number for the scene
  35952. */
  35953. getUniqueId(): number;
  35954. /**
  35955. * Add a mesh to the list of scene's meshes
  35956. * @param newMesh defines the mesh to add
  35957. * @param recursive if all child meshes should also be added to the scene
  35958. */
  35959. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35960. /**
  35961. * Remove a mesh for the list of scene's meshes
  35962. * @param toRemove defines the mesh to remove
  35963. * @param recursive if all child meshes should also be removed from the scene
  35964. * @returns the index where the mesh was in the mesh list
  35965. */
  35966. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35967. /**
  35968. * Add a transform node to the list of scene's transform nodes
  35969. * @param newTransformNode defines the transform node to add
  35970. */
  35971. addTransformNode(newTransformNode: TransformNode): void;
  35972. /**
  35973. * Remove a transform node for the list of scene's transform nodes
  35974. * @param toRemove defines the transform node to remove
  35975. * @returns the index where the transform node was in the transform node list
  35976. */
  35977. removeTransformNode(toRemove: TransformNode): number;
  35978. /**
  35979. * Remove a skeleton for the list of scene's skeletons
  35980. * @param toRemove defines the skeleton to remove
  35981. * @returns the index where the skeleton was in the skeleton list
  35982. */
  35983. removeSkeleton(toRemove: Skeleton): number;
  35984. /**
  35985. * Remove a morph target for the list of scene's morph targets
  35986. * @param toRemove defines the morph target to remove
  35987. * @returns the index where the morph target was in the morph target list
  35988. */
  35989. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35990. /**
  35991. * Remove a light for the list of scene's lights
  35992. * @param toRemove defines the light to remove
  35993. * @returns the index where the light was in the light list
  35994. */
  35995. removeLight(toRemove: Light): number;
  35996. /**
  35997. * Remove a camera for the list of scene's cameras
  35998. * @param toRemove defines the camera to remove
  35999. * @returns the index where the camera was in the camera list
  36000. */
  36001. removeCamera(toRemove: Camera): number;
  36002. /**
  36003. * Remove a particle system for the list of scene's particle systems
  36004. * @param toRemove defines the particle system to remove
  36005. * @returns the index where the particle system was in the particle system list
  36006. */
  36007. removeParticleSystem(toRemove: IParticleSystem): number;
  36008. /**
  36009. * Remove a animation for the list of scene's animations
  36010. * @param toRemove defines the animation to remove
  36011. * @returns the index where the animation was in the animation list
  36012. */
  36013. removeAnimation(toRemove: Animation): number;
  36014. /**
  36015. * Will stop the animation of the given target
  36016. * @param target - the target
  36017. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36018. * @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)
  36019. */
  36020. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36021. /**
  36022. * Removes the given animation group from this scene.
  36023. * @param toRemove The animation group to remove
  36024. * @returns The index of the removed animation group
  36025. */
  36026. removeAnimationGroup(toRemove: AnimationGroup): number;
  36027. /**
  36028. * Removes the given multi-material from this scene.
  36029. * @param toRemove The multi-material to remove
  36030. * @returns The index of the removed multi-material
  36031. */
  36032. removeMultiMaterial(toRemove: MultiMaterial): number;
  36033. /**
  36034. * Removes the given material from this scene.
  36035. * @param toRemove The material to remove
  36036. * @returns The index of the removed material
  36037. */
  36038. removeMaterial(toRemove: Material): number;
  36039. /**
  36040. * Removes the given action manager from this scene.
  36041. * @param toRemove The action manager to remove
  36042. * @returns The index of the removed action manager
  36043. */
  36044. removeActionManager(toRemove: AbstractActionManager): number;
  36045. /**
  36046. * Removes the given texture from this scene.
  36047. * @param toRemove The texture to remove
  36048. * @returns The index of the removed texture
  36049. */
  36050. removeTexture(toRemove: BaseTexture): number;
  36051. /**
  36052. * Adds the given light to this scene
  36053. * @param newLight The light to add
  36054. */
  36055. addLight(newLight: Light): void;
  36056. /**
  36057. * Sorts the list list based on light priorities
  36058. */
  36059. sortLightsByPriority(): void;
  36060. /**
  36061. * Adds the given camera to this scene
  36062. * @param newCamera The camera to add
  36063. */
  36064. addCamera(newCamera: Camera): void;
  36065. /**
  36066. * Adds the given skeleton to this scene
  36067. * @param newSkeleton The skeleton to add
  36068. */
  36069. addSkeleton(newSkeleton: Skeleton): void;
  36070. /**
  36071. * Adds the given particle system to this scene
  36072. * @param newParticleSystem The particle system to add
  36073. */
  36074. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36075. /**
  36076. * Adds the given animation to this scene
  36077. * @param newAnimation The animation to add
  36078. */
  36079. addAnimation(newAnimation: Animation): void;
  36080. /**
  36081. * Adds the given animation group to this scene.
  36082. * @param newAnimationGroup The animation group to add
  36083. */
  36084. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36085. /**
  36086. * Adds the given multi-material to this scene
  36087. * @param newMultiMaterial The multi-material to add
  36088. */
  36089. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36090. /**
  36091. * Adds the given material to this scene
  36092. * @param newMaterial The material to add
  36093. */
  36094. addMaterial(newMaterial: Material): void;
  36095. /**
  36096. * Adds the given morph target to this scene
  36097. * @param newMorphTargetManager The morph target to add
  36098. */
  36099. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36100. /**
  36101. * Adds the given geometry to this scene
  36102. * @param newGeometry The geometry to add
  36103. */
  36104. addGeometry(newGeometry: Geometry): void;
  36105. /**
  36106. * Adds the given action manager to this scene
  36107. * @param newActionManager The action manager to add
  36108. */
  36109. addActionManager(newActionManager: AbstractActionManager): void;
  36110. /**
  36111. * Adds the given texture to this scene.
  36112. * @param newTexture The texture to add
  36113. */
  36114. addTexture(newTexture: BaseTexture): void;
  36115. /**
  36116. * Switch active camera
  36117. * @param newCamera defines the new active camera
  36118. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36119. */
  36120. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36121. /**
  36122. * sets the active camera of the scene using its ID
  36123. * @param id defines the camera's ID
  36124. * @return the new active camera or null if none found.
  36125. */
  36126. setActiveCameraByID(id: string): Nullable<Camera>;
  36127. /**
  36128. * sets the active camera of the scene using its name
  36129. * @param name defines the camera's name
  36130. * @returns the new active camera or null if none found.
  36131. */
  36132. setActiveCameraByName(name: string): Nullable<Camera>;
  36133. /**
  36134. * get an animation group using its name
  36135. * @param name defines the material's name
  36136. * @return the animation group or null if none found.
  36137. */
  36138. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36139. /**
  36140. * Get a material using its unique id
  36141. * @param uniqueId defines the material's unique id
  36142. * @return the material or null if none found.
  36143. */
  36144. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36145. /**
  36146. * get a material using its id
  36147. * @param id defines the material's ID
  36148. * @return the material or null if none found.
  36149. */
  36150. getMaterialByID(id: string): Nullable<Material>;
  36151. /**
  36152. * Gets a the last added material using a given id
  36153. * @param id defines the material's ID
  36154. * @return the last material with the given id or null if none found.
  36155. */
  36156. getLastMaterialByID(id: string): Nullable<Material>;
  36157. /**
  36158. * Gets a material using its name
  36159. * @param name defines the material's name
  36160. * @return the material or null if none found.
  36161. */
  36162. getMaterialByName(name: string): Nullable<Material>;
  36163. /**
  36164. * Get a texture using its unique id
  36165. * @param uniqueId defines the texture's unique id
  36166. * @return the texture or null if none found.
  36167. */
  36168. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36169. /**
  36170. * Gets a camera using its id
  36171. * @param id defines the id to look for
  36172. * @returns the camera or null if not found
  36173. */
  36174. getCameraByID(id: string): Nullable<Camera>;
  36175. /**
  36176. * Gets a camera using its unique id
  36177. * @param uniqueId defines the unique id to look for
  36178. * @returns the camera or null if not found
  36179. */
  36180. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36181. /**
  36182. * Gets a camera using its name
  36183. * @param name defines the camera's name
  36184. * @return the camera or null if none found.
  36185. */
  36186. getCameraByName(name: string): Nullable<Camera>;
  36187. /**
  36188. * Gets a bone using its id
  36189. * @param id defines the bone's id
  36190. * @return the bone or null if not found
  36191. */
  36192. getBoneByID(id: string): Nullable<Bone>;
  36193. /**
  36194. * Gets a bone using its id
  36195. * @param name defines the bone's name
  36196. * @return the bone or null if not found
  36197. */
  36198. getBoneByName(name: string): Nullable<Bone>;
  36199. /**
  36200. * Gets a light node using its name
  36201. * @param name defines the the light's name
  36202. * @return the light or null if none found.
  36203. */
  36204. getLightByName(name: string): Nullable<Light>;
  36205. /**
  36206. * Gets a light node using its id
  36207. * @param id defines the light's id
  36208. * @return the light or null if none found.
  36209. */
  36210. getLightByID(id: string): Nullable<Light>;
  36211. /**
  36212. * Gets a light node using its scene-generated unique ID
  36213. * @param uniqueId defines the light's unique id
  36214. * @return the light or null if none found.
  36215. */
  36216. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36217. /**
  36218. * Gets a particle system by id
  36219. * @param id defines the particle system id
  36220. * @return the corresponding system or null if none found
  36221. */
  36222. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36223. /**
  36224. * Gets a geometry using its ID
  36225. * @param id defines the geometry's id
  36226. * @return the geometry or null if none found.
  36227. */
  36228. getGeometryByID(id: string): Nullable<Geometry>;
  36229. private _getGeometryByUniqueID;
  36230. /**
  36231. * Add a new geometry to this scene
  36232. * @param geometry defines the geometry to be added to the scene.
  36233. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36234. * @return a boolean defining if the geometry was added or not
  36235. */
  36236. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36237. /**
  36238. * Removes an existing geometry
  36239. * @param geometry defines the geometry to be removed from the scene
  36240. * @return a boolean defining if the geometry was removed or not
  36241. */
  36242. removeGeometry(geometry: Geometry): boolean;
  36243. /**
  36244. * Gets the list of geometries attached to the scene
  36245. * @returns an array of Geometry
  36246. */
  36247. getGeometries(): Geometry[];
  36248. /**
  36249. * Gets the first added mesh found of a given ID
  36250. * @param id defines the id to search for
  36251. * @return the mesh found or null if not found at all
  36252. */
  36253. getMeshByID(id: string): Nullable<AbstractMesh>;
  36254. /**
  36255. * Gets a list of meshes using their id
  36256. * @param id defines the id to search for
  36257. * @returns a list of meshes
  36258. */
  36259. getMeshesByID(id: string): Array<AbstractMesh>;
  36260. /**
  36261. * Gets the first added transform node found of a given ID
  36262. * @param id defines the id to search for
  36263. * @return the found transform node or null if not found at all.
  36264. */
  36265. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36266. /**
  36267. * Gets a transform node with its auto-generated unique id
  36268. * @param uniqueId efines the unique id to search for
  36269. * @return the found transform node or null if not found at all.
  36270. */
  36271. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36272. /**
  36273. * Gets a list of transform nodes using their id
  36274. * @param id defines the id to search for
  36275. * @returns a list of transform nodes
  36276. */
  36277. getTransformNodesByID(id: string): Array<TransformNode>;
  36278. /**
  36279. * Gets a mesh with its auto-generated unique id
  36280. * @param uniqueId defines the unique id to search for
  36281. * @return the found mesh or null if not found at all.
  36282. */
  36283. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36284. /**
  36285. * Gets a the last added mesh using a given id
  36286. * @param id defines the id to search for
  36287. * @return the found mesh or null if not found at all.
  36288. */
  36289. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36290. /**
  36291. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36292. * @param id defines the id to search for
  36293. * @return the found node or null if not found at all
  36294. */
  36295. getLastEntryByID(id: string): Nullable<Node>;
  36296. /**
  36297. * Gets a node (Mesh, Camera, Light) using a given id
  36298. * @param id defines the id to search for
  36299. * @return the found node or null if not found at all
  36300. */
  36301. getNodeByID(id: string): Nullable<Node>;
  36302. /**
  36303. * Gets a node (Mesh, Camera, Light) using a given name
  36304. * @param name defines the name to search for
  36305. * @return the found node or null if not found at all.
  36306. */
  36307. getNodeByName(name: string): Nullable<Node>;
  36308. /**
  36309. * Gets a mesh using a given name
  36310. * @param name defines the name to search for
  36311. * @return the found mesh or null if not found at all.
  36312. */
  36313. getMeshByName(name: string): Nullable<AbstractMesh>;
  36314. /**
  36315. * Gets a transform node using a given name
  36316. * @param name defines the name to search for
  36317. * @return the found transform node or null if not found at all.
  36318. */
  36319. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36320. /**
  36321. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36322. * @param id defines the id to search for
  36323. * @return the found skeleton or null if not found at all.
  36324. */
  36325. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36326. /**
  36327. * Gets a skeleton using a given auto generated unique id
  36328. * @param uniqueId defines the unique id to search for
  36329. * @return the found skeleton or null if not found at all.
  36330. */
  36331. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36332. /**
  36333. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36334. * @param id defines the id to search for
  36335. * @return the found skeleton or null if not found at all.
  36336. */
  36337. getSkeletonById(id: string): Nullable<Skeleton>;
  36338. /**
  36339. * Gets a skeleton using a given name
  36340. * @param name defines the name to search for
  36341. * @return the found skeleton or null if not found at all.
  36342. */
  36343. getSkeletonByName(name: string): Nullable<Skeleton>;
  36344. /**
  36345. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36346. * @param id defines the id to search for
  36347. * @return the found morph target manager or null if not found at all.
  36348. */
  36349. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36350. /**
  36351. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36352. * @param id defines the id to search for
  36353. * @return the found morph target or null if not found at all.
  36354. */
  36355. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36356. /**
  36357. * Gets a boolean indicating if the given mesh is active
  36358. * @param mesh defines the mesh to look for
  36359. * @returns true if the mesh is in the active list
  36360. */
  36361. isActiveMesh(mesh: AbstractMesh): boolean;
  36362. /**
  36363. * Return a unique id as a string which can serve as an identifier for the scene
  36364. */
  36365. get uid(): string;
  36366. /**
  36367. * Add an externaly attached data from its key.
  36368. * This method call will fail and return false, if such key already exists.
  36369. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36370. * @param key the unique key that identifies the data
  36371. * @param data the data object to associate to the key for this Engine instance
  36372. * @return true if no such key were already present and the data was added successfully, false otherwise
  36373. */
  36374. addExternalData<T>(key: string, data: T): boolean;
  36375. /**
  36376. * Get an externaly attached data from its key
  36377. * @param key the unique key that identifies the data
  36378. * @return the associated data, if present (can be null), or undefined if not present
  36379. */
  36380. getExternalData<T>(key: string): Nullable<T>;
  36381. /**
  36382. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36383. * @param key the unique key that identifies the data
  36384. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36385. * @return the associated data, can be null if the factory returned null.
  36386. */
  36387. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36388. /**
  36389. * Remove an externaly attached data from the Engine instance
  36390. * @param key the unique key that identifies the data
  36391. * @return true if the data was successfully removed, false if it doesn't exist
  36392. */
  36393. removeExternalData(key: string): boolean;
  36394. private _evaluateSubMesh;
  36395. /**
  36396. * Clear the processed materials smart array preventing retention point in material dispose.
  36397. */
  36398. freeProcessedMaterials(): void;
  36399. private _preventFreeActiveMeshesAndRenderingGroups;
  36400. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36401. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36402. * when disposing several meshes in a row or a hierarchy of meshes.
  36403. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36404. */
  36405. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36406. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36407. /**
  36408. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36409. */
  36410. freeActiveMeshes(): void;
  36411. /**
  36412. * Clear the info related to rendering groups preventing retention points during dispose.
  36413. */
  36414. freeRenderingGroups(): void;
  36415. /** @hidden */
  36416. _isInIntermediateRendering(): boolean;
  36417. /**
  36418. * Lambda returning the list of potentially active meshes.
  36419. */
  36420. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36421. /**
  36422. * Lambda returning the list of potentially active sub meshes.
  36423. */
  36424. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36425. /**
  36426. * Lambda returning the list of potentially intersecting sub meshes.
  36427. */
  36428. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36429. /**
  36430. * Lambda returning the list of potentially colliding sub meshes.
  36431. */
  36432. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36433. private _activeMeshesFrozen;
  36434. private _skipEvaluateActiveMeshesCompletely;
  36435. /**
  36436. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36437. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36438. * @returns the current scene
  36439. */
  36440. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36441. /**
  36442. * Use this function to restart evaluating active meshes on every frame
  36443. * @returns the current scene
  36444. */
  36445. unfreezeActiveMeshes(): Scene;
  36446. private _evaluateActiveMeshes;
  36447. private _activeMesh;
  36448. /**
  36449. * Update the transform matrix to update from the current active camera
  36450. * @param force defines a boolean used to force the update even if cache is up to date
  36451. */
  36452. updateTransformMatrix(force?: boolean): void;
  36453. private _bindFrameBuffer;
  36454. /** @hidden */
  36455. _allowPostProcessClearColor: boolean;
  36456. /** @hidden */
  36457. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36458. private _processSubCameras;
  36459. private _checkIntersections;
  36460. /** @hidden */
  36461. _advancePhysicsEngineStep(step: number): void;
  36462. /**
  36463. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36464. */
  36465. getDeterministicFrameTime: () => number;
  36466. /** @hidden */
  36467. _animate(): void;
  36468. /** Execute all animations (for a frame) */
  36469. animate(): void;
  36470. /**
  36471. * Render the scene
  36472. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36473. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36474. */
  36475. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36476. /**
  36477. * Freeze all materials
  36478. * A frozen material will not be updatable but should be faster to render
  36479. */
  36480. freezeMaterials(): void;
  36481. /**
  36482. * Unfreeze all materials
  36483. * A frozen material will not be updatable but should be faster to render
  36484. */
  36485. unfreezeMaterials(): void;
  36486. /**
  36487. * Releases all held ressources
  36488. */
  36489. dispose(): void;
  36490. /**
  36491. * Gets if the scene is already disposed
  36492. */
  36493. get isDisposed(): boolean;
  36494. /**
  36495. * Call this function to reduce memory footprint of the scene.
  36496. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36497. */
  36498. clearCachedVertexData(): void;
  36499. /**
  36500. * This function will remove the local cached buffer data from texture.
  36501. * It will save memory but will prevent the texture from being rebuilt
  36502. */
  36503. cleanCachedTextureBuffer(): void;
  36504. /**
  36505. * Get the world extend vectors with an optional filter
  36506. *
  36507. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36508. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36509. */
  36510. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36511. min: Vector3;
  36512. max: Vector3;
  36513. };
  36514. /**
  36515. * Creates a ray that can be used to pick in the scene
  36516. * @param x defines the x coordinate of the origin (on-screen)
  36517. * @param y defines the y coordinate of the origin (on-screen)
  36518. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36519. * @param camera defines the camera to use for the picking
  36520. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36521. * @returns a Ray
  36522. */
  36523. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36524. /**
  36525. * Creates a ray that can be used to pick in the scene
  36526. * @param x defines the x coordinate of the origin (on-screen)
  36527. * @param y defines the y coordinate of the origin (on-screen)
  36528. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36529. * @param result defines the ray where to store the picking ray
  36530. * @param camera defines the camera to use for the picking
  36531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36532. * @returns the current scene
  36533. */
  36534. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36535. /**
  36536. * Creates a ray that can be used to pick in the scene
  36537. * @param x defines the x coordinate of the origin (on-screen)
  36538. * @param y defines the y coordinate of the origin (on-screen)
  36539. * @param camera defines the camera to use for the picking
  36540. * @returns a Ray
  36541. */
  36542. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36543. /**
  36544. * Creates a ray that can be used to pick in the scene
  36545. * @param x defines the x coordinate of the origin (on-screen)
  36546. * @param y defines the y coordinate of the origin (on-screen)
  36547. * @param result defines the ray where to store the picking ray
  36548. * @param camera defines the camera to use for the picking
  36549. * @returns the current scene
  36550. */
  36551. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36552. /** Launch a ray to try to pick a mesh in the scene
  36553. * @param x position on screen
  36554. * @param y position on screen
  36555. * @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
  36556. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36557. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36558. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36559. * @returns a PickingInfo
  36560. */
  36561. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36562. /** Use the given ray to pick a mesh in the scene
  36563. * @param ray The ray to use to pick meshes
  36564. * @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
  36565. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36566. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36567. * @returns a PickingInfo
  36568. */
  36569. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36570. /**
  36571. * Launch a ray to try to pick a mesh in the scene
  36572. * @param x X position on screen
  36573. * @param y Y position on screen
  36574. * @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
  36575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36576. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36577. * @returns an array of PickingInfo
  36578. */
  36579. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36580. /**
  36581. * Launch a ray to try to pick a mesh in the scene
  36582. * @param ray Ray to use
  36583. * @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
  36584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36585. * @returns an array of PickingInfo
  36586. */
  36587. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36588. /**
  36589. * Force the value of meshUnderPointer
  36590. * @param mesh defines the mesh to use
  36591. */
  36592. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36593. /**
  36594. * Gets the mesh under the pointer
  36595. * @returns a Mesh or null if no mesh is under the pointer
  36596. */
  36597. getPointerOverMesh(): Nullable<AbstractMesh>;
  36598. /** @hidden */
  36599. _rebuildGeometries(): void;
  36600. /** @hidden */
  36601. _rebuildTextures(): void;
  36602. private _getByTags;
  36603. /**
  36604. * Get a list of meshes by tags
  36605. * @param tagsQuery defines the tags query to use
  36606. * @param forEach defines a predicate used to filter results
  36607. * @returns an array of Mesh
  36608. */
  36609. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36610. /**
  36611. * Get a list of cameras by tags
  36612. * @param tagsQuery defines the tags query to use
  36613. * @param forEach defines a predicate used to filter results
  36614. * @returns an array of Camera
  36615. */
  36616. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36617. /**
  36618. * Get a list of lights by tags
  36619. * @param tagsQuery defines the tags query to use
  36620. * @param forEach defines a predicate used to filter results
  36621. * @returns an array of Light
  36622. */
  36623. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36624. /**
  36625. * Get a list of materials by tags
  36626. * @param tagsQuery defines the tags query to use
  36627. * @param forEach defines a predicate used to filter results
  36628. * @returns an array of Material
  36629. */
  36630. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36631. /**
  36632. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36633. * This allowed control for front to back rendering or reversly depending of the special needs.
  36634. *
  36635. * @param renderingGroupId The rendering group id corresponding to its index
  36636. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36637. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36638. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36639. */
  36640. 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;
  36641. /**
  36642. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36643. *
  36644. * @param renderingGroupId The rendering group id corresponding to its index
  36645. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36646. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36647. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36648. */
  36649. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36650. /**
  36651. * Gets the current auto clear configuration for one rendering group of the rendering
  36652. * manager.
  36653. * @param index the rendering group index to get the information for
  36654. * @returns The auto clear setup for the requested rendering group
  36655. */
  36656. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36657. private _blockMaterialDirtyMechanism;
  36658. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36659. get blockMaterialDirtyMechanism(): boolean;
  36660. set blockMaterialDirtyMechanism(value: boolean);
  36661. /**
  36662. * Will flag all materials as dirty to trigger new shader compilation
  36663. * @param flag defines the flag used to specify which material part must be marked as dirty
  36664. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36665. */
  36666. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36667. /** @hidden */
  36668. _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;
  36669. /** @hidden */
  36670. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36671. /** @hidden */
  36672. _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;
  36673. /** @hidden */
  36674. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36675. /** @hidden */
  36676. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36677. /** @hidden */
  36678. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36679. }
  36680. }
  36681. declare module BABYLON {
  36682. /**
  36683. * Set of assets to keep when moving a scene into an asset container.
  36684. */
  36685. export class KeepAssets extends AbstractScene {
  36686. }
  36687. /**
  36688. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36689. */
  36690. export class InstantiatedEntries {
  36691. /**
  36692. * List of new root nodes (eg. nodes with no parent)
  36693. */
  36694. rootNodes: TransformNode[];
  36695. /**
  36696. * List of new skeletons
  36697. */
  36698. skeletons: Skeleton[];
  36699. /**
  36700. * List of new animation groups
  36701. */
  36702. animationGroups: AnimationGroup[];
  36703. }
  36704. /**
  36705. * Container with a set of assets that can be added or removed from a scene.
  36706. */
  36707. export class AssetContainer extends AbstractScene {
  36708. /**
  36709. * The scene the AssetContainer belongs to.
  36710. */
  36711. scene: Scene;
  36712. /**
  36713. * Instantiates an AssetContainer.
  36714. * @param scene The scene the AssetContainer belongs to.
  36715. */
  36716. constructor(scene: Scene);
  36717. /**
  36718. * Instantiate or clone all meshes and add the new ones to the scene.
  36719. * Skeletons and animation groups will all be cloned
  36720. * @param nameFunction defines an optional function used to get new names for clones
  36721. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36722. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36723. */
  36724. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36725. /**
  36726. * Adds all the assets from the container to the scene.
  36727. */
  36728. addAllToScene(): void;
  36729. /**
  36730. * Removes all the assets in the container from the scene
  36731. */
  36732. removeAllFromScene(): void;
  36733. /**
  36734. * Disposes all the assets in the container
  36735. */
  36736. dispose(): void;
  36737. private _moveAssets;
  36738. /**
  36739. * Removes all the assets contained in the scene and adds them to the container.
  36740. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36741. */
  36742. moveAllFromScene(keepAssets?: KeepAssets): void;
  36743. /**
  36744. * 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.
  36745. * @returns the root mesh
  36746. */
  36747. createRootMesh(): Mesh;
  36748. /**
  36749. * Merge animations from this asset container into a scene
  36750. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36751. * @param animatables set of animatables to retarget to a node from the scene
  36752. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36753. */
  36754. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36755. }
  36756. }
  36757. declare module BABYLON {
  36758. /**
  36759. * Defines how the parser contract is defined.
  36760. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36761. */
  36762. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36763. /**
  36764. * Defines how the individual parser contract is defined.
  36765. * These parser can parse an individual asset
  36766. */
  36767. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36768. /**
  36769. * Base class of the scene acting as a container for the different elements composing a scene.
  36770. * This class is dynamically extended by the different components of the scene increasing
  36771. * flexibility and reducing coupling
  36772. */
  36773. export abstract class AbstractScene {
  36774. /**
  36775. * Stores the list of available parsers in the application.
  36776. */
  36777. private static _BabylonFileParsers;
  36778. /**
  36779. * Stores the list of available individual parsers in the application.
  36780. */
  36781. private static _IndividualBabylonFileParsers;
  36782. /**
  36783. * Adds a parser in the list of available ones
  36784. * @param name Defines the name of the parser
  36785. * @param parser Defines the parser to add
  36786. */
  36787. static AddParser(name: string, parser: BabylonFileParser): void;
  36788. /**
  36789. * Gets a general parser from the list of avaialble ones
  36790. * @param name Defines the name of the parser
  36791. * @returns the requested parser or null
  36792. */
  36793. static GetParser(name: string): Nullable<BabylonFileParser>;
  36794. /**
  36795. * Adds n individual parser in the list of available ones
  36796. * @param name Defines the name of the parser
  36797. * @param parser Defines the parser to add
  36798. */
  36799. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36800. /**
  36801. * Gets an individual parser from the list of avaialble ones
  36802. * @param name Defines the name of the parser
  36803. * @returns the requested parser or null
  36804. */
  36805. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36806. /**
  36807. * Parser json data and populate both a scene and its associated container object
  36808. * @param jsonData Defines the data to parse
  36809. * @param scene Defines the scene to parse the data for
  36810. * @param container Defines the container attached to the parsing sequence
  36811. * @param rootUrl Defines the root url of the data
  36812. */
  36813. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36814. /**
  36815. * Gets the list of root nodes (ie. nodes with no parent)
  36816. */
  36817. rootNodes: Node[];
  36818. /** All of the cameras added to this scene
  36819. * @see http://doc.babylonjs.com/babylon101/cameras
  36820. */
  36821. cameras: Camera[];
  36822. /**
  36823. * All of the lights added to this scene
  36824. * @see http://doc.babylonjs.com/babylon101/lights
  36825. */
  36826. lights: Light[];
  36827. /**
  36828. * All of the (abstract) meshes added to this scene
  36829. */
  36830. meshes: AbstractMesh[];
  36831. /**
  36832. * The list of skeletons added to the scene
  36833. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36834. */
  36835. skeletons: Skeleton[];
  36836. /**
  36837. * All of the particle systems added to this scene
  36838. * @see http://doc.babylonjs.com/babylon101/particles
  36839. */
  36840. particleSystems: IParticleSystem[];
  36841. /**
  36842. * Gets a list of Animations associated with the scene
  36843. */
  36844. animations: Animation[];
  36845. /**
  36846. * All of the animation groups added to this scene
  36847. * @see http://doc.babylonjs.com/how_to/group
  36848. */
  36849. animationGroups: AnimationGroup[];
  36850. /**
  36851. * All of the multi-materials added to this scene
  36852. * @see http://doc.babylonjs.com/how_to/multi_materials
  36853. */
  36854. multiMaterials: MultiMaterial[];
  36855. /**
  36856. * All of the materials added to this scene
  36857. * In the context of a Scene, it is not supposed to be modified manually.
  36858. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36859. * Note also that the order of the Material within the array is not significant and might change.
  36860. * @see http://doc.babylonjs.com/babylon101/materials
  36861. */
  36862. materials: Material[];
  36863. /**
  36864. * The list of morph target managers added to the scene
  36865. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36866. */
  36867. morphTargetManagers: MorphTargetManager[];
  36868. /**
  36869. * The list of geometries used in the scene.
  36870. */
  36871. geometries: Geometry[];
  36872. /**
  36873. * All of the tranform nodes added to this scene
  36874. * In the context of a Scene, it is not supposed to be modified manually.
  36875. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36876. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36877. * @see http://doc.babylonjs.com/how_to/transformnode
  36878. */
  36879. transformNodes: TransformNode[];
  36880. /**
  36881. * ActionManagers available on the scene.
  36882. */
  36883. actionManagers: AbstractActionManager[];
  36884. /**
  36885. * Textures to keep.
  36886. */
  36887. textures: BaseTexture[];
  36888. /**
  36889. * Environment texture for the scene
  36890. */
  36891. environmentTexture: Nullable<BaseTexture>;
  36892. /**
  36893. * @returns all meshes, lights, cameras, transformNodes and bones
  36894. */
  36895. getNodes(): Array<Node>;
  36896. }
  36897. }
  36898. declare module BABYLON {
  36899. /**
  36900. * Interface used to define options for Sound class
  36901. */
  36902. export interface ISoundOptions {
  36903. /**
  36904. * Does the sound autoplay once loaded.
  36905. */
  36906. autoplay?: boolean;
  36907. /**
  36908. * Does the sound loop after it finishes playing once.
  36909. */
  36910. loop?: boolean;
  36911. /**
  36912. * Sound's volume
  36913. */
  36914. volume?: number;
  36915. /**
  36916. * Is it a spatial sound?
  36917. */
  36918. spatialSound?: boolean;
  36919. /**
  36920. * Maximum distance to hear that sound
  36921. */
  36922. maxDistance?: number;
  36923. /**
  36924. * Uses user defined attenuation function
  36925. */
  36926. useCustomAttenuation?: boolean;
  36927. /**
  36928. * Define the roll off factor of spatial sounds.
  36929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36930. */
  36931. rolloffFactor?: number;
  36932. /**
  36933. * Define the reference distance the sound should be heard perfectly.
  36934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36935. */
  36936. refDistance?: number;
  36937. /**
  36938. * Define the distance attenuation model the sound will follow.
  36939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36940. */
  36941. distanceModel?: string;
  36942. /**
  36943. * Defines the playback speed (1 by default)
  36944. */
  36945. playbackRate?: number;
  36946. /**
  36947. * Defines if the sound is from a streaming source
  36948. */
  36949. streaming?: boolean;
  36950. /**
  36951. * Defines an optional length (in seconds) inside the sound file
  36952. */
  36953. length?: number;
  36954. /**
  36955. * Defines an optional offset (in seconds) inside the sound file
  36956. */
  36957. offset?: number;
  36958. /**
  36959. * If true, URLs will not be required to state the audio file codec to use.
  36960. */
  36961. skipCodecCheck?: boolean;
  36962. }
  36963. /**
  36964. * Defines a sound that can be played in the application.
  36965. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36967. */
  36968. export class Sound {
  36969. /**
  36970. * The name of the sound in the scene.
  36971. */
  36972. name: string;
  36973. /**
  36974. * Does the sound autoplay once loaded.
  36975. */
  36976. autoplay: boolean;
  36977. /**
  36978. * Does the sound loop after it finishes playing once.
  36979. */
  36980. loop: boolean;
  36981. /**
  36982. * Does the sound use a custom attenuation curve to simulate the falloff
  36983. * happening when the source gets further away from the camera.
  36984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36985. */
  36986. useCustomAttenuation: boolean;
  36987. /**
  36988. * The sound track id this sound belongs to.
  36989. */
  36990. soundTrackId: number;
  36991. /**
  36992. * Is this sound currently played.
  36993. */
  36994. isPlaying: boolean;
  36995. /**
  36996. * Is this sound currently paused.
  36997. */
  36998. isPaused: boolean;
  36999. /**
  37000. * Does this sound enables spatial sound.
  37001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37002. */
  37003. spatialSound: boolean;
  37004. /**
  37005. * Define the reference distance the sound should be heard perfectly.
  37006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37007. */
  37008. refDistance: number;
  37009. /**
  37010. * Define the roll off factor of spatial sounds.
  37011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37012. */
  37013. rolloffFactor: number;
  37014. /**
  37015. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37017. */
  37018. maxDistance: number;
  37019. /**
  37020. * Define the distance attenuation model the sound will follow.
  37021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37022. */
  37023. distanceModel: string;
  37024. /**
  37025. * @hidden
  37026. * Back Compat
  37027. **/
  37028. onended: () => any;
  37029. /**
  37030. * Observable event when the current playing sound finishes.
  37031. */
  37032. onEndedObservable: Observable<Sound>;
  37033. private _panningModel;
  37034. private _playbackRate;
  37035. private _streaming;
  37036. private _startTime;
  37037. private _startOffset;
  37038. private _position;
  37039. /** @hidden */
  37040. _positionInEmitterSpace: boolean;
  37041. private _localDirection;
  37042. private _volume;
  37043. private _isReadyToPlay;
  37044. private _isDirectional;
  37045. private _readyToPlayCallback;
  37046. private _audioBuffer;
  37047. private _soundSource;
  37048. private _streamingSource;
  37049. private _soundPanner;
  37050. private _soundGain;
  37051. private _inputAudioNode;
  37052. private _outputAudioNode;
  37053. private _coneInnerAngle;
  37054. private _coneOuterAngle;
  37055. private _coneOuterGain;
  37056. private _scene;
  37057. private _connectedTransformNode;
  37058. private _customAttenuationFunction;
  37059. private _registerFunc;
  37060. private _isOutputConnected;
  37061. private _htmlAudioElement;
  37062. private _urlType;
  37063. private _length?;
  37064. private _offset?;
  37065. /** @hidden */
  37066. static _SceneComponentInitialization: (scene: Scene) => void;
  37067. /**
  37068. * Create a sound and attach it to a scene
  37069. * @param name Name of your sound
  37070. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37071. * @param scene defines the scene the sound belongs to
  37072. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37073. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37074. */
  37075. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37076. /**
  37077. * Release the sound and its associated resources
  37078. */
  37079. dispose(): void;
  37080. /**
  37081. * Gets if the sounds is ready to be played or not.
  37082. * @returns true if ready, otherwise false
  37083. */
  37084. isReady(): boolean;
  37085. private _soundLoaded;
  37086. /**
  37087. * Sets the data of the sound from an audiobuffer
  37088. * @param audioBuffer The audioBuffer containing the data
  37089. */
  37090. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37091. /**
  37092. * Updates the current sounds options such as maxdistance, loop...
  37093. * @param options A JSON object containing values named as the object properties
  37094. */
  37095. updateOptions(options: ISoundOptions): void;
  37096. private _createSpatialParameters;
  37097. private _updateSpatialParameters;
  37098. /**
  37099. * Switch the panning model to HRTF:
  37100. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37102. */
  37103. switchPanningModelToHRTF(): void;
  37104. /**
  37105. * Switch the panning model to Equal Power:
  37106. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37108. */
  37109. switchPanningModelToEqualPower(): void;
  37110. private _switchPanningModel;
  37111. /**
  37112. * Connect this sound to a sound track audio node like gain...
  37113. * @param soundTrackAudioNode the sound track audio node to connect to
  37114. */
  37115. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37116. /**
  37117. * Transform this sound into a directional source
  37118. * @param coneInnerAngle Size of the inner cone in degree
  37119. * @param coneOuterAngle Size of the outer cone in degree
  37120. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37121. */
  37122. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37123. /**
  37124. * Gets or sets the inner angle for the directional cone.
  37125. */
  37126. get directionalConeInnerAngle(): number;
  37127. /**
  37128. * Gets or sets the inner angle for the directional cone.
  37129. */
  37130. set directionalConeInnerAngle(value: number);
  37131. /**
  37132. * Gets or sets the outer angle for the directional cone.
  37133. */
  37134. get directionalConeOuterAngle(): number;
  37135. /**
  37136. * Gets or sets the outer angle for the directional cone.
  37137. */
  37138. set directionalConeOuterAngle(value: number);
  37139. /**
  37140. * Sets the position of the emitter if spatial sound is enabled
  37141. * @param newPosition Defines the new posisiton
  37142. */
  37143. setPosition(newPosition: Vector3): void;
  37144. /**
  37145. * Sets the local direction of the emitter if spatial sound is enabled
  37146. * @param newLocalDirection Defines the new local direction
  37147. */
  37148. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37149. private _updateDirection;
  37150. /** @hidden */
  37151. updateDistanceFromListener(): void;
  37152. /**
  37153. * Sets a new custom attenuation function for the sound.
  37154. * @param callback Defines the function used for the attenuation
  37155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37156. */
  37157. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37158. /**
  37159. * Play the sound
  37160. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37161. * @param offset (optional) Start the sound at a specific time in seconds
  37162. * @param length (optional) Sound duration (in seconds)
  37163. */
  37164. play(time?: number, offset?: number, length?: number): void;
  37165. private _onended;
  37166. /**
  37167. * Stop the sound
  37168. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37169. */
  37170. stop(time?: number): void;
  37171. /**
  37172. * Put the sound in pause
  37173. */
  37174. pause(): void;
  37175. /**
  37176. * Sets a dedicated volume for this sounds
  37177. * @param newVolume Define the new volume of the sound
  37178. * @param time Define time for gradual change to new volume
  37179. */
  37180. setVolume(newVolume: number, time?: number): void;
  37181. /**
  37182. * Set the sound play back rate
  37183. * @param newPlaybackRate Define the playback rate the sound should be played at
  37184. */
  37185. setPlaybackRate(newPlaybackRate: number): void;
  37186. /**
  37187. * Gets the volume of the sound.
  37188. * @returns the volume of the sound
  37189. */
  37190. getVolume(): number;
  37191. /**
  37192. * Attach the sound to a dedicated mesh
  37193. * @param transformNode The transform node to connect the sound with
  37194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37195. */
  37196. attachToMesh(transformNode: TransformNode): void;
  37197. /**
  37198. * Detach the sound from the previously attached mesh
  37199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37200. */
  37201. detachFromMesh(): void;
  37202. private _onRegisterAfterWorldMatrixUpdate;
  37203. /**
  37204. * Clone the current sound in the scene.
  37205. * @returns the new sound clone
  37206. */
  37207. clone(): Nullable<Sound>;
  37208. /**
  37209. * Gets the current underlying audio buffer containing the data
  37210. * @returns the audio buffer
  37211. */
  37212. getAudioBuffer(): Nullable<AudioBuffer>;
  37213. /**
  37214. * Serializes the Sound in a JSON representation
  37215. * @returns the JSON representation of the sound
  37216. */
  37217. serialize(): any;
  37218. /**
  37219. * Parse a JSON representation of a sound to innstantiate in a given scene
  37220. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37221. * @param scene Define the scene the new parsed sound should be created in
  37222. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37223. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37224. * @returns the newly parsed sound
  37225. */
  37226. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /**
  37231. * This defines an action helpful to play a defined sound on a triggered action.
  37232. */
  37233. export class PlaySoundAction extends Action {
  37234. private _sound;
  37235. /**
  37236. * Instantiate the action
  37237. * @param triggerOptions defines the trigger options
  37238. * @param sound defines the sound to play
  37239. * @param condition defines the trigger related conditions
  37240. */
  37241. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37242. /** @hidden */
  37243. _prepare(): void;
  37244. /**
  37245. * Execute the action and play the sound.
  37246. */
  37247. execute(): void;
  37248. /**
  37249. * Serializes the actions and its related information.
  37250. * @param parent defines the object to serialize in
  37251. * @returns the serialized object
  37252. */
  37253. serialize(parent: any): any;
  37254. }
  37255. /**
  37256. * This defines an action helpful to stop a defined sound on a triggered action.
  37257. */
  37258. export class StopSoundAction extends Action {
  37259. private _sound;
  37260. /**
  37261. * Instantiate the action
  37262. * @param triggerOptions defines the trigger options
  37263. * @param sound defines the sound to stop
  37264. * @param condition defines the trigger related conditions
  37265. */
  37266. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37267. /** @hidden */
  37268. _prepare(): void;
  37269. /**
  37270. * Execute the action and stop the sound.
  37271. */
  37272. execute(): void;
  37273. /**
  37274. * Serializes the actions and its related information.
  37275. * @param parent defines the object to serialize in
  37276. * @returns the serialized object
  37277. */
  37278. serialize(parent: any): any;
  37279. }
  37280. }
  37281. declare module BABYLON {
  37282. /**
  37283. * This defines an action responsible to change the value of a property
  37284. * by interpolating between its current value and the newly set one once triggered.
  37285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37286. */
  37287. export class InterpolateValueAction extends Action {
  37288. /**
  37289. * Defines the path of the property where the value should be interpolated
  37290. */
  37291. propertyPath: string;
  37292. /**
  37293. * Defines the target value at the end of the interpolation.
  37294. */
  37295. value: any;
  37296. /**
  37297. * Defines the time it will take for the property to interpolate to the value.
  37298. */
  37299. duration: number;
  37300. /**
  37301. * Defines if the other scene animations should be stopped when the action has been triggered
  37302. */
  37303. stopOtherAnimations?: boolean;
  37304. /**
  37305. * Defines a callback raised once the interpolation animation has been done.
  37306. */
  37307. onInterpolationDone?: () => void;
  37308. /**
  37309. * Observable triggered once the interpolation animation has been done.
  37310. */
  37311. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37312. private _target;
  37313. private _effectiveTarget;
  37314. private _property;
  37315. /**
  37316. * Instantiate the action
  37317. * @param triggerOptions defines the trigger options
  37318. * @param target defines the object containing the value to interpolate
  37319. * @param propertyPath defines the path to the property in the target object
  37320. * @param value defines the target value at the end of the interpolation
  37321. * @param duration deines the time it will take for the property to interpolate to the value.
  37322. * @param condition defines the trigger related conditions
  37323. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37324. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37325. */
  37326. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37327. /** @hidden */
  37328. _prepare(): void;
  37329. /**
  37330. * Execute the action starts the value interpolation.
  37331. */
  37332. execute(): void;
  37333. /**
  37334. * Serializes the actions and its related information.
  37335. * @param parent defines the object to serialize in
  37336. * @returns the serialized object
  37337. */
  37338. serialize(parent: any): any;
  37339. }
  37340. }
  37341. declare module BABYLON {
  37342. /**
  37343. * Options allowed during the creation of a sound track.
  37344. */
  37345. export interface ISoundTrackOptions {
  37346. /**
  37347. * The volume the sound track should take during creation
  37348. */
  37349. volume?: number;
  37350. /**
  37351. * Define if the sound track is the main sound track of the scene
  37352. */
  37353. mainTrack?: boolean;
  37354. }
  37355. /**
  37356. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37357. * It will be also used in a future release to apply effects on a specific track.
  37358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37359. */
  37360. export class SoundTrack {
  37361. /**
  37362. * The unique identifier of the sound track in the scene.
  37363. */
  37364. id: number;
  37365. /**
  37366. * The list of sounds included in the sound track.
  37367. */
  37368. soundCollection: Array<Sound>;
  37369. private _outputAudioNode;
  37370. private _scene;
  37371. private _connectedAnalyser;
  37372. private _options;
  37373. private _isInitialized;
  37374. /**
  37375. * Creates a new sound track.
  37376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37377. * @param scene Define the scene the sound track belongs to
  37378. * @param options
  37379. */
  37380. constructor(scene: Scene, options?: ISoundTrackOptions);
  37381. private _initializeSoundTrackAudioGraph;
  37382. /**
  37383. * Release the sound track and its associated resources
  37384. */
  37385. dispose(): void;
  37386. /**
  37387. * Adds a sound to this sound track
  37388. * @param sound define the cound to add
  37389. * @ignoreNaming
  37390. */
  37391. AddSound(sound: Sound): void;
  37392. /**
  37393. * Removes a sound to this sound track
  37394. * @param sound define the cound to remove
  37395. * @ignoreNaming
  37396. */
  37397. RemoveSound(sound: Sound): void;
  37398. /**
  37399. * Set a global volume for the full sound track.
  37400. * @param newVolume Define the new volume of the sound track
  37401. */
  37402. setVolume(newVolume: number): void;
  37403. /**
  37404. * Switch the panning model to HRTF:
  37405. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37407. */
  37408. switchPanningModelToHRTF(): void;
  37409. /**
  37410. * Switch the panning model to Equal Power:
  37411. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37413. */
  37414. switchPanningModelToEqualPower(): void;
  37415. /**
  37416. * Connect the sound track to an audio analyser allowing some amazing
  37417. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37419. * @param analyser The analyser to connect to the engine
  37420. */
  37421. connectToAnalyser(analyser: Analyser): void;
  37422. }
  37423. }
  37424. declare module BABYLON {
  37425. interface AbstractScene {
  37426. /**
  37427. * The list of sounds used in the scene.
  37428. */
  37429. sounds: Nullable<Array<Sound>>;
  37430. }
  37431. interface Scene {
  37432. /**
  37433. * @hidden
  37434. * Backing field
  37435. */
  37436. _mainSoundTrack: SoundTrack;
  37437. /**
  37438. * The main sound track played by the scene.
  37439. * It cotains your primary collection of sounds.
  37440. */
  37441. mainSoundTrack: SoundTrack;
  37442. /**
  37443. * The list of sound tracks added to the scene
  37444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37445. */
  37446. soundTracks: Nullable<Array<SoundTrack>>;
  37447. /**
  37448. * Gets a sound using a given name
  37449. * @param name defines the name to search for
  37450. * @return the found sound or null if not found at all.
  37451. */
  37452. getSoundByName(name: string): Nullable<Sound>;
  37453. /**
  37454. * Gets or sets if audio support is enabled
  37455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37456. */
  37457. audioEnabled: boolean;
  37458. /**
  37459. * Gets or sets if audio will be output to headphones
  37460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37461. */
  37462. headphone: boolean;
  37463. /**
  37464. * Gets or sets custom audio listener position provider
  37465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37466. */
  37467. audioListenerPositionProvider: Nullable<() => Vector3>;
  37468. /**
  37469. * Gets or sets a refresh rate when using 3D audio positioning
  37470. */
  37471. audioPositioningRefreshRate: number;
  37472. }
  37473. /**
  37474. * Defines the sound scene component responsible to manage any sounds
  37475. * in a given scene.
  37476. */
  37477. export class AudioSceneComponent implements ISceneSerializableComponent {
  37478. /**
  37479. * The component name helpfull to identify the component in the list of scene components.
  37480. */
  37481. readonly name: string;
  37482. /**
  37483. * The scene the component belongs to.
  37484. */
  37485. scene: Scene;
  37486. private _audioEnabled;
  37487. /**
  37488. * Gets whether audio is enabled or not.
  37489. * Please use related enable/disable method to switch state.
  37490. */
  37491. get audioEnabled(): boolean;
  37492. private _headphone;
  37493. /**
  37494. * Gets whether audio is outputing to headphone or not.
  37495. * Please use the according Switch methods to change output.
  37496. */
  37497. get headphone(): boolean;
  37498. /**
  37499. * Gets or sets a refresh rate when using 3D audio positioning
  37500. */
  37501. audioPositioningRefreshRate: number;
  37502. private _audioListenerPositionProvider;
  37503. /**
  37504. * Gets the current audio listener position provider
  37505. */
  37506. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37507. /**
  37508. * Sets a custom listener position for all sounds in the scene
  37509. * By default, this is the position of the first active camera
  37510. */
  37511. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37512. /**
  37513. * Creates a new instance of the component for the given scene
  37514. * @param scene Defines the scene to register the component in
  37515. */
  37516. constructor(scene: Scene);
  37517. /**
  37518. * Registers the component in a given scene
  37519. */
  37520. register(): void;
  37521. /**
  37522. * Rebuilds the elements related to this component in case of
  37523. * context lost for instance.
  37524. */
  37525. rebuild(): void;
  37526. /**
  37527. * Serializes the component data to the specified json object
  37528. * @param serializationObject The object to serialize to
  37529. */
  37530. serialize(serializationObject: any): void;
  37531. /**
  37532. * Adds all the elements from the container to the scene
  37533. * @param container the container holding the elements
  37534. */
  37535. addFromContainer(container: AbstractScene): void;
  37536. /**
  37537. * Removes all the elements in the container from the scene
  37538. * @param container contains the elements to remove
  37539. * @param dispose if the removed element should be disposed (default: false)
  37540. */
  37541. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37542. /**
  37543. * Disposes the component and the associated ressources.
  37544. */
  37545. dispose(): void;
  37546. /**
  37547. * Disables audio in the associated scene.
  37548. */
  37549. disableAudio(): void;
  37550. /**
  37551. * Enables audio in the associated scene.
  37552. */
  37553. enableAudio(): void;
  37554. /**
  37555. * Switch audio to headphone output.
  37556. */
  37557. switchAudioModeForHeadphones(): void;
  37558. /**
  37559. * Switch audio to normal speakers.
  37560. */
  37561. switchAudioModeForNormalSpeakers(): void;
  37562. private _cachedCameraDirection;
  37563. private _cachedCameraPosition;
  37564. private _lastCheck;
  37565. private _afterRender;
  37566. }
  37567. }
  37568. declare module BABYLON {
  37569. /**
  37570. * Wraps one or more Sound objects and selects one with random weight for playback.
  37571. */
  37572. export class WeightedSound {
  37573. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37574. loop: boolean;
  37575. private _coneInnerAngle;
  37576. private _coneOuterAngle;
  37577. private _volume;
  37578. /** A Sound is currently playing. */
  37579. isPlaying: boolean;
  37580. /** A Sound is currently paused. */
  37581. isPaused: boolean;
  37582. private _sounds;
  37583. private _weights;
  37584. private _currentIndex?;
  37585. /**
  37586. * Creates a new WeightedSound from the list of sounds given.
  37587. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37588. * @param sounds Array of Sounds that will be selected from.
  37589. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37590. */
  37591. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37592. /**
  37593. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37594. */
  37595. get directionalConeInnerAngle(): number;
  37596. /**
  37597. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37598. */
  37599. set directionalConeInnerAngle(value: number);
  37600. /**
  37601. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37602. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37603. */
  37604. get directionalConeOuterAngle(): number;
  37605. /**
  37606. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37607. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37608. */
  37609. set directionalConeOuterAngle(value: number);
  37610. /**
  37611. * Playback volume.
  37612. */
  37613. get volume(): number;
  37614. /**
  37615. * Playback volume.
  37616. */
  37617. set volume(value: number);
  37618. private _onended;
  37619. /**
  37620. * Suspend playback
  37621. */
  37622. pause(): void;
  37623. /**
  37624. * Stop playback
  37625. */
  37626. stop(): void;
  37627. /**
  37628. * Start playback.
  37629. * @param startOffset Position the clip head at a specific time in seconds.
  37630. */
  37631. play(startOffset?: number): void;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. /**
  37636. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37638. */
  37639. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37640. /**
  37641. * Gets the name of the behavior.
  37642. */
  37643. get name(): string;
  37644. /**
  37645. * The easing function used by animations
  37646. */
  37647. static EasingFunction: BackEase;
  37648. /**
  37649. * The easing mode used by animations
  37650. */
  37651. static EasingMode: number;
  37652. /**
  37653. * The duration of the animation, in milliseconds
  37654. */
  37655. transitionDuration: number;
  37656. /**
  37657. * Length of the distance animated by the transition when lower radius is reached
  37658. */
  37659. lowerRadiusTransitionRange: number;
  37660. /**
  37661. * Length of the distance animated by the transition when upper radius is reached
  37662. */
  37663. upperRadiusTransitionRange: number;
  37664. private _autoTransitionRange;
  37665. /**
  37666. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37667. */
  37668. get autoTransitionRange(): boolean;
  37669. /**
  37670. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37671. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37672. */
  37673. set autoTransitionRange(value: boolean);
  37674. private _attachedCamera;
  37675. private _onAfterCheckInputsObserver;
  37676. private _onMeshTargetChangedObserver;
  37677. /**
  37678. * Initializes the behavior.
  37679. */
  37680. init(): void;
  37681. /**
  37682. * Attaches the behavior to its arc rotate camera.
  37683. * @param camera Defines the camera to attach the behavior to
  37684. */
  37685. attach(camera: ArcRotateCamera): void;
  37686. /**
  37687. * Detaches the behavior from its current arc rotate camera.
  37688. */
  37689. detach(): void;
  37690. private _radiusIsAnimating;
  37691. private _radiusBounceTransition;
  37692. private _animatables;
  37693. private _cachedWheelPrecision;
  37694. /**
  37695. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37696. * @param radiusLimit The limit to check against.
  37697. * @return Bool to indicate if at limit.
  37698. */
  37699. private _isRadiusAtLimit;
  37700. /**
  37701. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37702. * @param radiusDelta The delta by which to animate to. Can be negative.
  37703. */
  37704. private _applyBoundRadiusAnimation;
  37705. /**
  37706. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37707. */
  37708. protected _clearAnimationLocks(): void;
  37709. /**
  37710. * Stops and removes all animations that have been applied to the camera
  37711. */
  37712. stopAllAnimations(): void;
  37713. }
  37714. }
  37715. declare module BABYLON {
  37716. /**
  37717. * 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.
  37718. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37719. */
  37720. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37721. /**
  37722. * Gets the name of the behavior.
  37723. */
  37724. get name(): string;
  37725. private _mode;
  37726. private _radiusScale;
  37727. private _positionScale;
  37728. private _defaultElevation;
  37729. private _elevationReturnTime;
  37730. private _elevationReturnWaitTime;
  37731. private _zoomStopsAnimation;
  37732. private _framingTime;
  37733. /**
  37734. * The easing function used by animations
  37735. */
  37736. static EasingFunction: ExponentialEase;
  37737. /**
  37738. * The easing mode used by animations
  37739. */
  37740. static EasingMode: number;
  37741. /**
  37742. * Sets the current mode used by the behavior
  37743. */
  37744. set mode(mode: number);
  37745. /**
  37746. * Gets current mode used by the behavior.
  37747. */
  37748. get mode(): number;
  37749. /**
  37750. * Sets the scale applied to the radius (1 by default)
  37751. */
  37752. set radiusScale(radius: number);
  37753. /**
  37754. * Gets the scale applied to the radius
  37755. */
  37756. get radiusScale(): number;
  37757. /**
  37758. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37759. */
  37760. set positionScale(scale: number);
  37761. /**
  37762. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37763. */
  37764. get positionScale(): number;
  37765. /**
  37766. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37767. * behaviour is triggered, in radians.
  37768. */
  37769. set defaultElevation(elevation: number);
  37770. /**
  37771. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37772. * behaviour is triggered, in radians.
  37773. */
  37774. get defaultElevation(): number;
  37775. /**
  37776. * Sets the time (in milliseconds) taken to return to the default beta position.
  37777. * Negative value indicates camera should not return to default.
  37778. */
  37779. set elevationReturnTime(speed: number);
  37780. /**
  37781. * Gets the time (in milliseconds) taken to return to the default beta position.
  37782. * Negative value indicates camera should not return to default.
  37783. */
  37784. get elevationReturnTime(): number;
  37785. /**
  37786. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37787. */
  37788. set elevationReturnWaitTime(time: number);
  37789. /**
  37790. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37791. */
  37792. get elevationReturnWaitTime(): number;
  37793. /**
  37794. * Sets the flag that indicates if user zooming should stop animation.
  37795. */
  37796. set zoomStopsAnimation(flag: boolean);
  37797. /**
  37798. * Gets the flag that indicates if user zooming should stop animation.
  37799. */
  37800. get zoomStopsAnimation(): boolean;
  37801. /**
  37802. * Sets the transition time when framing the mesh, in milliseconds
  37803. */
  37804. set framingTime(time: number);
  37805. /**
  37806. * Gets the transition time when framing the mesh, in milliseconds
  37807. */
  37808. get framingTime(): number;
  37809. /**
  37810. * Define if the behavior should automatically change the configured
  37811. * camera limits and sensibilities.
  37812. */
  37813. autoCorrectCameraLimitsAndSensibility: boolean;
  37814. private _onPrePointerObservableObserver;
  37815. private _onAfterCheckInputsObserver;
  37816. private _onMeshTargetChangedObserver;
  37817. private _attachedCamera;
  37818. private _isPointerDown;
  37819. private _lastInteractionTime;
  37820. /**
  37821. * Initializes the behavior.
  37822. */
  37823. init(): void;
  37824. /**
  37825. * Attaches the behavior to its arc rotate camera.
  37826. * @param camera Defines the camera to attach the behavior to
  37827. */
  37828. attach(camera: ArcRotateCamera): void;
  37829. /**
  37830. * Detaches the behavior from its current arc rotate camera.
  37831. */
  37832. detach(): void;
  37833. private _animatables;
  37834. private _betaIsAnimating;
  37835. private _betaTransition;
  37836. private _radiusTransition;
  37837. private _vectorTransition;
  37838. /**
  37839. * Targets the given mesh and updates zoom level accordingly.
  37840. * @param mesh The mesh to target.
  37841. * @param radius Optional. If a cached radius position already exists, overrides default.
  37842. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37843. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37844. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37845. */
  37846. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37847. /**
  37848. * Targets the given mesh with its children and updates zoom level accordingly.
  37849. * @param mesh The mesh to target.
  37850. * @param radius Optional. If a cached radius position already exists, overrides default.
  37851. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37852. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37853. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37854. */
  37855. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37856. /**
  37857. * Targets the given meshes with their children and updates zoom level accordingly.
  37858. * @param meshes The mesh to target.
  37859. * @param radius Optional. If a cached radius position already exists, overrides default.
  37860. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37861. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37862. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37863. */
  37864. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37865. /**
  37866. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37867. * @param minimumWorld Determines the smaller position of the bounding box extend
  37868. * @param maximumWorld Determines the bigger position of the bounding box extend
  37869. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37870. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37871. */
  37872. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37873. /**
  37874. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37875. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37876. * frustum width.
  37877. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37878. * to fully enclose the mesh in the viewing frustum.
  37879. */
  37880. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37881. /**
  37882. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37883. * is automatically returned to its default position (expected to be above ground plane).
  37884. */
  37885. private _maintainCameraAboveGround;
  37886. /**
  37887. * Returns the frustum slope based on the canvas ratio and camera FOV
  37888. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37889. */
  37890. private _getFrustumSlope;
  37891. /**
  37892. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37893. */
  37894. private _clearAnimationLocks;
  37895. /**
  37896. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37897. */
  37898. private _applyUserInteraction;
  37899. /**
  37900. * Stops and removes all animations that have been applied to the camera
  37901. */
  37902. stopAllAnimations(): void;
  37903. /**
  37904. * Gets a value indicating if the user is moving the camera
  37905. */
  37906. get isUserIsMoving(): boolean;
  37907. /**
  37908. * The camera can move all the way towards the mesh.
  37909. */
  37910. static IgnoreBoundsSizeMode: number;
  37911. /**
  37912. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37913. */
  37914. static FitFrustumSidesMode: number;
  37915. }
  37916. }
  37917. declare module BABYLON {
  37918. /**
  37919. * Base class for Camera Pointer Inputs.
  37920. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37921. * for example usage.
  37922. */
  37923. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37924. /**
  37925. * Defines the camera the input is attached to.
  37926. */
  37927. abstract camera: Camera;
  37928. /**
  37929. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37930. */
  37931. protected _altKey: boolean;
  37932. protected _ctrlKey: boolean;
  37933. protected _metaKey: boolean;
  37934. protected _shiftKey: boolean;
  37935. /**
  37936. * Which mouse buttons were pressed at time of last mouse event.
  37937. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37938. */
  37939. protected _buttonsPressed: number;
  37940. /**
  37941. * Defines the buttons associated with the input to handle camera move.
  37942. */
  37943. buttons: number[];
  37944. /**
  37945. * Attach the input controls to a specific dom element to get the input from.
  37946. * @param element Defines the element the controls should be listened from
  37947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37948. */
  37949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37950. /**
  37951. * Detach the current controls from the specified dom element.
  37952. * @param element Defines the element to stop listening the inputs from
  37953. */
  37954. detachControl(element: Nullable<HTMLElement>): void;
  37955. /**
  37956. * Gets the class name of the current input.
  37957. * @returns the class name
  37958. */
  37959. getClassName(): string;
  37960. /**
  37961. * Get the friendly name associated with the input class.
  37962. * @returns the input friendly name
  37963. */
  37964. getSimpleName(): string;
  37965. /**
  37966. * Called on pointer POINTERDOUBLETAP event.
  37967. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37968. */
  37969. protected onDoubleTap(type: string): void;
  37970. /**
  37971. * Called on pointer POINTERMOVE event if only a single touch is active.
  37972. * Override this method to provide functionality.
  37973. */
  37974. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37975. /**
  37976. * Called on pointer POINTERMOVE event if multiple touches are active.
  37977. * Override this method to provide functionality.
  37978. */
  37979. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37980. /**
  37981. * Called on JS contextmenu event.
  37982. * Override this method to provide functionality.
  37983. */
  37984. protected onContextMenu(evt: PointerEvent): void;
  37985. /**
  37986. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37987. * press.
  37988. * Override this method to provide functionality.
  37989. */
  37990. protected onButtonDown(evt: PointerEvent): void;
  37991. /**
  37992. * Called each time a new POINTERUP event occurs. Ie, for each button
  37993. * release.
  37994. * Override this method to provide functionality.
  37995. */
  37996. protected onButtonUp(evt: PointerEvent): void;
  37997. /**
  37998. * Called when window becomes inactive.
  37999. * Override this method to provide functionality.
  38000. */
  38001. protected onLostFocus(): void;
  38002. private _pointerInput;
  38003. private _observer;
  38004. private _onLostFocus;
  38005. private pointA;
  38006. private pointB;
  38007. }
  38008. }
  38009. declare module BABYLON {
  38010. /**
  38011. * Manage the pointers inputs to control an arc rotate camera.
  38012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38013. */
  38014. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38015. /**
  38016. * Defines the camera the input is attached to.
  38017. */
  38018. camera: ArcRotateCamera;
  38019. /**
  38020. * Gets the class name of the current input.
  38021. * @returns the class name
  38022. */
  38023. getClassName(): string;
  38024. /**
  38025. * Defines the buttons associated with the input to handle camera move.
  38026. */
  38027. buttons: number[];
  38028. /**
  38029. * Defines the pointer angular sensibility along the X axis or how fast is
  38030. * the camera rotating.
  38031. */
  38032. angularSensibilityX: number;
  38033. /**
  38034. * Defines the pointer angular sensibility along the Y axis or how fast is
  38035. * the camera rotating.
  38036. */
  38037. angularSensibilityY: number;
  38038. /**
  38039. * Defines the pointer pinch precision or how fast is the camera zooming.
  38040. */
  38041. pinchPrecision: number;
  38042. /**
  38043. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38044. * from 0.
  38045. * It defines the percentage of current camera.radius to use as delta when
  38046. * pinch zoom is used.
  38047. */
  38048. pinchDeltaPercentage: number;
  38049. /**
  38050. * Defines the pointer panning sensibility or how fast is the camera moving.
  38051. */
  38052. panningSensibility: number;
  38053. /**
  38054. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38055. */
  38056. multiTouchPanning: boolean;
  38057. /**
  38058. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38059. * zoom (pinch) through multitouch.
  38060. */
  38061. multiTouchPanAndZoom: boolean;
  38062. /**
  38063. * Revers pinch action direction.
  38064. */
  38065. pinchInwards: boolean;
  38066. private _isPanClick;
  38067. private _twoFingerActivityCount;
  38068. private _isPinching;
  38069. /**
  38070. * Called on pointer POINTERMOVE event if only a single touch is active.
  38071. */
  38072. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38073. /**
  38074. * Called on pointer POINTERDOUBLETAP event.
  38075. */
  38076. protected onDoubleTap(type: string): void;
  38077. /**
  38078. * Called on pointer POINTERMOVE event if multiple touches are active.
  38079. */
  38080. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38081. /**
  38082. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38083. * press.
  38084. */
  38085. protected onButtonDown(evt: PointerEvent): void;
  38086. /**
  38087. * Called each time a new POINTERUP event occurs. Ie, for each button
  38088. * release.
  38089. */
  38090. protected onButtonUp(evt: PointerEvent): void;
  38091. /**
  38092. * Called when window becomes inactive.
  38093. */
  38094. protected onLostFocus(): void;
  38095. }
  38096. }
  38097. declare module BABYLON {
  38098. /**
  38099. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38101. */
  38102. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38103. /**
  38104. * Defines the camera the input is attached to.
  38105. */
  38106. camera: ArcRotateCamera;
  38107. /**
  38108. * Defines the list of key codes associated with the up action (increase alpha)
  38109. */
  38110. keysUp: number[];
  38111. /**
  38112. * Defines the list of key codes associated with the down action (decrease alpha)
  38113. */
  38114. keysDown: number[];
  38115. /**
  38116. * Defines the list of key codes associated with the left action (increase beta)
  38117. */
  38118. keysLeft: number[];
  38119. /**
  38120. * Defines the list of key codes associated with the right action (decrease beta)
  38121. */
  38122. keysRight: number[];
  38123. /**
  38124. * Defines the list of key codes associated with the reset action.
  38125. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38126. */
  38127. keysReset: number[];
  38128. /**
  38129. * Defines the panning sensibility of the inputs.
  38130. * (How fast is the camera paning)
  38131. */
  38132. panningSensibility: number;
  38133. /**
  38134. * Defines the zooming sensibility of the inputs.
  38135. * (How fast is the camera zooming)
  38136. */
  38137. zoomingSensibility: number;
  38138. /**
  38139. * Defines wether maintaining the alt key down switch the movement mode from
  38140. * orientation to zoom.
  38141. */
  38142. useAltToZoom: boolean;
  38143. /**
  38144. * Rotation speed of the camera
  38145. */
  38146. angularSpeed: number;
  38147. private _keys;
  38148. private _ctrlPressed;
  38149. private _altPressed;
  38150. private _onCanvasBlurObserver;
  38151. private _onKeyboardObserver;
  38152. private _engine;
  38153. private _scene;
  38154. /**
  38155. * Attach the input controls to a specific dom element to get the input from.
  38156. * @param element Defines the element the controls should be listened from
  38157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38158. */
  38159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38160. /**
  38161. * Detach the current controls from the specified dom element.
  38162. * @param element Defines the element to stop listening the inputs from
  38163. */
  38164. detachControl(element: Nullable<HTMLElement>): void;
  38165. /**
  38166. * Update the current camera state depending on the inputs that have been used this frame.
  38167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38168. */
  38169. checkInputs(): void;
  38170. /**
  38171. * Gets the class name of the current intput.
  38172. * @returns the class name
  38173. */
  38174. getClassName(): string;
  38175. /**
  38176. * Get the friendly name associated with the input class.
  38177. * @returns the input friendly name
  38178. */
  38179. getSimpleName(): string;
  38180. }
  38181. }
  38182. declare module BABYLON {
  38183. /**
  38184. * Manage the mouse wheel inputs to control an arc rotate camera.
  38185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38186. */
  38187. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38188. /**
  38189. * Defines the camera the input is attached to.
  38190. */
  38191. camera: ArcRotateCamera;
  38192. /**
  38193. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38194. */
  38195. wheelPrecision: number;
  38196. /**
  38197. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38198. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38199. */
  38200. wheelDeltaPercentage: number;
  38201. private _wheel;
  38202. private _observer;
  38203. private computeDeltaFromMouseWheelLegacyEvent;
  38204. /**
  38205. * Attach the input controls to a specific dom element to get the input from.
  38206. * @param element Defines the element the controls should be listened from
  38207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38208. */
  38209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38210. /**
  38211. * Detach the current controls from the specified dom element.
  38212. * @param element Defines the element to stop listening the inputs from
  38213. */
  38214. detachControl(element: Nullable<HTMLElement>): void;
  38215. /**
  38216. * Gets the class name of the current intput.
  38217. * @returns the class name
  38218. */
  38219. getClassName(): string;
  38220. /**
  38221. * Get the friendly name associated with the input class.
  38222. * @returns the input friendly name
  38223. */
  38224. getSimpleName(): string;
  38225. }
  38226. }
  38227. declare module BABYLON {
  38228. /**
  38229. * Default Inputs manager for the ArcRotateCamera.
  38230. * It groups all the default supported inputs for ease of use.
  38231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38232. */
  38233. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38234. /**
  38235. * Instantiates a new ArcRotateCameraInputsManager.
  38236. * @param camera Defines the camera the inputs belong to
  38237. */
  38238. constructor(camera: ArcRotateCamera);
  38239. /**
  38240. * Add mouse wheel input support to the input manager.
  38241. * @returns the current input manager
  38242. */
  38243. addMouseWheel(): ArcRotateCameraInputsManager;
  38244. /**
  38245. * Add pointers input support to the input manager.
  38246. * @returns the current input manager
  38247. */
  38248. addPointers(): ArcRotateCameraInputsManager;
  38249. /**
  38250. * Add keyboard input support to the input manager.
  38251. * @returns the current input manager
  38252. */
  38253. addKeyboard(): ArcRotateCameraInputsManager;
  38254. }
  38255. }
  38256. declare module BABYLON {
  38257. /**
  38258. * This represents an orbital type of camera.
  38259. *
  38260. * 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.
  38261. * 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.
  38262. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38263. */
  38264. export class ArcRotateCamera extends TargetCamera {
  38265. /**
  38266. * Defines the rotation angle of the camera along the longitudinal axis.
  38267. */
  38268. alpha: number;
  38269. /**
  38270. * Defines the rotation angle of the camera along the latitudinal axis.
  38271. */
  38272. beta: number;
  38273. /**
  38274. * Defines the radius of the camera from it s target point.
  38275. */
  38276. radius: number;
  38277. protected _target: Vector3;
  38278. protected _targetHost: Nullable<AbstractMesh>;
  38279. /**
  38280. * Defines the target point of the camera.
  38281. * The camera looks towards it form the radius distance.
  38282. */
  38283. get target(): Vector3;
  38284. set target(value: Vector3);
  38285. /**
  38286. * Define the current local position of the camera in the scene
  38287. */
  38288. get position(): Vector3;
  38289. set position(newPosition: Vector3);
  38290. protected _upVector: Vector3;
  38291. protected _upToYMatrix: Matrix;
  38292. protected _YToUpMatrix: Matrix;
  38293. /**
  38294. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38295. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38296. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38297. */
  38298. set upVector(vec: Vector3);
  38299. get upVector(): Vector3;
  38300. /**
  38301. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38302. */
  38303. setMatUp(): void;
  38304. /**
  38305. * Current inertia value on the longitudinal axis.
  38306. * The bigger this number the longer it will take for the camera to stop.
  38307. */
  38308. inertialAlphaOffset: number;
  38309. /**
  38310. * Current inertia value on the latitudinal axis.
  38311. * The bigger this number the longer it will take for the camera to stop.
  38312. */
  38313. inertialBetaOffset: number;
  38314. /**
  38315. * Current inertia value on the radius axis.
  38316. * The bigger this number the longer it will take for the camera to stop.
  38317. */
  38318. inertialRadiusOffset: number;
  38319. /**
  38320. * Minimum allowed angle on the longitudinal axis.
  38321. * This can help limiting how the Camera is able to move in the scene.
  38322. */
  38323. lowerAlphaLimit: Nullable<number>;
  38324. /**
  38325. * Maximum allowed angle on the longitudinal axis.
  38326. * This can help limiting how the Camera is able to move in the scene.
  38327. */
  38328. upperAlphaLimit: Nullable<number>;
  38329. /**
  38330. * Minimum allowed angle on the latitudinal axis.
  38331. * This can help limiting how the Camera is able to move in the scene.
  38332. */
  38333. lowerBetaLimit: number;
  38334. /**
  38335. * Maximum allowed angle on the latitudinal axis.
  38336. * This can help limiting how the Camera is able to move in the scene.
  38337. */
  38338. upperBetaLimit: number;
  38339. /**
  38340. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38341. * This can help limiting how the Camera is able to move in the scene.
  38342. */
  38343. lowerRadiusLimit: Nullable<number>;
  38344. /**
  38345. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38346. * This can help limiting how the Camera is able to move in the scene.
  38347. */
  38348. upperRadiusLimit: Nullable<number>;
  38349. /**
  38350. * Defines the current inertia value used during panning of the camera along the X axis.
  38351. */
  38352. inertialPanningX: number;
  38353. /**
  38354. * Defines the current inertia value used during panning of the camera along the Y axis.
  38355. */
  38356. inertialPanningY: number;
  38357. /**
  38358. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38359. * Basically if your fingers moves away from more than this distance you will be considered
  38360. * in pinch mode.
  38361. */
  38362. pinchToPanMaxDistance: number;
  38363. /**
  38364. * Defines the maximum distance the camera can pan.
  38365. * This could help keeping the cammera always in your scene.
  38366. */
  38367. panningDistanceLimit: Nullable<number>;
  38368. /**
  38369. * Defines the target of the camera before paning.
  38370. */
  38371. panningOriginTarget: Vector3;
  38372. /**
  38373. * Defines the value of the inertia used during panning.
  38374. * 0 would mean stop inertia and one would mean no decelleration at all.
  38375. */
  38376. panningInertia: number;
  38377. /**
  38378. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38379. */
  38380. get angularSensibilityX(): number;
  38381. set angularSensibilityX(value: number);
  38382. /**
  38383. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38384. */
  38385. get angularSensibilityY(): number;
  38386. set angularSensibilityY(value: number);
  38387. /**
  38388. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38389. */
  38390. get pinchPrecision(): number;
  38391. set pinchPrecision(value: number);
  38392. /**
  38393. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38394. * It will be used instead of pinchDeltaPrecision if different from 0.
  38395. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38396. */
  38397. get pinchDeltaPercentage(): number;
  38398. set pinchDeltaPercentage(value: number);
  38399. /**
  38400. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38401. */
  38402. get panningSensibility(): number;
  38403. set panningSensibility(value: number);
  38404. /**
  38405. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38406. */
  38407. get keysUp(): number[];
  38408. set keysUp(value: number[]);
  38409. /**
  38410. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38411. */
  38412. get keysDown(): number[];
  38413. set keysDown(value: number[]);
  38414. /**
  38415. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38416. */
  38417. get keysLeft(): number[];
  38418. set keysLeft(value: number[]);
  38419. /**
  38420. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38421. */
  38422. get keysRight(): number[];
  38423. set keysRight(value: number[]);
  38424. /**
  38425. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38426. */
  38427. get wheelPrecision(): number;
  38428. set wheelPrecision(value: number);
  38429. /**
  38430. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38431. * It will be used instead of pinchDeltaPrecision if different from 0.
  38432. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38433. */
  38434. get wheelDeltaPercentage(): number;
  38435. set wheelDeltaPercentage(value: number);
  38436. /**
  38437. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38438. */
  38439. zoomOnFactor: number;
  38440. /**
  38441. * Defines a screen offset for the camera position.
  38442. */
  38443. targetScreenOffset: Vector2;
  38444. /**
  38445. * Allows the camera to be completely reversed.
  38446. * If false the camera can not arrive upside down.
  38447. */
  38448. allowUpsideDown: boolean;
  38449. /**
  38450. * Define if double tap/click is used to restore the previously saved state of the camera.
  38451. */
  38452. useInputToRestoreState: boolean;
  38453. /** @hidden */
  38454. _viewMatrix: Matrix;
  38455. /** @hidden */
  38456. _useCtrlForPanning: boolean;
  38457. /** @hidden */
  38458. _panningMouseButton: number;
  38459. /**
  38460. * Defines the input associated to the camera.
  38461. */
  38462. inputs: ArcRotateCameraInputsManager;
  38463. /** @hidden */
  38464. _reset: () => void;
  38465. /**
  38466. * Defines the allowed panning axis.
  38467. */
  38468. panningAxis: Vector3;
  38469. protected _localDirection: Vector3;
  38470. protected _transformedDirection: Vector3;
  38471. private _bouncingBehavior;
  38472. /**
  38473. * Gets the bouncing behavior of the camera if it has been enabled.
  38474. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38475. */
  38476. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38477. /**
  38478. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38479. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38480. */
  38481. get useBouncingBehavior(): boolean;
  38482. set useBouncingBehavior(value: boolean);
  38483. private _framingBehavior;
  38484. /**
  38485. * Gets the framing behavior of the camera if it has been enabled.
  38486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38487. */
  38488. get framingBehavior(): Nullable<FramingBehavior>;
  38489. /**
  38490. * Defines if the framing behavior of the camera is enabled on the camera.
  38491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38492. */
  38493. get useFramingBehavior(): boolean;
  38494. set useFramingBehavior(value: boolean);
  38495. private _autoRotationBehavior;
  38496. /**
  38497. * Gets the auto rotation behavior of the camera if it has been enabled.
  38498. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38499. */
  38500. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38501. /**
  38502. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38504. */
  38505. get useAutoRotationBehavior(): boolean;
  38506. set useAutoRotationBehavior(value: boolean);
  38507. /**
  38508. * Observable triggered when the mesh target has been changed on the camera.
  38509. */
  38510. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38511. /**
  38512. * Event raised when the camera is colliding with a mesh.
  38513. */
  38514. onCollide: (collidedMesh: AbstractMesh) => void;
  38515. /**
  38516. * Defines whether the camera should check collision with the objects oh the scene.
  38517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38518. */
  38519. checkCollisions: boolean;
  38520. /**
  38521. * Defines the collision radius of the camera.
  38522. * This simulates a sphere around the camera.
  38523. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38524. */
  38525. collisionRadius: Vector3;
  38526. protected _collider: Collider;
  38527. protected _previousPosition: Vector3;
  38528. protected _collisionVelocity: Vector3;
  38529. protected _newPosition: Vector3;
  38530. protected _previousAlpha: number;
  38531. protected _previousBeta: number;
  38532. protected _previousRadius: number;
  38533. protected _collisionTriggered: boolean;
  38534. protected _targetBoundingCenter: Nullable<Vector3>;
  38535. private _computationVector;
  38536. /**
  38537. * Instantiates a new ArcRotateCamera in a given scene
  38538. * @param name Defines the name of the camera
  38539. * @param alpha Defines the camera rotation along the logitudinal axis
  38540. * @param beta Defines the camera rotation along the latitudinal axis
  38541. * @param radius Defines the camera distance from its target
  38542. * @param target Defines the camera target
  38543. * @param scene Defines the scene the camera belongs to
  38544. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38545. */
  38546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38547. /** @hidden */
  38548. _initCache(): void;
  38549. /** @hidden */
  38550. _updateCache(ignoreParentClass?: boolean): void;
  38551. protected _getTargetPosition(): Vector3;
  38552. private _storedAlpha;
  38553. private _storedBeta;
  38554. private _storedRadius;
  38555. private _storedTarget;
  38556. private _storedTargetScreenOffset;
  38557. /**
  38558. * Stores the current state of the camera (alpha, beta, radius and target)
  38559. * @returns the camera itself
  38560. */
  38561. storeState(): Camera;
  38562. /**
  38563. * @hidden
  38564. * Restored camera state. You must call storeState() first
  38565. */
  38566. _restoreStateValues(): boolean;
  38567. /** @hidden */
  38568. _isSynchronizedViewMatrix(): boolean;
  38569. /**
  38570. * Attached controls to the current camera.
  38571. * @param element Defines the element the controls should be listened from
  38572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38573. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38574. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38575. */
  38576. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38577. /**
  38578. * Detach the current controls from the camera.
  38579. * The camera will stop reacting to inputs.
  38580. * @param element Defines the element to stop listening the inputs from
  38581. */
  38582. detachControl(element: HTMLElement): void;
  38583. /** @hidden */
  38584. _checkInputs(): void;
  38585. protected _checkLimits(): void;
  38586. /**
  38587. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38588. */
  38589. rebuildAnglesAndRadius(): void;
  38590. /**
  38591. * Use a position to define the current camera related information like alpha, beta and radius
  38592. * @param position Defines the position to set the camera at
  38593. */
  38594. setPosition(position: Vector3): void;
  38595. /**
  38596. * Defines the target the camera should look at.
  38597. * This will automatically adapt alpha beta and radius to fit within the new target.
  38598. * @param target Defines the new target as a Vector or a mesh
  38599. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38600. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38601. */
  38602. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38603. /** @hidden */
  38604. _getViewMatrix(): Matrix;
  38605. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38606. /**
  38607. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38608. * @param meshes Defines the mesh to zoom on
  38609. * @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)
  38610. */
  38611. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38612. /**
  38613. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38614. * The target will be changed but the radius
  38615. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38616. * @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)
  38617. */
  38618. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38619. min: Vector3;
  38620. max: Vector3;
  38621. distance: number;
  38622. }, doNotUpdateMaxZ?: boolean): void;
  38623. /**
  38624. * @override
  38625. * Override Camera.createRigCamera
  38626. */
  38627. createRigCamera(name: string, cameraIndex: number): Camera;
  38628. /**
  38629. * @hidden
  38630. * @override
  38631. * Override Camera._updateRigCameras
  38632. */
  38633. _updateRigCameras(): void;
  38634. /**
  38635. * Destroy the camera and release the current resources hold by it.
  38636. */
  38637. dispose(): void;
  38638. /**
  38639. * Gets the current object class name.
  38640. * @return the class name
  38641. */
  38642. getClassName(): string;
  38643. }
  38644. }
  38645. declare module BABYLON {
  38646. /**
  38647. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38649. */
  38650. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38651. /**
  38652. * Gets the name of the behavior.
  38653. */
  38654. get name(): string;
  38655. private _zoomStopsAnimation;
  38656. private _idleRotationSpeed;
  38657. private _idleRotationWaitTime;
  38658. private _idleRotationSpinupTime;
  38659. /**
  38660. * Sets the flag that indicates if user zooming should stop animation.
  38661. */
  38662. set zoomStopsAnimation(flag: boolean);
  38663. /**
  38664. * Gets the flag that indicates if user zooming should stop animation.
  38665. */
  38666. get zoomStopsAnimation(): boolean;
  38667. /**
  38668. * Sets the default speed at which the camera rotates around the model.
  38669. */
  38670. set idleRotationSpeed(speed: number);
  38671. /**
  38672. * Gets the default speed at which the camera rotates around the model.
  38673. */
  38674. get idleRotationSpeed(): number;
  38675. /**
  38676. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38677. */
  38678. set idleRotationWaitTime(time: number);
  38679. /**
  38680. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38681. */
  38682. get idleRotationWaitTime(): number;
  38683. /**
  38684. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38685. */
  38686. set idleRotationSpinupTime(time: number);
  38687. /**
  38688. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38689. */
  38690. get idleRotationSpinupTime(): number;
  38691. /**
  38692. * Gets a value indicating if the camera is currently rotating because of this behavior
  38693. */
  38694. get rotationInProgress(): boolean;
  38695. private _onPrePointerObservableObserver;
  38696. private _onAfterCheckInputsObserver;
  38697. private _attachedCamera;
  38698. private _isPointerDown;
  38699. private _lastFrameTime;
  38700. private _lastInteractionTime;
  38701. private _cameraRotationSpeed;
  38702. /**
  38703. * Initializes the behavior.
  38704. */
  38705. init(): void;
  38706. /**
  38707. * Attaches the behavior to its arc rotate camera.
  38708. * @param camera Defines the camera to attach the behavior to
  38709. */
  38710. attach(camera: ArcRotateCamera): void;
  38711. /**
  38712. * Detaches the behavior from its current arc rotate camera.
  38713. */
  38714. detach(): void;
  38715. /**
  38716. * Returns true if user is scrolling.
  38717. * @return true if user is scrolling.
  38718. */
  38719. private _userIsZooming;
  38720. private _lastFrameRadius;
  38721. private _shouldAnimationStopForInteraction;
  38722. /**
  38723. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38724. */
  38725. private _applyUserInteraction;
  38726. private _userIsMoving;
  38727. }
  38728. }
  38729. declare module BABYLON {
  38730. /**
  38731. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38732. */
  38733. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38734. private ui;
  38735. /**
  38736. * The name of the behavior
  38737. */
  38738. name: string;
  38739. /**
  38740. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38741. */
  38742. distanceAwayFromFace: number;
  38743. /**
  38744. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38745. */
  38746. distanceAwayFromBottomOfFace: number;
  38747. private _faceVectors;
  38748. private _target;
  38749. private _scene;
  38750. private _onRenderObserver;
  38751. private _tmpMatrix;
  38752. private _tmpVector;
  38753. /**
  38754. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38755. * @param ui The transform node that should be attched to the mesh
  38756. */
  38757. constructor(ui: TransformNode);
  38758. /**
  38759. * Initializes the behavior
  38760. */
  38761. init(): void;
  38762. private _closestFace;
  38763. private _zeroVector;
  38764. private _lookAtTmpMatrix;
  38765. private _lookAtToRef;
  38766. /**
  38767. * Attaches the AttachToBoxBehavior to the passed in mesh
  38768. * @param target The mesh that the specified node will be attached to
  38769. */
  38770. attach(target: Mesh): void;
  38771. /**
  38772. * Detaches the behavior from the mesh
  38773. */
  38774. detach(): void;
  38775. }
  38776. }
  38777. declare module BABYLON {
  38778. /**
  38779. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38780. */
  38781. export class FadeInOutBehavior implements Behavior<Mesh> {
  38782. /**
  38783. * Time in milliseconds to delay before fading in (Default: 0)
  38784. */
  38785. delay: number;
  38786. /**
  38787. * Time in milliseconds for the mesh to fade in (Default: 300)
  38788. */
  38789. fadeInTime: number;
  38790. private _millisecondsPerFrame;
  38791. private _hovered;
  38792. private _hoverValue;
  38793. private _ownerNode;
  38794. /**
  38795. * Instatiates the FadeInOutBehavior
  38796. */
  38797. constructor();
  38798. /**
  38799. * The name of the behavior
  38800. */
  38801. get name(): string;
  38802. /**
  38803. * Initializes the behavior
  38804. */
  38805. init(): void;
  38806. /**
  38807. * Attaches the fade behavior on the passed in mesh
  38808. * @param ownerNode The mesh that will be faded in/out once attached
  38809. */
  38810. attach(ownerNode: Mesh): void;
  38811. /**
  38812. * Detaches the behavior from the mesh
  38813. */
  38814. detach(): void;
  38815. /**
  38816. * Triggers the mesh to begin fading in or out
  38817. * @param value if the object should fade in or out (true to fade in)
  38818. */
  38819. fadeIn(value: boolean): void;
  38820. private _update;
  38821. private _setAllVisibility;
  38822. }
  38823. }
  38824. declare module BABYLON {
  38825. /**
  38826. * Class containing a set of static utilities functions for managing Pivots
  38827. * @hidden
  38828. */
  38829. export class PivotTools {
  38830. private static _PivotCached;
  38831. private static _OldPivotPoint;
  38832. private static _PivotTranslation;
  38833. private static _PivotTmpVector;
  38834. /** @hidden */
  38835. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38836. /** @hidden */
  38837. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38838. }
  38839. }
  38840. declare module BABYLON {
  38841. /**
  38842. * Class containing static functions to help procedurally build meshes
  38843. */
  38844. export class PlaneBuilder {
  38845. /**
  38846. * Creates a plane mesh
  38847. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38848. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38849. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38851. * * 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
  38852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38853. * @param name defines the name of the mesh
  38854. * @param options defines the options used to create the mesh
  38855. * @param scene defines the hosting scene
  38856. * @returns the plane mesh
  38857. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38858. */
  38859. static CreatePlane(name: string, options: {
  38860. size?: number;
  38861. width?: number;
  38862. height?: number;
  38863. sideOrientation?: number;
  38864. frontUVs?: Vector4;
  38865. backUVs?: Vector4;
  38866. updatable?: boolean;
  38867. sourcePlane?: Plane;
  38868. }, scene?: Nullable<Scene>): Mesh;
  38869. }
  38870. }
  38871. declare module BABYLON {
  38872. /**
  38873. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38874. */
  38875. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38876. private static _AnyMouseID;
  38877. /**
  38878. * Abstract mesh the behavior is set on
  38879. */
  38880. attachedNode: AbstractMesh;
  38881. private _dragPlane;
  38882. private _scene;
  38883. private _pointerObserver;
  38884. private _beforeRenderObserver;
  38885. private static _planeScene;
  38886. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38887. /**
  38888. * 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)
  38889. */
  38890. maxDragAngle: number;
  38891. /**
  38892. * @hidden
  38893. */
  38894. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38895. /**
  38896. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38897. */
  38898. currentDraggingPointerID: number;
  38899. /**
  38900. * The last position where the pointer hit the drag plane in world space
  38901. */
  38902. lastDragPosition: Vector3;
  38903. /**
  38904. * If the behavior is currently in a dragging state
  38905. */
  38906. dragging: boolean;
  38907. /**
  38908. * 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)
  38909. */
  38910. dragDeltaRatio: number;
  38911. /**
  38912. * If the drag plane orientation should be updated during the dragging (Default: true)
  38913. */
  38914. updateDragPlane: boolean;
  38915. private _debugMode;
  38916. private _moving;
  38917. /**
  38918. * Fires each time the attached mesh is dragged with the pointer
  38919. * * delta between last drag position and current drag position in world space
  38920. * * dragDistance along the drag axis
  38921. * * dragPlaneNormal normal of the current drag plane used during the drag
  38922. * * dragPlanePoint in world space where the drag intersects the drag plane
  38923. */
  38924. onDragObservable: Observable<{
  38925. delta: Vector3;
  38926. dragPlanePoint: Vector3;
  38927. dragPlaneNormal: Vector3;
  38928. dragDistance: number;
  38929. pointerId: number;
  38930. }>;
  38931. /**
  38932. * Fires each time a drag begins (eg. mouse down on mesh)
  38933. */
  38934. onDragStartObservable: Observable<{
  38935. dragPlanePoint: Vector3;
  38936. pointerId: number;
  38937. }>;
  38938. /**
  38939. * Fires each time a drag ends (eg. mouse release after drag)
  38940. */
  38941. onDragEndObservable: Observable<{
  38942. dragPlanePoint: Vector3;
  38943. pointerId: number;
  38944. }>;
  38945. /**
  38946. * If the attached mesh should be moved when dragged
  38947. */
  38948. moveAttached: boolean;
  38949. /**
  38950. * If the drag behavior will react to drag events (Default: true)
  38951. */
  38952. enabled: boolean;
  38953. /**
  38954. * If pointer events should start and release the drag (Default: true)
  38955. */
  38956. startAndReleaseDragOnPointerEvents: boolean;
  38957. /**
  38958. * If camera controls should be detached during the drag
  38959. */
  38960. detachCameraControls: boolean;
  38961. /**
  38962. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38963. */
  38964. useObjectOrientationForDragging: boolean;
  38965. private _options;
  38966. /**
  38967. * Gets the options used by the behavior
  38968. */
  38969. get options(): {
  38970. dragAxis?: Vector3;
  38971. dragPlaneNormal?: Vector3;
  38972. };
  38973. /**
  38974. * Sets the options used by the behavior
  38975. */
  38976. set options(options: {
  38977. dragAxis?: Vector3;
  38978. dragPlaneNormal?: Vector3;
  38979. });
  38980. /**
  38981. * Creates a pointer drag behavior that can be attached to a mesh
  38982. * @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)
  38983. */
  38984. constructor(options?: {
  38985. dragAxis?: Vector3;
  38986. dragPlaneNormal?: Vector3;
  38987. });
  38988. /**
  38989. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38990. */
  38991. validateDrag: (targetPosition: Vector3) => boolean;
  38992. /**
  38993. * The name of the behavior
  38994. */
  38995. get name(): string;
  38996. /**
  38997. * Initializes the behavior
  38998. */
  38999. init(): void;
  39000. private _tmpVector;
  39001. private _alternatePickedPoint;
  39002. private _worldDragAxis;
  39003. private _targetPosition;
  39004. private _attachedElement;
  39005. /**
  39006. * Attaches the drag behavior the passed in mesh
  39007. * @param ownerNode The mesh that will be dragged around once attached
  39008. * @param predicate Predicate to use for pick filtering
  39009. */
  39010. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39011. /**
  39012. * Force relase the drag action by code.
  39013. */
  39014. releaseDrag(): void;
  39015. private _startDragRay;
  39016. private _lastPointerRay;
  39017. /**
  39018. * Simulates the start of a pointer drag event on the behavior
  39019. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39020. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39021. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39022. */
  39023. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39024. private _startDrag;
  39025. private _dragDelta;
  39026. private _moveDrag;
  39027. private _pickWithRayOnDragPlane;
  39028. private _pointA;
  39029. private _pointB;
  39030. private _pointC;
  39031. private _lineA;
  39032. private _lineB;
  39033. private _localAxis;
  39034. private _lookAt;
  39035. private _updateDragPlanePosition;
  39036. /**
  39037. * Detaches the behavior from the mesh
  39038. */
  39039. detach(): void;
  39040. }
  39041. }
  39042. declare module BABYLON {
  39043. /**
  39044. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39045. */
  39046. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39047. private _dragBehaviorA;
  39048. private _dragBehaviorB;
  39049. private _startDistance;
  39050. private _initialScale;
  39051. private _targetScale;
  39052. private _ownerNode;
  39053. private _sceneRenderObserver;
  39054. /**
  39055. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39056. */
  39057. constructor();
  39058. /**
  39059. * The name of the behavior
  39060. */
  39061. get name(): string;
  39062. /**
  39063. * Initializes the behavior
  39064. */
  39065. init(): void;
  39066. private _getCurrentDistance;
  39067. /**
  39068. * Attaches the scale behavior the passed in mesh
  39069. * @param ownerNode The mesh that will be scaled around once attached
  39070. */
  39071. attach(ownerNode: Mesh): void;
  39072. /**
  39073. * Detaches the behavior from the mesh
  39074. */
  39075. detach(): void;
  39076. }
  39077. }
  39078. declare module BABYLON {
  39079. /**
  39080. * 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
  39081. */
  39082. export class SixDofDragBehavior implements Behavior<Mesh> {
  39083. private static _virtualScene;
  39084. private _ownerNode;
  39085. private _sceneRenderObserver;
  39086. private _scene;
  39087. private _targetPosition;
  39088. private _virtualOriginMesh;
  39089. private _virtualDragMesh;
  39090. private _pointerObserver;
  39091. private _moving;
  39092. private _startingOrientation;
  39093. /**
  39094. * 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)
  39095. */
  39096. private zDragFactor;
  39097. /**
  39098. * If the object should rotate to face the drag origin
  39099. */
  39100. rotateDraggedObject: boolean;
  39101. /**
  39102. * If the behavior is currently in a dragging state
  39103. */
  39104. dragging: boolean;
  39105. /**
  39106. * 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)
  39107. */
  39108. dragDeltaRatio: number;
  39109. /**
  39110. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39111. */
  39112. currentDraggingPointerID: number;
  39113. /**
  39114. * If camera controls should be detached during the drag
  39115. */
  39116. detachCameraControls: boolean;
  39117. /**
  39118. * Fires each time a drag starts
  39119. */
  39120. onDragStartObservable: Observable<{}>;
  39121. /**
  39122. * Fires each time a drag ends (eg. mouse release after drag)
  39123. */
  39124. onDragEndObservable: Observable<{}>;
  39125. /**
  39126. * 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
  39127. */
  39128. constructor();
  39129. /**
  39130. * The name of the behavior
  39131. */
  39132. get name(): string;
  39133. /**
  39134. * Initializes the behavior
  39135. */
  39136. init(): void;
  39137. /**
  39138. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39139. */
  39140. private get _pointerCamera();
  39141. /**
  39142. * Attaches the scale behavior the passed in mesh
  39143. * @param ownerNode The mesh that will be scaled around once attached
  39144. */
  39145. attach(ownerNode: Mesh): void;
  39146. /**
  39147. * Detaches the behavior from the mesh
  39148. */
  39149. detach(): void;
  39150. }
  39151. }
  39152. declare module BABYLON {
  39153. /**
  39154. * Class used to apply inverse kinematics to bones
  39155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39156. */
  39157. export class BoneIKController {
  39158. private static _tmpVecs;
  39159. private static _tmpQuat;
  39160. private static _tmpMats;
  39161. /**
  39162. * Gets or sets the target mesh
  39163. */
  39164. targetMesh: AbstractMesh;
  39165. /** Gets or sets the mesh used as pole */
  39166. poleTargetMesh: AbstractMesh;
  39167. /**
  39168. * Gets or sets the bone used as pole
  39169. */
  39170. poleTargetBone: Nullable<Bone>;
  39171. /**
  39172. * Gets or sets the target position
  39173. */
  39174. targetPosition: Vector3;
  39175. /**
  39176. * Gets or sets the pole target position
  39177. */
  39178. poleTargetPosition: Vector3;
  39179. /**
  39180. * Gets or sets the pole target local offset
  39181. */
  39182. poleTargetLocalOffset: Vector3;
  39183. /**
  39184. * Gets or sets the pole angle
  39185. */
  39186. poleAngle: number;
  39187. /**
  39188. * Gets or sets the mesh associated with the controller
  39189. */
  39190. mesh: AbstractMesh;
  39191. /**
  39192. * 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)
  39193. */
  39194. slerpAmount: number;
  39195. private _bone1Quat;
  39196. private _bone1Mat;
  39197. private _bone2Ang;
  39198. private _bone1;
  39199. private _bone2;
  39200. private _bone1Length;
  39201. private _bone2Length;
  39202. private _maxAngle;
  39203. private _maxReach;
  39204. private _rightHandedSystem;
  39205. private _bendAxis;
  39206. private _slerping;
  39207. private _adjustRoll;
  39208. /**
  39209. * Gets or sets maximum allowed angle
  39210. */
  39211. get maxAngle(): number;
  39212. set maxAngle(value: number);
  39213. /**
  39214. * Creates a new BoneIKController
  39215. * @param mesh defines the mesh to control
  39216. * @param bone defines the bone to control
  39217. * @param options defines options to set up the controller
  39218. */
  39219. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39220. targetMesh?: AbstractMesh;
  39221. poleTargetMesh?: AbstractMesh;
  39222. poleTargetBone?: Bone;
  39223. poleTargetLocalOffset?: Vector3;
  39224. poleAngle?: number;
  39225. bendAxis?: Vector3;
  39226. maxAngle?: number;
  39227. slerpAmount?: number;
  39228. });
  39229. private _setMaxAngle;
  39230. /**
  39231. * Force the controller to update the bones
  39232. */
  39233. update(): void;
  39234. }
  39235. }
  39236. declare module BABYLON {
  39237. /**
  39238. * Class used to make a bone look toward a point in space
  39239. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39240. */
  39241. export class BoneLookController {
  39242. private static _tmpVecs;
  39243. private static _tmpQuat;
  39244. private static _tmpMats;
  39245. /**
  39246. * The target Vector3 that the bone will look at
  39247. */
  39248. target: Vector3;
  39249. /**
  39250. * The mesh that the bone is attached to
  39251. */
  39252. mesh: AbstractMesh;
  39253. /**
  39254. * The bone that will be looking to the target
  39255. */
  39256. bone: Bone;
  39257. /**
  39258. * The up axis of the coordinate system that is used when the bone is rotated
  39259. */
  39260. upAxis: Vector3;
  39261. /**
  39262. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39263. */
  39264. upAxisSpace: Space;
  39265. /**
  39266. * Used to make an adjustment to the yaw of the bone
  39267. */
  39268. adjustYaw: number;
  39269. /**
  39270. * Used to make an adjustment to the pitch of the bone
  39271. */
  39272. adjustPitch: number;
  39273. /**
  39274. * Used to make an adjustment to the roll of the bone
  39275. */
  39276. adjustRoll: number;
  39277. /**
  39278. * 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)
  39279. */
  39280. slerpAmount: number;
  39281. private _minYaw;
  39282. private _maxYaw;
  39283. private _minPitch;
  39284. private _maxPitch;
  39285. private _minYawSin;
  39286. private _minYawCos;
  39287. private _maxYawSin;
  39288. private _maxYawCos;
  39289. private _midYawConstraint;
  39290. private _minPitchTan;
  39291. private _maxPitchTan;
  39292. private _boneQuat;
  39293. private _slerping;
  39294. private _transformYawPitch;
  39295. private _transformYawPitchInv;
  39296. private _firstFrameSkipped;
  39297. private _yawRange;
  39298. private _fowardAxis;
  39299. /**
  39300. * Gets or sets the minimum yaw angle that the bone can look to
  39301. */
  39302. get minYaw(): number;
  39303. set minYaw(value: number);
  39304. /**
  39305. * Gets or sets the maximum yaw angle that the bone can look to
  39306. */
  39307. get maxYaw(): number;
  39308. set maxYaw(value: number);
  39309. /**
  39310. * Gets or sets the minimum pitch angle that the bone can look to
  39311. */
  39312. get minPitch(): number;
  39313. set minPitch(value: number);
  39314. /**
  39315. * Gets or sets the maximum pitch angle that the bone can look to
  39316. */
  39317. get maxPitch(): number;
  39318. set maxPitch(value: number);
  39319. /**
  39320. * Create a BoneLookController
  39321. * @param mesh the mesh that the bone belongs to
  39322. * @param bone the bone that will be looking to the target
  39323. * @param target the target Vector3 to look at
  39324. * @param options optional settings:
  39325. * * maxYaw: the maximum angle the bone will yaw to
  39326. * * minYaw: the minimum angle the bone will yaw to
  39327. * * maxPitch: the maximum angle the bone will pitch to
  39328. * * minPitch: the minimum angle the bone will yaw to
  39329. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39330. * * upAxis: the up axis of the coordinate system
  39331. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39332. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39333. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39334. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39335. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39336. * * adjustRoll: used to make an adjustment to the roll of the bone
  39337. **/
  39338. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39339. maxYaw?: number;
  39340. minYaw?: number;
  39341. maxPitch?: number;
  39342. minPitch?: number;
  39343. slerpAmount?: number;
  39344. upAxis?: Vector3;
  39345. upAxisSpace?: Space;
  39346. yawAxis?: Vector3;
  39347. pitchAxis?: Vector3;
  39348. adjustYaw?: number;
  39349. adjustPitch?: number;
  39350. adjustRoll?: number;
  39351. });
  39352. /**
  39353. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39354. */
  39355. update(): void;
  39356. private _getAngleDiff;
  39357. private _getAngleBetween;
  39358. private _isAngleBetween;
  39359. }
  39360. }
  39361. declare module BABYLON {
  39362. /**
  39363. * Manage the gamepad inputs to control an arc rotate camera.
  39364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39365. */
  39366. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39367. /**
  39368. * Defines the camera the input is attached to.
  39369. */
  39370. camera: ArcRotateCamera;
  39371. /**
  39372. * Defines the gamepad the input is gathering event from.
  39373. */
  39374. gamepad: Nullable<Gamepad>;
  39375. /**
  39376. * Defines the gamepad rotation sensiblity.
  39377. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39378. */
  39379. gamepadRotationSensibility: number;
  39380. /**
  39381. * Defines the gamepad move sensiblity.
  39382. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39383. */
  39384. gamepadMoveSensibility: number;
  39385. private _yAxisScale;
  39386. /**
  39387. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39388. */
  39389. get invertYAxis(): boolean;
  39390. set invertYAxis(value: boolean);
  39391. private _onGamepadConnectedObserver;
  39392. private _onGamepadDisconnectedObserver;
  39393. /**
  39394. * Attach the input controls to a specific dom element to get the input from.
  39395. * @param element Defines the element the controls should be listened from
  39396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39399. /**
  39400. * Detach the current controls from the specified dom element.
  39401. * @param element Defines the element to stop listening the inputs from
  39402. */
  39403. detachControl(element: Nullable<HTMLElement>): void;
  39404. /**
  39405. * Update the current camera state depending on the inputs that have been used this frame.
  39406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39407. */
  39408. checkInputs(): void;
  39409. /**
  39410. * Gets the class name of the current intput.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Get the friendly name associated with the input class.
  39416. * @returns the input friendly name
  39417. */
  39418. getSimpleName(): string;
  39419. }
  39420. }
  39421. declare module BABYLON {
  39422. interface ArcRotateCameraInputsManager {
  39423. /**
  39424. * Add orientation input support to the input manager.
  39425. * @returns the current input manager
  39426. */
  39427. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39428. }
  39429. /**
  39430. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39432. */
  39433. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39434. /**
  39435. * Defines the camera the input is attached to.
  39436. */
  39437. camera: ArcRotateCamera;
  39438. /**
  39439. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39440. */
  39441. alphaCorrection: number;
  39442. /**
  39443. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39444. */
  39445. gammaCorrection: number;
  39446. private _alpha;
  39447. private _gamma;
  39448. private _dirty;
  39449. private _deviceOrientationHandler;
  39450. /**
  39451. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39452. */
  39453. constructor();
  39454. /**
  39455. * Attach the input controls to a specific dom element to get the input from.
  39456. * @param element Defines the element the controls should be listened from
  39457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39458. */
  39459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39460. /** @hidden */
  39461. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39462. /**
  39463. * Update the current camera state depending on the inputs that have been used this frame.
  39464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39465. */
  39466. checkInputs(): void;
  39467. /**
  39468. * Detach the current controls from the specified dom element.
  39469. * @param element Defines the element to stop listening the inputs from
  39470. */
  39471. detachControl(element: Nullable<HTMLElement>): void;
  39472. /**
  39473. * Gets the class name of the current intput.
  39474. * @returns the class name
  39475. */
  39476. getClassName(): string;
  39477. /**
  39478. * Get the friendly name associated with the input class.
  39479. * @returns the input friendly name
  39480. */
  39481. getSimpleName(): string;
  39482. }
  39483. }
  39484. declare module BABYLON {
  39485. /**
  39486. * Listen to mouse events to control the camera.
  39487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39488. */
  39489. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39490. /**
  39491. * Defines the camera the input is attached to.
  39492. */
  39493. camera: FlyCamera;
  39494. /**
  39495. * Defines if touch is enabled. (Default is true.)
  39496. */
  39497. touchEnabled: boolean;
  39498. /**
  39499. * Defines the buttons associated with the input to handle camera rotation.
  39500. */
  39501. buttons: number[];
  39502. /**
  39503. * Assign buttons for Yaw control.
  39504. */
  39505. buttonsYaw: number[];
  39506. /**
  39507. * Assign buttons for Pitch control.
  39508. */
  39509. buttonsPitch: number[];
  39510. /**
  39511. * Assign buttons for Roll control.
  39512. */
  39513. buttonsRoll: number[];
  39514. /**
  39515. * Detect if any button is being pressed while mouse is moved.
  39516. * -1 = Mouse locked.
  39517. * 0 = Left button.
  39518. * 1 = Middle Button.
  39519. * 2 = Right Button.
  39520. */
  39521. activeButton: number;
  39522. /**
  39523. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39524. * Higher values reduce its sensitivity.
  39525. */
  39526. angularSensibility: number;
  39527. private _mousemoveCallback;
  39528. private _observer;
  39529. private _rollObserver;
  39530. private previousPosition;
  39531. private noPreventDefault;
  39532. private element;
  39533. /**
  39534. * Listen to mouse events to control the camera.
  39535. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39537. */
  39538. constructor(touchEnabled?: boolean);
  39539. /**
  39540. * Attach the mouse control to the HTML DOM element.
  39541. * @param element Defines the element that listens to the input events.
  39542. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39543. */
  39544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39545. /**
  39546. * Detach the current controls from the specified dom element.
  39547. * @param element Defines the element to stop listening the inputs from
  39548. */
  39549. detachControl(element: Nullable<HTMLElement>): void;
  39550. /**
  39551. * Gets the class name of the current input.
  39552. * @returns the class name.
  39553. */
  39554. getClassName(): string;
  39555. /**
  39556. * Get the friendly name associated with the input class.
  39557. * @returns the input's friendly name.
  39558. */
  39559. getSimpleName(): string;
  39560. private _pointerInput;
  39561. private _onMouseMove;
  39562. /**
  39563. * Rotate camera by mouse offset.
  39564. */
  39565. private rotateCamera;
  39566. }
  39567. }
  39568. declare module BABYLON {
  39569. /**
  39570. * Default Inputs manager for the FlyCamera.
  39571. * It groups all the default supported inputs for ease of use.
  39572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39573. */
  39574. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39575. /**
  39576. * Instantiates a new FlyCameraInputsManager.
  39577. * @param camera Defines the camera the inputs belong to.
  39578. */
  39579. constructor(camera: FlyCamera);
  39580. /**
  39581. * Add keyboard input support to the input manager.
  39582. * @returns the new FlyCameraKeyboardMoveInput().
  39583. */
  39584. addKeyboard(): FlyCameraInputsManager;
  39585. /**
  39586. * Add mouse input support to the input manager.
  39587. * @param touchEnabled Enable touch screen support.
  39588. * @returns the new FlyCameraMouseInput().
  39589. */
  39590. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39591. }
  39592. }
  39593. declare module BABYLON {
  39594. /**
  39595. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39596. * such as in a 3D Space Shooter or a Flight Simulator.
  39597. */
  39598. export class FlyCamera extends TargetCamera {
  39599. /**
  39600. * Define the collision ellipsoid of the camera.
  39601. * This is helpful for simulating a camera body, like a player's body.
  39602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39603. */
  39604. ellipsoid: Vector3;
  39605. /**
  39606. * Define an offset for the position of the ellipsoid around the camera.
  39607. * This can be helpful if the camera is attached away from the player's body center,
  39608. * such as at its head.
  39609. */
  39610. ellipsoidOffset: Vector3;
  39611. /**
  39612. * Enable or disable collisions of the camera with the rest of the scene objects.
  39613. */
  39614. checkCollisions: boolean;
  39615. /**
  39616. * Enable or disable gravity on the camera.
  39617. */
  39618. applyGravity: boolean;
  39619. /**
  39620. * Define the current direction the camera is moving to.
  39621. */
  39622. cameraDirection: Vector3;
  39623. /**
  39624. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39625. * This overrides and empties cameraRotation.
  39626. */
  39627. rotationQuaternion: Quaternion;
  39628. /**
  39629. * Track Roll to maintain the wanted Rolling when looking around.
  39630. */
  39631. _trackRoll: number;
  39632. /**
  39633. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39634. */
  39635. rollCorrect: number;
  39636. /**
  39637. * Mimic a banked turn, Rolling the camera when Yawing.
  39638. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39639. */
  39640. bankedTurn: boolean;
  39641. /**
  39642. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39643. */
  39644. bankedTurnLimit: number;
  39645. /**
  39646. * Value of 0 disables the banked Roll.
  39647. * Value of 1 is equal to the Yaw angle in radians.
  39648. */
  39649. bankedTurnMultiplier: number;
  39650. /**
  39651. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39652. */
  39653. inputs: FlyCameraInputsManager;
  39654. /**
  39655. * Gets the input sensibility for mouse input.
  39656. * Higher values reduce sensitivity.
  39657. */
  39658. get angularSensibility(): number;
  39659. /**
  39660. * Sets the input sensibility for a mouse input.
  39661. * Higher values reduce sensitivity.
  39662. */
  39663. set angularSensibility(value: number);
  39664. /**
  39665. * Get the keys for camera movement forward.
  39666. */
  39667. get keysForward(): number[];
  39668. /**
  39669. * Set the keys for camera movement forward.
  39670. */
  39671. set keysForward(value: number[]);
  39672. /**
  39673. * Get the keys for camera movement backward.
  39674. */
  39675. get keysBackward(): number[];
  39676. set keysBackward(value: number[]);
  39677. /**
  39678. * Get the keys for camera movement up.
  39679. */
  39680. get keysUp(): number[];
  39681. /**
  39682. * Set the keys for camera movement up.
  39683. */
  39684. set keysUp(value: number[]);
  39685. /**
  39686. * Get the keys for camera movement down.
  39687. */
  39688. get keysDown(): number[];
  39689. /**
  39690. * Set the keys for camera movement down.
  39691. */
  39692. set keysDown(value: number[]);
  39693. /**
  39694. * Get the keys for camera movement left.
  39695. */
  39696. get keysLeft(): number[];
  39697. /**
  39698. * Set the keys for camera movement left.
  39699. */
  39700. set keysLeft(value: number[]);
  39701. /**
  39702. * Set the keys for camera movement right.
  39703. */
  39704. get keysRight(): number[];
  39705. /**
  39706. * Set the keys for camera movement right.
  39707. */
  39708. set keysRight(value: number[]);
  39709. /**
  39710. * Event raised when the camera collides with a mesh in the scene.
  39711. */
  39712. onCollide: (collidedMesh: AbstractMesh) => void;
  39713. private _collider;
  39714. private _needMoveForGravity;
  39715. private _oldPosition;
  39716. private _diffPosition;
  39717. private _newPosition;
  39718. /** @hidden */
  39719. _localDirection: Vector3;
  39720. /** @hidden */
  39721. _transformedDirection: Vector3;
  39722. /**
  39723. * Instantiates a FlyCamera.
  39724. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39725. * such as in a 3D Space Shooter or a Flight Simulator.
  39726. * @param name Define the name of the camera in the scene.
  39727. * @param position Define the starting position of the camera in the scene.
  39728. * @param scene Define the scene the camera belongs to.
  39729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39730. */
  39731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39732. /**
  39733. * Attach a control to the HTML DOM element.
  39734. * @param element Defines the element that listens to the input events.
  39735. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39736. */
  39737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39738. /**
  39739. * Detach a control from the HTML DOM element.
  39740. * The camera will stop reacting to that input.
  39741. * @param element Defines the element that listens to the input events.
  39742. */
  39743. detachControl(element: HTMLElement): void;
  39744. private _collisionMask;
  39745. /**
  39746. * Get the mask that the camera ignores in collision events.
  39747. */
  39748. get collisionMask(): number;
  39749. /**
  39750. * Set the mask that the camera ignores in collision events.
  39751. */
  39752. set collisionMask(mask: number);
  39753. /** @hidden */
  39754. _collideWithWorld(displacement: Vector3): void;
  39755. /** @hidden */
  39756. private _onCollisionPositionChange;
  39757. /** @hidden */
  39758. _checkInputs(): void;
  39759. /** @hidden */
  39760. _decideIfNeedsToMove(): boolean;
  39761. /** @hidden */
  39762. _updatePosition(): void;
  39763. /**
  39764. * Restore the Roll to its target value at the rate specified.
  39765. * @param rate - Higher means slower restoring.
  39766. * @hidden
  39767. */
  39768. restoreRoll(rate: number): void;
  39769. /**
  39770. * Destroy the camera and release the current resources held by it.
  39771. */
  39772. dispose(): void;
  39773. /**
  39774. * Get the current object class name.
  39775. * @returns the class name.
  39776. */
  39777. getClassName(): string;
  39778. }
  39779. }
  39780. declare module BABYLON {
  39781. /**
  39782. * Listen to keyboard events to control the camera.
  39783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39784. */
  39785. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39786. /**
  39787. * Defines the camera the input is attached to.
  39788. */
  39789. camera: FlyCamera;
  39790. /**
  39791. * The list of keyboard keys used to control the forward move of the camera.
  39792. */
  39793. keysForward: number[];
  39794. /**
  39795. * The list of keyboard keys used to control the backward move of the camera.
  39796. */
  39797. keysBackward: number[];
  39798. /**
  39799. * The list of keyboard keys used to control the forward move of the camera.
  39800. */
  39801. keysUp: number[];
  39802. /**
  39803. * The list of keyboard keys used to control the backward move of the camera.
  39804. */
  39805. keysDown: number[];
  39806. /**
  39807. * The list of keyboard keys used to control the right strafe move of the camera.
  39808. */
  39809. keysRight: number[];
  39810. /**
  39811. * The list of keyboard keys used to control the left strafe move of the camera.
  39812. */
  39813. keysLeft: number[];
  39814. private _keys;
  39815. private _onCanvasBlurObserver;
  39816. private _onKeyboardObserver;
  39817. private _engine;
  39818. private _scene;
  39819. /**
  39820. * Attach the input controls to a specific dom element to get the input from.
  39821. * @param element Defines the element the controls should be listened from
  39822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39823. */
  39824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39825. /**
  39826. * Detach the current controls from the specified dom element.
  39827. * @param element Defines the element to stop listening the inputs from
  39828. */
  39829. detachControl(element: Nullable<HTMLElement>): void;
  39830. /**
  39831. * Gets the class name of the current intput.
  39832. * @returns the class name
  39833. */
  39834. getClassName(): string;
  39835. /** @hidden */
  39836. _onLostFocus(e: FocusEvent): void;
  39837. /**
  39838. * Get the friendly name associated with the input class.
  39839. * @returns the input friendly name
  39840. */
  39841. getSimpleName(): string;
  39842. /**
  39843. * Update the current camera state depending on the inputs that have been used this frame.
  39844. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39845. */
  39846. checkInputs(): void;
  39847. }
  39848. }
  39849. declare module BABYLON {
  39850. /**
  39851. * Manage the mouse wheel inputs to control a follow camera.
  39852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39853. */
  39854. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39855. /**
  39856. * Defines the camera the input is attached to.
  39857. */
  39858. camera: FollowCamera;
  39859. /**
  39860. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39861. */
  39862. axisControlRadius: boolean;
  39863. /**
  39864. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39865. */
  39866. axisControlHeight: boolean;
  39867. /**
  39868. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39869. */
  39870. axisControlRotation: boolean;
  39871. /**
  39872. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39873. * relation to mouseWheel events.
  39874. */
  39875. wheelPrecision: number;
  39876. /**
  39877. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39878. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39879. */
  39880. wheelDeltaPercentage: number;
  39881. private _wheel;
  39882. private _observer;
  39883. /**
  39884. * Attach the input controls to a specific dom element to get the input from.
  39885. * @param element Defines the element the controls should be listened from
  39886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39887. */
  39888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39889. /**
  39890. * Detach the current controls from the specified dom element.
  39891. * @param element Defines the element to stop listening the inputs from
  39892. */
  39893. detachControl(element: Nullable<HTMLElement>): void;
  39894. /**
  39895. * Gets the class name of the current intput.
  39896. * @returns the class name
  39897. */
  39898. getClassName(): string;
  39899. /**
  39900. * Get the friendly name associated with the input class.
  39901. * @returns the input friendly name
  39902. */
  39903. getSimpleName(): string;
  39904. }
  39905. }
  39906. declare module BABYLON {
  39907. /**
  39908. * Manage the pointers inputs to control an follow camera.
  39909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39910. */
  39911. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39912. /**
  39913. * Defines the camera the input is attached to.
  39914. */
  39915. camera: FollowCamera;
  39916. /**
  39917. * Gets the class name of the current input.
  39918. * @returns the class name
  39919. */
  39920. getClassName(): string;
  39921. /**
  39922. * Defines the pointer angular sensibility along the X axis or how fast is
  39923. * the camera rotating.
  39924. * A negative number will reverse the axis direction.
  39925. */
  39926. angularSensibilityX: number;
  39927. /**
  39928. * Defines the pointer angular sensibility along the Y axis or how fast is
  39929. * the camera rotating.
  39930. * A negative number will reverse the axis direction.
  39931. */
  39932. angularSensibilityY: number;
  39933. /**
  39934. * Defines the pointer pinch precision or how fast is the camera zooming.
  39935. * A negative number will reverse the axis direction.
  39936. */
  39937. pinchPrecision: number;
  39938. /**
  39939. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39940. * from 0.
  39941. * It defines the percentage of current camera.radius to use as delta when
  39942. * pinch zoom is used.
  39943. */
  39944. pinchDeltaPercentage: number;
  39945. /**
  39946. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39947. */
  39948. axisXControlRadius: boolean;
  39949. /**
  39950. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39951. */
  39952. axisXControlHeight: boolean;
  39953. /**
  39954. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39955. */
  39956. axisXControlRotation: boolean;
  39957. /**
  39958. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39959. */
  39960. axisYControlRadius: boolean;
  39961. /**
  39962. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39963. */
  39964. axisYControlHeight: boolean;
  39965. /**
  39966. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39967. */
  39968. axisYControlRotation: boolean;
  39969. /**
  39970. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39971. */
  39972. axisPinchControlRadius: boolean;
  39973. /**
  39974. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39975. */
  39976. axisPinchControlHeight: boolean;
  39977. /**
  39978. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39979. */
  39980. axisPinchControlRotation: boolean;
  39981. /**
  39982. * Log error messages if basic misconfiguration has occurred.
  39983. */
  39984. warningEnable: boolean;
  39985. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39986. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39987. private _warningCounter;
  39988. private _warning;
  39989. }
  39990. }
  39991. declare module BABYLON {
  39992. /**
  39993. * Default Inputs manager for the FollowCamera.
  39994. * It groups all the default supported inputs for ease of use.
  39995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39996. */
  39997. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39998. /**
  39999. * Instantiates a new FollowCameraInputsManager.
  40000. * @param camera Defines the camera the inputs belong to
  40001. */
  40002. constructor(camera: FollowCamera);
  40003. /**
  40004. * Add keyboard input support to the input manager.
  40005. * @returns the current input manager
  40006. */
  40007. addKeyboard(): FollowCameraInputsManager;
  40008. /**
  40009. * Add mouse wheel input support to the input manager.
  40010. * @returns the current input manager
  40011. */
  40012. addMouseWheel(): FollowCameraInputsManager;
  40013. /**
  40014. * Add pointers input support to the input manager.
  40015. * @returns the current input manager
  40016. */
  40017. addPointers(): FollowCameraInputsManager;
  40018. /**
  40019. * Add orientation input support to the input manager.
  40020. * @returns the current input manager
  40021. */
  40022. addVRDeviceOrientation(): FollowCameraInputsManager;
  40023. }
  40024. }
  40025. declare module BABYLON {
  40026. /**
  40027. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40028. * an arc rotate version arcFollowCamera are available.
  40029. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40030. */
  40031. export class FollowCamera extends TargetCamera {
  40032. /**
  40033. * Distance the follow camera should follow an object at
  40034. */
  40035. radius: number;
  40036. /**
  40037. * Minimum allowed distance of the camera to the axis of rotation
  40038. * (The camera can not get closer).
  40039. * This can help limiting how the Camera is able to move in the scene.
  40040. */
  40041. lowerRadiusLimit: Nullable<number>;
  40042. /**
  40043. * Maximum allowed distance of the camera to the axis of rotation
  40044. * (The camera can not get further).
  40045. * This can help limiting how the Camera is able to move in the scene.
  40046. */
  40047. upperRadiusLimit: Nullable<number>;
  40048. /**
  40049. * Define a rotation offset between the camera and the object it follows
  40050. */
  40051. rotationOffset: number;
  40052. /**
  40053. * Minimum allowed angle to camera position relative to target object.
  40054. * This can help limiting how the Camera is able to move in the scene.
  40055. */
  40056. lowerRotationOffsetLimit: Nullable<number>;
  40057. /**
  40058. * Maximum allowed angle to camera position relative to target object.
  40059. * This can help limiting how the Camera is able to move in the scene.
  40060. */
  40061. upperRotationOffsetLimit: Nullable<number>;
  40062. /**
  40063. * Define a height offset between the camera and the object it follows.
  40064. * It can help following an object from the top (like a car chaing a plane)
  40065. */
  40066. heightOffset: number;
  40067. /**
  40068. * Minimum allowed height of camera position relative to target object.
  40069. * This can help limiting how the Camera is able to move in the scene.
  40070. */
  40071. lowerHeightOffsetLimit: Nullable<number>;
  40072. /**
  40073. * Maximum allowed height of camera position relative to target object.
  40074. * This can help limiting how the Camera is able to move in the scene.
  40075. */
  40076. upperHeightOffsetLimit: Nullable<number>;
  40077. /**
  40078. * Define how fast the camera can accelerate to follow it s target.
  40079. */
  40080. cameraAcceleration: number;
  40081. /**
  40082. * Define the speed limit of the camera following an object.
  40083. */
  40084. maxCameraSpeed: number;
  40085. /**
  40086. * Define the target of the camera.
  40087. */
  40088. lockedTarget: Nullable<AbstractMesh>;
  40089. /**
  40090. * Defines the input associated with the camera.
  40091. */
  40092. inputs: FollowCameraInputsManager;
  40093. /**
  40094. * Instantiates the follow camera.
  40095. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40096. * @param name Define the name of the camera in the scene
  40097. * @param position Define the position of the camera
  40098. * @param scene Define the scene the camera belong to
  40099. * @param lockedTarget Define the target of the camera
  40100. */
  40101. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40102. private _follow;
  40103. /**
  40104. * Attached controls to the current camera.
  40105. * @param element Defines the element the controls should be listened from
  40106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40107. */
  40108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40109. /**
  40110. * Detach the current controls from the camera.
  40111. * The camera will stop reacting to inputs.
  40112. * @param element Defines the element to stop listening the inputs from
  40113. */
  40114. detachControl(element: HTMLElement): void;
  40115. /** @hidden */
  40116. _checkInputs(): void;
  40117. private _checkLimits;
  40118. /**
  40119. * Gets the camera class name.
  40120. * @returns the class name
  40121. */
  40122. getClassName(): string;
  40123. }
  40124. /**
  40125. * Arc Rotate version of the follow camera.
  40126. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40127. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40128. */
  40129. export class ArcFollowCamera extends TargetCamera {
  40130. /** The longitudinal angle of the camera */
  40131. alpha: number;
  40132. /** The latitudinal angle of the camera */
  40133. beta: number;
  40134. /** The radius of the camera from its target */
  40135. radius: number;
  40136. /** Define the camera target (the messh it should follow) */
  40137. target: Nullable<AbstractMesh>;
  40138. private _cartesianCoordinates;
  40139. /**
  40140. * Instantiates a new ArcFollowCamera
  40141. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40142. * @param name Define the name of the camera
  40143. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40144. * @param beta Define the rotation angle of the camera around the elevation axis
  40145. * @param radius Define the radius of the camera from its target point
  40146. * @param target Define the target of the camera
  40147. * @param scene Define the scene the camera belongs to
  40148. */
  40149. constructor(name: string,
  40150. /** The longitudinal angle of the camera */
  40151. alpha: number,
  40152. /** The latitudinal angle of the camera */
  40153. beta: number,
  40154. /** The radius of the camera from its target */
  40155. radius: number,
  40156. /** Define the camera target (the messh it should follow) */
  40157. target: Nullable<AbstractMesh>, scene: Scene);
  40158. private _follow;
  40159. /** @hidden */
  40160. _checkInputs(): void;
  40161. /**
  40162. * Returns the class name of the object.
  40163. * It is mostly used internally for serialization purposes.
  40164. */
  40165. getClassName(): string;
  40166. }
  40167. }
  40168. declare module BABYLON {
  40169. /**
  40170. * Manage the keyboard inputs to control the movement of a follow camera.
  40171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40172. */
  40173. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40174. /**
  40175. * Defines the camera the input is attached to.
  40176. */
  40177. camera: FollowCamera;
  40178. /**
  40179. * Defines the list of key codes associated with the up action (increase heightOffset)
  40180. */
  40181. keysHeightOffsetIncr: number[];
  40182. /**
  40183. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40184. */
  40185. keysHeightOffsetDecr: number[];
  40186. /**
  40187. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40188. */
  40189. keysHeightOffsetModifierAlt: boolean;
  40190. /**
  40191. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40192. */
  40193. keysHeightOffsetModifierCtrl: boolean;
  40194. /**
  40195. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40196. */
  40197. keysHeightOffsetModifierShift: boolean;
  40198. /**
  40199. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40200. */
  40201. keysRotationOffsetIncr: number[];
  40202. /**
  40203. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40204. */
  40205. keysRotationOffsetDecr: number[];
  40206. /**
  40207. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40208. */
  40209. keysRotationOffsetModifierAlt: boolean;
  40210. /**
  40211. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40212. */
  40213. keysRotationOffsetModifierCtrl: boolean;
  40214. /**
  40215. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40216. */
  40217. keysRotationOffsetModifierShift: boolean;
  40218. /**
  40219. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40220. */
  40221. keysRadiusIncr: number[];
  40222. /**
  40223. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40224. */
  40225. keysRadiusDecr: number[];
  40226. /**
  40227. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40228. */
  40229. keysRadiusModifierAlt: boolean;
  40230. /**
  40231. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40232. */
  40233. keysRadiusModifierCtrl: boolean;
  40234. /**
  40235. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40236. */
  40237. keysRadiusModifierShift: boolean;
  40238. /**
  40239. * Defines the rate of change of heightOffset.
  40240. */
  40241. heightSensibility: number;
  40242. /**
  40243. * Defines the rate of change of rotationOffset.
  40244. */
  40245. rotationSensibility: number;
  40246. /**
  40247. * Defines the rate of change of radius.
  40248. */
  40249. radiusSensibility: number;
  40250. private _keys;
  40251. private _ctrlPressed;
  40252. private _altPressed;
  40253. private _shiftPressed;
  40254. private _onCanvasBlurObserver;
  40255. private _onKeyboardObserver;
  40256. private _engine;
  40257. private _scene;
  40258. /**
  40259. * Attach the input controls to a specific dom element to get the input from.
  40260. * @param element Defines the element the controls should be listened from
  40261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40262. */
  40263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40264. /**
  40265. * Detach the current controls from the specified dom element.
  40266. * @param element Defines the element to stop listening the inputs from
  40267. */
  40268. detachControl(element: Nullable<HTMLElement>): void;
  40269. /**
  40270. * Update the current camera state depending on the inputs that have been used this frame.
  40271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40272. */
  40273. checkInputs(): void;
  40274. /**
  40275. * Gets the class name of the current input.
  40276. * @returns the class name
  40277. */
  40278. getClassName(): string;
  40279. /**
  40280. * Get the friendly name associated with the input class.
  40281. * @returns the input friendly name
  40282. */
  40283. getSimpleName(): string;
  40284. /**
  40285. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40286. * allow modification of the heightOffset value.
  40287. */
  40288. private _modifierHeightOffset;
  40289. /**
  40290. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40291. * allow modification of the rotationOffset value.
  40292. */
  40293. private _modifierRotationOffset;
  40294. /**
  40295. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40296. * allow modification of the radius value.
  40297. */
  40298. private _modifierRadius;
  40299. }
  40300. }
  40301. declare module BABYLON {
  40302. interface FreeCameraInputsManager {
  40303. /**
  40304. * @hidden
  40305. */
  40306. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40307. /**
  40308. * Add orientation input support to the input manager.
  40309. * @returns the current input manager
  40310. */
  40311. addDeviceOrientation(): FreeCameraInputsManager;
  40312. }
  40313. /**
  40314. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40315. * Screen rotation is taken into account.
  40316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40317. */
  40318. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40319. private _camera;
  40320. private _screenOrientationAngle;
  40321. private _constantTranform;
  40322. private _screenQuaternion;
  40323. private _alpha;
  40324. private _beta;
  40325. private _gamma;
  40326. /**
  40327. * Can be used to detect if a device orientation sensor is available on a device
  40328. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40329. * @returns a promise that will resolve on orientation change
  40330. */
  40331. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40332. /**
  40333. * @hidden
  40334. */
  40335. _onDeviceOrientationChangedObservable: Observable<void>;
  40336. /**
  40337. * Instantiates a new input
  40338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40339. */
  40340. constructor();
  40341. /**
  40342. * Define the camera controlled by the input.
  40343. */
  40344. get camera(): FreeCamera;
  40345. set camera(camera: FreeCamera);
  40346. /**
  40347. * Attach the input controls to a specific dom element to get the input from.
  40348. * @param element Defines the element the controls should be listened from
  40349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40350. */
  40351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40352. private _orientationChanged;
  40353. private _deviceOrientation;
  40354. /**
  40355. * Detach the current controls from the specified dom element.
  40356. * @param element Defines the element to stop listening the inputs from
  40357. */
  40358. detachControl(element: Nullable<HTMLElement>): void;
  40359. /**
  40360. * Update the current camera state depending on the inputs that have been used this frame.
  40361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40362. */
  40363. checkInputs(): void;
  40364. /**
  40365. * Gets the class name of the current intput.
  40366. * @returns the class name
  40367. */
  40368. getClassName(): string;
  40369. /**
  40370. * Get the friendly name associated with the input class.
  40371. * @returns the input friendly name
  40372. */
  40373. getSimpleName(): string;
  40374. }
  40375. }
  40376. declare module BABYLON {
  40377. /**
  40378. * Manage the gamepad inputs to control a free camera.
  40379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40380. */
  40381. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40382. /**
  40383. * Define the camera the input is attached to.
  40384. */
  40385. camera: FreeCamera;
  40386. /**
  40387. * Define the Gamepad controlling the input
  40388. */
  40389. gamepad: Nullable<Gamepad>;
  40390. /**
  40391. * Defines the gamepad rotation sensiblity.
  40392. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40393. */
  40394. gamepadAngularSensibility: number;
  40395. /**
  40396. * Defines the gamepad move sensiblity.
  40397. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40398. */
  40399. gamepadMoveSensibility: number;
  40400. private _yAxisScale;
  40401. /**
  40402. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40403. */
  40404. get invertYAxis(): boolean;
  40405. set invertYAxis(value: boolean);
  40406. private _onGamepadConnectedObserver;
  40407. private _onGamepadDisconnectedObserver;
  40408. private _cameraTransform;
  40409. private _deltaTransform;
  40410. private _vector3;
  40411. private _vector2;
  40412. /**
  40413. * Attach the input controls to a specific dom element to get the input from.
  40414. * @param element Defines the element the controls should be listened from
  40415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40416. */
  40417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40418. /**
  40419. * Detach the current controls from the specified dom element.
  40420. * @param element Defines the element to stop listening the inputs from
  40421. */
  40422. detachControl(element: Nullable<HTMLElement>): void;
  40423. /**
  40424. * Update the current camera state depending on the inputs that have been used this frame.
  40425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40426. */
  40427. checkInputs(): void;
  40428. /**
  40429. * Gets the class name of the current intput.
  40430. * @returns the class name
  40431. */
  40432. getClassName(): string;
  40433. /**
  40434. * Get the friendly name associated with the input class.
  40435. * @returns the input friendly name
  40436. */
  40437. getSimpleName(): string;
  40438. }
  40439. }
  40440. declare module BABYLON {
  40441. /**
  40442. * Defines the potential axis of a Joystick
  40443. */
  40444. export enum JoystickAxis {
  40445. /** X axis */
  40446. X = 0,
  40447. /** Y axis */
  40448. Y = 1,
  40449. /** Z axis */
  40450. Z = 2
  40451. }
  40452. /**
  40453. * Class used to define virtual joystick (used in touch mode)
  40454. */
  40455. export class VirtualJoystick {
  40456. /**
  40457. * Gets or sets a boolean indicating that left and right values must be inverted
  40458. */
  40459. reverseLeftRight: boolean;
  40460. /**
  40461. * Gets or sets a boolean indicating that up and down values must be inverted
  40462. */
  40463. reverseUpDown: boolean;
  40464. /**
  40465. * Gets the offset value for the position (ie. the change of the position value)
  40466. */
  40467. deltaPosition: Vector3;
  40468. /**
  40469. * Gets a boolean indicating if the virtual joystick was pressed
  40470. */
  40471. pressed: boolean;
  40472. /**
  40473. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40474. */
  40475. static Canvas: Nullable<HTMLCanvasElement>;
  40476. private static _globalJoystickIndex;
  40477. private static vjCanvasContext;
  40478. private static vjCanvasWidth;
  40479. private static vjCanvasHeight;
  40480. private static halfWidth;
  40481. private _action;
  40482. private _axisTargetedByLeftAndRight;
  40483. private _axisTargetedByUpAndDown;
  40484. private _joystickSensibility;
  40485. private _inversedSensibility;
  40486. private _joystickPointerID;
  40487. private _joystickColor;
  40488. private _joystickPointerPos;
  40489. private _joystickPreviousPointerPos;
  40490. private _joystickPointerStartPos;
  40491. private _deltaJoystickVector;
  40492. private _leftJoystick;
  40493. private _touches;
  40494. private _onPointerDownHandlerRef;
  40495. private _onPointerMoveHandlerRef;
  40496. private _onPointerUpHandlerRef;
  40497. private _onResize;
  40498. /**
  40499. * Creates a new virtual joystick
  40500. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40501. */
  40502. constructor(leftJoystick?: boolean);
  40503. /**
  40504. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40505. * @param newJoystickSensibility defines the new sensibility
  40506. */
  40507. setJoystickSensibility(newJoystickSensibility: number): void;
  40508. private _onPointerDown;
  40509. private _onPointerMove;
  40510. private _onPointerUp;
  40511. /**
  40512. * Change the color of the virtual joystick
  40513. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40514. */
  40515. setJoystickColor(newColor: string): void;
  40516. /**
  40517. * Defines a callback to call when the joystick is touched
  40518. * @param action defines the callback
  40519. */
  40520. setActionOnTouch(action: () => any): void;
  40521. /**
  40522. * Defines which axis you'd like to control for left & right
  40523. * @param axis defines the axis to use
  40524. */
  40525. setAxisForLeftRight(axis: JoystickAxis): void;
  40526. /**
  40527. * Defines which axis you'd like to control for up & down
  40528. * @param axis defines the axis to use
  40529. */
  40530. setAxisForUpDown(axis: JoystickAxis): void;
  40531. private _drawVirtualJoystick;
  40532. /**
  40533. * Release internal HTML canvas
  40534. */
  40535. releaseCanvas(): void;
  40536. }
  40537. }
  40538. declare module BABYLON {
  40539. interface FreeCameraInputsManager {
  40540. /**
  40541. * Add virtual joystick input support to the input manager.
  40542. * @returns the current input manager
  40543. */
  40544. addVirtualJoystick(): FreeCameraInputsManager;
  40545. }
  40546. /**
  40547. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40549. */
  40550. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40551. /**
  40552. * Defines the camera the input is attached to.
  40553. */
  40554. camera: FreeCamera;
  40555. private _leftjoystick;
  40556. private _rightjoystick;
  40557. /**
  40558. * Gets the left stick of the virtual joystick.
  40559. * @returns The virtual Joystick
  40560. */
  40561. getLeftJoystick(): VirtualJoystick;
  40562. /**
  40563. * Gets the right stick of the virtual joystick.
  40564. * @returns The virtual Joystick
  40565. */
  40566. getRightJoystick(): VirtualJoystick;
  40567. /**
  40568. * Update the current camera state depending on the inputs that have been used this frame.
  40569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40570. */
  40571. checkInputs(): void;
  40572. /**
  40573. * Attach the input controls to a specific dom element to get the input from.
  40574. * @param element Defines the element the controls should be listened from
  40575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40576. */
  40577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40578. /**
  40579. * Detach the current controls from the specified dom element.
  40580. * @param element Defines the element to stop listening the inputs from
  40581. */
  40582. detachControl(element: Nullable<HTMLElement>): void;
  40583. /**
  40584. * Gets the class name of the current intput.
  40585. * @returns the class name
  40586. */
  40587. getClassName(): string;
  40588. /**
  40589. * Get the friendly name associated with the input class.
  40590. * @returns the input friendly name
  40591. */
  40592. getSimpleName(): string;
  40593. }
  40594. }
  40595. declare module BABYLON {
  40596. /**
  40597. * This represents a FPS type of camera controlled by touch.
  40598. * This is like a universal camera minus the Gamepad controls.
  40599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40600. */
  40601. export class TouchCamera extends FreeCamera {
  40602. /**
  40603. * Defines the touch sensibility for rotation.
  40604. * The higher the faster.
  40605. */
  40606. get touchAngularSensibility(): number;
  40607. set touchAngularSensibility(value: number);
  40608. /**
  40609. * Defines the touch sensibility for move.
  40610. * The higher the faster.
  40611. */
  40612. get touchMoveSensibility(): number;
  40613. set touchMoveSensibility(value: number);
  40614. /**
  40615. * Instantiates a new touch camera.
  40616. * This represents a FPS type of camera controlled by touch.
  40617. * This is like a universal camera minus the Gamepad controls.
  40618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40619. * @param name Define the name of the camera in the scene
  40620. * @param position Define the start position of the camera in the scene
  40621. * @param scene Define the scene the camera belongs to
  40622. */
  40623. constructor(name: string, position: Vector3, scene: Scene);
  40624. /**
  40625. * Gets the current object class name.
  40626. * @return the class name
  40627. */
  40628. getClassName(): string;
  40629. /** @hidden */
  40630. _setupInputs(): void;
  40631. }
  40632. }
  40633. declare module BABYLON {
  40634. /**
  40635. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40636. * being tilted forward or back and left or right.
  40637. */
  40638. export class DeviceOrientationCamera extends FreeCamera {
  40639. private _initialQuaternion;
  40640. private _quaternionCache;
  40641. private _tmpDragQuaternion;
  40642. private _disablePointerInputWhenUsingDeviceOrientation;
  40643. /**
  40644. * Creates a new device orientation camera
  40645. * @param name The name of the camera
  40646. * @param position The start position camera
  40647. * @param scene The scene the camera belongs to
  40648. */
  40649. constructor(name: string, position: Vector3, scene: Scene);
  40650. /**
  40651. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40652. */
  40653. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40654. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40655. private _dragFactor;
  40656. /**
  40657. * Enabled turning on the y axis when the orientation sensor is active
  40658. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40659. */
  40660. enableHorizontalDragging(dragFactor?: number): void;
  40661. /**
  40662. * Gets the current instance class name ("DeviceOrientationCamera").
  40663. * This helps avoiding instanceof at run time.
  40664. * @returns the class name
  40665. */
  40666. getClassName(): string;
  40667. /**
  40668. * @hidden
  40669. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40670. */
  40671. _checkInputs(): void;
  40672. /**
  40673. * Reset the camera to its default orientation on the specified axis only.
  40674. * @param axis The axis to reset
  40675. */
  40676. resetToCurrentRotation(axis?: Axis): void;
  40677. }
  40678. }
  40679. declare module BABYLON {
  40680. /**
  40681. * Defines supported buttons for XBox360 compatible gamepads
  40682. */
  40683. export enum Xbox360Button {
  40684. /** A */
  40685. A = 0,
  40686. /** B */
  40687. B = 1,
  40688. /** X */
  40689. X = 2,
  40690. /** Y */
  40691. Y = 3,
  40692. /** Start */
  40693. Start = 4,
  40694. /** Back */
  40695. Back = 5,
  40696. /** Left button */
  40697. LB = 6,
  40698. /** Right button */
  40699. RB = 7,
  40700. /** Left stick */
  40701. LeftStick = 8,
  40702. /** Right stick */
  40703. RightStick = 9
  40704. }
  40705. /** Defines values for XBox360 DPad */
  40706. export enum Xbox360Dpad {
  40707. /** Up */
  40708. Up = 0,
  40709. /** Down */
  40710. Down = 1,
  40711. /** Left */
  40712. Left = 2,
  40713. /** Right */
  40714. Right = 3
  40715. }
  40716. /**
  40717. * Defines a XBox360 gamepad
  40718. */
  40719. export class Xbox360Pad extends Gamepad {
  40720. private _leftTrigger;
  40721. private _rightTrigger;
  40722. private _onlefttriggerchanged;
  40723. private _onrighttriggerchanged;
  40724. private _onbuttondown;
  40725. private _onbuttonup;
  40726. private _ondpaddown;
  40727. private _ondpadup;
  40728. /** Observable raised when a button is pressed */
  40729. onButtonDownObservable: Observable<Xbox360Button>;
  40730. /** Observable raised when a button is released */
  40731. onButtonUpObservable: Observable<Xbox360Button>;
  40732. /** Observable raised when a pad is pressed */
  40733. onPadDownObservable: Observable<Xbox360Dpad>;
  40734. /** Observable raised when a pad is released */
  40735. onPadUpObservable: Observable<Xbox360Dpad>;
  40736. private _buttonA;
  40737. private _buttonB;
  40738. private _buttonX;
  40739. private _buttonY;
  40740. private _buttonBack;
  40741. private _buttonStart;
  40742. private _buttonLB;
  40743. private _buttonRB;
  40744. private _buttonLeftStick;
  40745. private _buttonRightStick;
  40746. private _dPadUp;
  40747. private _dPadDown;
  40748. private _dPadLeft;
  40749. private _dPadRight;
  40750. private _isXboxOnePad;
  40751. /**
  40752. * Creates a new XBox360 gamepad object
  40753. * @param id defines the id of this gamepad
  40754. * @param index defines its index
  40755. * @param gamepad defines the internal HTML gamepad object
  40756. * @param xboxOne defines if it is a XBox One gamepad
  40757. */
  40758. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40759. /**
  40760. * Defines the callback to call when left trigger is pressed
  40761. * @param callback defines the callback to use
  40762. */
  40763. onlefttriggerchanged(callback: (value: number) => void): void;
  40764. /**
  40765. * Defines the callback to call when right trigger is pressed
  40766. * @param callback defines the callback to use
  40767. */
  40768. onrighttriggerchanged(callback: (value: number) => void): void;
  40769. /**
  40770. * Gets the left trigger value
  40771. */
  40772. get leftTrigger(): number;
  40773. /**
  40774. * Sets the left trigger value
  40775. */
  40776. set leftTrigger(newValue: number);
  40777. /**
  40778. * Gets the right trigger value
  40779. */
  40780. get rightTrigger(): number;
  40781. /**
  40782. * Sets the right trigger value
  40783. */
  40784. set rightTrigger(newValue: number);
  40785. /**
  40786. * Defines the callback to call when a button is pressed
  40787. * @param callback defines the callback to use
  40788. */
  40789. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40790. /**
  40791. * Defines the callback to call when a button is released
  40792. * @param callback defines the callback to use
  40793. */
  40794. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40795. /**
  40796. * Defines the callback to call when a pad is pressed
  40797. * @param callback defines the callback to use
  40798. */
  40799. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40800. /**
  40801. * Defines the callback to call when a pad is released
  40802. * @param callback defines the callback to use
  40803. */
  40804. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40805. private _setButtonValue;
  40806. private _setDPadValue;
  40807. /**
  40808. * Gets the value of the `A` button
  40809. */
  40810. get buttonA(): number;
  40811. /**
  40812. * Sets the value of the `A` button
  40813. */
  40814. set buttonA(value: number);
  40815. /**
  40816. * Gets the value of the `B` button
  40817. */
  40818. get buttonB(): number;
  40819. /**
  40820. * Sets the value of the `B` button
  40821. */
  40822. set buttonB(value: number);
  40823. /**
  40824. * Gets the value of the `X` button
  40825. */
  40826. get buttonX(): number;
  40827. /**
  40828. * Sets the value of the `X` button
  40829. */
  40830. set buttonX(value: number);
  40831. /**
  40832. * Gets the value of the `Y` button
  40833. */
  40834. get buttonY(): number;
  40835. /**
  40836. * Sets the value of the `Y` button
  40837. */
  40838. set buttonY(value: number);
  40839. /**
  40840. * Gets the value of the `Start` button
  40841. */
  40842. get buttonStart(): number;
  40843. /**
  40844. * Sets the value of the `Start` button
  40845. */
  40846. set buttonStart(value: number);
  40847. /**
  40848. * Gets the value of the `Back` button
  40849. */
  40850. get buttonBack(): number;
  40851. /**
  40852. * Sets the value of the `Back` button
  40853. */
  40854. set buttonBack(value: number);
  40855. /**
  40856. * Gets the value of the `Left` button
  40857. */
  40858. get buttonLB(): number;
  40859. /**
  40860. * Sets the value of the `Left` button
  40861. */
  40862. set buttonLB(value: number);
  40863. /**
  40864. * Gets the value of the `Right` button
  40865. */
  40866. get buttonRB(): number;
  40867. /**
  40868. * Sets the value of the `Right` button
  40869. */
  40870. set buttonRB(value: number);
  40871. /**
  40872. * Gets the value of the Left joystick
  40873. */
  40874. get buttonLeftStick(): number;
  40875. /**
  40876. * Sets the value of the Left joystick
  40877. */
  40878. set buttonLeftStick(value: number);
  40879. /**
  40880. * Gets the value of the Right joystick
  40881. */
  40882. get buttonRightStick(): number;
  40883. /**
  40884. * Sets the value of the Right joystick
  40885. */
  40886. set buttonRightStick(value: number);
  40887. /**
  40888. * Gets the value of D-pad up
  40889. */
  40890. get dPadUp(): number;
  40891. /**
  40892. * Sets the value of D-pad up
  40893. */
  40894. set dPadUp(value: number);
  40895. /**
  40896. * Gets the value of D-pad down
  40897. */
  40898. get dPadDown(): number;
  40899. /**
  40900. * Sets the value of D-pad down
  40901. */
  40902. set dPadDown(value: number);
  40903. /**
  40904. * Gets the value of D-pad left
  40905. */
  40906. get dPadLeft(): number;
  40907. /**
  40908. * Sets the value of D-pad left
  40909. */
  40910. set dPadLeft(value: number);
  40911. /**
  40912. * Gets the value of D-pad right
  40913. */
  40914. get dPadRight(): number;
  40915. /**
  40916. * Sets the value of D-pad right
  40917. */
  40918. set dPadRight(value: number);
  40919. /**
  40920. * Force the gamepad to synchronize with device values
  40921. */
  40922. update(): void;
  40923. /**
  40924. * Disposes the gamepad
  40925. */
  40926. dispose(): void;
  40927. }
  40928. }
  40929. declare module BABYLON {
  40930. /**
  40931. * Defines supported buttons for DualShock compatible gamepads
  40932. */
  40933. export enum DualShockButton {
  40934. /** Cross */
  40935. Cross = 0,
  40936. /** Circle */
  40937. Circle = 1,
  40938. /** Square */
  40939. Square = 2,
  40940. /** Triangle */
  40941. Triangle = 3,
  40942. /** Options */
  40943. Options = 4,
  40944. /** Share */
  40945. Share = 5,
  40946. /** L1 */
  40947. L1 = 6,
  40948. /** R1 */
  40949. R1 = 7,
  40950. /** Left stick */
  40951. LeftStick = 8,
  40952. /** Right stick */
  40953. RightStick = 9
  40954. }
  40955. /** Defines values for DualShock DPad */
  40956. export enum DualShockDpad {
  40957. /** Up */
  40958. Up = 0,
  40959. /** Down */
  40960. Down = 1,
  40961. /** Left */
  40962. Left = 2,
  40963. /** Right */
  40964. Right = 3
  40965. }
  40966. /**
  40967. * Defines a DualShock gamepad
  40968. */
  40969. export class DualShockPad extends Gamepad {
  40970. private _leftTrigger;
  40971. private _rightTrigger;
  40972. private _onlefttriggerchanged;
  40973. private _onrighttriggerchanged;
  40974. private _onbuttondown;
  40975. private _onbuttonup;
  40976. private _ondpaddown;
  40977. private _ondpadup;
  40978. /** Observable raised when a button is pressed */
  40979. onButtonDownObservable: Observable<DualShockButton>;
  40980. /** Observable raised when a button is released */
  40981. onButtonUpObservable: Observable<DualShockButton>;
  40982. /** Observable raised when a pad is pressed */
  40983. onPadDownObservable: Observable<DualShockDpad>;
  40984. /** Observable raised when a pad is released */
  40985. onPadUpObservable: Observable<DualShockDpad>;
  40986. private _buttonCross;
  40987. private _buttonCircle;
  40988. private _buttonSquare;
  40989. private _buttonTriangle;
  40990. private _buttonShare;
  40991. private _buttonOptions;
  40992. private _buttonL1;
  40993. private _buttonR1;
  40994. private _buttonLeftStick;
  40995. private _buttonRightStick;
  40996. private _dPadUp;
  40997. private _dPadDown;
  40998. private _dPadLeft;
  40999. private _dPadRight;
  41000. /**
  41001. * Creates a new DualShock gamepad object
  41002. * @param id defines the id of this gamepad
  41003. * @param index defines its index
  41004. * @param gamepad defines the internal HTML gamepad object
  41005. */
  41006. constructor(id: string, index: number, gamepad: any);
  41007. /**
  41008. * Defines the callback to call when left trigger is pressed
  41009. * @param callback defines the callback to use
  41010. */
  41011. onlefttriggerchanged(callback: (value: number) => void): void;
  41012. /**
  41013. * Defines the callback to call when right trigger is pressed
  41014. * @param callback defines the callback to use
  41015. */
  41016. onrighttriggerchanged(callback: (value: number) => void): void;
  41017. /**
  41018. * Gets the left trigger value
  41019. */
  41020. get leftTrigger(): number;
  41021. /**
  41022. * Sets the left trigger value
  41023. */
  41024. set leftTrigger(newValue: number);
  41025. /**
  41026. * Gets the right trigger value
  41027. */
  41028. get rightTrigger(): number;
  41029. /**
  41030. * Sets the right trigger value
  41031. */
  41032. set rightTrigger(newValue: number);
  41033. /**
  41034. * Defines the callback to call when a button is pressed
  41035. * @param callback defines the callback to use
  41036. */
  41037. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41038. /**
  41039. * Defines the callback to call when a button is released
  41040. * @param callback defines the callback to use
  41041. */
  41042. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41043. /**
  41044. * Defines the callback to call when a pad is pressed
  41045. * @param callback defines the callback to use
  41046. */
  41047. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41048. /**
  41049. * Defines the callback to call when a pad is released
  41050. * @param callback defines the callback to use
  41051. */
  41052. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41053. private _setButtonValue;
  41054. private _setDPadValue;
  41055. /**
  41056. * Gets the value of the `Cross` button
  41057. */
  41058. get buttonCross(): number;
  41059. /**
  41060. * Sets the value of the `Cross` button
  41061. */
  41062. set buttonCross(value: number);
  41063. /**
  41064. * Gets the value of the `Circle` button
  41065. */
  41066. get buttonCircle(): number;
  41067. /**
  41068. * Sets the value of the `Circle` button
  41069. */
  41070. set buttonCircle(value: number);
  41071. /**
  41072. * Gets the value of the `Square` button
  41073. */
  41074. get buttonSquare(): number;
  41075. /**
  41076. * Sets the value of the `Square` button
  41077. */
  41078. set buttonSquare(value: number);
  41079. /**
  41080. * Gets the value of the `Triangle` button
  41081. */
  41082. get buttonTriangle(): number;
  41083. /**
  41084. * Sets the value of the `Triangle` button
  41085. */
  41086. set buttonTriangle(value: number);
  41087. /**
  41088. * Gets the value of the `Options` button
  41089. */
  41090. get buttonOptions(): number;
  41091. /**
  41092. * Sets the value of the `Options` button
  41093. */
  41094. set buttonOptions(value: number);
  41095. /**
  41096. * Gets the value of the `Share` button
  41097. */
  41098. get buttonShare(): number;
  41099. /**
  41100. * Sets the value of the `Share` button
  41101. */
  41102. set buttonShare(value: number);
  41103. /**
  41104. * Gets the value of the `L1` button
  41105. */
  41106. get buttonL1(): number;
  41107. /**
  41108. * Sets the value of the `L1` button
  41109. */
  41110. set buttonL1(value: number);
  41111. /**
  41112. * Gets the value of the `R1` button
  41113. */
  41114. get buttonR1(): number;
  41115. /**
  41116. * Sets the value of the `R1` button
  41117. */
  41118. set buttonR1(value: number);
  41119. /**
  41120. * Gets the value of the Left joystick
  41121. */
  41122. get buttonLeftStick(): number;
  41123. /**
  41124. * Sets the value of the Left joystick
  41125. */
  41126. set buttonLeftStick(value: number);
  41127. /**
  41128. * Gets the value of the Right joystick
  41129. */
  41130. get buttonRightStick(): number;
  41131. /**
  41132. * Sets the value of the Right joystick
  41133. */
  41134. set buttonRightStick(value: number);
  41135. /**
  41136. * Gets the value of D-pad up
  41137. */
  41138. get dPadUp(): number;
  41139. /**
  41140. * Sets the value of D-pad up
  41141. */
  41142. set dPadUp(value: number);
  41143. /**
  41144. * Gets the value of D-pad down
  41145. */
  41146. get dPadDown(): number;
  41147. /**
  41148. * Sets the value of D-pad down
  41149. */
  41150. set dPadDown(value: number);
  41151. /**
  41152. * Gets the value of D-pad left
  41153. */
  41154. get dPadLeft(): number;
  41155. /**
  41156. * Sets the value of D-pad left
  41157. */
  41158. set dPadLeft(value: number);
  41159. /**
  41160. * Gets the value of D-pad right
  41161. */
  41162. get dPadRight(): number;
  41163. /**
  41164. * Sets the value of D-pad right
  41165. */
  41166. set dPadRight(value: number);
  41167. /**
  41168. * Force the gamepad to synchronize with device values
  41169. */
  41170. update(): void;
  41171. /**
  41172. * Disposes the gamepad
  41173. */
  41174. dispose(): void;
  41175. }
  41176. }
  41177. declare module BABYLON {
  41178. /**
  41179. * Manager for handling gamepads
  41180. */
  41181. export class GamepadManager {
  41182. private _scene?;
  41183. private _babylonGamepads;
  41184. private _oneGamepadConnected;
  41185. /** @hidden */
  41186. _isMonitoring: boolean;
  41187. private _gamepadEventSupported;
  41188. private _gamepadSupport?;
  41189. /**
  41190. * observable to be triggered when the gamepad controller has been connected
  41191. */
  41192. onGamepadConnectedObservable: Observable<Gamepad>;
  41193. /**
  41194. * observable to be triggered when the gamepad controller has been disconnected
  41195. */
  41196. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41197. private _onGamepadConnectedEvent;
  41198. private _onGamepadDisconnectedEvent;
  41199. /**
  41200. * Initializes the gamepad manager
  41201. * @param _scene BabylonJS scene
  41202. */
  41203. constructor(_scene?: Scene | undefined);
  41204. /**
  41205. * The gamepads in the game pad manager
  41206. */
  41207. get gamepads(): Gamepad[];
  41208. /**
  41209. * Get the gamepad controllers based on type
  41210. * @param type The type of gamepad controller
  41211. * @returns Nullable gamepad
  41212. */
  41213. getGamepadByType(type?: number): Nullable<Gamepad>;
  41214. /**
  41215. * Disposes the gamepad manager
  41216. */
  41217. dispose(): void;
  41218. private _addNewGamepad;
  41219. private _startMonitoringGamepads;
  41220. private _stopMonitoringGamepads;
  41221. /** @hidden */
  41222. _checkGamepadsStatus(): void;
  41223. private _updateGamepadObjects;
  41224. }
  41225. }
  41226. declare module BABYLON {
  41227. interface Scene {
  41228. /** @hidden */
  41229. _gamepadManager: Nullable<GamepadManager>;
  41230. /**
  41231. * Gets the gamepad manager associated with the scene
  41232. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41233. */
  41234. gamepadManager: GamepadManager;
  41235. }
  41236. /**
  41237. * Interface representing a free camera inputs manager
  41238. */
  41239. interface FreeCameraInputsManager {
  41240. /**
  41241. * Adds gamepad input support to the FreeCameraInputsManager.
  41242. * @returns the FreeCameraInputsManager
  41243. */
  41244. addGamepad(): FreeCameraInputsManager;
  41245. }
  41246. /**
  41247. * Interface representing an arc rotate camera inputs manager
  41248. */
  41249. interface ArcRotateCameraInputsManager {
  41250. /**
  41251. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41252. * @returns the camera inputs manager
  41253. */
  41254. addGamepad(): ArcRotateCameraInputsManager;
  41255. }
  41256. /**
  41257. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41258. */
  41259. export class GamepadSystemSceneComponent implements ISceneComponent {
  41260. /**
  41261. * The component name helpfull to identify the component in the list of scene components.
  41262. */
  41263. readonly name: string;
  41264. /**
  41265. * The scene the component belongs to.
  41266. */
  41267. scene: Scene;
  41268. /**
  41269. * Creates a new instance of the component for the given scene
  41270. * @param scene Defines the scene to register the component in
  41271. */
  41272. constructor(scene: Scene);
  41273. /**
  41274. * Registers the component in a given scene
  41275. */
  41276. register(): void;
  41277. /**
  41278. * Rebuilds the elements related to this component in case of
  41279. * context lost for instance.
  41280. */
  41281. rebuild(): void;
  41282. /**
  41283. * Disposes the component and the associated ressources
  41284. */
  41285. dispose(): void;
  41286. private _beforeCameraUpdate;
  41287. }
  41288. }
  41289. declare module BABYLON {
  41290. /**
  41291. * 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,
  41292. * which still works and will still be found in many Playgrounds.
  41293. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41294. */
  41295. export class UniversalCamera extends TouchCamera {
  41296. /**
  41297. * Defines the gamepad rotation sensiblity.
  41298. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41299. */
  41300. get gamepadAngularSensibility(): number;
  41301. set gamepadAngularSensibility(value: number);
  41302. /**
  41303. * Defines the gamepad move sensiblity.
  41304. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41305. */
  41306. get gamepadMoveSensibility(): number;
  41307. set gamepadMoveSensibility(value: number);
  41308. /**
  41309. * 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,
  41310. * which still works and will still be found in many Playgrounds.
  41311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41312. * @param name Define the name of the camera in the scene
  41313. * @param position Define the start position of the camera in the scene
  41314. * @param scene Define the scene the camera belongs to
  41315. */
  41316. constructor(name: string, position: Vector3, scene: Scene);
  41317. /**
  41318. * Gets the current object class name.
  41319. * @return the class name
  41320. */
  41321. getClassName(): string;
  41322. }
  41323. }
  41324. declare module BABYLON {
  41325. /**
  41326. * This represents a FPS type of camera. This is only here for back compat purpose.
  41327. * Please use the UniversalCamera instead as both are identical.
  41328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41329. */
  41330. export class GamepadCamera extends UniversalCamera {
  41331. /**
  41332. * Instantiates a new Gamepad Camera
  41333. * This represents a FPS type of camera. This is only here for back compat purpose.
  41334. * Please use the UniversalCamera instead as both are identical.
  41335. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41336. * @param name Define the name of the camera in the scene
  41337. * @param position Define the start position of the camera in the scene
  41338. * @param scene Define the scene the camera belongs to
  41339. */
  41340. constructor(name: string, position: Vector3, scene: Scene);
  41341. /**
  41342. * Gets the current object class name.
  41343. * @return the class name
  41344. */
  41345. getClassName(): string;
  41346. }
  41347. }
  41348. declare module BABYLON {
  41349. /** @hidden */
  41350. export var passPixelShader: {
  41351. name: string;
  41352. shader: string;
  41353. };
  41354. }
  41355. declare module BABYLON {
  41356. /** @hidden */
  41357. export var passCubePixelShader: {
  41358. name: string;
  41359. shader: string;
  41360. };
  41361. }
  41362. declare module BABYLON {
  41363. /**
  41364. * PassPostProcess which produces an output the same as it's input
  41365. */
  41366. export class PassPostProcess extends PostProcess {
  41367. /**
  41368. * Creates the PassPostProcess
  41369. * @param name The name of the effect.
  41370. * @param options The required width/height ratio to downsize to before computing the render pass.
  41371. * @param camera The camera to apply the render pass to.
  41372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41373. * @param engine The engine which the post process will be applied. (default: current engine)
  41374. * @param reusable If the post process can be reused on the same frame. (default: false)
  41375. * @param textureType The type of texture to be used when performing the post processing.
  41376. * @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)
  41377. */
  41378. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41379. }
  41380. /**
  41381. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41382. */
  41383. export class PassCubePostProcess extends PostProcess {
  41384. private _face;
  41385. /**
  41386. * Gets or sets the cube face to display.
  41387. * * 0 is +X
  41388. * * 1 is -X
  41389. * * 2 is +Y
  41390. * * 3 is -Y
  41391. * * 4 is +Z
  41392. * * 5 is -Z
  41393. */
  41394. get face(): number;
  41395. set face(value: number);
  41396. /**
  41397. * Creates the PassCubePostProcess
  41398. * @param name The name of the effect.
  41399. * @param options The required width/height ratio to downsize to before computing the render pass.
  41400. * @param camera The camera to apply the render pass to.
  41401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41402. * @param engine The engine which the post process will be applied. (default: current engine)
  41403. * @param reusable If the post process can be reused on the same frame. (default: false)
  41404. * @param textureType The type of texture to be used when performing the post processing.
  41405. * @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)
  41406. */
  41407. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41408. }
  41409. }
  41410. declare module BABYLON {
  41411. /** @hidden */
  41412. export var anaglyphPixelShader: {
  41413. name: string;
  41414. shader: string;
  41415. };
  41416. }
  41417. declare module BABYLON {
  41418. /**
  41419. * Postprocess used to generate anaglyphic rendering
  41420. */
  41421. export class AnaglyphPostProcess extends PostProcess {
  41422. private _passedProcess;
  41423. /**
  41424. * Creates a new AnaglyphPostProcess
  41425. * @param name defines postprocess name
  41426. * @param options defines creation options or target ratio scale
  41427. * @param rigCameras defines cameras using this postprocess
  41428. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41429. * @param engine defines hosting engine
  41430. * @param reusable defines if the postprocess will be reused multiple times per frame
  41431. */
  41432. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41433. }
  41434. }
  41435. declare module BABYLON {
  41436. /**
  41437. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41438. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41439. */
  41440. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41441. /**
  41442. * Creates a new AnaglyphArcRotateCamera
  41443. * @param name defines camera name
  41444. * @param alpha defines alpha angle (in radians)
  41445. * @param beta defines beta angle (in radians)
  41446. * @param radius defines radius
  41447. * @param target defines camera target
  41448. * @param interaxialDistance defines distance between each color axis
  41449. * @param scene defines the hosting scene
  41450. */
  41451. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41452. /**
  41453. * Gets camera class name
  41454. * @returns AnaglyphArcRotateCamera
  41455. */
  41456. getClassName(): string;
  41457. }
  41458. }
  41459. declare module BABYLON {
  41460. /**
  41461. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41462. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41463. */
  41464. export class AnaglyphFreeCamera extends FreeCamera {
  41465. /**
  41466. * Creates a new AnaglyphFreeCamera
  41467. * @param name defines camera name
  41468. * @param position defines initial position
  41469. * @param interaxialDistance defines distance between each color axis
  41470. * @param scene defines the hosting scene
  41471. */
  41472. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41473. /**
  41474. * Gets camera class name
  41475. * @returns AnaglyphFreeCamera
  41476. */
  41477. getClassName(): string;
  41478. }
  41479. }
  41480. declare module BABYLON {
  41481. /**
  41482. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41484. */
  41485. export class AnaglyphGamepadCamera extends GamepadCamera {
  41486. /**
  41487. * Creates a new AnaglyphGamepadCamera
  41488. * @param name defines camera name
  41489. * @param position defines initial position
  41490. * @param interaxialDistance defines distance between each color axis
  41491. * @param scene defines the hosting scene
  41492. */
  41493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41494. /**
  41495. * Gets camera class name
  41496. * @returns AnaglyphGamepadCamera
  41497. */
  41498. getClassName(): string;
  41499. }
  41500. }
  41501. declare module BABYLON {
  41502. /**
  41503. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41504. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41505. */
  41506. export class AnaglyphUniversalCamera extends UniversalCamera {
  41507. /**
  41508. * Creates a new AnaglyphUniversalCamera
  41509. * @param name defines camera name
  41510. * @param position defines initial position
  41511. * @param interaxialDistance defines distance between each color axis
  41512. * @param scene defines the hosting scene
  41513. */
  41514. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41515. /**
  41516. * Gets camera class name
  41517. * @returns AnaglyphUniversalCamera
  41518. */
  41519. getClassName(): string;
  41520. }
  41521. }
  41522. declare module BABYLON {
  41523. /** @hidden */
  41524. export var stereoscopicInterlacePixelShader: {
  41525. name: string;
  41526. shader: string;
  41527. };
  41528. }
  41529. declare module BABYLON {
  41530. /**
  41531. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41532. */
  41533. export class StereoscopicInterlacePostProcess extends PostProcess {
  41534. private _stepSize;
  41535. private _passedProcess;
  41536. /**
  41537. * Initializes a StereoscopicInterlacePostProcess
  41538. * @param name The name of the effect.
  41539. * @param rigCameras The rig cameras to be appled to the post process
  41540. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41542. * @param engine The engine which the post process will be applied. (default: current engine)
  41543. * @param reusable If the post process can be reused on the same frame. (default: false)
  41544. */
  41545. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41546. }
  41547. }
  41548. declare module BABYLON {
  41549. /**
  41550. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41551. * @see http://doc.babylonjs.com/features/cameras
  41552. */
  41553. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41554. /**
  41555. * Creates a new StereoscopicArcRotateCamera
  41556. * @param name defines camera name
  41557. * @param alpha defines alpha angle (in radians)
  41558. * @param beta defines beta angle (in radians)
  41559. * @param radius defines radius
  41560. * @param target defines camera target
  41561. * @param interaxialDistance defines distance between each color axis
  41562. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41563. * @param scene defines the hosting scene
  41564. */
  41565. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41566. /**
  41567. * Gets camera class name
  41568. * @returns StereoscopicArcRotateCamera
  41569. */
  41570. getClassName(): string;
  41571. }
  41572. }
  41573. declare module BABYLON {
  41574. /**
  41575. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41576. * @see http://doc.babylonjs.com/features/cameras
  41577. */
  41578. export class StereoscopicFreeCamera extends FreeCamera {
  41579. /**
  41580. * Creates a new StereoscopicFreeCamera
  41581. * @param name defines camera name
  41582. * @param position defines initial position
  41583. * @param interaxialDistance defines distance between each color axis
  41584. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41585. * @param scene defines the hosting scene
  41586. */
  41587. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41588. /**
  41589. * Gets camera class name
  41590. * @returns StereoscopicFreeCamera
  41591. */
  41592. getClassName(): string;
  41593. }
  41594. }
  41595. declare module BABYLON {
  41596. /**
  41597. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41598. * @see http://doc.babylonjs.com/features/cameras
  41599. */
  41600. export class StereoscopicGamepadCamera extends GamepadCamera {
  41601. /**
  41602. * Creates a new StereoscopicGamepadCamera
  41603. * @param name defines camera name
  41604. * @param position defines initial position
  41605. * @param interaxialDistance defines distance between each color axis
  41606. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41607. * @param scene defines the hosting scene
  41608. */
  41609. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41610. /**
  41611. * Gets camera class name
  41612. * @returns StereoscopicGamepadCamera
  41613. */
  41614. getClassName(): string;
  41615. }
  41616. }
  41617. declare module BABYLON {
  41618. /**
  41619. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41620. * @see http://doc.babylonjs.com/features/cameras
  41621. */
  41622. export class StereoscopicUniversalCamera extends UniversalCamera {
  41623. /**
  41624. * Creates a new StereoscopicUniversalCamera
  41625. * @param name defines camera name
  41626. * @param position defines initial position
  41627. * @param interaxialDistance defines distance between each color axis
  41628. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41629. * @param scene defines the hosting scene
  41630. */
  41631. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41632. /**
  41633. * Gets camera class name
  41634. * @returns StereoscopicUniversalCamera
  41635. */
  41636. getClassName(): string;
  41637. }
  41638. }
  41639. declare module BABYLON {
  41640. /**
  41641. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41642. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41643. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41644. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41645. */
  41646. export class VirtualJoysticksCamera extends FreeCamera {
  41647. /**
  41648. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41649. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41650. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41651. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41652. * @param name Define the name of the camera in the scene
  41653. * @param position Define the start position of the camera in the scene
  41654. * @param scene Define the scene the camera belongs to
  41655. */
  41656. constructor(name: string, position: Vector3, scene: Scene);
  41657. /**
  41658. * Gets the current object class name.
  41659. * @return the class name
  41660. */
  41661. getClassName(): string;
  41662. }
  41663. }
  41664. declare module BABYLON {
  41665. /**
  41666. * This represents all the required metrics to create a VR camera.
  41667. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41668. */
  41669. export class VRCameraMetrics {
  41670. /**
  41671. * Define the horizontal resolution off the screen.
  41672. */
  41673. hResolution: number;
  41674. /**
  41675. * Define the vertical resolution off the screen.
  41676. */
  41677. vResolution: number;
  41678. /**
  41679. * Define the horizontal screen size.
  41680. */
  41681. hScreenSize: number;
  41682. /**
  41683. * Define the vertical screen size.
  41684. */
  41685. vScreenSize: number;
  41686. /**
  41687. * Define the vertical screen center position.
  41688. */
  41689. vScreenCenter: number;
  41690. /**
  41691. * Define the distance of the eyes to the screen.
  41692. */
  41693. eyeToScreenDistance: number;
  41694. /**
  41695. * Define the distance between both lenses
  41696. */
  41697. lensSeparationDistance: number;
  41698. /**
  41699. * Define the distance between both viewer's eyes.
  41700. */
  41701. interpupillaryDistance: number;
  41702. /**
  41703. * Define the distortion factor of the VR postprocess.
  41704. * Please, touch with care.
  41705. */
  41706. distortionK: number[];
  41707. /**
  41708. * Define the chromatic aberration correction factors for the VR post process.
  41709. */
  41710. chromaAbCorrection: number[];
  41711. /**
  41712. * Define the scale factor of the post process.
  41713. * The smaller the better but the slower.
  41714. */
  41715. postProcessScaleFactor: number;
  41716. /**
  41717. * Define an offset for the lens center.
  41718. */
  41719. lensCenterOffset: number;
  41720. /**
  41721. * Define if the current vr camera should compensate the distortion of the lense or not.
  41722. */
  41723. compensateDistortion: boolean;
  41724. /**
  41725. * Defines if multiview should be enabled when rendering (Default: false)
  41726. */
  41727. multiviewEnabled: boolean;
  41728. /**
  41729. * Gets the rendering aspect ratio based on the provided resolutions.
  41730. */
  41731. get aspectRatio(): number;
  41732. /**
  41733. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41734. */
  41735. get aspectRatioFov(): number;
  41736. /**
  41737. * @hidden
  41738. */
  41739. get leftHMatrix(): Matrix;
  41740. /**
  41741. * @hidden
  41742. */
  41743. get rightHMatrix(): Matrix;
  41744. /**
  41745. * @hidden
  41746. */
  41747. get leftPreViewMatrix(): Matrix;
  41748. /**
  41749. * @hidden
  41750. */
  41751. get rightPreViewMatrix(): Matrix;
  41752. /**
  41753. * Get the default VRMetrics based on the most generic setup.
  41754. * @returns the default vr metrics
  41755. */
  41756. static GetDefault(): VRCameraMetrics;
  41757. }
  41758. }
  41759. declare module BABYLON {
  41760. /** @hidden */
  41761. export var vrDistortionCorrectionPixelShader: {
  41762. name: string;
  41763. shader: string;
  41764. };
  41765. }
  41766. declare module BABYLON {
  41767. /**
  41768. * VRDistortionCorrectionPostProcess used for mobile VR
  41769. */
  41770. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41771. private _isRightEye;
  41772. private _distortionFactors;
  41773. private _postProcessScaleFactor;
  41774. private _lensCenterOffset;
  41775. private _scaleIn;
  41776. private _scaleFactor;
  41777. private _lensCenter;
  41778. /**
  41779. * Initializes the VRDistortionCorrectionPostProcess
  41780. * @param name The name of the effect.
  41781. * @param camera The camera to apply the render pass to.
  41782. * @param isRightEye If this is for the right eye distortion
  41783. * @param vrMetrics All the required metrics for the VR camera
  41784. */
  41785. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41786. }
  41787. }
  41788. declare module BABYLON {
  41789. /**
  41790. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41791. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41792. */
  41793. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41794. /**
  41795. * Creates a new VRDeviceOrientationArcRotateCamera
  41796. * @param name defines camera name
  41797. * @param alpha defines the camera rotation along the logitudinal axis
  41798. * @param beta defines the camera rotation along the latitudinal axis
  41799. * @param radius defines the camera distance from its target
  41800. * @param target defines the camera target
  41801. * @param scene defines the scene the camera belongs to
  41802. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41803. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41804. */
  41805. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41806. /**
  41807. * Gets camera class name
  41808. * @returns VRDeviceOrientationArcRotateCamera
  41809. */
  41810. getClassName(): string;
  41811. }
  41812. }
  41813. declare module BABYLON {
  41814. /**
  41815. * Camera used to simulate VR rendering (based on FreeCamera)
  41816. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41817. */
  41818. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41819. /**
  41820. * Creates a new VRDeviceOrientationFreeCamera
  41821. * @param name defines camera name
  41822. * @param position defines the start position of the camera
  41823. * @param scene defines the scene the camera belongs to
  41824. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41825. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41826. */
  41827. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41828. /**
  41829. * Gets camera class name
  41830. * @returns VRDeviceOrientationFreeCamera
  41831. */
  41832. getClassName(): string;
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41838. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41839. */
  41840. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41841. /**
  41842. * Creates a new VRDeviceOrientationGamepadCamera
  41843. * @param name defines camera name
  41844. * @param position defines the start position of the camera
  41845. * @param scene defines the scene the camera belongs to
  41846. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41847. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41848. */
  41849. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41850. /**
  41851. * Gets camera class name
  41852. * @returns VRDeviceOrientationGamepadCamera
  41853. */
  41854. getClassName(): string;
  41855. }
  41856. }
  41857. declare module BABYLON {
  41858. /** @hidden */
  41859. export var imageProcessingPixelShader: {
  41860. name: string;
  41861. shader: string;
  41862. };
  41863. }
  41864. declare module BABYLON {
  41865. /**
  41866. * ImageProcessingPostProcess
  41867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41868. */
  41869. export class ImageProcessingPostProcess extends PostProcess {
  41870. /**
  41871. * Default configuration related to image processing available in the PBR Material.
  41872. */
  41873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41874. /**
  41875. * Gets the image processing configuration used either in this material.
  41876. */
  41877. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41878. /**
  41879. * Sets the Default image processing configuration used either in the this material.
  41880. *
  41881. * If sets to null, the scene one is in use.
  41882. */
  41883. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41884. /**
  41885. * Keep track of the image processing observer to allow dispose and replace.
  41886. */
  41887. private _imageProcessingObserver;
  41888. /**
  41889. * Attaches a new image processing configuration to the PBR Material.
  41890. * @param configuration
  41891. */
  41892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41893. /**
  41894. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41895. */
  41896. get colorCurves(): Nullable<ColorCurves>;
  41897. /**
  41898. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41899. */
  41900. set colorCurves(value: Nullable<ColorCurves>);
  41901. /**
  41902. * Gets wether the color curves effect is enabled.
  41903. */
  41904. get colorCurvesEnabled(): boolean;
  41905. /**
  41906. * Sets wether the color curves effect is enabled.
  41907. */
  41908. set colorCurvesEnabled(value: boolean);
  41909. /**
  41910. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41911. */
  41912. get colorGradingTexture(): Nullable<BaseTexture>;
  41913. /**
  41914. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41915. */
  41916. set colorGradingTexture(value: Nullable<BaseTexture>);
  41917. /**
  41918. * Gets wether the color grading effect is enabled.
  41919. */
  41920. get colorGradingEnabled(): boolean;
  41921. /**
  41922. * Gets wether the color grading effect is enabled.
  41923. */
  41924. set colorGradingEnabled(value: boolean);
  41925. /**
  41926. * Gets exposure used in the effect.
  41927. */
  41928. get exposure(): number;
  41929. /**
  41930. * Sets exposure used in the effect.
  41931. */
  41932. set exposure(value: number);
  41933. /**
  41934. * Gets wether tonemapping is enabled or not.
  41935. */
  41936. get toneMappingEnabled(): boolean;
  41937. /**
  41938. * Sets wether tonemapping is enabled or not
  41939. */
  41940. set toneMappingEnabled(value: boolean);
  41941. /**
  41942. * Gets the type of tone mapping effect.
  41943. */
  41944. get toneMappingType(): number;
  41945. /**
  41946. * Sets the type of tone mapping effect.
  41947. */
  41948. set toneMappingType(value: number);
  41949. /**
  41950. * Gets contrast used in the effect.
  41951. */
  41952. get contrast(): number;
  41953. /**
  41954. * Sets contrast used in the effect.
  41955. */
  41956. set contrast(value: number);
  41957. /**
  41958. * Gets Vignette stretch size.
  41959. */
  41960. get vignetteStretch(): number;
  41961. /**
  41962. * Sets Vignette stretch size.
  41963. */
  41964. set vignetteStretch(value: number);
  41965. /**
  41966. * Gets Vignette centre X Offset.
  41967. */
  41968. get vignetteCentreX(): number;
  41969. /**
  41970. * Sets Vignette centre X Offset.
  41971. */
  41972. set vignetteCentreX(value: number);
  41973. /**
  41974. * Gets Vignette centre Y Offset.
  41975. */
  41976. get vignetteCentreY(): number;
  41977. /**
  41978. * Sets Vignette centre Y Offset.
  41979. */
  41980. set vignetteCentreY(value: number);
  41981. /**
  41982. * Gets Vignette weight or intensity of the vignette effect.
  41983. */
  41984. get vignetteWeight(): number;
  41985. /**
  41986. * Sets Vignette weight or intensity of the vignette effect.
  41987. */
  41988. set vignetteWeight(value: number);
  41989. /**
  41990. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41991. * if vignetteEnabled is set to true.
  41992. */
  41993. get vignetteColor(): Color4;
  41994. /**
  41995. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41996. * if vignetteEnabled is set to true.
  41997. */
  41998. set vignetteColor(value: Color4);
  41999. /**
  42000. * Gets Camera field of view used by the Vignette effect.
  42001. */
  42002. get vignetteCameraFov(): number;
  42003. /**
  42004. * Sets Camera field of view used by the Vignette effect.
  42005. */
  42006. set vignetteCameraFov(value: number);
  42007. /**
  42008. * Gets the vignette blend mode allowing different kind of effect.
  42009. */
  42010. get vignetteBlendMode(): number;
  42011. /**
  42012. * Sets the vignette blend mode allowing different kind of effect.
  42013. */
  42014. set vignetteBlendMode(value: number);
  42015. /**
  42016. * Gets wether the vignette effect is enabled.
  42017. */
  42018. get vignetteEnabled(): boolean;
  42019. /**
  42020. * Sets wether the vignette effect is enabled.
  42021. */
  42022. set vignetteEnabled(value: boolean);
  42023. private _fromLinearSpace;
  42024. /**
  42025. * Gets wether the input of the processing is in Gamma or Linear Space.
  42026. */
  42027. get fromLinearSpace(): boolean;
  42028. /**
  42029. * Sets wether the input of the processing is in Gamma or Linear Space.
  42030. */
  42031. set fromLinearSpace(value: boolean);
  42032. /**
  42033. * Defines cache preventing GC.
  42034. */
  42035. private _defines;
  42036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42037. /**
  42038. * "ImageProcessingPostProcess"
  42039. * @returns "ImageProcessingPostProcess"
  42040. */
  42041. getClassName(): string;
  42042. protected _updateParameters(): void;
  42043. dispose(camera?: Camera): void;
  42044. }
  42045. }
  42046. declare module BABYLON {
  42047. /**
  42048. * Class containing static functions to help procedurally build meshes
  42049. */
  42050. export class GroundBuilder {
  42051. /**
  42052. * Creates a ground mesh
  42053. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42054. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42056. * @param name defines the name of the mesh
  42057. * @param options defines the options used to create the mesh
  42058. * @param scene defines the hosting scene
  42059. * @returns the ground mesh
  42060. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42061. */
  42062. static CreateGround(name: string, options: {
  42063. width?: number;
  42064. height?: number;
  42065. subdivisions?: number;
  42066. subdivisionsX?: number;
  42067. subdivisionsY?: number;
  42068. updatable?: boolean;
  42069. }, scene: any): Mesh;
  42070. /**
  42071. * Creates a tiled ground mesh
  42072. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42073. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42074. * * 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
  42075. * * 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
  42076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42077. * @param name defines the name of the mesh
  42078. * @param options defines the options used to create the mesh
  42079. * @param scene defines the hosting scene
  42080. * @returns the tiled ground mesh
  42081. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42082. */
  42083. static CreateTiledGround(name: string, options: {
  42084. xmin: number;
  42085. zmin: number;
  42086. xmax: number;
  42087. zmax: number;
  42088. subdivisions?: {
  42089. w: number;
  42090. h: number;
  42091. };
  42092. precision?: {
  42093. w: number;
  42094. h: number;
  42095. };
  42096. updatable?: boolean;
  42097. }, scene?: Nullable<Scene>): Mesh;
  42098. /**
  42099. * Creates a ground mesh from a height map
  42100. * * The parameter `url` sets the URL of the height map image resource.
  42101. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42102. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42103. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42104. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42105. * * 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.
  42106. * * 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).
  42107. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42109. * @param name defines the name of the mesh
  42110. * @param url defines the url to the height map
  42111. * @param options defines the options used to create the mesh
  42112. * @param scene defines the hosting scene
  42113. * @returns the ground mesh
  42114. * @see https://doc.babylonjs.com/babylon101/height_map
  42115. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42116. */
  42117. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42118. width?: number;
  42119. height?: number;
  42120. subdivisions?: number;
  42121. minHeight?: number;
  42122. maxHeight?: number;
  42123. colorFilter?: Color3;
  42124. alphaFilter?: number;
  42125. updatable?: boolean;
  42126. onReady?: (mesh: GroundMesh) => void;
  42127. }, scene?: Nullable<Scene>): GroundMesh;
  42128. }
  42129. }
  42130. declare module BABYLON {
  42131. /**
  42132. * Class containing static functions to help procedurally build meshes
  42133. */
  42134. export class TorusBuilder {
  42135. /**
  42136. * Creates a torus mesh
  42137. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42138. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42139. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42141. * * 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
  42142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42143. * @param name defines the name of the mesh
  42144. * @param options defines the options used to create the mesh
  42145. * @param scene defines the hosting scene
  42146. * @returns the torus mesh
  42147. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42148. */
  42149. static CreateTorus(name: string, options: {
  42150. diameter?: number;
  42151. thickness?: number;
  42152. tessellation?: number;
  42153. updatable?: boolean;
  42154. sideOrientation?: number;
  42155. frontUVs?: Vector4;
  42156. backUVs?: Vector4;
  42157. }, scene: any): Mesh;
  42158. }
  42159. }
  42160. declare module BABYLON {
  42161. /**
  42162. * Class containing static functions to help procedurally build meshes
  42163. */
  42164. export class CylinderBuilder {
  42165. /**
  42166. * Creates a cylinder or a cone mesh
  42167. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42168. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42169. * * 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.
  42170. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42171. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42172. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42173. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42174. * * 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).
  42175. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42176. * * 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).
  42177. * * 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
  42178. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42179. * * 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
  42180. * * 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.
  42181. * * If `enclose` is false, a ring surface is one element.
  42182. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42183. * * 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
  42184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42185. * * 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
  42186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42187. * @param name defines the name of the mesh
  42188. * @param options defines the options used to create the mesh
  42189. * @param scene defines the hosting scene
  42190. * @returns the cylinder mesh
  42191. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42192. */
  42193. static CreateCylinder(name: string, options: {
  42194. height?: number;
  42195. diameterTop?: number;
  42196. diameterBottom?: number;
  42197. diameter?: number;
  42198. tessellation?: number;
  42199. subdivisions?: number;
  42200. arc?: number;
  42201. faceColors?: Color4[];
  42202. faceUV?: Vector4[];
  42203. updatable?: boolean;
  42204. hasRings?: boolean;
  42205. enclose?: boolean;
  42206. cap?: number;
  42207. sideOrientation?: number;
  42208. frontUVs?: Vector4;
  42209. backUVs?: Vector4;
  42210. }, scene: any): Mesh;
  42211. }
  42212. }
  42213. declare module BABYLON {
  42214. /**
  42215. * States of the webXR experience
  42216. */
  42217. export enum WebXRState {
  42218. /**
  42219. * Transitioning to being in XR mode
  42220. */
  42221. ENTERING_XR = 0,
  42222. /**
  42223. * Transitioning to non XR mode
  42224. */
  42225. EXITING_XR = 1,
  42226. /**
  42227. * In XR mode and presenting
  42228. */
  42229. IN_XR = 2,
  42230. /**
  42231. * Not entered XR mode
  42232. */
  42233. NOT_IN_XR = 3
  42234. }
  42235. /**
  42236. * Abstraction of the XR render target
  42237. */
  42238. export interface WebXRRenderTarget extends IDisposable {
  42239. /**
  42240. * xrpresent context of the canvas which can be used to display/mirror xr content
  42241. */
  42242. canvasContext: WebGLRenderingContext;
  42243. /**
  42244. * xr layer for the canvas
  42245. */
  42246. xrLayer: Nullable<XRWebGLLayer>;
  42247. /**
  42248. * Initializes the xr layer for the session
  42249. * @param xrSession xr session
  42250. * @returns a promise that will resolve once the XR Layer has been created
  42251. */
  42252. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. /**
  42257. * COnfiguration object for WebXR output canvas
  42258. */
  42259. export class WebXRManagedOutputCanvasOptions {
  42260. /**
  42261. * Options for this XR Layer output
  42262. */
  42263. canvasOptions: XRWebGLLayerOptions;
  42264. /**
  42265. * CSS styling for a newly created canvas (if not provided)
  42266. */
  42267. newCanvasCssStyle?: string;
  42268. /**
  42269. * Get the default values of the configuration object
  42270. * @returns default values of this configuration object
  42271. */
  42272. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42273. }
  42274. /**
  42275. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42276. */
  42277. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42278. private configuration;
  42279. private _engine;
  42280. private _canvas;
  42281. /**
  42282. * xrpresent context of the canvas which can be used to display/mirror xr content
  42283. */
  42284. canvasContext: WebGLRenderingContext;
  42285. /**
  42286. * xr layer for the canvas
  42287. */
  42288. xrLayer: Nullable<XRWebGLLayer>;
  42289. /**
  42290. * Initializes the xr layer for the session
  42291. * @param xrSession xr session
  42292. * @returns a promise that will resolve once the XR Layer has been created
  42293. */
  42294. initializeXRLayerAsync(xrSession: any): any;
  42295. /**
  42296. * Initializes the canvas to be added/removed upon entering/exiting xr
  42297. * @param engine the Babylon engine
  42298. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42299. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42300. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42301. */
  42302. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42303. /**
  42304. * Disposes of the object
  42305. */
  42306. dispose(): void;
  42307. private _setManagedOutputCanvas;
  42308. private _addCanvas;
  42309. private _removeCanvas;
  42310. }
  42311. }
  42312. declare module BABYLON {
  42313. /**
  42314. * Manages an XRSession to work with Babylon's engine
  42315. * @see https://doc.babylonjs.com/how_to/webxr
  42316. */
  42317. export class WebXRSessionManager implements IDisposable {
  42318. /** The scene which the session should be created for */
  42319. scene: Scene;
  42320. /**
  42321. * Fires every time a new xrFrame arrives which can be used to update the camera
  42322. */
  42323. onXRFrameObservable: Observable<XRFrame>;
  42324. /**
  42325. * Fires when the xr session is ended either by the device or manually done
  42326. */
  42327. onXRSessionEnded: Observable<any>;
  42328. /**
  42329. * Fires when the xr session is ended either by the device or manually done
  42330. */
  42331. onXRSessionInit: Observable<XRSession>;
  42332. /**
  42333. * Underlying xr session
  42334. */
  42335. session: XRSession;
  42336. /**
  42337. * Type of reference space used when creating the session
  42338. */
  42339. referenceSpace: XRReferenceSpace;
  42340. /**
  42341. * Current XR frame
  42342. */
  42343. currentFrame: Nullable<XRFrame>;
  42344. /** WebXR timestamp updated every frame */
  42345. currentTimestamp: number;
  42346. private _xrNavigator;
  42347. private baseLayer;
  42348. private _rttProvider;
  42349. private _sessionEnded;
  42350. /**
  42351. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42352. * @param scene The scene which the session should be created for
  42353. */
  42354. constructor(
  42355. /** The scene which the session should be created for */
  42356. scene: Scene);
  42357. /**
  42358. * Initializes the manager
  42359. * After initialization enterXR can be called to start an XR session
  42360. * @returns Promise which resolves after it is initialized
  42361. */
  42362. initializeAsync(): Promise<void>;
  42363. /**
  42364. * Initializes an xr session
  42365. * @param xrSessionMode mode to initialize
  42366. * @param optionalFeatures defines optional values to pass to the session builder
  42367. * @returns a promise which will resolve once the session has been initialized
  42368. */
  42369. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42370. /**
  42371. * Sets the reference space on the xr session
  42372. * @param referenceSpace space to set
  42373. * @returns a promise that will resolve once the reference space has been set
  42374. */
  42375. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42376. /**
  42377. * Updates the render state of the session
  42378. * @param state state to set
  42379. * @returns a promise that resolves once the render state has been updated
  42380. */
  42381. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42382. /**
  42383. * Starts rendering to the xr layer
  42384. * @returns a promise that will resolve once rendering has started
  42385. */
  42386. startRenderingToXRAsync(): Promise<void>;
  42387. /**
  42388. * Gets the correct render target texture to be rendered this frame for this eye
  42389. * @param eye the eye for which to get the render target
  42390. * @returns the render target for the specified eye
  42391. */
  42392. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42393. /**
  42394. * Stops the xrSession and restores the renderloop
  42395. * @returns Promise which resolves after it exits XR
  42396. */
  42397. exitXRAsync(): Promise<void>;
  42398. /**
  42399. * Checks if a session would be supported for the creation options specified
  42400. * @param sessionMode session mode to check if supported eg. immersive-vr
  42401. * @returns true if supported
  42402. */
  42403. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42404. /**
  42405. * Creates a WebXRRenderTarget object for the XR session
  42406. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42407. * @param options optional options to provide when creating a new render target
  42408. * @returns a WebXR render target to which the session can render
  42409. */
  42410. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42411. /**
  42412. * @hidden
  42413. * Converts the render layer of xrSession to a render target
  42414. * @param session session to create render target for
  42415. * @param scene scene the new render target should be created for
  42416. * @param baseLayer the webgl layer to create the render target for
  42417. */
  42418. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42419. /**
  42420. * Disposes of the session manager
  42421. */
  42422. dispose(): void;
  42423. /**
  42424. * Gets a promise returning true when fullfiled if the given session mode is supported
  42425. * @param sessionMode defines the session to test
  42426. * @returns a promise
  42427. */
  42428. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42429. }
  42430. }
  42431. declare module BABYLON {
  42432. /**
  42433. * WebXR Camera which holds the views for the xrSession
  42434. * @see https://doc.babylonjs.com/how_to/webxr
  42435. */
  42436. export class WebXRCamera extends FreeCamera {
  42437. /**
  42438. * Is the camera in debug mode. Used when using an emulator
  42439. */
  42440. debugMode: boolean;
  42441. /**
  42442. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42443. * @param name the name of the camera
  42444. * @param scene the scene to add the camera to
  42445. */
  42446. constructor(name: string, scene: Scene);
  42447. private _updateNumberOfRigCameras;
  42448. /** @hidden */
  42449. _updateForDualEyeDebugging(): void;
  42450. /**
  42451. * Updates the cameras position from the current pose information of the XR session
  42452. * @param xrSessionManager the session containing pose information
  42453. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42454. */
  42455. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Defining the interface required for a (webxr) feature
  42461. */
  42462. export interface IWebXRFeature extends IDisposable {
  42463. /**
  42464. * Attach the feature to the session
  42465. * Will usually be called by the features manager
  42466. *
  42467. * @returns true if successful.
  42468. */
  42469. attach(): boolean;
  42470. /**
  42471. * Detach the feature from the session
  42472. * Will usually be called by the features manager
  42473. *
  42474. * @returns true if successful.
  42475. */
  42476. detach(): boolean;
  42477. }
  42478. /**
  42479. * Defining the constructor of a feature. Used to register the modules.
  42480. */
  42481. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42482. /**
  42483. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42484. * It is mainly used in AR sessions.
  42485. *
  42486. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42487. */
  42488. export class WebXRFeaturesManager implements IDisposable {
  42489. private _xrSessionManager;
  42490. private static readonly _AvailableFeatures;
  42491. /**
  42492. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42493. * Mainly used internally.
  42494. *
  42495. * @param featureName the name of the feature to register
  42496. * @param constructorFunction the function used to construct the module
  42497. * @param version the (babylon) version of the module
  42498. * @param stable is that a stable version of this module
  42499. */
  42500. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42501. /**
  42502. * Returns a constructor of a specific feature.
  42503. *
  42504. * @param featureName the name of the feature to construct
  42505. * @param version the version of the feature to load
  42506. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42507. * @param options optional options provided to the module.
  42508. * @returns a function that, when called, will return a new instance of this feature
  42509. */
  42510. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42511. /**
  42512. * Return the latest unstable version of this feature
  42513. * @param featureName the name of the feature to search
  42514. * @returns the version number. if not found will return -1
  42515. */
  42516. static GetLatestVersionOfFeature(featureName: string): number;
  42517. /**
  42518. * Return the latest stable version of this feature
  42519. * @param featureName the name of the feature to search
  42520. * @returns the version number. if not found will return -1
  42521. */
  42522. static GetStableVersionOfFeature(featureName: string): number;
  42523. /**
  42524. * Can be used to return the list of features currently registered
  42525. *
  42526. * @returns an Array of available features
  42527. */
  42528. static GetAvailableFeatures(): string[];
  42529. /**
  42530. * Gets the versions available for a specific feature
  42531. * @param featureName the name of the feature
  42532. * @returns an array with the available versions
  42533. */
  42534. static GetAvailableVersions(featureName: string): string[];
  42535. private _features;
  42536. /**
  42537. * constructs a new features manages.
  42538. *
  42539. * @param _xrSessionManager an instance of WebXRSessionManager
  42540. */
  42541. constructor(_xrSessionManager: WebXRSessionManager);
  42542. /**
  42543. * 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.
  42544. *
  42545. * @param featureName the name of the feature to load or the class of the feature
  42546. * @param version optional version to load. if not provided the latest version will be enabled
  42547. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42548. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42549. * @returns a new constructed feature or throws an error if feature not found.
  42550. */
  42551. enableFeature(featureName: string | {
  42552. Name: string;
  42553. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42554. /**
  42555. * Used to disable an already-enabled feature
  42556. * @param featureName the feature to disable
  42557. * @returns true if disable was successful
  42558. */
  42559. disableFeature(featureName: string | {
  42560. Name: string;
  42561. }): boolean;
  42562. /**
  42563. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42564. * Can be used during a session to start a feature
  42565. * @param featureName the name of feature to attach
  42566. */
  42567. attachFeature(featureName: string): void;
  42568. /**
  42569. * Can be used inside a session or when the session ends to detach a specific feature
  42570. * @param featureName the name of the feature to detach
  42571. */
  42572. detachFeature(featureName: string): void;
  42573. /**
  42574. * Get the list of enabled features
  42575. * @returns an array of enabled features
  42576. */
  42577. getEnabledFeatures(): string[];
  42578. /**
  42579. * get the implementation of an enabled feature.
  42580. * @param featureName the name of the feature to load
  42581. * @returns the feature class, if found
  42582. */
  42583. getEnabledFeature(featureName: string): IWebXRFeature;
  42584. /**
  42585. * dispose this features manager
  42586. */
  42587. dispose(): void;
  42588. }
  42589. }
  42590. declare module BABYLON {
  42591. /**
  42592. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42593. * @see https://doc.babylonjs.com/how_to/webxr
  42594. */
  42595. export class WebXRExperienceHelper implements IDisposable {
  42596. private scene;
  42597. /**
  42598. * 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
  42599. */
  42600. container: AbstractMesh;
  42601. /**
  42602. * Camera used to render xr content
  42603. */
  42604. camera: WebXRCamera;
  42605. /**
  42606. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42607. */
  42608. state: WebXRState;
  42609. private _setState;
  42610. private static _TmpVector;
  42611. /**
  42612. * Fires when the state of the experience helper has changed
  42613. */
  42614. onStateChangedObservable: Observable<WebXRState>;
  42615. /** Session manager used to keep track of xr session */
  42616. sessionManager: WebXRSessionManager;
  42617. /** A features manager for this xr session */
  42618. featuresManager: WebXRFeaturesManager;
  42619. private _nonVRCamera;
  42620. private _originalSceneAutoClear;
  42621. private _supported;
  42622. /**
  42623. * Creates the experience helper
  42624. * @param scene the scene to attach the experience helper to
  42625. * @returns a promise for the experience helper
  42626. */
  42627. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42628. /**
  42629. * Creates a WebXRExperienceHelper
  42630. * @param scene The scene the helper should be created in
  42631. */
  42632. private constructor();
  42633. /**
  42634. * Exits XR mode and returns the scene to its original state
  42635. * @returns promise that resolves after xr mode has exited
  42636. */
  42637. exitXRAsync(): Promise<void>;
  42638. /**
  42639. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42640. * @param sessionMode options for the XR session
  42641. * @param referenceSpaceType frame of reference of the XR session
  42642. * @param renderTarget the output canvas that will be used to enter XR mode
  42643. * @returns promise that resolves after xr mode has entered
  42644. */
  42645. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42646. /**
  42647. * Updates the global position of the camera by moving the camera's container
  42648. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42649. * @param position The desired global position of the camera
  42650. */
  42651. setPositionOfCameraUsingContainer(position: Vector3): void;
  42652. /**
  42653. * Rotates the xr camera by rotating the camera's container around the camera's position
  42654. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42655. * @param rotation the desired quaternion rotation to apply to the camera
  42656. */
  42657. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42658. /**
  42659. * Disposes of the experience helper
  42660. */
  42661. dispose(): void;
  42662. }
  42663. }
  42664. declare module BABYLON {
  42665. /**
  42666. * Represents an XR input
  42667. */
  42668. export class WebXRController {
  42669. private scene;
  42670. /** The underlying input source for the controller */
  42671. inputSource: XRInputSource;
  42672. private parentContainer;
  42673. /**
  42674. * 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
  42675. */
  42676. grip?: AbstractMesh;
  42677. /**
  42678. * Pointer which can be used to select objects or attach a visible laser to
  42679. */
  42680. pointer: AbstractMesh;
  42681. private _gamepadMode;
  42682. /**
  42683. * If available, this is the gamepad object related to this controller.
  42684. * Using this object it is possible to get click events and trackpad changes of the
  42685. * webxr controller that is currently being used.
  42686. */
  42687. gamepadController?: WebVRController;
  42688. /**
  42689. * Event that fires when the controller is removed/disposed
  42690. */
  42691. onDisposeObservable: Observable<{}>;
  42692. private _tmpQuaternion;
  42693. private _tmpVector;
  42694. /**
  42695. * Creates the controller
  42696. * @see https://doc.babylonjs.com/how_to/webxr
  42697. * @param scene the scene which the controller should be associated to
  42698. * @param inputSource the underlying input source for the controller
  42699. * @param parentContainer parent that the controller meshes should be children of
  42700. */
  42701. constructor(scene: Scene,
  42702. /** The underlying input source for the controller */
  42703. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42704. /**
  42705. * Updates the controller pose based on the given XRFrame
  42706. * @param xrFrame xr frame to update the pose with
  42707. * @param referenceSpace reference space to use
  42708. */
  42709. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42710. /**
  42711. * Gets a world space ray coming from the controller
  42712. * @param result the resulting ray
  42713. */
  42714. getWorldPointerRayToRef(result: Ray): void;
  42715. /**
  42716. * Get the scene associated with this controller
  42717. * @returns the scene object
  42718. */
  42719. getScene(): Scene;
  42720. /**
  42721. * Disposes of the object
  42722. */
  42723. dispose(): void;
  42724. }
  42725. }
  42726. declare module BABYLON {
  42727. /**
  42728. * XR input used to track XR inputs such as controllers/rays
  42729. */
  42730. export class WebXRInput implements IDisposable {
  42731. /**
  42732. * Base experience the input listens to
  42733. */
  42734. baseExperience: WebXRExperienceHelper;
  42735. /**
  42736. * XR controllers being tracked
  42737. */
  42738. controllers: Array<WebXRController>;
  42739. private _frameObserver;
  42740. private _stateObserver;
  42741. /**
  42742. * Event when a controller has been connected/added
  42743. */
  42744. onControllerAddedObservable: Observable<WebXRController>;
  42745. /**
  42746. * Event when a controller has been removed/disconnected
  42747. */
  42748. onControllerRemovedObservable: Observable<WebXRController>;
  42749. /**
  42750. * Initializes the WebXRInput
  42751. * @param baseExperience experience helper which the input should be created for
  42752. */
  42753. constructor(
  42754. /**
  42755. * Base experience the input listens to
  42756. */
  42757. baseExperience: WebXRExperienceHelper);
  42758. private _onInputSourcesChange;
  42759. private _addAndRemoveControllers;
  42760. /**
  42761. * Disposes of the object
  42762. */
  42763. dispose(): void;
  42764. }
  42765. }
  42766. declare module BABYLON {
  42767. /**
  42768. * Class used to represent data loading progression
  42769. */
  42770. export class SceneLoaderProgressEvent {
  42771. /** defines if data length to load can be evaluated */
  42772. readonly lengthComputable: boolean;
  42773. /** defines the loaded data length */
  42774. readonly loaded: number;
  42775. /** defines the data length to load */
  42776. readonly total: number;
  42777. /**
  42778. * Create a new progress event
  42779. * @param lengthComputable defines if data length to load can be evaluated
  42780. * @param loaded defines the loaded data length
  42781. * @param total defines the data length to load
  42782. */
  42783. constructor(
  42784. /** defines if data length to load can be evaluated */
  42785. lengthComputable: boolean,
  42786. /** defines the loaded data length */
  42787. loaded: number,
  42788. /** defines the data length to load */
  42789. total: number);
  42790. /**
  42791. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42792. * @param event defines the source event
  42793. * @returns a new SceneLoaderProgressEvent
  42794. */
  42795. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42796. }
  42797. /**
  42798. * Interface used by SceneLoader plugins to define supported file extensions
  42799. */
  42800. export interface ISceneLoaderPluginExtensions {
  42801. /**
  42802. * Defines the list of supported extensions
  42803. */
  42804. [extension: string]: {
  42805. isBinary: boolean;
  42806. };
  42807. }
  42808. /**
  42809. * Interface used by SceneLoader plugin factory
  42810. */
  42811. export interface ISceneLoaderPluginFactory {
  42812. /**
  42813. * Defines the name of the factory
  42814. */
  42815. name: string;
  42816. /**
  42817. * Function called to create a new plugin
  42818. * @return the new plugin
  42819. */
  42820. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42821. /**
  42822. * The callback that returns true if the data can be directly loaded.
  42823. * @param data string containing the file data
  42824. * @returns if the data can be loaded directly
  42825. */
  42826. canDirectLoad?(data: string): boolean;
  42827. }
  42828. /**
  42829. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42830. */
  42831. export interface ISceneLoaderPluginBase {
  42832. /**
  42833. * The friendly name of this plugin.
  42834. */
  42835. name: string;
  42836. /**
  42837. * The file extensions supported by this plugin.
  42838. */
  42839. extensions: string | ISceneLoaderPluginExtensions;
  42840. /**
  42841. * The callback called when loading from a url.
  42842. * @param scene scene loading this url
  42843. * @param url url to load
  42844. * @param onSuccess callback called when the file successfully loads
  42845. * @param onProgress callback called while file is loading (if the server supports this mode)
  42846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42847. * @param onError callback called when the file fails to load
  42848. * @returns a file request object
  42849. */
  42850. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42851. /**
  42852. * The callback called when loading from a file object.
  42853. * @param scene scene loading this file
  42854. * @param file defines the file to load
  42855. * @param onSuccess defines the callback to call when data is loaded
  42856. * @param onProgress defines the callback to call during loading process
  42857. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42858. * @param onError defines the callback to call when an error occurs
  42859. * @returns a file request object
  42860. */
  42861. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42862. /**
  42863. * The callback that returns true if the data can be directly loaded.
  42864. * @param data string containing the file data
  42865. * @returns if the data can be loaded directly
  42866. */
  42867. canDirectLoad?(data: string): boolean;
  42868. /**
  42869. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42870. * @param scene scene loading this data
  42871. * @param data string containing the data
  42872. * @returns data to pass to the plugin
  42873. */
  42874. directLoad?(scene: Scene, data: string): any;
  42875. /**
  42876. * The callback that allows custom handling of the root url based on the response url.
  42877. * @param rootUrl the original root url
  42878. * @param responseURL the response url if available
  42879. * @returns the new root url
  42880. */
  42881. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42882. }
  42883. /**
  42884. * Interface used to define a SceneLoader plugin
  42885. */
  42886. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42887. /**
  42888. * Import meshes into a scene.
  42889. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42890. * @param scene The scene to import into
  42891. * @param data The data to import
  42892. * @param rootUrl The root url for scene and resources
  42893. * @param meshes The meshes array to import into
  42894. * @param particleSystems The particle systems array to import into
  42895. * @param skeletons The skeletons array to import into
  42896. * @param onError The callback when import fails
  42897. * @returns True if successful or false otherwise
  42898. */
  42899. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42900. /**
  42901. * Load into a scene.
  42902. * @param scene The scene to load into
  42903. * @param data The data to import
  42904. * @param rootUrl The root url for scene and resources
  42905. * @param onError The callback when import fails
  42906. * @returns True if successful or false otherwise
  42907. */
  42908. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42909. /**
  42910. * Load into an asset container.
  42911. * @param scene The scene to load into
  42912. * @param data The data to import
  42913. * @param rootUrl The root url for scene and resources
  42914. * @param onError The callback when import fails
  42915. * @returns The loaded asset container
  42916. */
  42917. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42918. }
  42919. /**
  42920. * Interface used to define an async SceneLoader plugin
  42921. */
  42922. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42923. /**
  42924. * Import meshes into a scene.
  42925. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42926. * @param scene The scene to import into
  42927. * @param data The data to import
  42928. * @param rootUrl The root url for scene and resources
  42929. * @param onProgress The callback when the load progresses
  42930. * @param fileName Defines the name of the file to load
  42931. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42932. */
  42933. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42934. meshes: AbstractMesh[];
  42935. particleSystems: IParticleSystem[];
  42936. skeletons: Skeleton[];
  42937. animationGroups: AnimationGroup[];
  42938. }>;
  42939. /**
  42940. * Load into a scene.
  42941. * @param scene The scene to load into
  42942. * @param data The data to import
  42943. * @param rootUrl The root url for scene and resources
  42944. * @param onProgress The callback when the load progresses
  42945. * @param fileName Defines the name of the file to load
  42946. * @returns Nothing
  42947. */
  42948. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42949. /**
  42950. * Load into an asset container.
  42951. * @param scene The scene to load into
  42952. * @param data The data to import
  42953. * @param rootUrl The root url for scene and resources
  42954. * @param onProgress The callback when the load progresses
  42955. * @param fileName Defines the name of the file to load
  42956. * @returns The loaded asset container
  42957. */
  42958. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42959. }
  42960. /**
  42961. * Mode that determines how to handle old animation groups before loading new ones.
  42962. */
  42963. export enum SceneLoaderAnimationGroupLoadingMode {
  42964. /**
  42965. * Reset all old animations to initial state then dispose them.
  42966. */
  42967. Clean = 0,
  42968. /**
  42969. * Stop all old animations.
  42970. */
  42971. Stop = 1,
  42972. /**
  42973. * Restart old animations from first frame.
  42974. */
  42975. Sync = 2,
  42976. /**
  42977. * Old animations remains untouched.
  42978. */
  42979. NoSync = 3
  42980. }
  42981. /**
  42982. * Class used to load scene from various file formats using registered plugins
  42983. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42984. */
  42985. export class SceneLoader {
  42986. /**
  42987. * No logging while loading
  42988. */
  42989. static readonly NO_LOGGING: number;
  42990. /**
  42991. * Minimal logging while loading
  42992. */
  42993. static readonly MINIMAL_LOGGING: number;
  42994. /**
  42995. * Summary logging while loading
  42996. */
  42997. static readonly SUMMARY_LOGGING: number;
  42998. /**
  42999. * Detailled logging while loading
  43000. */
  43001. static readonly DETAILED_LOGGING: number;
  43002. /**
  43003. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43004. */
  43005. static get ForceFullSceneLoadingForIncremental(): boolean;
  43006. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43007. /**
  43008. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43009. */
  43010. static get ShowLoadingScreen(): boolean;
  43011. static set ShowLoadingScreen(value: boolean);
  43012. /**
  43013. * Defines the current logging level (while loading the scene)
  43014. * @ignorenaming
  43015. */
  43016. static get loggingLevel(): number;
  43017. static set loggingLevel(value: number);
  43018. /**
  43019. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43020. */
  43021. static get CleanBoneMatrixWeights(): boolean;
  43022. static set CleanBoneMatrixWeights(value: boolean);
  43023. /**
  43024. * Event raised when a plugin is used to load a scene
  43025. */
  43026. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43027. private static _registeredPlugins;
  43028. private static _getDefaultPlugin;
  43029. private static _getPluginForExtension;
  43030. private static _getPluginForDirectLoad;
  43031. private static _getPluginForFilename;
  43032. private static _getDirectLoad;
  43033. private static _loadData;
  43034. private static _getFileInfo;
  43035. /**
  43036. * Gets a plugin that can load the given extension
  43037. * @param extension defines the extension to load
  43038. * @returns a plugin or null if none works
  43039. */
  43040. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43041. /**
  43042. * Gets a boolean indicating that the given extension can be loaded
  43043. * @param extension defines the extension to load
  43044. * @returns true if the extension is supported
  43045. */
  43046. static IsPluginForExtensionAvailable(extension: string): boolean;
  43047. /**
  43048. * Adds a new plugin to the list of registered plugins
  43049. * @param plugin defines the plugin to add
  43050. */
  43051. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43052. /**
  43053. * Import meshes into a scene
  43054. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43055. * @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)
  43056. * @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)
  43057. * @param scene the instance of BABYLON.Scene to append to
  43058. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43059. * @param onProgress a callback with a progress event for each file being loaded
  43060. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43061. * @param pluginExtension the extension used to determine the plugin
  43062. * @returns The loaded plugin
  43063. */
  43064. 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>;
  43065. /**
  43066. * Import meshes into a scene
  43067. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43068. * @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)
  43069. * @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)
  43070. * @param scene the instance of BABYLON.Scene to append to
  43071. * @param onProgress a callback with a progress event for each file being loaded
  43072. * @param pluginExtension the extension used to determine the plugin
  43073. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43074. */
  43075. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43076. meshes: AbstractMesh[];
  43077. particleSystems: IParticleSystem[];
  43078. skeletons: Skeleton[];
  43079. animationGroups: AnimationGroup[];
  43080. }>;
  43081. /**
  43082. * Load a scene
  43083. * @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)
  43084. * @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)
  43085. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43086. * @param onSuccess a callback with the scene when import succeeds
  43087. * @param onProgress a callback with a progress event for each file being loaded
  43088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43089. * @param pluginExtension the extension used to determine the plugin
  43090. * @returns The loaded plugin
  43091. */
  43092. 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>;
  43093. /**
  43094. * Load a scene
  43095. * @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)
  43096. * @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)
  43097. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43098. * @param onProgress a callback with a progress event for each file being loaded
  43099. * @param pluginExtension the extension used to determine the plugin
  43100. * @returns The loaded scene
  43101. */
  43102. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43103. /**
  43104. * Append a scene
  43105. * @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)
  43106. * @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)
  43107. * @param scene is the instance of BABYLON.Scene to append to
  43108. * @param onSuccess a callback with the scene when import succeeds
  43109. * @param onProgress a callback with a progress event for each file being loaded
  43110. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43111. * @param pluginExtension the extension used to determine the plugin
  43112. * @returns The loaded plugin
  43113. */
  43114. 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>;
  43115. /**
  43116. * Append a scene
  43117. * @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)
  43118. * @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)
  43119. * @param scene is the instance of BABYLON.Scene to append to
  43120. * @param onProgress a callback with a progress event for each file being loaded
  43121. * @param pluginExtension the extension used to determine the plugin
  43122. * @returns The given scene
  43123. */
  43124. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43125. /**
  43126. * Load a scene into an asset container
  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 onSuccess a callback with the scene when import succeeds
  43131. * @param onProgress a callback with a progress event for each file being loaded
  43132. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43133. * @param pluginExtension the extension used to determine the plugin
  43134. * @returns The loaded plugin
  43135. */
  43136. 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>;
  43137. /**
  43138. * Load a scene into an asset container
  43139. * @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)
  43140. * @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)
  43141. * @param scene is the instance of Scene to append to
  43142. * @param onProgress a callback with a progress event for each file being loaded
  43143. * @param pluginExtension the extension used to determine the plugin
  43144. * @returns The loaded asset container
  43145. */
  43146. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43147. /**
  43148. * Import animations from a file into a scene
  43149. * @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)
  43150. * @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)
  43151. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43152. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43153. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43154. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43155. * @param onSuccess a callback with the scene when import succeeds
  43156. * @param onProgress a callback with a progress event for each file being loaded
  43157. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43158. */
  43159. 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;
  43160. /**
  43161. * Import animations from a file into a scene
  43162. * @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)
  43163. * @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)
  43164. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43165. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43166. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43167. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43168. * @param onSuccess a callback with the scene when import succeeds
  43169. * @param onProgress a callback with a progress event for each file being loaded
  43170. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43171. * @returns the updated scene with imported animations
  43172. */
  43173. 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>;
  43174. }
  43175. }
  43176. declare module BABYLON {
  43177. /**
  43178. * Generic Controller
  43179. */
  43180. export class GenericController extends WebVRController {
  43181. /**
  43182. * Base Url for the controller model.
  43183. */
  43184. static readonly MODEL_BASE_URL: string;
  43185. /**
  43186. * File name for the controller model.
  43187. */
  43188. static readonly MODEL_FILENAME: string;
  43189. /**
  43190. * Creates a new GenericController from a gamepad
  43191. * @param vrGamepad the gamepad that the controller should be created from
  43192. */
  43193. constructor(vrGamepad: any);
  43194. /**
  43195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43196. * @param scene scene in which to add meshes
  43197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43198. */
  43199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43200. /**
  43201. * Called once for each button that changed state since the last frame
  43202. * @param buttonIdx Which button index changed
  43203. * @param state New state of the button
  43204. * @param changes Which properties on the state changed since last frame
  43205. */
  43206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43207. }
  43208. }
  43209. declare module BABYLON {
  43210. /**
  43211. * Defines the WindowsMotionController object that the state of the windows motion controller
  43212. */
  43213. export class WindowsMotionController extends WebVRController {
  43214. /**
  43215. * The base url used to load the left and right controller models
  43216. */
  43217. static MODEL_BASE_URL: string;
  43218. /**
  43219. * The name of the left controller model file
  43220. */
  43221. static MODEL_LEFT_FILENAME: string;
  43222. /**
  43223. * The name of the right controller model file
  43224. */
  43225. static MODEL_RIGHT_FILENAME: string;
  43226. /**
  43227. * The controller name prefix for this controller type
  43228. */
  43229. static readonly GAMEPAD_ID_PREFIX: string;
  43230. /**
  43231. * The controller id pattern for this controller type
  43232. */
  43233. private static readonly GAMEPAD_ID_PATTERN;
  43234. private _loadedMeshInfo;
  43235. protected readonly _mapping: {
  43236. buttons: string[];
  43237. buttonMeshNames: {
  43238. 'trigger': string;
  43239. 'menu': string;
  43240. 'grip': string;
  43241. 'thumbstick': string;
  43242. 'trackpad': string;
  43243. };
  43244. buttonObservableNames: {
  43245. 'trigger': string;
  43246. 'menu': string;
  43247. 'grip': string;
  43248. 'thumbstick': string;
  43249. 'trackpad': string;
  43250. };
  43251. axisMeshNames: string[];
  43252. pointingPoseMeshName: string;
  43253. };
  43254. /**
  43255. * Fired when the trackpad on this controller is clicked
  43256. */
  43257. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43258. /**
  43259. * Fired when the trackpad on this controller is modified
  43260. */
  43261. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43262. /**
  43263. * The current x and y values of this controller's trackpad
  43264. */
  43265. trackpad: StickValues;
  43266. /**
  43267. * Creates a new WindowsMotionController from a gamepad
  43268. * @param vrGamepad the gamepad that the controller should be created from
  43269. */
  43270. constructor(vrGamepad: any);
  43271. /**
  43272. * Fired when the trigger on this controller is modified
  43273. */
  43274. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43275. /**
  43276. * Fired when the menu button on this controller is modified
  43277. */
  43278. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the grip button on this controller is modified
  43281. */
  43282. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Fired when the thumbstick button on this controller is modified
  43285. */
  43286. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43287. /**
  43288. * Fired when the touchpad button on this controller is modified
  43289. */
  43290. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43291. /**
  43292. * Fired when the touchpad values on this controller are modified
  43293. */
  43294. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  43295. protected _updateTrackpad(): void;
  43296. /**
  43297. * Called once per frame by the engine.
  43298. */
  43299. update(): void;
  43300. /**
  43301. * Called once for each button that changed state since the last frame
  43302. * @param buttonIdx Which button index changed
  43303. * @param state New state of the button
  43304. * @param changes Which properties on the state changed since last frame
  43305. */
  43306. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43307. /**
  43308. * Moves the buttons on the controller mesh based on their current state
  43309. * @param buttonName the name of the button to move
  43310. * @param buttonValue the value of the button which determines the buttons new position
  43311. */
  43312. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43313. /**
  43314. * Moves the axis on the controller mesh based on its current state
  43315. * @param axis the index of the axis
  43316. * @param axisValue the value of the axis which determines the meshes new position
  43317. * @hidden
  43318. */
  43319. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43320. /**
  43321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43322. * @param scene scene in which to add meshes
  43323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43324. */
  43325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43326. /**
  43327. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43328. * can be transformed by button presses and axes values, based on this._mapping.
  43329. *
  43330. * @param scene scene in which the meshes exist
  43331. * @param meshes list of meshes that make up the controller model to process
  43332. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43333. */
  43334. private processModel;
  43335. private createMeshInfo;
  43336. /**
  43337. * Gets the ray of the controller in the direction the controller is pointing
  43338. * @param length the length the resulting ray should be
  43339. * @returns a ray in the direction the controller is pointing
  43340. */
  43341. getForwardRay(length?: number): Ray;
  43342. /**
  43343. * Disposes of the controller
  43344. */
  43345. dispose(): void;
  43346. }
  43347. /**
  43348. * This class represents a new windows motion controller in XR.
  43349. */
  43350. export class XRWindowsMotionController extends WindowsMotionController {
  43351. /**
  43352. * Changing the original WIndowsMotionController mapping to fir the new mapping
  43353. */
  43354. protected readonly _mapping: {
  43355. buttons: string[];
  43356. buttonMeshNames: {
  43357. 'trigger': string;
  43358. 'menu': string;
  43359. 'grip': string;
  43360. 'thumbstick': string;
  43361. 'trackpad': string;
  43362. };
  43363. buttonObservableNames: {
  43364. 'trigger': string;
  43365. 'menu': string;
  43366. 'grip': string;
  43367. 'thumbstick': string;
  43368. 'trackpad': string;
  43369. };
  43370. axisMeshNames: string[];
  43371. pointingPoseMeshName: string;
  43372. };
  43373. /**
  43374. * Construct a new XR-Based windows motion controller
  43375. *
  43376. * @param gamepadInfo the gamepad object from the browser
  43377. */
  43378. constructor(gamepadInfo: any);
  43379. /**
  43380. * holds the thumbstick values (X,Y)
  43381. */
  43382. thumbstickValues: StickValues;
  43383. /**
  43384. * Fired when the thumbstick on this controller is clicked
  43385. */
  43386. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  43387. /**
  43388. * Fired when the thumbstick on this controller is modified
  43389. */
  43390. onThumbstickValuesChangedObservable: Observable<StickValues>;
  43391. /**
  43392. * Fired when the touchpad button on this controller is modified
  43393. */
  43394. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43395. /**
  43396. * Fired when the touchpad values on this controller are modified
  43397. */
  43398. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43399. /**
  43400. * Fired when the thumbstick button on this controller is modified
  43401. * here to prevent breaking changes
  43402. */
  43403. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43404. /**
  43405. * updating the thumbstick(!) and not the trackpad.
  43406. * This is named this way due to the difference between WebVR and XR and to avoid
  43407. * changing the parent class.
  43408. */
  43409. protected _updateTrackpad(): void;
  43410. /**
  43411. * Disposes the class with joy
  43412. */
  43413. dispose(): void;
  43414. }
  43415. }
  43416. declare module BABYLON {
  43417. /**
  43418. * Oculus Touch Controller
  43419. */
  43420. export class OculusTouchController extends WebVRController {
  43421. /**
  43422. * Base Url for the controller model.
  43423. */
  43424. static MODEL_BASE_URL: string;
  43425. /**
  43426. * File name for the left controller model.
  43427. */
  43428. static MODEL_LEFT_FILENAME: string;
  43429. /**
  43430. * File name for the right controller model.
  43431. */
  43432. static MODEL_RIGHT_FILENAME: string;
  43433. /**
  43434. * Base Url for the Quest controller model.
  43435. */
  43436. static QUEST_MODEL_BASE_URL: string;
  43437. /**
  43438. * @hidden
  43439. * If the controllers are running on a device that needs the updated Quest controller models
  43440. */
  43441. static _IsQuest: boolean;
  43442. /**
  43443. * Fired when the secondary trigger on this controller is modified
  43444. */
  43445. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43446. /**
  43447. * Fired when the thumb rest on this controller is modified
  43448. */
  43449. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43450. /**
  43451. * Creates a new OculusTouchController from a gamepad
  43452. * @param vrGamepad the gamepad that the controller should be created from
  43453. */
  43454. constructor(vrGamepad: any);
  43455. /**
  43456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43457. * @param scene scene in which to add meshes
  43458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43459. */
  43460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43461. /**
  43462. * Fired when the A button on this controller is modified
  43463. */
  43464. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43465. /**
  43466. * Fired when the B button on this controller is modified
  43467. */
  43468. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43469. /**
  43470. * Fired when the X button on this controller is modified
  43471. */
  43472. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43473. /**
  43474. * Fired when the Y button on this controller is modified
  43475. */
  43476. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43477. /**
  43478. * Called once for each button that changed state since the last frame
  43479. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43480. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43481. * 2) secondary trigger (same)
  43482. * 3) A (right) X (left), touch, pressed = value
  43483. * 4) B / Y
  43484. * 5) thumb rest
  43485. * @param buttonIdx Which button index changed
  43486. * @param state New state of the button
  43487. * @param changes Which properties on the state changed since last frame
  43488. */
  43489. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43490. }
  43491. }
  43492. declare module BABYLON {
  43493. /**
  43494. * Vive Controller
  43495. */
  43496. export class ViveController extends WebVRController {
  43497. /**
  43498. * Base Url for the controller model.
  43499. */
  43500. static MODEL_BASE_URL: string;
  43501. /**
  43502. * File name for the controller model.
  43503. */
  43504. static MODEL_FILENAME: string;
  43505. /**
  43506. * Creates a new ViveController from a gamepad
  43507. * @param vrGamepad the gamepad that the controller should be created from
  43508. */
  43509. constructor(vrGamepad: any);
  43510. /**
  43511. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43512. * @param scene scene in which to add meshes
  43513. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43514. */
  43515. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43516. /**
  43517. * Fired when the left button on this controller is modified
  43518. */
  43519. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43520. /**
  43521. * Fired when the right button on this controller is modified
  43522. */
  43523. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43524. /**
  43525. * Fired when the menu button on this controller is modified
  43526. */
  43527. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43528. /**
  43529. * Called once for each button that changed state since the last frame
  43530. * Vive mapping:
  43531. * 0: touchpad
  43532. * 1: trigger
  43533. * 2: left AND right buttons
  43534. * 3: menu button
  43535. * @param buttonIdx Which button index changed
  43536. * @param state New state of the button
  43537. * @param changes Which properties on the state changed since last frame
  43538. */
  43539. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43540. }
  43541. }
  43542. declare module BABYLON {
  43543. /**
  43544. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43545. */
  43546. export class WebXRControllerModelLoader {
  43547. /**
  43548. * an observable that triggers when a new model (the mesh itself) was initialized.
  43549. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43550. */
  43551. onControllerModelLoaded: Observable<WebXRController>;
  43552. /**
  43553. * Creates the WebXRControllerModelLoader
  43554. * @param input xr input that creates the controllers
  43555. */
  43556. constructor(input: WebXRInput);
  43557. }
  43558. }
  43559. declare module BABYLON {
  43560. /**
  43561. * Handles pointer input automatically for the pointer of XR controllers
  43562. */
  43563. export class WebXRControllerPointerSelection {
  43564. private static _idCounter;
  43565. private _tmpRay;
  43566. /**
  43567. * Creates a WebXRControllerPointerSelection
  43568. * @param input input manager to setup pointer selection
  43569. */
  43570. constructor(input: WebXRInput);
  43571. private _convertNormalToDirectionOfRay;
  43572. private _updatePointerDistance;
  43573. }
  43574. }
  43575. declare module BABYLON {
  43576. /**
  43577. * Enables teleportation
  43578. */
  43579. export class WebXRControllerTeleportation {
  43580. private _teleportationFillColor;
  43581. private _teleportationBorderColor;
  43582. private _tmpRay;
  43583. private _tmpVector;
  43584. /**
  43585. * when set to true (default) teleportation will wait for thumbstick changes.
  43586. * When set to false teleportation will be disabled.
  43587. *
  43588. * If set to false while teleporting results can be unexpected.
  43589. */
  43590. enabled: boolean;
  43591. /**
  43592. * Creates a WebXRControllerTeleportation
  43593. * @param input input manager to add teleportation to
  43594. * @param floorMeshes floormeshes which can be teleported to
  43595. */
  43596. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43597. }
  43598. }
  43599. declare module BABYLON {
  43600. /**
  43601. * Button which can be used to enter a different mode of XR
  43602. */
  43603. export class WebXREnterExitUIButton {
  43604. /** button element */
  43605. element: HTMLElement;
  43606. /** XR initialization options for the button */
  43607. sessionMode: XRSessionMode;
  43608. /** Reference space type */
  43609. referenceSpaceType: XRReferenceSpaceType;
  43610. /**
  43611. * Creates a WebXREnterExitUIButton
  43612. * @param element button element
  43613. * @param sessionMode XR initialization session mode
  43614. * @param referenceSpaceType the type of reference space to be used
  43615. */
  43616. constructor(
  43617. /** button element */
  43618. element: HTMLElement,
  43619. /** XR initialization options for the button */
  43620. sessionMode: XRSessionMode,
  43621. /** Reference space type */
  43622. referenceSpaceType: XRReferenceSpaceType);
  43623. /**
  43624. * Overwritable function which can be used to update the button's visuals when the state changes
  43625. * @param activeButton the current active button in the UI
  43626. */
  43627. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43628. }
  43629. /**
  43630. * Options to create the webXR UI
  43631. */
  43632. export class WebXREnterExitUIOptions {
  43633. /**
  43634. * Context to enter xr with
  43635. */
  43636. renderTarget?: Nullable<WebXRRenderTarget>;
  43637. /**
  43638. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43639. */
  43640. customButtons?: Array<WebXREnterExitUIButton>;
  43641. /**
  43642. * A session mode to use when creating the default button.
  43643. * Default is immersive-vr
  43644. */
  43645. sessionMode?: XRSessionMode;
  43646. /**
  43647. * A reference space type to use when creating the default button.
  43648. * Default is local-floor
  43649. */
  43650. referenceSpaceType?: XRReferenceSpaceType;
  43651. }
  43652. /**
  43653. * UI to allow the user to enter/exit XR mode
  43654. */
  43655. export class WebXREnterExitUI implements IDisposable {
  43656. private scene;
  43657. /** version of the options passed to this UI */
  43658. options: WebXREnterExitUIOptions;
  43659. private _overlay;
  43660. private _buttons;
  43661. private _activeButton;
  43662. /**
  43663. * Fired every time the active button is changed.
  43664. *
  43665. * When xr is entered via a button that launches xr that button will be the callback parameter
  43666. *
  43667. * When exiting xr the callback parameter will be null)
  43668. */
  43669. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43670. /**
  43671. * Creates UI to allow the user to enter/exit XR mode
  43672. * @param scene the scene to add the ui to
  43673. * @param helper the xr experience helper to enter/exit xr with
  43674. * @param options options to configure the UI
  43675. * @returns the created ui
  43676. */
  43677. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43678. /**
  43679. *
  43680. * @param scene babylon scene object to use
  43681. * @param options (read-only) version of the options passed to this UI
  43682. */
  43683. private constructor();
  43684. private _updateButtons;
  43685. /**
  43686. * Disposes of the object
  43687. */
  43688. dispose(): void;
  43689. }
  43690. }
  43691. declare module BABYLON {
  43692. /**
  43693. * Options for the default xr helper
  43694. */
  43695. export class WebXRDefaultExperienceOptions {
  43696. /**
  43697. * Floor meshes that should be used for teleporting
  43698. */
  43699. floorMeshes: Array<AbstractMesh>;
  43700. /**
  43701. * Enable or disable default UI to enter XR
  43702. */
  43703. disableDefaultUI?: boolean;
  43704. /**
  43705. * optional configuration for the output canvas
  43706. */
  43707. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43708. /**
  43709. * optional UI options. This can be used among other to change session mode and reference space type
  43710. */
  43711. uiOptions?: WebXREnterExitUIOptions;
  43712. }
  43713. /**
  43714. * Default experience which provides a similar setup to the previous webVRExperience
  43715. */
  43716. export class WebXRDefaultExperience {
  43717. /**
  43718. * Base experience
  43719. */
  43720. baseExperience: WebXRExperienceHelper;
  43721. /**
  43722. * Input experience extension
  43723. */
  43724. input: WebXRInput;
  43725. /**
  43726. * Loads the controller models
  43727. */
  43728. controllerModelLoader: WebXRControllerModelLoader;
  43729. /**
  43730. * Enables laser pointer and selection
  43731. */
  43732. pointerSelection: WebXRControllerPointerSelection;
  43733. /**
  43734. * Enables teleportation
  43735. */
  43736. teleportation: WebXRControllerTeleportation;
  43737. /**
  43738. * Enables ui for entering/exiting xr
  43739. */
  43740. enterExitUI: WebXREnterExitUI;
  43741. /**
  43742. * Default target xr should render to
  43743. */
  43744. renderTarget: WebXRRenderTarget;
  43745. /**
  43746. * Creates the default xr experience
  43747. * @param scene scene
  43748. * @param options options for basic configuration
  43749. * @returns resulting WebXRDefaultExperience
  43750. */
  43751. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43752. private constructor();
  43753. /**
  43754. * DIsposes of the experience helper
  43755. */
  43756. dispose(): void;
  43757. }
  43758. }
  43759. declare module BABYLON {
  43760. /**
  43761. * Options to modify the vr teleportation behavior.
  43762. */
  43763. export interface VRTeleportationOptions {
  43764. /**
  43765. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43766. */
  43767. floorMeshName?: string;
  43768. /**
  43769. * A list of meshes to be used as the teleportation floor. (default: empty)
  43770. */
  43771. floorMeshes?: Mesh[];
  43772. /**
  43773. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43774. */
  43775. teleportationMode?: number;
  43776. /**
  43777. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43778. */
  43779. teleportationTime?: number;
  43780. /**
  43781. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43782. */
  43783. teleportationSpeed?: number;
  43784. /**
  43785. * The easing function used in the animation or null for Linear. (default CircleEase)
  43786. */
  43787. easingFunction?: EasingFunction;
  43788. }
  43789. /**
  43790. * Options to modify the vr experience helper's behavior.
  43791. */
  43792. export interface VRExperienceHelperOptions extends WebVROptions {
  43793. /**
  43794. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43795. */
  43796. createDeviceOrientationCamera?: boolean;
  43797. /**
  43798. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43799. */
  43800. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43801. /**
  43802. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43803. */
  43804. laserToggle?: boolean;
  43805. /**
  43806. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43807. */
  43808. floorMeshes?: Mesh[];
  43809. /**
  43810. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43811. */
  43812. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43813. /**
  43814. * Defines if WebXR should be used instead of WebVR (if available)
  43815. */
  43816. useXR?: boolean;
  43817. }
  43818. /**
  43819. * Event containing information after VR has been entered
  43820. */
  43821. export class OnAfterEnteringVRObservableEvent {
  43822. /**
  43823. * If entering vr was successful
  43824. */
  43825. success: boolean;
  43826. }
  43827. /**
  43828. * Helps to quickly add VR support to an existing scene.
  43829. * See http://doc.babylonjs.com/how_to/webvr_helper
  43830. */
  43831. export class VRExperienceHelper {
  43832. /** Options to modify the vr experience helper's behavior. */
  43833. webVROptions: VRExperienceHelperOptions;
  43834. private _scene;
  43835. private _position;
  43836. private _btnVR;
  43837. private _btnVRDisplayed;
  43838. private _webVRsupported;
  43839. private _webVRready;
  43840. private _webVRrequesting;
  43841. private _webVRpresenting;
  43842. private _hasEnteredVR;
  43843. private _fullscreenVRpresenting;
  43844. private _inputElement;
  43845. private _webVRCamera;
  43846. private _vrDeviceOrientationCamera;
  43847. private _deviceOrientationCamera;
  43848. private _existingCamera;
  43849. private _onKeyDown;
  43850. private _onVrDisplayPresentChange;
  43851. private _onVRDisplayChanged;
  43852. private _onVRRequestPresentStart;
  43853. private _onVRRequestPresentComplete;
  43854. /**
  43855. * 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)
  43856. */
  43857. enableGazeEvenWhenNoPointerLock: boolean;
  43858. /**
  43859. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43860. */
  43861. exitVROnDoubleTap: boolean;
  43862. /**
  43863. * Observable raised right before entering VR.
  43864. */
  43865. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43866. /**
  43867. * Observable raised when entering VR has completed.
  43868. */
  43869. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43870. /**
  43871. * Observable raised when exiting VR.
  43872. */
  43873. onExitingVRObservable: Observable<VRExperienceHelper>;
  43874. /**
  43875. * Observable raised when controller mesh is loaded.
  43876. */
  43877. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43878. /** Return this.onEnteringVRObservable
  43879. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43880. */
  43881. get onEnteringVR(): Observable<VRExperienceHelper>;
  43882. /** Return this.onExitingVRObservable
  43883. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43884. */
  43885. get onExitingVR(): Observable<VRExperienceHelper>;
  43886. /** Return this.onControllerMeshLoadedObservable
  43887. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43888. */
  43889. get onControllerMeshLoaded(): Observable<WebVRController>;
  43890. private _rayLength;
  43891. private _useCustomVRButton;
  43892. private _teleportationRequested;
  43893. private _teleportActive;
  43894. private _floorMeshName;
  43895. private _floorMeshesCollection;
  43896. private _teleportationMode;
  43897. private _teleportationTime;
  43898. private _teleportationSpeed;
  43899. private _teleportationEasing;
  43900. private _rotationAllowed;
  43901. private _teleportBackwardsVector;
  43902. private _teleportationTarget;
  43903. private _isDefaultTeleportationTarget;
  43904. private _postProcessMove;
  43905. private _teleportationFillColor;
  43906. private _teleportationBorderColor;
  43907. private _rotationAngle;
  43908. private _haloCenter;
  43909. private _cameraGazer;
  43910. private _padSensibilityUp;
  43911. private _padSensibilityDown;
  43912. private _leftController;
  43913. private _rightController;
  43914. private _gazeColor;
  43915. private _laserColor;
  43916. private _pickedLaserColor;
  43917. private _pickedGazeColor;
  43918. /**
  43919. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43920. */
  43921. onNewMeshSelected: Observable<AbstractMesh>;
  43922. /**
  43923. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43924. * This observable will provide the mesh and the controller used to select the mesh
  43925. */
  43926. onMeshSelectedWithController: Observable<{
  43927. mesh: AbstractMesh;
  43928. controller: WebVRController;
  43929. }>;
  43930. /**
  43931. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43932. */
  43933. onNewMeshPicked: Observable<PickingInfo>;
  43934. private _circleEase;
  43935. /**
  43936. * Observable raised before camera teleportation
  43937. */
  43938. onBeforeCameraTeleport: Observable<Vector3>;
  43939. /**
  43940. * Observable raised after camera teleportation
  43941. */
  43942. onAfterCameraTeleport: Observable<Vector3>;
  43943. /**
  43944. * Observable raised when current selected mesh gets unselected
  43945. */
  43946. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43947. private _raySelectionPredicate;
  43948. /**
  43949. * To be optionaly changed by user to define custom ray selection
  43950. */
  43951. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43952. /**
  43953. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43954. */
  43955. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43956. /**
  43957. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43958. */
  43959. teleportationEnabled: boolean;
  43960. private _defaultHeight;
  43961. private _teleportationInitialized;
  43962. private _interactionsEnabled;
  43963. private _interactionsRequested;
  43964. private _displayGaze;
  43965. private _displayLaserPointer;
  43966. /**
  43967. * The mesh used to display where the user is going to teleport.
  43968. */
  43969. get teleportationTarget(): Mesh;
  43970. /**
  43971. * Sets the mesh to be used to display where the user is going to teleport.
  43972. */
  43973. set teleportationTarget(value: Mesh);
  43974. /**
  43975. * 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
  43976. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43977. * See http://doc.babylonjs.com/resources/baking_transformations
  43978. */
  43979. get gazeTrackerMesh(): Mesh;
  43980. set gazeTrackerMesh(value: Mesh);
  43981. /**
  43982. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43983. */
  43984. updateGazeTrackerScale: boolean;
  43985. /**
  43986. * If the gaze trackers color should be updated when selecting meshes
  43987. */
  43988. updateGazeTrackerColor: boolean;
  43989. /**
  43990. * If the controller laser color should be updated when selecting meshes
  43991. */
  43992. updateControllerLaserColor: boolean;
  43993. /**
  43994. * The gaze tracking mesh corresponding to the left controller
  43995. */
  43996. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  43997. /**
  43998. * The gaze tracking mesh corresponding to the right controller
  43999. */
  44000. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44001. /**
  44002. * If the ray of the gaze should be displayed.
  44003. */
  44004. get displayGaze(): boolean;
  44005. /**
  44006. * Sets if the ray of the gaze should be displayed.
  44007. */
  44008. set displayGaze(value: boolean);
  44009. /**
  44010. * If the ray of the LaserPointer should be displayed.
  44011. */
  44012. get displayLaserPointer(): boolean;
  44013. /**
  44014. * Sets if the ray of the LaserPointer should be displayed.
  44015. */
  44016. set displayLaserPointer(value: boolean);
  44017. /**
  44018. * The deviceOrientationCamera used as the camera when not in VR.
  44019. */
  44020. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44021. /**
  44022. * Based on the current WebVR support, returns the current VR camera used.
  44023. */
  44024. get currentVRCamera(): Nullable<Camera>;
  44025. /**
  44026. * The webVRCamera which is used when in VR.
  44027. */
  44028. get webVRCamera(): WebVRFreeCamera;
  44029. /**
  44030. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44031. */
  44032. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44033. /**
  44034. * The html button that is used to trigger entering into VR.
  44035. */
  44036. get vrButton(): Nullable<HTMLButtonElement>;
  44037. private get _teleportationRequestInitiated();
  44038. /**
  44039. * Defines wether or not Pointer lock should be requested when switching to
  44040. * full screen.
  44041. */
  44042. requestPointerLockOnFullScreen: boolean;
  44043. /**
  44044. * If asking to force XR, this will be populated with the default xr experience
  44045. */
  44046. xr: WebXRDefaultExperience;
  44047. /**
  44048. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44049. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44050. */
  44051. xrTestDone: boolean;
  44052. /**
  44053. * Instantiates a VRExperienceHelper.
  44054. * Helps to quickly add VR support to an existing scene.
  44055. * @param scene The scene the VRExperienceHelper belongs to.
  44056. * @param webVROptions Options to modify the vr experience helper's behavior.
  44057. */
  44058. constructor(scene: Scene,
  44059. /** Options to modify the vr experience helper's behavior. */
  44060. webVROptions?: VRExperienceHelperOptions);
  44061. private completeVRInit;
  44062. private _onDefaultMeshLoaded;
  44063. private _onResize;
  44064. private _onFullscreenChange;
  44065. /**
  44066. * Gets a value indicating if we are currently in VR mode.
  44067. */
  44068. get isInVRMode(): boolean;
  44069. private onVrDisplayPresentChange;
  44070. private onVRDisplayChanged;
  44071. private moveButtonToBottomRight;
  44072. private displayVRButton;
  44073. private updateButtonVisibility;
  44074. private _cachedAngularSensibility;
  44075. /**
  44076. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44077. * Otherwise, will use the fullscreen API.
  44078. */
  44079. enterVR(): void;
  44080. /**
  44081. * Attempt to exit VR, or fullscreen.
  44082. */
  44083. exitVR(): void;
  44084. /**
  44085. * The position of the vr experience helper.
  44086. */
  44087. get position(): Vector3;
  44088. /**
  44089. * Sets the position of the vr experience helper.
  44090. */
  44091. set position(value: Vector3);
  44092. /**
  44093. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44094. */
  44095. enableInteractions(): void;
  44096. private get _noControllerIsActive();
  44097. private beforeRender;
  44098. private _isTeleportationFloor;
  44099. /**
  44100. * Adds a floor mesh to be used for teleportation.
  44101. * @param floorMesh the mesh to be used for teleportation.
  44102. */
  44103. addFloorMesh(floorMesh: Mesh): void;
  44104. /**
  44105. * Removes a floor mesh from being used for teleportation.
  44106. * @param floorMesh the mesh to be removed.
  44107. */
  44108. removeFloorMesh(floorMesh: Mesh): void;
  44109. /**
  44110. * Enables interactions and teleportation using the VR controllers and gaze.
  44111. * @param vrTeleportationOptions options to modify teleportation behavior.
  44112. */
  44113. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44114. private _onNewGamepadConnected;
  44115. private _tryEnableInteractionOnController;
  44116. private _onNewGamepadDisconnected;
  44117. private _enableInteractionOnController;
  44118. private _checkTeleportWithRay;
  44119. private _checkRotate;
  44120. private _checkTeleportBackwards;
  44121. private _enableTeleportationOnController;
  44122. private _createTeleportationCircles;
  44123. private _displayTeleportationTarget;
  44124. private _hideTeleportationTarget;
  44125. private _rotateCamera;
  44126. private _moveTeleportationSelectorTo;
  44127. private _workingVector;
  44128. private _workingQuaternion;
  44129. private _workingMatrix;
  44130. /**
  44131. * Time Constant Teleportation Mode
  44132. */
  44133. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44134. /**
  44135. * Speed Constant Teleportation Mode
  44136. */
  44137. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44138. /**
  44139. * Teleports the users feet to the desired location
  44140. * @param location The location where the user's feet should be placed
  44141. */
  44142. teleportCamera(location: Vector3): void;
  44143. private _convertNormalToDirectionOfRay;
  44144. private _castRayAndSelectObject;
  44145. private _notifySelectedMeshUnselected;
  44146. /**
  44147. * Permanently set new colors for the laser pointer
  44148. * @param color the new laser color
  44149. * @param pickedColor the new laser color when picked mesh detected
  44150. */
  44151. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44152. /**
  44153. * Permanently set new colors for the gaze pointer
  44154. * @param color the new gaze color
  44155. * @param pickedColor the new gaze color when picked mesh detected
  44156. */
  44157. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44158. /**
  44159. * Sets the color of the laser ray from the vr controllers.
  44160. * @param color new color for the ray.
  44161. */
  44162. changeLaserColor(color: Color3): void;
  44163. /**
  44164. * Sets the color of the ray from the vr headsets gaze.
  44165. * @param color new color for the ray.
  44166. */
  44167. changeGazeColor(color: Color3): void;
  44168. /**
  44169. * Exits VR and disposes of the vr experience helper
  44170. */
  44171. dispose(): void;
  44172. /**
  44173. * Gets the name of the VRExperienceHelper class
  44174. * @returns "VRExperienceHelper"
  44175. */
  44176. getClassName(): string;
  44177. }
  44178. }
  44179. declare module BABYLON {
  44180. /**
  44181. * Options used for hit testing
  44182. */
  44183. export interface IWebXRHitTestOptions {
  44184. /**
  44185. * Only test when user interacted with the scene. Default - hit test every frame
  44186. */
  44187. testOnPointerDownOnly?: boolean;
  44188. /**
  44189. * The node to use to transform the local results to world coordinates
  44190. */
  44191. worldParentNode?: TransformNode;
  44192. }
  44193. /**
  44194. * Interface defining the babylon result of raycasting/hit-test
  44195. */
  44196. export interface IWebXRHitResult {
  44197. /**
  44198. * The native hit test result
  44199. */
  44200. xrHitResult: XRHitResult;
  44201. /**
  44202. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44203. */
  44204. transformationMatrix: Matrix;
  44205. }
  44206. /**
  44207. * The currently-working hit-test module.
  44208. * Hit test (or raycasting) is used to interact with the real world.
  44209. * For further information read here - https://github.com/immersive-web/hit-test
  44210. */
  44211. export class WebXRHitTestLegacy implements IWebXRFeature {
  44212. private _xrSessionManager;
  44213. /**
  44214. * options to use when constructing this feature
  44215. */
  44216. readonly options: IWebXRHitTestOptions;
  44217. /**
  44218. * The module's name
  44219. */
  44220. static readonly Name: string;
  44221. /**
  44222. * The (Babylon) version of this module.
  44223. * This is an integer representing the implementation version.
  44224. * This number does not correspond to the webxr specs version
  44225. */
  44226. static readonly Version: number;
  44227. /**
  44228. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44229. * @param event the (select) event to use to select with
  44230. * @param referenceSpace the reference space to use for this hit test
  44231. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44232. */
  44233. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44234. /**
  44235. * execute a hit test with an XR Ray
  44236. *
  44237. * @param xrSession a native xrSession that will execute this hit test
  44238. * @param xrRay the ray (position and direction) to use for raycasting
  44239. * @param referenceSpace native XR reference space to use for the hit-test
  44240. * @param filter filter function that will filter the results
  44241. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44242. */
  44243. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44244. /**
  44245. * Triggered when new babylon (transformed) hit test results are available
  44246. */
  44247. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44248. /**
  44249. * Creates a new instance of the (legacy version) hit test feature
  44250. * @param _xrSessionManager an instance of WebXRSessionManager
  44251. * @param options options to use when constructing this feature
  44252. */
  44253. constructor(_xrSessionManager: WebXRSessionManager,
  44254. /**
  44255. * options to use when constructing this feature
  44256. */
  44257. options?: IWebXRHitTestOptions);
  44258. private _onSelectEnabled;
  44259. private _xrFrameObserver;
  44260. private _attached;
  44261. /**
  44262. * Populated with the last native XR Hit Results
  44263. */
  44264. lastNativeXRHitResults: XRHitResult[];
  44265. /**
  44266. * attach this feature
  44267. * Will usually be called by the features manager
  44268. *
  44269. * @returns true if successful.
  44270. */
  44271. attach(): boolean;
  44272. /**
  44273. * detach this feature.
  44274. * Will usually be called by the features manager
  44275. *
  44276. * @returns true if successful.
  44277. */
  44278. detach(): boolean;
  44279. private _onHitTestResults;
  44280. private _onSelect;
  44281. /**
  44282. * Dispose this feature and all of the resources attached
  44283. */
  44284. dispose(): void;
  44285. }
  44286. }
  44287. declare module BABYLON {
  44288. /**
  44289. * Options used in the plane detector module
  44290. */
  44291. export interface IWebXRPlaneDetectorOptions {
  44292. /**
  44293. * The node to use to transform the local results to world coordinates
  44294. */
  44295. worldParentNode?: TransformNode;
  44296. }
  44297. /**
  44298. * A babylon interface for a webxr plane.
  44299. * A Plane is actually a polygon, built from N points in space
  44300. */
  44301. export interface IWebXRPlane {
  44302. /**
  44303. * a babylon-assigned ID for this polygon
  44304. */
  44305. id: number;
  44306. /**
  44307. * the native xr-plane object
  44308. */
  44309. xrPlane: XRPlane;
  44310. /**
  44311. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44312. */
  44313. polygonDefinition: Array<Vector3>;
  44314. /**
  44315. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44316. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44317. */
  44318. transformationMatrix: Matrix;
  44319. }
  44320. /**
  44321. * The plane detector is used to detect planes in the real world when in AR
  44322. * For more information see https://github.com/immersive-web/real-world-geometry/
  44323. */
  44324. export class WebXRPlaneDetector implements IWebXRFeature {
  44325. private _xrSessionManager;
  44326. private _options;
  44327. /**
  44328. * The module's name
  44329. */
  44330. static readonly Name: string;
  44331. /**
  44332. * The (Babylon) version of this module.
  44333. * This is an integer representing the implementation version.
  44334. * This number does not correspond to the webxr specs version
  44335. */
  44336. static readonly Version: number;
  44337. /**
  44338. * Observers registered here will be executed when a new plane was added to the session
  44339. */
  44340. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44341. /**
  44342. * Observers registered here will be executed when a plane is no longer detected in the session
  44343. */
  44344. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44345. /**
  44346. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44347. * This can execute N times every frame
  44348. */
  44349. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44350. private _enabled;
  44351. private _attached;
  44352. private _detectedPlanes;
  44353. private _lastFrameDetected;
  44354. private _observerTracked;
  44355. /**
  44356. * construct a new Plane Detector
  44357. * @param _xrSessionManager an instance of xr Session manager
  44358. * @param _options configuration to use when constructing this feature
  44359. */
  44360. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44361. /**
  44362. * attach this feature
  44363. * Will usually be called by the features manager
  44364. *
  44365. * @returns true if successful.
  44366. */
  44367. attach(): boolean;
  44368. /**
  44369. * detach this feature.
  44370. * Will usually be called by the features manager
  44371. *
  44372. * @returns true if successful.
  44373. */
  44374. detach(): boolean;
  44375. /**
  44376. * Dispose this feature and all of the resources attached
  44377. */
  44378. dispose(): void;
  44379. private _updatePlaneWithXRPlane;
  44380. /**
  44381. * avoiding using Array.find for global support.
  44382. * @param xrPlane the plane to find in the array
  44383. */
  44384. private findIndexInPlaneArray;
  44385. }
  44386. }
  44387. declare module BABYLON {
  44388. /**
  44389. * Configuration options of the anchor system
  44390. */
  44391. export interface IWebXRAnchorSystemOptions {
  44392. /**
  44393. * a node that will be used to convert local to world coordinates
  44394. */
  44395. worldParentNode?: TransformNode;
  44396. /**
  44397. * should the anchor system use plane detection.
  44398. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44399. */
  44400. usePlaneDetection?: boolean;
  44401. /**
  44402. * Should a new anchor be added every time a select event is triggered
  44403. */
  44404. addAnchorOnSelect?: boolean;
  44405. }
  44406. /**
  44407. * A babylon container for an XR Anchor
  44408. */
  44409. export interface IWebXRAnchor {
  44410. /**
  44411. * A babylon-assigned ID for this anchor
  44412. */
  44413. id: number;
  44414. /**
  44415. * The native anchor object
  44416. */
  44417. xrAnchor: XRAnchor;
  44418. /**
  44419. * Transformation matrix to apply to an object attached to this anchor
  44420. */
  44421. transformationMatrix: Matrix;
  44422. }
  44423. /**
  44424. * An implementation of the anchor system of WebXR.
  44425. * Note that the current documented implementation is not available in any browser. Future implementations
  44426. * will use the frame to create an anchor and not the session or a detected plane
  44427. * For further information see https://github.com/immersive-web/anchors/
  44428. */
  44429. export class WebXRAnchorSystem implements IWebXRFeature {
  44430. private _xrSessionManager;
  44431. private _options;
  44432. /**
  44433. * The module's name
  44434. */
  44435. static readonly Name: string;
  44436. /**
  44437. * The (Babylon) version of this module.
  44438. * This is an integer representing the implementation version.
  44439. * This number does not correspond to the webxr specs version
  44440. */
  44441. static readonly Version: number;
  44442. /**
  44443. * Observers registered here will be executed when a new anchor was added to the session
  44444. */
  44445. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44446. /**
  44447. * Observers registered here will be executed when an existing anchor updates
  44448. * This can execute N times every frame
  44449. */
  44450. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44451. /**
  44452. * Observers registered here will be executed when an anchor was removed from the session
  44453. */
  44454. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44455. private _planeDetector;
  44456. private _hitTestModule;
  44457. private _enabled;
  44458. private _attached;
  44459. private _trackedAnchors;
  44460. private _lastFrameDetected;
  44461. private _observerTracked;
  44462. /**
  44463. * constructs a new anchor system
  44464. * @param _xrSessionManager an instance of WebXRSessionManager
  44465. * @param _options configuration object for this feature
  44466. */
  44467. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44468. /**
  44469. * set the plane detector to use in order to create anchors from frames
  44470. * @param planeDetector the plane-detector module to use
  44471. * @param enable enable plane-anchors. default is true
  44472. */
  44473. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44474. /**
  44475. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44476. * @param hitTestModule the hit-test module to use.
  44477. */
  44478. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44479. /**
  44480. * attach this feature
  44481. * Will usually be called by the features manager
  44482. *
  44483. * @returns true if successful.
  44484. */
  44485. attach(): boolean;
  44486. /**
  44487. * detach this feature.
  44488. * Will usually be called by the features manager
  44489. *
  44490. * @returns true if successful.
  44491. */
  44492. detach(): boolean;
  44493. /**
  44494. * Dispose this feature and all of the resources attached
  44495. */
  44496. dispose(): void;
  44497. private _onSelect;
  44498. /**
  44499. * Add anchor at a specific XR point.
  44500. *
  44501. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44502. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44503. * @returns a promise the fulfills when the anchor was created
  44504. */
  44505. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44506. private _updateAnchorWithXRFrame;
  44507. /**
  44508. * avoiding using Array.find for global support.
  44509. * @param xrAnchor the plane to find in the array
  44510. */
  44511. private _findIndexInAnchorArray;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * Options interface for the background remover plugin
  44517. */
  44518. export interface IWebXRBackgroundRemoverOptions {
  44519. /**
  44520. * don't disable the environment helper
  44521. */
  44522. ignoreEnvironmentHelper?: boolean;
  44523. /**
  44524. * flags to configure the removal of the environment helper.
  44525. * If not set, the entire background will be removed. If set, flags should be set as well.
  44526. */
  44527. environmentHelperRemovalFlags?: {
  44528. /**
  44529. * Should the skybox be removed (default false)
  44530. */
  44531. skyBox?: boolean;
  44532. /**
  44533. * Should the ground be removed (default false)
  44534. */
  44535. ground?: boolean;
  44536. };
  44537. /**
  44538. * Further background meshes to disable when entering AR
  44539. */
  44540. backgroundMeshes?: AbstractMesh[];
  44541. }
  44542. /**
  44543. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44544. */
  44545. export class WebXRBackgroundRemover implements IWebXRFeature {
  44546. private _xrSessionManager;
  44547. /**
  44548. * read-only options to be used in this module
  44549. */
  44550. readonly options: IWebXRBackgroundRemoverOptions;
  44551. /**
  44552. * The module's name
  44553. */
  44554. static readonly Name: string;
  44555. /**
  44556. * The (Babylon) version of this module.
  44557. * This is an integer representing the implementation version.
  44558. * This number does not correspond to the webxr specs version
  44559. */
  44560. static readonly Version: number;
  44561. /**
  44562. * registered observers will be triggered when the background state changes
  44563. */
  44564. onBackgroundStateChangedObservable: Observable<boolean>;
  44565. /**
  44566. * constructs a new background remover module
  44567. * @param _xrSessionManager the session manager for this module
  44568. * @param options read-only options to be used in this module
  44569. */
  44570. constructor(_xrSessionManager: WebXRSessionManager,
  44571. /**
  44572. * read-only options to be used in this module
  44573. */
  44574. options?: IWebXRBackgroundRemoverOptions);
  44575. /**
  44576. * attach this feature
  44577. * Will usually be called by the features manager
  44578. *
  44579. * @returns true if successful.
  44580. */
  44581. attach(): boolean;
  44582. /**
  44583. * detach this feature.
  44584. * Will usually be called by the features manager
  44585. *
  44586. * @returns true if successful.
  44587. */
  44588. detach(): boolean;
  44589. private _setBackgroundState;
  44590. /**
  44591. * Dispose this feature and all of the resources attached
  44592. */
  44593. dispose(): void;
  44594. }
  44595. }
  44596. declare module BABYLON {
  44597. /**
  44598. * Contains an array of blocks representing the octree
  44599. */
  44600. export interface IOctreeContainer<T> {
  44601. /**
  44602. * Blocks within the octree
  44603. */
  44604. blocks: Array<OctreeBlock<T>>;
  44605. }
  44606. /**
  44607. * Class used to store a cell in an octree
  44608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44609. */
  44610. export class OctreeBlock<T> {
  44611. /**
  44612. * Gets the content of the current block
  44613. */
  44614. entries: T[];
  44615. /**
  44616. * Gets the list of block children
  44617. */
  44618. blocks: Array<OctreeBlock<T>>;
  44619. private _depth;
  44620. private _maxDepth;
  44621. private _capacity;
  44622. private _minPoint;
  44623. private _maxPoint;
  44624. private _boundingVectors;
  44625. private _creationFunc;
  44626. /**
  44627. * Creates a new block
  44628. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44629. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44630. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44631. * @param depth defines the current depth of this block in the octree
  44632. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44633. * @param creationFunc defines a callback to call when an element is added to the block
  44634. */
  44635. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44636. /**
  44637. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44638. */
  44639. get capacity(): number;
  44640. /**
  44641. * Gets the minimum vector (in world space) of the block's bounding box
  44642. */
  44643. get minPoint(): Vector3;
  44644. /**
  44645. * Gets the maximum vector (in world space) of the block's bounding box
  44646. */
  44647. get maxPoint(): Vector3;
  44648. /**
  44649. * Add a new element to this block
  44650. * @param entry defines the element to add
  44651. */
  44652. addEntry(entry: T): void;
  44653. /**
  44654. * Remove an element from this block
  44655. * @param entry defines the element to remove
  44656. */
  44657. removeEntry(entry: T): void;
  44658. /**
  44659. * Add an array of elements to this block
  44660. * @param entries defines the array of elements to add
  44661. */
  44662. addEntries(entries: T[]): void;
  44663. /**
  44664. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44665. * @param frustumPlanes defines the frustum planes to test
  44666. * @param selection defines the array to store current content if selection is positive
  44667. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44668. */
  44669. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44670. /**
  44671. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44672. * @param sphereCenter defines the bounding sphere center
  44673. * @param sphereRadius defines the bounding sphere radius
  44674. * @param selection defines the array to store current content if selection is positive
  44675. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44676. */
  44677. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44678. /**
  44679. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44680. * @param ray defines the ray to test with
  44681. * @param selection defines the array to store current content if selection is positive
  44682. */
  44683. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44684. /**
  44685. * Subdivide the content into child blocks (this block will then be empty)
  44686. */
  44687. createInnerBlocks(): void;
  44688. /**
  44689. * @hidden
  44690. */
  44691. 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;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44698. */
  44699. export class Octree<T> {
  44700. /** 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.) */
  44701. maxDepth: number;
  44702. /**
  44703. * Blocks within the octree containing objects
  44704. */
  44705. blocks: Array<OctreeBlock<T>>;
  44706. /**
  44707. * Content stored in the octree
  44708. */
  44709. dynamicContent: T[];
  44710. private _maxBlockCapacity;
  44711. private _selectionContent;
  44712. private _creationFunc;
  44713. /**
  44714. * Creates a octree
  44715. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44716. * @param creationFunc function to be used to instatiate the octree
  44717. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44718. * @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.)
  44719. */
  44720. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44721. /** 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.) */
  44722. maxDepth?: number);
  44723. /**
  44724. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44725. * @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);
  44726. * @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);
  44727. * @param entries meshes to be added to the octree blocks
  44728. */
  44729. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44730. /**
  44731. * Adds a mesh to the octree
  44732. * @param entry Mesh to add to the octree
  44733. */
  44734. addMesh(entry: T): void;
  44735. /**
  44736. * Remove an element from the octree
  44737. * @param entry defines the element to remove
  44738. */
  44739. removeMesh(entry: T): void;
  44740. /**
  44741. * Selects an array of meshes within the frustum
  44742. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44743. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44744. * @returns array of meshes within the frustum
  44745. */
  44746. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44747. /**
  44748. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44749. * @param sphereCenter defines the bounding sphere center
  44750. * @param sphereRadius defines the bounding sphere radius
  44751. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44752. * @returns an array of objects that intersect the sphere
  44753. */
  44754. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44755. /**
  44756. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44757. * @param ray defines the ray to test with
  44758. * @returns array of intersected objects
  44759. */
  44760. intersectsRay(ray: Ray): SmartArray<T>;
  44761. /**
  44762. * Adds a mesh into the octree block if it intersects the block
  44763. */
  44764. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44765. /**
  44766. * Adds a submesh into the octree block if it intersects the block
  44767. */
  44768. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44769. }
  44770. }
  44771. declare module BABYLON {
  44772. interface Scene {
  44773. /**
  44774. * @hidden
  44775. * Backing Filed
  44776. */
  44777. _selectionOctree: Octree<AbstractMesh>;
  44778. /**
  44779. * Gets the octree used to boost mesh selection (picking)
  44780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44781. */
  44782. selectionOctree: Octree<AbstractMesh>;
  44783. /**
  44784. * Creates or updates the octree used to boost selection (picking)
  44785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44786. * @param maxCapacity defines the maximum capacity per leaf
  44787. * @param maxDepth defines the maximum depth of the octree
  44788. * @returns an octree of AbstractMesh
  44789. */
  44790. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44791. }
  44792. interface AbstractMesh {
  44793. /**
  44794. * @hidden
  44795. * Backing Field
  44796. */
  44797. _submeshesOctree: Octree<SubMesh>;
  44798. /**
  44799. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44800. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44801. * @param maxCapacity defines the maximum size of each block (64 by default)
  44802. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44803. * @returns the new octree
  44804. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44806. */
  44807. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44808. }
  44809. /**
  44810. * Defines the octree scene component responsible to manage any octrees
  44811. * in a given scene.
  44812. */
  44813. export class OctreeSceneComponent {
  44814. /**
  44815. * The component name help to identify the component in the list of scene components.
  44816. */
  44817. readonly name: string;
  44818. /**
  44819. * The scene the component belongs to.
  44820. */
  44821. scene: Scene;
  44822. /**
  44823. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44824. */
  44825. readonly checksIsEnabled: boolean;
  44826. /**
  44827. * Creates a new instance of the component for the given scene
  44828. * @param scene Defines the scene to register the component in
  44829. */
  44830. constructor(scene: Scene);
  44831. /**
  44832. * Registers the component in a given scene
  44833. */
  44834. register(): void;
  44835. /**
  44836. * Return the list of active meshes
  44837. * @returns the list of active meshes
  44838. */
  44839. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44840. /**
  44841. * Return the list of active sub meshes
  44842. * @param mesh The mesh to get the candidates sub meshes from
  44843. * @returns the list of active sub meshes
  44844. */
  44845. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44846. private _tempRay;
  44847. /**
  44848. * Return the list of sub meshes intersecting with a given local ray
  44849. * @param mesh defines the mesh to find the submesh for
  44850. * @param localRay defines the ray in local space
  44851. * @returns the list of intersecting sub meshes
  44852. */
  44853. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44854. /**
  44855. * Return the list of sub meshes colliding with a collider
  44856. * @param mesh defines the mesh to find the submesh for
  44857. * @param collider defines the collider to evaluate the collision against
  44858. * @returns the list of colliding sub meshes
  44859. */
  44860. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44861. /**
  44862. * Rebuilds the elements related to this component in case of
  44863. * context lost for instance.
  44864. */
  44865. rebuild(): void;
  44866. /**
  44867. * Disposes the component and the associated ressources.
  44868. */
  44869. dispose(): void;
  44870. }
  44871. }
  44872. declare module BABYLON {
  44873. /**
  44874. * Renders a layer on top of an existing scene
  44875. */
  44876. export class UtilityLayerRenderer implements IDisposable {
  44877. /** the original scene that will be rendered on top of */
  44878. originalScene: Scene;
  44879. private _pointerCaptures;
  44880. private _lastPointerEvents;
  44881. private static _DefaultUtilityLayer;
  44882. private static _DefaultKeepDepthUtilityLayer;
  44883. private _sharedGizmoLight;
  44884. private _renderCamera;
  44885. /**
  44886. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44887. * @returns the camera that is used when rendering the utility layer
  44888. */
  44889. getRenderCamera(): Nullable<Camera>;
  44890. /**
  44891. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44892. * @param cam the camera that should be used when rendering the utility layer
  44893. */
  44894. setRenderCamera(cam: Nullable<Camera>): void;
  44895. /**
  44896. * @hidden
  44897. * Light which used by gizmos to get light shading
  44898. */
  44899. _getSharedGizmoLight(): HemisphericLight;
  44900. /**
  44901. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44902. */
  44903. pickUtilitySceneFirst: boolean;
  44904. /**
  44905. * 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)
  44906. */
  44907. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44908. /**
  44909. * 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)
  44910. */
  44911. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44912. /**
  44913. * The scene that is rendered on top of the original scene
  44914. */
  44915. utilityLayerScene: Scene;
  44916. /**
  44917. * If the utility layer should automatically be rendered on top of existing scene
  44918. */
  44919. shouldRender: boolean;
  44920. /**
  44921. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44922. */
  44923. onlyCheckPointerDownEvents: boolean;
  44924. /**
  44925. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44926. */
  44927. processAllEvents: boolean;
  44928. /**
  44929. * Observable raised when the pointer move from the utility layer scene to the main scene
  44930. */
  44931. onPointerOutObservable: Observable<number>;
  44932. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44933. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44934. private _afterRenderObserver;
  44935. private _sceneDisposeObserver;
  44936. private _originalPointerObserver;
  44937. /**
  44938. * Instantiates a UtilityLayerRenderer
  44939. * @param originalScene the original scene that will be rendered on top of
  44940. * @param handleEvents boolean indicating if the utility layer should handle events
  44941. */
  44942. constructor(
  44943. /** the original scene that will be rendered on top of */
  44944. originalScene: Scene, handleEvents?: boolean);
  44945. private _notifyObservers;
  44946. /**
  44947. * Renders the utility layers scene on top of the original scene
  44948. */
  44949. render(): void;
  44950. /**
  44951. * Disposes of the renderer
  44952. */
  44953. dispose(): void;
  44954. private _updateCamera;
  44955. }
  44956. }
  44957. declare module BABYLON {
  44958. /**
  44959. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44960. */
  44961. export class Gizmo implements IDisposable {
  44962. /** The utility layer the gizmo will be added to */
  44963. gizmoLayer: UtilityLayerRenderer;
  44964. /**
  44965. * The root mesh of the gizmo
  44966. */
  44967. _rootMesh: Mesh;
  44968. private _attachedMesh;
  44969. /**
  44970. * Ratio for the scale of the gizmo (Default: 1)
  44971. */
  44972. scaleRatio: number;
  44973. /**
  44974. * If a custom mesh has been set (Default: false)
  44975. */
  44976. protected _customMeshSet: boolean;
  44977. /**
  44978. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44979. * * When set, interactions will be enabled
  44980. */
  44981. get attachedMesh(): Nullable<AbstractMesh>;
  44982. set attachedMesh(value: Nullable<AbstractMesh>);
  44983. /**
  44984. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44985. * @param mesh The mesh to replace the default mesh of the gizmo
  44986. */
  44987. setCustomMesh(mesh: Mesh): void;
  44988. /**
  44989. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44990. */
  44991. updateGizmoRotationToMatchAttachedMesh: boolean;
  44992. /**
  44993. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44994. */
  44995. updateGizmoPositionToMatchAttachedMesh: boolean;
  44996. /**
  44997. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44998. */
  44999. updateScale: boolean;
  45000. protected _interactionsEnabled: boolean;
  45001. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45002. private _beforeRenderObserver;
  45003. private _tempVector;
  45004. /**
  45005. * Creates a gizmo
  45006. * @param gizmoLayer The utility layer the gizmo will be added to
  45007. */
  45008. constructor(
  45009. /** The utility layer the gizmo will be added to */
  45010. gizmoLayer?: UtilityLayerRenderer);
  45011. /**
  45012. * Updates the gizmo to match the attached mesh's position/rotation
  45013. */
  45014. protected _update(): void;
  45015. /**
  45016. * Disposes of the gizmo
  45017. */
  45018. dispose(): void;
  45019. }
  45020. }
  45021. declare module BABYLON {
  45022. /**
  45023. * Single plane drag gizmo
  45024. */
  45025. export class PlaneDragGizmo extends Gizmo {
  45026. /**
  45027. * Drag behavior responsible for the gizmos dragging interactions
  45028. */
  45029. dragBehavior: PointerDragBehavior;
  45030. private _pointerObserver;
  45031. /**
  45032. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45033. */
  45034. snapDistance: number;
  45035. /**
  45036. * Event that fires each time the gizmo snaps to a new location.
  45037. * * snapDistance is the the change in distance
  45038. */
  45039. onSnapObservable: Observable<{
  45040. snapDistance: number;
  45041. }>;
  45042. private _plane;
  45043. private _coloredMaterial;
  45044. private _hoverMaterial;
  45045. private _isEnabled;
  45046. private _parent;
  45047. /** @hidden */
  45048. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45049. /** @hidden */
  45050. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45051. /**
  45052. * Creates a PlaneDragGizmo
  45053. * @param gizmoLayer The utility layer the gizmo will be added to
  45054. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45055. * @param color The color of the gizmo
  45056. */
  45057. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45058. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45059. /**
  45060. * If the gizmo is enabled
  45061. */
  45062. set isEnabled(value: boolean);
  45063. get isEnabled(): boolean;
  45064. /**
  45065. * Disposes of the gizmo
  45066. */
  45067. dispose(): void;
  45068. }
  45069. }
  45070. declare module BABYLON {
  45071. /**
  45072. * Gizmo that enables dragging a mesh along 3 axis
  45073. */
  45074. export class PositionGizmo extends Gizmo {
  45075. /**
  45076. * Internal gizmo used for interactions on the x axis
  45077. */
  45078. xGizmo: AxisDragGizmo;
  45079. /**
  45080. * Internal gizmo used for interactions on the y axis
  45081. */
  45082. yGizmo: AxisDragGizmo;
  45083. /**
  45084. * Internal gizmo used for interactions on the z axis
  45085. */
  45086. zGizmo: AxisDragGizmo;
  45087. /**
  45088. * Internal gizmo used for interactions on the yz plane
  45089. */
  45090. xPlaneGizmo: PlaneDragGizmo;
  45091. /**
  45092. * Internal gizmo used for interactions on the xz plane
  45093. */
  45094. yPlaneGizmo: PlaneDragGizmo;
  45095. /**
  45096. * Internal gizmo used for interactions on the xy plane
  45097. */
  45098. zPlaneGizmo: PlaneDragGizmo;
  45099. /**
  45100. * private variables
  45101. */
  45102. private _meshAttached;
  45103. private _updateGizmoRotationToMatchAttachedMesh;
  45104. private _snapDistance;
  45105. private _scaleRatio;
  45106. /** Fires an event when any of it's sub gizmos are dragged */
  45107. onDragStartObservable: Observable<unknown>;
  45108. /** Fires an event when any of it's sub gizmos are released from dragging */
  45109. onDragEndObservable: Observable<unknown>;
  45110. /**
  45111. * If set to true, planar drag is enabled
  45112. */
  45113. private _planarGizmoEnabled;
  45114. get attachedMesh(): Nullable<AbstractMesh>;
  45115. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45116. /**
  45117. * Creates a PositionGizmo
  45118. * @param gizmoLayer The utility layer the gizmo will be added to
  45119. */
  45120. constructor(gizmoLayer?: UtilityLayerRenderer);
  45121. /**
  45122. * If the planar drag gizmo is enabled
  45123. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45124. */
  45125. set planarGizmoEnabled(value: boolean);
  45126. get planarGizmoEnabled(): boolean;
  45127. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45128. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45129. /**
  45130. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45131. */
  45132. set snapDistance(value: number);
  45133. get snapDistance(): number;
  45134. /**
  45135. * Ratio for the scale of the gizmo (Default: 1)
  45136. */
  45137. set scaleRatio(value: number);
  45138. get scaleRatio(): number;
  45139. /**
  45140. * Disposes of the gizmo
  45141. */
  45142. dispose(): void;
  45143. /**
  45144. * CustomMeshes are not supported by this gizmo
  45145. * @param mesh The mesh to replace the default mesh of the gizmo
  45146. */
  45147. setCustomMesh(mesh: Mesh): void;
  45148. }
  45149. }
  45150. declare module BABYLON {
  45151. /**
  45152. * Single axis drag gizmo
  45153. */
  45154. export class AxisDragGizmo extends Gizmo {
  45155. /**
  45156. * Drag behavior responsible for the gizmos dragging interactions
  45157. */
  45158. dragBehavior: PointerDragBehavior;
  45159. private _pointerObserver;
  45160. /**
  45161. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45162. */
  45163. snapDistance: number;
  45164. /**
  45165. * Event that fires each time the gizmo snaps to a new location.
  45166. * * snapDistance is the the change in distance
  45167. */
  45168. onSnapObservable: Observable<{
  45169. snapDistance: number;
  45170. }>;
  45171. private _isEnabled;
  45172. private _parent;
  45173. private _arrow;
  45174. private _coloredMaterial;
  45175. private _hoverMaterial;
  45176. /** @hidden */
  45177. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45178. /** @hidden */
  45179. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45180. /**
  45181. * Creates an AxisDragGizmo
  45182. * @param gizmoLayer The utility layer the gizmo will be added to
  45183. * @param dragAxis The axis which the gizmo will be able to drag on
  45184. * @param color The color of the gizmo
  45185. */
  45186. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45188. /**
  45189. * If the gizmo is enabled
  45190. */
  45191. set isEnabled(value: boolean);
  45192. get isEnabled(): boolean;
  45193. /**
  45194. * Disposes of the gizmo
  45195. */
  45196. dispose(): void;
  45197. }
  45198. }
  45199. declare module BABYLON.Debug {
  45200. /**
  45201. * The Axes viewer will show 3 axes in a specific point in space
  45202. */
  45203. export class AxesViewer {
  45204. private _xAxis;
  45205. private _yAxis;
  45206. private _zAxis;
  45207. private _scaleLinesFactor;
  45208. private _instanced;
  45209. /**
  45210. * Gets the hosting scene
  45211. */
  45212. scene: Scene;
  45213. /**
  45214. * Gets or sets a number used to scale line length
  45215. */
  45216. scaleLines: number;
  45217. /** Gets the node hierarchy used to render x-axis */
  45218. get xAxis(): TransformNode;
  45219. /** Gets the node hierarchy used to render y-axis */
  45220. get yAxis(): TransformNode;
  45221. /** Gets the node hierarchy used to render z-axis */
  45222. get zAxis(): TransformNode;
  45223. /**
  45224. * Creates a new AxesViewer
  45225. * @param scene defines the hosting scene
  45226. * @param scaleLines defines a number used to scale line length (1 by default)
  45227. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45228. * @param xAxis defines the node hierarchy used to render the x-axis
  45229. * @param yAxis defines the node hierarchy used to render the y-axis
  45230. * @param zAxis defines the node hierarchy used to render the z-axis
  45231. */
  45232. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45233. /**
  45234. * Force the viewer to update
  45235. * @param position defines the position of the viewer
  45236. * @param xaxis defines the x axis of the viewer
  45237. * @param yaxis defines the y axis of the viewer
  45238. * @param zaxis defines the z axis of the viewer
  45239. */
  45240. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45241. /**
  45242. * Creates an instance of this axes viewer.
  45243. * @returns a new axes viewer with instanced meshes
  45244. */
  45245. createInstance(): AxesViewer;
  45246. /** Releases resources */
  45247. dispose(): void;
  45248. private static _SetRenderingGroupId;
  45249. }
  45250. }
  45251. declare module BABYLON.Debug {
  45252. /**
  45253. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45254. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45255. */
  45256. export class BoneAxesViewer extends AxesViewer {
  45257. /**
  45258. * Gets or sets the target mesh where to display the axes viewer
  45259. */
  45260. mesh: Nullable<Mesh>;
  45261. /**
  45262. * Gets or sets the target bone where to display the axes viewer
  45263. */
  45264. bone: Nullable<Bone>;
  45265. /** Gets current position */
  45266. pos: Vector3;
  45267. /** Gets direction of X axis */
  45268. xaxis: Vector3;
  45269. /** Gets direction of Y axis */
  45270. yaxis: Vector3;
  45271. /** Gets direction of Z axis */
  45272. zaxis: Vector3;
  45273. /**
  45274. * Creates a new BoneAxesViewer
  45275. * @param scene defines the hosting scene
  45276. * @param bone defines the target bone
  45277. * @param mesh defines the target mesh
  45278. * @param scaleLines defines a scaling factor for line length (1 by default)
  45279. */
  45280. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45281. /**
  45282. * Force the viewer to update
  45283. */
  45284. update(): void;
  45285. /** Releases resources */
  45286. dispose(): void;
  45287. }
  45288. }
  45289. declare module BABYLON {
  45290. /**
  45291. * Interface used to define scene explorer extensibility option
  45292. */
  45293. export interface IExplorerExtensibilityOption {
  45294. /**
  45295. * Define the option label
  45296. */
  45297. label: string;
  45298. /**
  45299. * Defines the action to execute on click
  45300. */
  45301. action: (entity: any) => void;
  45302. }
  45303. /**
  45304. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45305. */
  45306. export interface IExplorerExtensibilityGroup {
  45307. /**
  45308. * Defines a predicate to test if a given type mut be extended
  45309. */
  45310. predicate: (entity: any) => boolean;
  45311. /**
  45312. * Gets the list of options added to a type
  45313. */
  45314. entries: IExplorerExtensibilityOption[];
  45315. }
  45316. /**
  45317. * Interface used to define the options to use to create the Inspector
  45318. */
  45319. export interface IInspectorOptions {
  45320. /**
  45321. * Display in overlay mode (default: false)
  45322. */
  45323. overlay?: boolean;
  45324. /**
  45325. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45326. */
  45327. globalRoot?: HTMLElement;
  45328. /**
  45329. * Display the Scene explorer
  45330. */
  45331. showExplorer?: boolean;
  45332. /**
  45333. * Display the property inspector
  45334. */
  45335. showInspector?: boolean;
  45336. /**
  45337. * Display in embed mode (both panes on the right)
  45338. */
  45339. embedMode?: boolean;
  45340. /**
  45341. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45342. */
  45343. handleResize?: boolean;
  45344. /**
  45345. * Allow the panes to popup (default: true)
  45346. */
  45347. enablePopup?: boolean;
  45348. /**
  45349. * Allow the panes to be closed by users (default: true)
  45350. */
  45351. enableClose?: boolean;
  45352. /**
  45353. * Optional list of extensibility entries
  45354. */
  45355. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45356. /**
  45357. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45358. */
  45359. inspectorURL?: string;
  45360. /**
  45361. * Optional initial tab (default to DebugLayerTab.Properties)
  45362. */
  45363. initialTab?: DebugLayerTab;
  45364. }
  45365. interface Scene {
  45366. /**
  45367. * @hidden
  45368. * Backing field
  45369. */
  45370. _debugLayer: DebugLayer;
  45371. /**
  45372. * Gets the debug layer (aka Inspector) associated with the scene
  45373. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45374. */
  45375. debugLayer: DebugLayer;
  45376. }
  45377. /**
  45378. * Enum of inspector action tab
  45379. */
  45380. export enum DebugLayerTab {
  45381. /**
  45382. * Properties tag (default)
  45383. */
  45384. Properties = 0,
  45385. /**
  45386. * Debug tab
  45387. */
  45388. Debug = 1,
  45389. /**
  45390. * Statistics tab
  45391. */
  45392. Statistics = 2,
  45393. /**
  45394. * Tools tab
  45395. */
  45396. Tools = 3,
  45397. /**
  45398. * Settings tab
  45399. */
  45400. Settings = 4
  45401. }
  45402. /**
  45403. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45404. * what is happening in your scene
  45405. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45406. */
  45407. export class DebugLayer {
  45408. /**
  45409. * Define the url to get the inspector script from.
  45410. * By default it uses the babylonjs CDN.
  45411. * @ignoreNaming
  45412. */
  45413. static InspectorURL: string;
  45414. private _scene;
  45415. private BJSINSPECTOR;
  45416. private _onPropertyChangedObservable?;
  45417. /**
  45418. * Observable triggered when a property is changed through the inspector.
  45419. */
  45420. get onPropertyChangedObservable(): any;
  45421. /**
  45422. * Instantiates a new debug layer.
  45423. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45424. * what is happening in your scene
  45425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45426. * @param scene Defines the scene to inspect
  45427. */
  45428. constructor(scene: Scene);
  45429. /** Creates the inspector window. */
  45430. private _createInspector;
  45431. /**
  45432. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45433. * @param entity defines the entity to select
  45434. * @param lineContainerTitle defines the specific block to highlight
  45435. */
  45436. select(entity: any, lineContainerTitle?: string): void;
  45437. /** Get the inspector from bundle or global */
  45438. private _getGlobalInspector;
  45439. /**
  45440. * Get if the inspector is visible or not.
  45441. * @returns true if visible otherwise, false
  45442. */
  45443. isVisible(): boolean;
  45444. /**
  45445. * Hide the inspector and close its window.
  45446. */
  45447. hide(): void;
  45448. /**
  45449. * Launch the debugLayer.
  45450. * @param config Define the configuration of the inspector
  45451. * @return a promise fulfilled when the debug layer is visible
  45452. */
  45453. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45454. }
  45455. }
  45456. declare module BABYLON {
  45457. /**
  45458. * Class containing static functions to help procedurally build meshes
  45459. */
  45460. export class BoxBuilder {
  45461. /**
  45462. * Creates a box mesh
  45463. * * The parameter `size` sets the size (float) of each box side (default 1)
  45464. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45465. * * 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)
  45466. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45468. * * 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
  45469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45470. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45471. * @param name defines the name of the mesh
  45472. * @param options defines the options used to create the mesh
  45473. * @param scene defines the hosting scene
  45474. * @returns the box mesh
  45475. */
  45476. static CreateBox(name: string, options: {
  45477. size?: number;
  45478. width?: number;
  45479. height?: number;
  45480. depth?: number;
  45481. faceUV?: Vector4[];
  45482. faceColors?: Color4[];
  45483. sideOrientation?: number;
  45484. frontUVs?: Vector4;
  45485. backUVs?: Vector4;
  45486. wrap?: boolean;
  45487. topBaseAt?: number;
  45488. bottomBaseAt?: number;
  45489. updatable?: boolean;
  45490. }, scene?: Nullable<Scene>): Mesh;
  45491. }
  45492. }
  45493. declare module BABYLON {
  45494. /**
  45495. * Class containing static functions to help procedurally build meshes
  45496. */
  45497. export class SphereBuilder {
  45498. /**
  45499. * Creates a sphere mesh
  45500. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45501. * * 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`)
  45502. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45503. * * 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
  45504. * * 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)
  45505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45506. * * 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
  45507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45508. * @param name defines the name of the mesh
  45509. * @param options defines the options used to create the mesh
  45510. * @param scene defines the hosting scene
  45511. * @returns the sphere mesh
  45512. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45513. */
  45514. static CreateSphere(name: string, options: {
  45515. segments?: number;
  45516. diameter?: number;
  45517. diameterX?: number;
  45518. diameterY?: number;
  45519. diameterZ?: number;
  45520. arc?: number;
  45521. slice?: number;
  45522. sideOrientation?: number;
  45523. frontUVs?: Vector4;
  45524. backUVs?: Vector4;
  45525. updatable?: boolean;
  45526. }, scene?: Nullable<Scene>): Mesh;
  45527. }
  45528. }
  45529. declare module BABYLON.Debug {
  45530. /**
  45531. * Used to show the physics impostor around the specific mesh
  45532. */
  45533. export class PhysicsViewer {
  45534. /** @hidden */
  45535. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45536. /** @hidden */
  45537. protected _meshes: Array<Nullable<AbstractMesh>>;
  45538. /** @hidden */
  45539. protected _scene: Nullable<Scene>;
  45540. /** @hidden */
  45541. protected _numMeshes: number;
  45542. /** @hidden */
  45543. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45544. private _renderFunction;
  45545. private _utilityLayer;
  45546. private _debugBoxMesh;
  45547. private _debugSphereMesh;
  45548. private _debugCylinderMesh;
  45549. private _debugMaterial;
  45550. private _debugMeshMeshes;
  45551. /**
  45552. * Creates a new PhysicsViewer
  45553. * @param scene defines the hosting scene
  45554. */
  45555. constructor(scene: Scene);
  45556. /** @hidden */
  45557. protected _updateDebugMeshes(): void;
  45558. /**
  45559. * Renders a specified physic impostor
  45560. * @param impostor defines the impostor to render
  45561. * @param targetMesh defines the mesh represented by the impostor
  45562. * @returns the new debug mesh used to render the impostor
  45563. */
  45564. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45565. /**
  45566. * Hides a specified physic impostor
  45567. * @param impostor defines the impostor to hide
  45568. */
  45569. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45570. private _getDebugMaterial;
  45571. private _getDebugBoxMesh;
  45572. private _getDebugSphereMesh;
  45573. private _getDebugCylinderMesh;
  45574. private _getDebugMeshMesh;
  45575. private _getDebugMesh;
  45576. /** Releases all resources */
  45577. dispose(): void;
  45578. }
  45579. }
  45580. declare module BABYLON {
  45581. /**
  45582. * Class containing static functions to help procedurally build meshes
  45583. */
  45584. export class LinesBuilder {
  45585. /**
  45586. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45587. * * 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
  45588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45589. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45590. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45591. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45592. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45593. * * 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
  45594. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45597. * @param name defines the name of the new line system
  45598. * @param options defines the options used to create the line system
  45599. * @param scene defines the hosting scene
  45600. * @returns a new line system mesh
  45601. */
  45602. static CreateLineSystem(name: string, options: {
  45603. lines: Vector3[][];
  45604. updatable?: boolean;
  45605. instance?: Nullable<LinesMesh>;
  45606. colors?: Nullable<Color4[][]>;
  45607. useVertexAlpha?: boolean;
  45608. }, scene: Nullable<Scene>): LinesMesh;
  45609. /**
  45610. * Creates a line mesh
  45611. * 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
  45612. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45613. * * The parameter `points` is an array successive Vector3
  45614. * * 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
  45615. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45616. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45617. * * When updating an instance, remember that only point positions can change, not the number of points
  45618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45620. * @param name defines the name of the new line system
  45621. * @param options defines the options used to create the line system
  45622. * @param scene defines the hosting scene
  45623. * @returns a new line mesh
  45624. */
  45625. static CreateLines(name: string, options: {
  45626. points: Vector3[];
  45627. updatable?: boolean;
  45628. instance?: Nullable<LinesMesh>;
  45629. colors?: Color4[];
  45630. useVertexAlpha?: boolean;
  45631. }, scene?: Nullable<Scene>): LinesMesh;
  45632. /**
  45633. * Creates a dashed line mesh
  45634. * * 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
  45635. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45636. * * The parameter `points` is an array successive Vector3
  45637. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45638. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45639. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45640. * * 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
  45641. * * When updating an instance, remember that only point positions can change, not the number of points
  45642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45643. * @param name defines the name of the mesh
  45644. * @param options defines the options used to create the mesh
  45645. * @param scene defines the hosting scene
  45646. * @returns the dashed line mesh
  45647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45648. */
  45649. static CreateDashedLines(name: string, options: {
  45650. points: Vector3[];
  45651. dashSize?: number;
  45652. gapSize?: number;
  45653. dashNb?: number;
  45654. updatable?: boolean;
  45655. instance?: LinesMesh;
  45656. }, scene?: Nullable<Scene>): LinesMesh;
  45657. }
  45658. }
  45659. declare module BABYLON {
  45660. /**
  45661. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45662. * in order to better appreciate the issue one might have.
  45663. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45664. */
  45665. export class RayHelper {
  45666. /**
  45667. * Defines the ray we are currently tryin to visualize.
  45668. */
  45669. ray: Nullable<Ray>;
  45670. private _renderPoints;
  45671. private _renderLine;
  45672. private _renderFunction;
  45673. private _scene;
  45674. private _updateToMeshFunction;
  45675. private _attachedToMesh;
  45676. private _meshSpaceDirection;
  45677. private _meshSpaceOrigin;
  45678. /**
  45679. * Helper function to create a colored helper in a scene in one line.
  45680. * @param ray Defines the ray we are currently tryin to visualize
  45681. * @param scene Defines the scene the ray is used in
  45682. * @param color Defines the color we want to see the ray in
  45683. * @returns The newly created ray helper.
  45684. */
  45685. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45686. /**
  45687. * Instantiate a new ray helper.
  45688. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45689. * in order to better appreciate the issue one might have.
  45690. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45691. * @param ray Defines the ray we are currently tryin to visualize
  45692. */
  45693. constructor(ray: Ray);
  45694. /**
  45695. * Shows the ray we are willing to debug.
  45696. * @param scene Defines the scene the ray needs to be rendered in
  45697. * @param color Defines the color the ray needs to be rendered in
  45698. */
  45699. show(scene: Scene, color?: Color3): void;
  45700. /**
  45701. * Hides the ray we are debugging.
  45702. */
  45703. hide(): void;
  45704. private _render;
  45705. /**
  45706. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45707. * @param mesh Defines the mesh we want the helper attached to
  45708. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45709. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45710. * @param length Defines the length of the ray
  45711. */
  45712. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45713. /**
  45714. * Detach the ray helper from the mesh it has previously been attached to.
  45715. */
  45716. detachFromMesh(): void;
  45717. private _updateToMesh;
  45718. /**
  45719. * Dispose the helper and release its associated resources.
  45720. */
  45721. dispose(): void;
  45722. }
  45723. }
  45724. declare module BABYLON.Debug {
  45725. /**
  45726. * Class used to render a debug view of a given skeleton
  45727. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45728. */
  45729. export class SkeletonViewer {
  45730. /** defines the skeleton to render */
  45731. skeleton: Skeleton;
  45732. /** defines the mesh attached to the skeleton */
  45733. mesh: AbstractMesh;
  45734. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45735. autoUpdateBonesMatrices: boolean;
  45736. /** defines the rendering group id to use with the viewer */
  45737. renderingGroupId: number;
  45738. /** Gets or sets the color used to render the skeleton */
  45739. color: Color3;
  45740. private _scene;
  45741. private _debugLines;
  45742. private _debugMesh;
  45743. private _isEnabled;
  45744. private _renderFunction;
  45745. private _utilityLayer;
  45746. /**
  45747. * Returns the mesh used to render the bones
  45748. */
  45749. get debugMesh(): Nullable<LinesMesh>;
  45750. /**
  45751. * Creates a new SkeletonViewer
  45752. * @param skeleton defines the skeleton to render
  45753. * @param mesh defines the mesh attached to the skeleton
  45754. * @param scene defines the hosting scene
  45755. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45756. * @param renderingGroupId defines the rendering group id to use with the viewer
  45757. */
  45758. constructor(
  45759. /** defines the skeleton to render */
  45760. skeleton: Skeleton,
  45761. /** defines the mesh attached to the skeleton */
  45762. mesh: AbstractMesh, scene: Scene,
  45763. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45764. autoUpdateBonesMatrices?: boolean,
  45765. /** defines the rendering group id to use with the viewer */
  45766. renderingGroupId?: number);
  45767. /** Gets or sets a boolean indicating if the viewer is enabled */
  45768. set isEnabled(value: boolean);
  45769. get isEnabled(): boolean;
  45770. private _getBonePosition;
  45771. private _getLinesForBonesWithLength;
  45772. private _getLinesForBonesNoLength;
  45773. /** Update the viewer to sync with current skeleton state */
  45774. update(): void;
  45775. /** Release associated resources */
  45776. dispose(): void;
  45777. }
  45778. }
  45779. declare module BABYLON {
  45780. /**
  45781. * Options to create the null engine
  45782. */
  45783. export class NullEngineOptions {
  45784. /**
  45785. * Render width (Default: 512)
  45786. */
  45787. renderWidth: number;
  45788. /**
  45789. * Render height (Default: 256)
  45790. */
  45791. renderHeight: number;
  45792. /**
  45793. * Texture size (Default: 512)
  45794. */
  45795. textureSize: number;
  45796. /**
  45797. * If delta time between frames should be constant
  45798. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45799. */
  45800. deterministicLockstep: boolean;
  45801. /**
  45802. * Maximum about of steps between frames (Default: 4)
  45803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45804. */
  45805. lockstepMaxSteps: number;
  45806. }
  45807. /**
  45808. * The null engine class provides support for headless version of babylon.js.
  45809. * This can be used in server side scenario or for testing purposes
  45810. */
  45811. export class NullEngine extends Engine {
  45812. private _options;
  45813. /**
  45814. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45816. * @returns true if engine is in deterministic lock step mode
  45817. */
  45818. isDeterministicLockStep(): boolean;
  45819. /**
  45820. * Gets the max steps when engine is running in deterministic lock step
  45821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45822. * @returns the max steps
  45823. */
  45824. getLockstepMaxSteps(): number;
  45825. /**
  45826. * Gets the current hardware scaling level.
  45827. * By default the hardware scaling level is computed from the window device ratio.
  45828. * 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.
  45829. * @returns a number indicating the current hardware scaling level
  45830. */
  45831. getHardwareScalingLevel(): number;
  45832. constructor(options?: NullEngineOptions);
  45833. /**
  45834. * Creates a vertex buffer
  45835. * @param vertices the data for the vertex buffer
  45836. * @returns the new WebGL static buffer
  45837. */
  45838. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45839. /**
  45840. * Creates a new index buffer
  45841. * @param indices defines the content of the index buffer
  45842. * @param updatable defines if the index buffer must be updatable
  45843. * @returns a new webGL buffer
  45844. */
  45845. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45846. /**
  45847. * Clear the current render buffer or the current render target (if any is set up)
  45848. * @param color defines the color to use
  45849. * @param backBuffer defines if the back buffer must be cleared
  45850. * @param depth defines if the depth buffer must be cleared
  45851. * @param stencil defines if the stencil buffer must be cleared
  45852. */
  45853. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45854. /**
  45855. * Gets the current render width
  45856. * @param useScreen defines if screen size must be used (or the current render target if any)
  45857. * @returns a number defining the current render width
  45858. */
  45859. getRenderWidth(useScreen?: boolean): number;
  45860. /**
  45861. * Gets the current render height
  45862. * @param useScreen defines if screen size must be used (or the current render target if any)
  45863. * @returns a number defining the current render height
  45864. */
  45865. getRenderHeight(useScreen?: boolean): number;
  45866. /**
  45867. * Set the WebGL's viewport
  45868. * @param viewport defines the viewport element to be used
  45869. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45870. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45871. */
  45872. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45873. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45874. /**
  45875. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45876. * @param pipelineContext defines the pipeline context to use
  45877. * @param uniformsNames defines the list of uniform names
  45878. * @returns an array of webGL uniform locations
  45879. */
  45880. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45881. /**
  45882. * Gets the lsit of active attributes for a given webGL program
  45883. * @param pipelineContext defines the pipeline context to use
  45884. * @param attributesNames defines the list of attribute names to get
  45885. * @returns an array of indices indicating the offset of each attribute
  45886. */
  45887. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45888. /**
  45889. * Binds an effect to the webGL context
  45890. * @param effect defines the effect to bind
  45891. */
  45892. bindSamplers(effect: Effect): void;
  45893. /**
  45894. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45895. * @param effect defines the effect to activate
  45896. */
  45897. enableEffect(effect: Effect): void;
  45898. /**
  45899. * Set various states to the webGL context
  45900. * @param culling defines backface culling state
  45901. * @param zOffset defines the value to apply to zOffset (0 by default)
  45902. * @param force defines if states must be applied even if cache is up to date
  45903. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45904. */
  45905. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45906. /**
  45907. * Set the value of an uniform to an array of int32
  45908. * @param uniform defines the webGL uniform location where to store the value
  45909. * @param array defines the array of int32 to store
  45910. */
  45911. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45912. /**
  45913. * Set the value of an uniform to an array of int32 (stored as vec2)
  45914. * @param uniform defines the webGL uniform location where to store the value
  45915. * @param array defines the array of int32 to store
  45916. */
  45917. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45918. /**
  45919. * Set the value of an uniform to an array of int32 (stored as vec3)
  45920. * @param uniform defines the webGL uniform location where to store the value
  45921. * @param array defines the array of int32 to store
  45922. */
  45923. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45924. /**
  45925. * Set the value of an uniform to an array of int32 (stored as vec4)
  45926. * @param uniform defines the webGL uniform location where to store the value
  45927. * @param array defines the array of int32 to store
  45928. */
  45929. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45930. /**
  45931. * Set the value of an uniform to an array of float32
  45932. * @param uniform defines the webGL uniform location where to store the value
  45933. * @param array defines the array of float32 to store
  45934. */
  45935. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45936. /**
  45937. * Set the value of an uniform to an array of float32 (stored as vec2)
  45938. * @param uniform defines the webGL uniform location where to store the value
  45939. * @param array defines the array of float32 to store
  45940. */
  45941. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45942. /**
  45943. * Set the value of an uniform to an array of float32 (stored as vec3)
  45944. * @param uniform defines the webGL uniform location where to store the value
  45945. * @param array defines the array of float32 to store
  45946. */
  45947. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45948. /**
  45949. * Set the value of an uniform to an array of float32 (stored as vec4)
  45950. * @param uniform defines the webGL uniform location where to store the value
  45951. * @param array defines the array of float32 to store
  45952. */
  45953. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45954. /**
  45955. * Set the value of an uniform to an array of number
  45956. * @param uniform defines the webGL uniform location where to store the value
  45957. * @param array defines the array of number to store
  45958. */
  45959. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45960. /**
  45961. * Set the value of an uniform to an array of number (stored as vec2)
  45962. * @param uniform defines the webGL uniform location where to store the value
  45963. * @param array defines the array of number to store
  45964. */
  45965. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45966. /**
  45967. * Set the value of an uniform to an array of number (stored as vec3)
  45968. * @param uniform defines the webGL uniform location where to store the value
  45969. * @param array defines the array of number to store
  45970. */
  45971. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45972. /**
  45973. * Set the value of an uniform to an array of number (stored as vec4)
  45974. * @param uniform defines the webGL uniform location where to store the value
  45975. * @param array defines the array of number to store
  45976. */
  45977. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45978. /**
  45979. * Set the value of an uniform to an array of float32 (stored as matrices)
  45980. * @param uniform defines the webGL uniform location where to store the value
  45981. * @param matrices defines the array of float32 to store
  45982. */
  45983. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45984. /**
  45985. * Set the value of an uniform to a matrix (3x3)
  45986. * @param uniform defines the webGL uniform location where to store the value
  45987. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45988. */
  45989. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45990. /**
  45991. * Set the value of an uniform to a matrix (2x2)
  45992. * @param uniform defines the webGL uniform location where to store the value
  45993. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45994. */
  45995. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45996. /**
  45997. * Set the value of an uniform to a number (float)
  45998. * @param uniform defines the webGL uniform location where to store the value
  45999. * @param value defines the float number to store
  46000. */
  46001. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46002. /**
  46003. * Set the value of an uniform to a vec2
  46004. * @param uniform defines the webGL uniform location where to store the value
  46005. * @param x defines the 1st component of the value
  46006. * @param y defines the 2nd component of the value
  46007. */
  46008. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46009. /**
  46010. * Set the value of an uniform to a vec3
  46011. * @param uniform defines the webGL uniform location where to store the value
  46012. * @param x defines the 1st component of the value
  46013. * @param y defines the 2nd component of the value
  46014. * @param z defines the 3rd component of the value
  46015. */
  46016. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46017. /**
  46018. * Set the value of an uniform to a boolean
  46019. * @param uniform defines the webGL uniform location where to store the value
  46020. * @param bool defines the boolean to store
  46021. */
  46022. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46023. /**
  46024. * Set the value of an uniform to a vec4
  46025. * @param uniform defines the webGL uniform location where to store the value
  46026. * @param x defines the 1st component of the value
  46027. * @param y defines the 2nd component of the value
  46028. * @param z defines the 3rd component of the value
  46029. * @param w defines the 4th component of the value
  46030. */
  46031. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46032. /**
  46033. * Sets the current alpha mode
  46034. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46035. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46036. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46037. */
  46038. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46039. /**
  46040. * Bind webGl buffers directly to the webGL context
  46041. * @param vertexBuffers defines the vertex buffer to bind
  46042. * @param indexBuffer defines the index buffer to bind
  46043. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46044. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46045. * @param effect defines the effect associated with the vertex buffer
  46046. */
  46047. bindBuffers(vertexBuffers: {
  46048. [key: string]: VertexBuffer;
  46049. }, indexBuffer: DataBuffer, effect: Effect): void;
  46050. /**
  46051. * Force the entire cache to be cleared
  46052. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46053. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46054. */
  46055. wipeCaches(bruteForce?: boolean): void;
  46056. /**
  46057. * Send a draw order
  46058. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46059. * @param indexStart defines the starting index
  46060. * @param indexCount defines the number of index to draw
  46061. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46062. */
  46063. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46064. /**
  46065. * Draw a list of indexed primitives
  46066. * @param fillMode defines the primitive to use
  46067. * @param indexStart defines the starting index
  46068. * @param indexCount defines the number of index to draw
  46069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46070. */
  46071. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46072. /**
  46073. * Draw a list of unindexed primitives
  46074. * @param fillMode defines the primitive to use
  46075. * @param verticesStart defines the index of first vertex to draw
  46076. * @param verticesCount defines the count of vertices to draw
  46077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46078. */
  46079. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46080. /** @hidden */
  46081. _createTexture(): WebGLTexture;
  46082. /** @hidden */
  46083. _releaseTexture(texture: InternalTexture): void;
  46084. /**
  46085. * Usually called from Texture.ts.
  46086. * Passed information to create a WebGLTexture
  46087. * @param urlArg defines a value which contains one of the following:
  46088. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46089. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46090. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46091. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46092. * @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)
  46093. * @param scene needed for loading to the correct scene
  46094. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46095. * @param onLoad optional callback to be called upon successful completion
  46096. * @param onError optional callback to be called upon failure
  46097. * @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
  46098. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46099. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46100. * @param forcedExtension defines the extension to use to pick the right loader
  46101. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46102. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46103. */
  46104. 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;
  46105. /**
  46106. * Creates a new render target texture
  46107. * @param size defines the size of the texture
  46108. * @param options defines the options used to create the texture
  46109. * @returns a new render target texture stored in an InternalTexture
  46110. */
  46111. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46112. /**
  46113. * Update the sampling mode of a given texture
  46114. * @param samplingMode defines the required sampling mode
  46115. * @param texture defines the texture to update
  46116. */
  46117. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46118. /**
  46119. * Binds the frame buffer to the specified texture.
  46120. * @param texture The texture to render to or null for the default canvas
  46121. * @param faceIndex The face of the texture to render to in case of cube texture
  46122. * @param requiredWidth The width of the target to render to
  46123. * @param requiredHeight The height of the target to render to
  46124. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46125. * @param depthStencilTexture The depth stencil texture to use to render
  46126. * @param lodLevel defines le lod level to bind to the frame buffer
  46127. */
  46128. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46129. /**
  46130. * Unbind the current render target texture from the webGL context
  46131. * @param texture defines the render target texture to unbind
  46132. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46133. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46134. */
  46135. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46136. /**
  46137. * Creates a dynamic vertex buffer
  46138. * @param vertices the data for the dynamic vertex buffer
  46139. * @returns the new WebGL dynamic buffer
  46140. */
  46141. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46142. /**
  46143. * Update the content of a dynamic texture
  46144. * @param texture defines the texture to update
  46145. * @param canvas defines the canvas containing the source
  46146. * @param invertY defines if data must be stored with Y axis inverted
  46147. * @param premulAlpha defines if alpha is stored as premultiplied
  46148. * @param format defines the format of the data
  46149. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46150. */
  46151. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46152. /**
  46153. * Gets a boolean indicating if all created effects are ready
  46154. * @returns true if all effects are ready
  46155. */
  46156. areAllEffectsReady(): boolean;
  46157. /**
  46158. * @hidden
  46159. * Get the current error code of the webGL context
  46160. * @returns the error code
  46161. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46162. */
  46163. getError(): number;
  46164. /** @hidden */
  46165. _getUnpackAlignement(): number;
  46166. /** @hidden */
  46167. _unpackFlipY(value: boolean): void;
  46168. /**
  46169. * Update a dynamic index buffer
  46170. * @param indexBuffer defines the target index buffer
  46171. * @param indices defines the data to update
  46172. * @param offset defines the offset in the target index buffer where update should start
  46173. */
  46174. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46175. /**
  46176. * Updates a dynamic vertex buffer.
  46177. * @param vertexBuffer the vertex buffer to update
  46178. * @param vertices the data used to update the vertex buffer
  46179. * @param byteOffset the byte offset of the data (optional)
  46180. * @param byteLength the byte length of the data (optional)
  46181. */
  46182. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46183. /** @hidden */
  46184. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46185. /** @hidden */
  46186. _bindTexture(channel: number, texture: InternalTexture): void;
  46187. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46188. /**
  46189. * 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
  46190. */
  46191. releaseEffects(): void;
  46192. displayLoadingUI(): void;
  46193. hideLoadingUI(): void;
  46194. /** @hidden */
  46195. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46196. /** @hidden */
  46197. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46198. /** @hidden */
  46199. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46200. /** @hidden */
  46201. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46202. }
  46203. }
  46204. declare module BABYLON {
  46205. /** @hidden */
  46206. export class _OcclusionDataStorage {
  46207. /** @hidden */
  46208. occlusionInternalRetryCounter: number;
  46209. /** @hidden */
  46210. isOcclusionQueryInProgress: boolean;
  46211. /** @hidden */
  46212. isOccluded: boolean;
  46213. /** @hidden */
  46214. occlusionRetryCount: number;
  46215. /** @hidden */
  46216. occlusionType: number;
  46217. /** @hidden */
  46218. occlusionQueryAlgorithmType: number;
  46219. }
  46220. interface Engine {
  46221. /**
  46222. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46223. * @return the new query
  46224. */
  46225. createQuery(): WebGLQuery;
  46226. /**
  46227. * Delete and release a webGL query
  46228. * @param query defines the query to delete
  46229. * @return the current engine
  46230. */
  46231. deleteQuery(query: WebGLQuery): Engine;
  46232. /**
  46233. * Check if a given query has resolved and got its value
  46234. * @param query defines the query to check
  46235. * @returns true if the query got its value
  46236. */
  46237. isQueryResultAvailable(query: WebGLQuery): boolean;
  46238. /**
  46239. * Gets the value of a given query
  46240. * @param query defines the query to check
  46241. * @returns the value of the query
  46242. */
  46243. getQueryResult(query: WebGLQuery): number;
  46244. /**
  46245. * Initiates an occlusion query
  46246. * @param algorithmType defines the algorithm to use
  46247. * @param query defines the query to use
  46248. * @returns the current engine
  46249. * @see http://doc.babylonjs.com/features/occlusionquery
  46250. */
  46251. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46252. /**
  46253. * Ends an occlusion query
  46254. * @see http://doc.babylonjs.com/features/occlusionquery
  46255. * @param algorithmType defines the algorithm to use
  46256. * @returns the current engine
  46257. */
  46258. endOcclusionQuery(algorithmType: number): Engine;
  46259. /**
  46260. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46261. * Please note that only one query can be issued at a time
  46262. * @returns a time token used to track the time span
  46263. */
  46264. startTimeQuery(): Nullable<_TimeToken>;
  46265. /**
  46266. * Ends a time query
  46267. * @param token defines the token used to measure the time span
  46268. * @returns the time spent (in ns)
  46269. */
  46270. endTimeQuery(token: _TimeToken): int;
  46271. /** @hidden */
  46272. _currentNonTimestampToken: Nullable<_TimeToken>;
  46273. /** @hidden */
  46274. _createTimeQuery(): WebGLQuery;
  46275. /** @hidden */
  46276. _deleteTimeQuery(query: WebGLQuery): void;
  46277. /** @hidden */
  46278. _getGlAlgorithmType(algorithmType: number): number;
  46279. /** @hidden */
  46280. _getTimeQueryResult(query: WebGLQuery): any;
  46281. /** @hidden */
  46282. _getTimeQueryAvailability(query: WebGLQuery): any;
  46283. }
  46284. interface AbstractMesh {
  46285. /**
  46286. * Backing filed
  46287. * @hidden
  46288. */
  46289. __occlusionDataStorage: _OcclusionDataStorage;
  46290. /**
  46291. * Access property
  46292. * @hidden
  46293. */
  46294. _occlusionDataStorage: _OcclusionDataStorage;
  46295. /**
  46296. * 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.
  46297. * The default value is -1 which means don't break the query and wait till the result
  46298. * @see http://doc.babylonjs.com/features/occlusionquery
  46299. */
  46300. occlusionRetryCount: number;
  46301. /**
  46302. * 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:
  46303. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46304. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46305. * * 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.
  46306. * @see http://doc.babylonjs.com/features/occlusionquery
  46307. */
  46308. occlusionType: number;
  46309. /**
  46310. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46311. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46312. * * 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.
  46313. * @see http://doc.babylonjs.com/features/occlusionquery
  46314. */
  46315. occlusionQueryAlgorithmType: number;
  46316. /**
  46317. * 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
  46318. * @see http://doc.babylonjs.com/features/occlusionquery
  46319. */
  46320. isOccluded: boolean;
  46321. /**
  46322. * Flag to check the progress status of the query
  46323. * @see http://doc.babylonjs.com/features/occlusionquery
  46324. */
  46325. isOcclusionQueryInProgress: boolean;
  46326. }
  46327. }
  46328. declare module BABYLON {
  46329. /** @hidden */
  46330. export var _forceTransformFeedbackToBundle: boolean;
  46331. interface Engine {
  46332. /**
  46333. * Creates a webGL transform feedback object
  46334. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46335. * @returns the webGL transform feedback object
  46336. */
  46337. createTransformFeedback(): WebGLTransformFeedback;
  46338. /**
  46339. * Delete a webGL transform feedback object
  46340. * @param value defines the webGL transform feedback object to delete
  46341. */
  46342. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46343. /**
  46344. * Bind a webGL transform feedback object to the webgl context
  46345. * @param value defines the webGL transform feedback object to bind
  46346. */
  46347. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46348. /**
  46349. * Begins a transform feedback operation
  46350. * @param usePoints defines if points or triangles must be used
  46351. */
  46352. beginTransformFeedback(usePoints: boolean): void;
  46353. /**
  46354. * Ends a transform feedback operation
  46355. */
  46356. endTransformFeedback(): void;
  46357. /**
  46358. * Specify the varyings to use with transform feedback
  46359. * @param program defines the associated webGL program
  46360. * @param value defines the list of strings representing the varying names
  46361. */
  46362. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46363. /**
  46364. * Bind a webGL buffer for a transform feedback operation
  46365. * @param value defines the webGL buffer to bind
  46366. */
  46367. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46368. }
  46369. }
  46370. declare module BABYLON {
  46371. /**
  46372. * Creation options of the multi render target texture.
  46373. */
  46374. export interface IMultiRenderTargetOptions {
  46375. /**
  46376. * Define if the texture needs to create mip maps after render.
  46377. */
  46378. generateMipMaps?: boolean;
  46379. /**
  46380. * Define the types of all the draw buffers we want to create
  46381. */
  46382. types?: number[];
  46383. /**
  46384. * Define the sampling modes of all the draw buffers we want to create
  46385. */
  46386. samplingModes?: number[];
  46387. /**
  46388. * Define if a depth buffer is required
  46389. */
  46390. generateDepthBuffer?: boolean;
  46391. /**
  46392. * Define if a stencil buffer is required
  46393. */
  46394. generateStencilBuffer?: boolean;
  46395. /**
  46396. * Define if a depth texture is required instead of a depth buffer
  46397. */
  46398. generateDepthTexture?: boolean;
  46399. /**
  46400. * Define the number of desired draw buffers
  46401. */
  46402. textureCount?: number;
  46403. /**
  46404. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46405. */
  46406. doNotChangeAspectRatio?: boolean;
  46407. /**
  46408. * Define the default type of the buffers we are creating
  46409. */
  46410. defaultType?: number;
  46411. }
  46412. /**
  46413. * A multi render target, like a render target provides the ability to render to a texture.
  46414. * Unlike the render target, it can render to several draw buffers in one draw.
  46415. * This is specially interesting in deferred rendering or for any effects requiring more than
  46416. * just one color from a single pass.
  46417. */
  46418. export class MultiRenderTarget extends RenderTargetTexture {
  46419. private _internalTextures;
  46420. private _textures;
  46421. private _multiRenderTargetOptions;
  46422. /**
  46423. * Get if draw buffers are currently supported by the used hardware and browser.
  46424. */
  46425. get isSupported(): boolean;
  46426. /**
  46427. * Get the list of textures generated by the multi render target.
  46428. */
  46429. get textures(): Texture[];
  46430. /**
  46431. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46432. */
  46433. get depthTexture(): Texture;
  46434. /**
  46435. * Set the wrapping mode on U of all the textures we are rendering to.
  46436. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46437. */
  46438. set wrapU(wrap: number);
  46439. /**
  46440. * Set the wrapping mode on V of all the textures we are rendering to.
  46441. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46442. */
  46443. set wrapV(wrap: number);
  46444. /**
  46445. * Instantiate a new multi render target texture.
  46446. * A multi render target, like a render target provides the ability to render to a texture.
  46447. * Unlike the render target, it can render to several draw buffers in one draw.
  46448. * This is specially interesting in deferred rendering or for any effects requiring more than
  46449. * just one color from a single pass.
  46450. * @param name Define the name of the texture
  46451. * @param size Define the size of the buffers to render to
  46452. * @param count Define the number of target we are rendering into
  46453. * @param scene Define the scene the texture belongs to
  46454. * @param options Define the options used to create the multi render target
  46455. */
  46456. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46457. /** @hidden */
  46458. _rebuild(): void;
  46459. private _createInternalTextures;
  46460. private _createTextures;
  46461. /**
  46462. * Define the number of samples used if MSAA is enabled.
  46463. */
  46464. get samples(): number;
  46465. set samples(value: number);
  46466. /**
  46467. * Resize all the textures in the multi render target.
  46468. * Be carrefull as it will recreate all the data in the new texture.
  46469. * @param size Define the new size
  46470. */
  46471. resize(size: any): void;
  46472. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46473. /**
  46474. * Dispose the render targets and their associated resources
  46475. */
  46476. dispose(): void;
  46477. /**
  46478. * Release all the underlying texture used as draw buffers.
  46479. */
  46480. releaseInternalTextures(): void;
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. interface ThinEngine {
  46485. /**
  46486. * Unbind a list of render target textures from the webGL context
  46487. * This is used only when drawBuffer extension or webGL2 are active
  46488. * @param textures defines the render target textures to unbind
  46489. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46490. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46491. */
  46492. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46493. /**
  46494. * Create a multi render target texture
  46495. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46496. * @param size defines the size of the texture
  46497. * @param options defines the creation options
  46498. * @returns the cube texture as an InternalTexture
  46499. */
  46500. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46501. /**
  46502. * Update the sample count for a given multiple render target texture
  46503. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46504. * @param textures defines the textures to update
  46505. * @param samples defines the sample count to set
  46506. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46507. */
  46508. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46509. }
  46510. }
  46511. declare module BABYLON {
  46512. /**
  46513. * Class used to define an additional view for the engine
  46514. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46515. */
  46516. export class EngineView {
  46517. /** Defines the canvas where to render the view */
  46518. target: HTMLCanvasElement;
  46519. /** Defines an optional camera used to render the view (will use active camera else) */
  46520. camera?: Camera;
  46521. }
  46522. interface Engine {
  46523. /**
  46524. * Gets or sets the HTML element to use for attaching events
  46525. */
  46526. inputElement: Nullable<HTMLElement>;
  46527. /**
  46528. * Gets the current engine view
  46529. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46530. */
  46531. activeView: Nullable<EngineView>;
  46532. /** Gets or sets the list of views */
  46533. views: EngineView[];
  46534. /**
  46535. * Register a new child canvas
  46536. * @param canvas defines the canvas to register
  46537. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46538. * @returns the associated view
  46539. */
  46540. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46541. /**
  46542. * Remove a registered child canvas
  46543. * @param canvas defines the canvas to remove
  46544. * @returns the current engine
  46545. */
  46546. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46547. }
  46548. }
  46549. declare module BABYLON {
  46550. /**
  46551. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46552. */
  46553. export interface CubeMapInfo {
  46554. /**
  46555. * The pixel array for the front face.
  46556. * This is stored in format, left to right, up to down format.
  46557. */
  46558. front: Nullable<ArrayBufferView>;
  46559. /**
  46560. * The pixel array for the back face.
  46561. * This is stored in format, left to right, up to down format.
  46562. */
  46563. back: Nullable<ArrayBufferView>;
  46564. /**
  46565. * The pixel array for the left face.
  46566. * This is stored in format, left to right, up to down format.
  46567. */
  46568. left: Nullable<ArrayBufferView>;
  46569. /**
  46570. * The pixel array for the right face.
  46571. * This is stored in format, left to right, up to down format.
  46572. */
  46573. right: Nullable<ArrayBufferView>;
  46574. /**
  46575. * The pixel array for the up face.
  46576. * This is stored in format, left to right, up to down format.
  46577. */
  46578. up: Nullable<ArrayBufferView>;
  46579. /**
  46580. * The pixel array for the down face.
  46581. * This is stored in format, left to right, up to down format.
  46582. */
  46583. down: Nullable<ArrayBufferView>;
  46584. /**
  46585. * The size of the cubemap stored.
  46586. *
  46587. * Each faces will be size * size pixels.
  46588. */
  46589. size: number;
  46590. /**
  46591. * The format of the texture.
  46592. *
  46593. * RGBA, RGB.
  46594. */
  46595. format: number;
  46596. /**
  46597. * The type of the texture data.
  46598. *
  46599. * UNSIGNED_INT, FLOAT.
  46600. */
  46601. type: number;
  46602. /**
  46603. * Specifies whether the texture is in gamma space.
  46604. */
  46605. gammaSpace: boolean;
  46606. }
  46607. /**
  46608. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46609. */
  46610. export class PanoramaToCubeMapTools {
  46611. private static FACE_FRONT;
  46612. private static FACE_BACK;
  46613. private static FACE_RIGHT;
  46614. private static FACE_LEFT;
  46615. private static FACE_DOWN;
  46616. private static FACE_UP;
  46617. /**
  46618. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46619. *
  46620. * @param float32Array The source data.
  46621. * @param inputWidth The width of the input panorama.
  46622. * @param inputHeight The height of the input panorama.
  46623. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46624. * @return The cubemap data
  46625. */
  46626. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46627. private static CreateCubemapTexture;
  46628. private static CalcProjectionSpherical;
  46629. }
  46630. }
  46631. declare module BABYLON {
  46632. /**
  46633. * Helper class dealing with the extraction of spherical polynomial dataArray
  46634. * from a cube map.
  46635. */
  46636. export class CubeMapToSphericalPolynomialTools {
  46637. private static FileFaces;
  46638. /**
  46639. * Converts a texture to the according Spherical Polynomial data.
  46640. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46641. *
  46642. * @param texture The texture to extract the information from.
  46643. * @return The Spherical Polynomial data.
  46644. */
  46645. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46646. /**
  46647. * Converts a cubemap to the according Spherical Polynomial data.
  46648. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46649. *
  46650. * @param cubeInfo The Cube map to extract the information from.
  46651. * @return The Spherical Polynomial data.
  46652. */
  46653. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46654. }
  46655. }
  46656. declare module BABYLON {
  46657. interface BaseTexture {
  46658. /**
  46659. * Get the polynomial representation of the texture data.
  46660. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46661. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46662. */
  46663. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46664. }
  46665. }
  46666. declare module BABYLON {
  46667. /** @hidden */
  46668. export var rgbdEncodePixelShader: {
  46669. name: string;
  46670. shader: string;
  46671. };
  46672. }
  46673. declare module BABYLON {
  46674. /** @hidden */
  46675. export var rgbdDecodePixelShader: {
  46676. name: string;
  46677. shader: string;
  46678. };
  46679. }
  46680. declare module BABYLON {
  46681. /**
  46682. * Raw texture data and descriptor sufficient for WebGL texture upload
  46683. */
  46684. export interface EnvironmentTextureInfo {
  46685. /**
  46686. * Version of the environment map
  46687. */
  46688. version: number;
  46689. /**
  46690. * Width of image
  46691. */
  46692. width: number;
  46693. /**
  46694. * Irradiance information stored in the file.
  46695. */
  46696. irradiance: any;
  46697. /**
  46698. * Specular information stored in the file.
  46699. */
  46700. specular: any;
  46701. }
  46702. /**
  46703. * Defines One Image in the file. It requires only the position in the file
  46704. * as well as the length.
  46705. */
  46706. interface BufferImageData {
  46707. /**
  46708. * Length of the image data.
  46709. */
  46710. length: number;
  46711. /**
  46712. * Position of the data from the null terminator delimiting the end of the JSON.
  46713. */
  46714. position: number;
  46715. }
  46716. /**
  46717. * Defines the specular data enclosed in the file.
  46718. * This corresponds to the version 1 of the data.
  46719. */
  46720. export interface EnvironmentTextureSpecularInfoV1 {
  46721. /**
  46722. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46723. */
  46724. specularDataPosition?: number;
  46725. /**
  46726. * This contains all the images data needed to reconstruct the cubemap.
  46727. */
  46728. mipmaps: Array<BufferImageData>;
  46729. /**
  46730. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46731. */
  46732. lodGenerationScale: number;
  46733. }
  46734. /**
  46735. * Sets of helpers addressing the serialization and deserialization of environment texture
  46736. * stored in a BabylonJS env file.
  46737. * Those files are usually stored as .env files.
  46738. */
  46739. export class EnvironmentTextureTools {
  46740. /**
  46741. * Magic number identifying the env file.
  46742. */
  46743. private static _MagicBytes;
  46744. /**
  46745. * Gets the environment info from an env file.
  46746. * @param data The array buffer containing the .env bytes.
  46747. * @returns the environment file info (the json header) if successfully parsed.
  46748. */
  46749. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46750. /**
  46751. * Creates an environment texture from a loaded cube texture.
  46752. * @param texture defines the cube texture to convert in env file
  46753. * @return a promise containing the environment data if succesfull.
  46754. */
  46755. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46756. /**
  46757. * Creates a JSON representation of the spherical data.
  46758. * @param texture defines the texture containing the polynomials
  46759. * @return the JSON representation of the spherical info
  46760. */
  46761. private static _CreateEnvTextureIrradiance;
  46762. /**
  46763. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46764. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46765. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46766. * @return the views described by info providing access to the underlying buffer
  46767. */
  46768. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46769. /**
  46770. * Uploads the texture info contained in the env file to the GPU.
  46771. * @param texture defines the internal texture to upload to
  46772. * @param arrayBuffer defines the buffer cotaining the data to load
  46773. * @param info defines the texture info retrieved through the GetEnvInfo method
  46774. * @returns a promise
  46775. */
  46776. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46777. private static _OnImageReadyAsync;
  46778. /**
  46779. * Uploads the levels of image data to the GPU.
  46780. * @param texture defines the internal texture to upload to
  46781. * @param imageData defines the array buffer views of image data [mipmap][face]
  46782. * @returns a promise
  46783. */
  46784. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46785. /**
  46786. * Uploads spherical polynomials information to the texture.
  46787. * @param texture defines the texture we are trying to upload the information to
  46788. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46789. */
  46790. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46791. /** @hidden */
  46792. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46793. }
  46794. }
  46795. declare module BABYLON {
  46796. /**
  46797. * Contains position and normal vectors for a vertex
  46798. */
  46799. export class PositionNormalVertex {
  46800. /** the position of the vertex (defaut: 0,0,0) */
  46801. position: Vector3;
  46802. /** the normal of the vertex (defaut: 0,1,0) */
  46803. normal: Vector3;
  46804. /**
  46805. * Creates a PositionNormalVertex
  46806. * @param position the position of the vertex (defaut: 0,0,0)
  46807. * @param normal the normal of the vertex (defaut: 0,1,0)
  46808. */
  46809. constructor(
  46810. /** the position of the vertex (defaut: 0,0,0) */
  46811. position?: Vector3,
  46812. /** the normal of the vertex (defaut: 0,1,0) */
  46813. normal?: Vector3);
  46814. /**
  46815. * Clones the PositionNormalVertex
  46816. * @returns the cloned PositionNormalVertex
  46817. */
  46818. clone(): PositionNormalVertex;
  46819. }
  46820. /**
  46821. * Contains position, normal and uv vectors for a vertex
  46822. */
  46823. export class PositionNormalTextureVertex {
  46824. /** the position of the vertex (defaut: 0,0,0) */
  46825. position: Vector3;
  46826. /** the normal of the vertex (defaut: 0,1,0) */
  46827. normal: Vector3;
  46828. /** the uv of the vertex (default: 0,0) */
  46829. uv: Vector2;
  46830. /**
  46831. * Creates a PositionNormalTextureVertex
  46832. * @param position the position of the vertex (defaut: 0,0,0)
  46833. * @param normal the normal of the vertex (defaut: 0,1,0)
  46834. * @param uv the uv of the vertex (default: 0,0)
  46835. */
  46836. constructor(
  46837. /** the position of the vertex (defaut: 0,0,0) */
  46838. position?: Vector3,
  46839. /** the normal of the vertex (defaut: 0,1,0) */
  46840. normal?: Vector3,
  46841. /** the uv of the vertex (default: 0,0) */
  46842. uv?: Vector2);
  46843. /**
  46844. * Clones the PositionNormalTextureVertex
  46845. * @returns the cloned PositionNormalTextureVertex
  46846. */
  46847. clone(): PositionNormalTextureVertex;
  46848. }
  46849. }
  46850. declare module BABYLON {
  46851. /** @hidden */
  46852. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46853. private _genericAttributeLocation;
  46854. private _varyingLocationCount;
  46855. private _varyingLocationMap;
  46856. private _replacements;
  46857. private _textureCount;
  46858. private _uniforms;
  46859. lineProcessor(line: string): string;
  46860. attributeProcessor(attribute: string): string;
  46861. varyingProcessor(varying: string, isFragment: boolean): string;
  46862. uniformProcessor(uniform: string): string;
  46863. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46864. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46865. }
  46866. }
  46867. declare module BABYLON {
  46868. /**
  46869. * Container for accessors for natively-stored mesh data buffers.
  46870. */
  46871. class NativeDataBuffer extends DataBuffer {
  46872. /**
  46873. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46874. */
  46875. nativeIndexBuffer?: any;
  46876. /**
  46877. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46878. */
  46879. nativeVertexBuffer?: any;
  46880. }
  46881. /** @hidden */
  46882. class NativeTexture extends InternalTexture {
  46883. getInternalTexture(): InternalTexture;
  46884. getViewCount(): number;
  46885. }
  46886. /** @hidden */
  46887. export class NativeEngine extends Engine {
  46888. private readonly _native;
  46889. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46890. private readonly INVALID_HANDLE;
  46891. getHardwareScalingLevel(): number;
  46892. constructor();
  46893. /**
  46894. * Can be used to override the current requestAnimationFrame requester.
  46895. * @hidden
  46896. */
  46897. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46898. /**
  46899. * Override default engine behavior.
  46900. * @param color
  46901. * @param backBuffer
  46902. * @param depth
  46903. * @param stencil
  46904. */
  46905. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46906. /**
  46907. * Gets host document
  46908. * @returns the host document object
  46909. */
  46910. getHostDocument(): Nullable<Document>;
  46911. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46912. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46913. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46914. recordVertexArrayObject(vertexBuffers: {
  46915. [key: string]: VertexBuffer;
  46916. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46917. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46918. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46919. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46920. /**
  46921. * Draw a list of indexed primitives
  46922. * @param fillMode defines the primitive to use
  46923. * @param indexStart defines the starting index
  46924. * @param indexCount defines the number of index to draw
  46925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46926. */
  46927. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46928. /**
  46929. * Draw a list of unindexed primitives
  46930. * @param fillMode defines the primitive to use
  46931. * @param verticesStart defines the index of first vertex to draw
  46932. * @param verticesCount defines the count of vertices to draw
  46933. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46934. */
  46935. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46936. createPipelineContext(): IPipelineContext;
  46937. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46938. /** @hidden */
  46939. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46940. /** @hidden */
  46941. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46942. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46943. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46944. protected _setProgram(program: WebGLProgram): void;
  46945. _releaseEffect(effect: Effect): void;
  46946. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46947. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46948. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46949. bindSamplers(effect: Effect): void;
  46950. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46951. getRenderWidth(useScreen?: boolean): number;
  46952. getRenderHeight(useScreen?: boolean): number;
  46953. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46954. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46955. /**
  46956. * Set the z offset to apply to current rendering
  46957. * @param value defines the offset to apply
  46958. */
  46959. setZOffset(value: number): void;
  46960. /**
  46961. * Gets the current value of the zOffset
  46962. * @returns the current zOffset state
  46963. */
  46964. getZOffset(): number;
  46965. /**
  46966. * Enable or disable depth buffering
  46967. * @param enable defines the state to set
  46968. */
  46969. setDepthBuffer(enable: boolean): void;
  46970. /**
  46971. * Gets a boolean indicating if depth writing is enabled
  46972. * @returns the current depth writing state
  46973. */
  46974. getDepthWrite(): boolean;
  46975. /**
  46976. * Enable or disable depth writing
  46977. * @param enable defines the state to set
  46978. */
  46979. setDepthWrite(enable: boolean): void;
  46980. /**
  46981. * Enable or disable color writing
  46982. * @param enable defines the state to set
  46983. */
  46984. setColorWrite(enable: boolean): void;
  46985. /**
  46986. * Gets a boolean indicating if color writing is enabled
  46987. * @returns the current color writing state
  46988. */
  46989. getColorWrite(): boolean;
  46990. /**
  46991. * Sets alpha constants used by some alpha blending modes
  46992. * @param r defines the red component
  46993. * @param g defines the green component
  46994. * @param b defines the blue component
  46995. * @param a defines the alpha component
  46996. */
  46997. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46998. /**
  46999. * Sets the current alpha mode
  47000. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47001. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47002. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47003. */
  47004. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47005. /**
  47006. * Gets the current alpha mode
  47007. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47008. * @returns the current alpha mode
  47009. */
  47010. getAlphaMode(): number;
  47011. setInt(uniform: WebGLUniformLocation, int: number): void;
  47012. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47013. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47014. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47015. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47016. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47017. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47018. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47019. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47020. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47021. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47022. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47023. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47024. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47025. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47026. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47027. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47028. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47029. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47030. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47031. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47032. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47033. wipeCaches(bruteForce?: boolean): void;
  47034. _createTexture(): WebGLTexture;
  47035. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47036. /**
  47037. * Usually called from BABYLON.Texture.ts.
  47038. * Passed information to create a WebGLTexture
  47039. * @param urlArg defines a value which contains one of the following:
  47040. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47041. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47042. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47043. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47044. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47045. * @param scene needed for loading to the correct scene
  47046. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47047. * @param onLoad optional callback to be called upon successful completion
  47048. * @param onError optional callback to be called upon failure
  47049. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47050. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47051. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47052. * @param forcedExtension defines the extension to use to pick the right loader
  47053. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47054. */
  47055. 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;
  47056. /**
  47057. * Creates a cube texture
  47058. * @param rootUrl defines the url where the files to load is located
  47059. * @param scene defines the current scene
  47060. * @param files defines the list of files to load (1 per face)
  47061. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47062. * @param onLoad defines an optional callback raised when the texture is loaded
  47063. * @param onError defines an optional callback raised if there is an issue to load the texture
  47064. * @param format defines the format of the data
  47065. * @param forcedExtension defines the extension to use to pick the right loader
  47066. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47067. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47068. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47069. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47070. * @returns the cube texture as an InternalTexture
  47071. */
  47072. 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;
  47073. private _getSamplingFilter;
  47074. private static _GetNativeTextureFormat;
  47075. createRenderTargetTexture(size: number | {
  47076. width: number;
  47077. height: number;
  47078. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47079. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47080. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47081. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47082. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47083. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47084. /**
  47085. * Updates a dynamic vertex buffer.
  47086. * @param vertexBuffer the vertex buffer to update
  47087. * @param data the data used to update the vertex buffer
  47088. * @param byteOffset the byte offset of the data (optional)
  47089. * @param byteLength the byte length of the data (optional)
  47090. */
  47091. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47092. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47093. private _updateAnisotropicLevel;
  47094. private _getAddressMode;
  47095. /** @hidden */
  47096. _bindTexture(channel: number, texture: InternalTexture): void;
  47097. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47098. releaseEffects(): void;
  47099. /** @hidden */
  47100. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47101. /** @hidden */
  47102. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47103. /** @hidden */
  47104. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47105. /** @hidden */
  47106. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47107. }
  47108. }
  47109. declare module BABYLON {
  47110. /**
  47111. * Gather the list of clipboard event types as constants.
  47112. */
  47113. export class ClipboardEventTypes {
  47114. /**
  47115. * The clipboard event is fired when a copy command is active (pressed).
  47116. */
  47117. static readonly COPY: number;
  47118. /**
  47119. * The clipboard event is fired when a cut command is active (pressed).
  47120. */
  47121. static readonly CUT: number;
  47122. /**
  47123. * The clipboard event is fired when a paste command is active (pressed).
  47124. */
  47125. static readonly PASTE: number;
  47126. }
  47127. /**
  47128. * This class is used to store clipboard related info for the onClipboardObservable event.
  47129. */
  47130. export class ClipboardInfo {
  47131. /**
  47132. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47133. */
  47134. type: number;
  47135. /**
  47136. * Defines the related dom event
  47137. */
  47138. event: ClipboardEvent;
  47139. /**
  47140. *Creates an instance of ClipboardInfo.
  47141. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47142. * @param event Defines the related dom event
  47143. */
  47144. constructor(
  47145. /**
  47146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47147. */
  47148. type: number,
  47149. /**
  47150. * Defines the related dom event
  47151. */
  47152. event: ClipboardEvent);
  47153. /**
  47154. * Get the clipboard event's type from the keycode.
  47155. * @param keyCode Defines the keyCode for the current keyboard event.
  47156. * @return {number}
  47157. */
  47158. static GetTypeFromCharacter(keyCode: number): number;
  47159. }
  47160. }
  47161. declare module BABYLON {
  47162. /**
  47163. * Google Daydream controller
  47164. */
  47165. export class DaydreamController extends WebVRController {
  47166. /**
  47167. * Base Url for the controller model.
  47168. */
  47169. static MODEL_BASE_URL: string;
  47170. /**
  47171. * File name for the controller model.
  47172. */
  47173. static MODEL_FILENAME: string;
  47174. /**
  47175. * Gamepad Id prefix used to identify Daydream Controller.
  47176. */
  47177. static readonly GAMEPAD_ID_PREFIX: string;
  47178. /**
  47179. * Creates a new DaydreamController from a gamepad
  47180. * @param vrGamepad the gamepad that the controller should be created from
  47181. */
  47182. constructor(vrGamepad: any);
  47183. /**
  47184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47185. * @param scene scene in which to add meshes
  47186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47187. */
  47188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47189. /**
  47190. * Called once for each button that changed state since the last frame
  47191. * @param buttonIdx Which button index changed
  47192. * @param state New state of the button
  47193. * @param changes Which properties on the state changed since last frame
  47194. */
  47195. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47196. }
  47197. }
  47198. declare module BABYLON {
  47199. /**
  47200. * Gear VR Controller
  47201. */
  47202. export class GearVRController extends WebVRController {
  47203. /**
  47204. * Base Url for the controller model.
  47205. */
  47206. static MODEL_BASE_URL: string;
  47207. /**
  47208. * File name for the controller model.
  47209. */
  47210. static MODEL_FILENAME: string;
  47211. /**
  47212. * Gamepad Id prefix used to identify this controller.
  47213. */
  47214. static readonly GAMEPAD_ID_PREFIX: string;
  47215. private readonly _buttonIndexToObservableNameMap;
  47216. /**
  47217. * Creates a new GearVRController from a gamepad
  47218. * @param vrGamepad the gamepad that the controller should be created from
  47219. */
  47220. constructor(vrGamepad: any);
  47221. /**
  47222. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47223. * @param scene scene in which to add meshes
  47224. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47225. */
  47226. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47227. /**
  47228. * Called once for each button that changed state since the last frame
  47229. * @param buttonIdx Which button index changed
  47230. * @param state New state of the button
  47231. * @param changes Which properties on the state changed since last frame
  47232. */
  47233. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47234. }
  47235. }
  47236. declare module BABYLON {
  47237. /**
  47238. * Class containing static functions to help procedurally build meshes
  47239. */
  47240. export class PolyhedronBuilder {
  47241. /**
  47242. * Creates a polyhedron mesh
  47243. * * 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
  47244. * * The parameter `size` (positive float, default 1) sets the polygon size
  47245. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47246. * * 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`
  47247. * * 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
  47248. * * 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)`)
  47249. * * 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
  47250. * * 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
  47251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47252. * * 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
  47253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47254. * @param name defines the name of the mesh
  47255. * @param options defines the options used to create the mesh
  47256. * @param scene defines the hosting scene
  47257. * @returns the polyhedron mesh
  47258. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47259. */
  47260. static CreatePolyhedron(name: string, options: {
  47261. type?: number;
  47262. size?: number;
  47263. sizeX?: number;
  47264. sizeY?: number;
  47265. sizeZ?: number;
  47266. custom?: any;
  47267. faceUV?: Vector4[];
  47268. faceColors?: Color4[];
  47269. flat?: boolean;
  47270. updatable?: boolean;
  47271. sideOrientation?: number;
  47272. frontUVs?: Vector4;
  47273. backUVs?: Vector4;
  47274. }, scene?: Nullable<Scene>): Mesh;
  47275. }
  47276. }
  47277. declare module BABYLON {
  47278. /**
  47279. * Gizmo that enables scaling a mesh along 3 axis
  47280. */
  47281. export class ScaleGizmo extends Gizmo {
  47282. /**
  47283. * Internal gizmo used for interactions on the x axis
  47284. */
  47285. xGizmo: AxisScaleGizmo;
  47286. /**
  47287. * Internal gizmo used for interactions on the y axis
  47288. */
  47289. yGizmo: AxisScaleGizmo;
  47290. /**
  47291. * Internal gizmo used for interactions on the z axis
  47292. */
  47293. zGizmo: AxisScaleGizmo;
  47294. /**
  47295. * Internal gizmo used to scale all axis equally
  47296. */
  47297. uniformScaleGizmo: AxisScaleGizmo;
  47298. private _meshAttached;
  47299. private _updateGizmoRotationToMatchAttachedMesh;
  47300. private _snapDistance;
  47301. private _scaleRatio;
  47302. private _uniformScalingMesh;
  47303. private _octahedron;
  47304. private _sensitivity;
  47305. /** Fires an event when any of it's sub gizmos are dragged */
  47306. onDragStartObservable: Observable<unknown>;
  47307. /** Fires an event when any of it's sub gizmos are released from dragging */
  47308. onDragEndObservable: Observable<unknown>;
  47309. get attachedMesh(): Nullable<AbstractMesh>;
  47310. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47311. /**
  47312. * Creates a ScaleGizmo
  47313. * @param gizmoLayer The utility layer the gizmo will be added to
  47314. */
  47315. constructor(gizmoLayer?: UtilityLayerRenderer);
  47316. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47317. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47318. /**
  47319. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47320. */
  47321. set snapDistance(value: number);
  47322. get snapDistance(): number;
  47323. /**
  47324. * Ratio for the scale of the gizmo (Default: 1)
  47325. */
  47326. set scaleRatio(value: number);
  47327. get scaleRatio(): number;
  47328. /**
  47329. * Sensitivity factor for dragging (Default: 1)
  47330. */
  47331. set sensitivity(value: number);
  47332. get sensitivity(): number;
  47333. /**
  47334. * Disposes of the gizmo
  47335. */
  47336. dispose(): void;
  47337. }
  47338. }
  47339. declare module BABYLON {
  47340. /**
  47341. * Single axis scale gizmo
  47342. */
  47343. export class AxisScaleGizmo extends Gizmo {
  47344. /**
  47345. * Drag behavior responsible for the gizmos dragging interactions
  47346. */
  47347. dragBehavior: PointerDragBehavior;
  47348. private _pointerObserver;
  47349. /**
  47350. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47351. */
  47352. snapDistance: number;
  47353. /**
  47354. * Event that fires each time the gizmo snaps to a new location.
  47355. * * snapDistance is the the change in distance
  47356. */
  47357. onSnapObservable: Observable<{
  47358. snapDistance: number;
  47359. }>;
  47360. /**
  47361. * If the scaling operation should be done on all axis (default: false)
  47362. */
  47363. uniformScaling: boolean;
  47364. /**
  47365. * Custom sensitivity value for the drag strength
  47366. */
  47367. sensitivity: number;
  47368. private _isEnabled;
  47369. private _parent;
  47370. private _arrow;
  47371. private _coloredMaterial;
  47372. private _hoverMaterial;
  47373. /**
  47374. * Creates an AxisScaleGizmo
  47375. * @param gizmoLayer The utility layer the gizmo will be added to
  47376. * @param dragAxis The axis which the gizmo will be able to scale on
  47377. * @param color The color of the gizmo
  47378. */
  47379. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47380. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47381. /**
  47382. * If the gizmo is enabled
  47383. */
  47384. set isEnabled(value: boolean);
  47385. get isEnabled(): boolean;
  47386. /**
  47387. * Disposes of the gizmo
  47388. */
  47389. dispose(): void;
  47390. /**
  47391. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47392. * @param mesh The mesh to replace the default mesh of the gizmo
  47393. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47394. */
  47395. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47396. }
  47397. }
  47398. declare module BABYLON {
  47399. /**
  47400. * Bounding box gizmo
  47401. */
  47402. export class BoundingBoxGizmo extends Gizmo {
  47403. private _lineBoundingBox;
  47404. private _rotateSpheresParent;
  47405. private _scaleBoxesParent;
  47406. private _boundingDimensions;
  47407. private _renderObserver;
  47408. private _pointerObserver;
  47409. private _scaleDragSpeed;
  47410. private _tmpQuaternion;
  47411. private _tmpVector;
  47412. private _tmpRotationMatrix;
  47413. /**
  47414. * 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)
  47415. */
  47416. ignoreChildren: boolean;
  47417. /**
  47418. * 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)
  47419. */
  47420. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47421. /**
  47422. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47423. */
  47424. rotationSphereSize: number;
  47425. /**
  47426. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47427. */
  47428. scaleBoxSize: number;
  47429. /**
  47430. * 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)
  47431. */
  47432. fixedDragMeshScreenSize: boolean;
  47433. /**
  47434. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47435. */
  47436. fixedDragMeshScreenSizeDistanceFactor: number;
  47437. /**
  47438. * Fired when a rotation sphere or scale box is dragged
  47439. */
  47440. onDragStartObservable: Observable<{}>;
  47441. /**
  47442. * Fired when a scale box is dragged
  47443. */
  47444. onScaleBoxDragObservable: Observable<{}>;
  47445. /**
  47446. * Fired when a scale box drag is ended
  47447. */
  47448. onScaleBoxDragEndObservable: Observable<{}>;
  47449. /**
  47450. * Fired when a rotation sphere is dragged
  47451. */
  47452. onRotationSphereDragObservable: Observable<{}>;
  47453. /**
  47454. * Fired when a rotation sphere drag is ended
  47455. */
  47456. onRotationSphereDragEndObservable: Observable<{}>;
  47457. /**
  47458. * 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)
  47459. */
  47460. scalePivot: Nullable<Vector3>;
  47461. /**
  47462. * Mesh used as a pivot to rotate the attached mesh
  47463. */
  47464. private _anchorMesh;
  47465. private _existingMeshScale;
  47466. private _dragMesh;
  47467. private pointerDragBehavior;
  47468. private coloredMaterial;
  47469. private hoverColoredMaterial;
  47470. /**
  47471. * Sets the color of the bounding box gizmo
  47472. * @param color the color to set
  47473. */
  47474. setColor(color: Color3): void;
  47475. /**
  47476. * Creates an BoundingBoxGizmo
  47477. * @param gizmoLayer The utility layer the gizmo will be added to
  47478. * @param color The color of the gizmo
  47479. */
  47480. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47481. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47482. private _selectNode;
  47483. /**
  47484. * Updates the bounding box information for the Gizmo
  47485. */
  47486. updateBoundingBox(): void;
  47487. private _updateRotationSpheres;
  47488. private _updateScaleBoxes;
  47489. /**
  47490. * Enables rotation on the specified axis and disables rotation on the others
  47491. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47492. */
  47493. setEnabledRotationAxis(axis: string): void;
  47494. /**
  47495. * Enables/disables scaling
  47496. * @param enable if scaling should be enabled
  47497. */
  47498. setEnabledScaling(enable: boolean): void;
  47499. private _updateDummy;
  47500. /**
  47501. * Enables a pointer drag behavior on the bounding box of the gizmo
  47502. */
  47503. enableDragBehavior(): void;
  47504. /**
  47505. * Disposes of the gizmo
  47506. */
  47507. dispose(): void;
  47508. /**
  47509. * 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)
  47510. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47511. * @returns the bounding box mesh with the passed in mesh as a child
  47512. */
  47513. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47514. /**
  47515. * CustomMeshes are not supported by this gizmo
  47516. * @param mesh The mesh to replace the default mesh of the gizmo
  47517. */
  47518. setCustomMesh(mesh: Mesh): void;
  47519. }
  47520. }
  47521. declare module BABYLON {
  47522. /**
  47523. * Single plane rotation gizmo
  47524. */
  47525. export class PlaneRotationGizmo extends Gizmo {
  47526. /**
  47527. * Drag behavior responsible for the gizmos dragging interactions
  47528. */
  47529. dragBehavior: PointerDragBehavior;
  47530. private _pointerObserver;
  47531. /**
  47532. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47533. */
  47534. snapDistance: number;
  47535. /**
  47536. * Event that fires each time the gizmo snaps to a new location.
  47537. * * snapDistance is the the change in distance
  47538. */
  47539. onSnapObservable: Observable<{
  47540. snapDistance: number;
  47541. }>;
  47542. private _isEnabled;
  47543. private _parent;
  47544. /**
  47545. * Creates a PlaneRotationGizmo
  47546. * @param gizmoLayer The utility layer the gizmo will be added to
  47547. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47548. * @param color The color of the gizmo
  47549. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47550. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47551. */
  47552. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47553. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47554. /**
  47555. * If the gizmo is enabled
  47556. */
  47557. set isEnabled(value: boolean);
  47558. get isEnabled(): boolean;
  47559. /**
  47560. * Disposes of the gizmo
  47561. */
  47562. dispose(): void;
  47563. }
  47564. }
  47565. declare module BABYLON {
  47566. /**
  47567. * Gizmo that enables rotating a mesh along 3 axis
  47568. */
  47569. export class RotationGizmo extends Gizmo {
  47570. /**
  47571. * Internal gizmo used for interactions on the x axis
  47572. */
  47573. xGizmo: PlaneRotationGizmo;
  47574. /**
  47575. * Internal gizmo used for interactions on the y axis
  47576. */
  47577. yGizmo: PlaneRotationGizmo;
  47578. /**
  47579. * Internal gizmo used for interactions on the z axis
  47580. */
  47581. zGizmo: PlaneRotationGizmo;
  47582. /** Fires an event when any of it's sub gizmos are dragged */
  47583. onDragStartObservable: Observable<unknown>;
  47584. /** Fires an event when any of it's sub gizmos are released from dragging */
  47585. onDragEndObservable: Observable<unknown>;
  47586. private _meshAttached;
  47587. get attachedMesh(): Nullable<AbstractMesh>;
  47588. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47589. /**
  47590. * Creates a RotationGizmo
  47591. * @param gizmoLayer The utility layer the gizmo will be added to
  47592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47593. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47594. */
  47595. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47596. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47597. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47598. /**
  47599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47600. */
  47601. set snapDistance(value: number);
  47602. get snapDistance(): number;
  47603. /**
  47604. * Ratio for the scale of the gizmo (Default: 1)
  47605. */
  47606. set scaleRatio(value: number);
  47607. get scaleRatio(): number;
  47608. /**
  47609. * Disposes of the gizmo
  47610. */
  47611. dispose(): void;
  47612. /**
  47613. * CustomMeshes are not supported by this gizmo
  47614. * @param mesh The mesh to replace the default mesh of the gizmo
  47615. */
  47616. setCustomMesh(mesh: Mesh): void;
  47617. }
  47618. }
  47619. declare module BABYLON {
  47620. /**
  47621. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47622. */
  47623. export class GizmoManager implements IDisposable {
  47624. private scene;
  47625. /**
  47626. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47627. */
  47628. gizmos: {
  47629. positionGizmo: Nullable<PositionGizmo>;
  47630. rotationGizmo: Nullable<RotationGizmo>;
  47631. scaleGizmo: Nullable<ScaleGizmo>;
  47632. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47633. };
  47634. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47635. clearGizmoOnEmptyPointerEvent: boolean;
  47636. /** Fires an event when the manager is attached to a mesh */
  47637. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47638. private _gizmosEnabled;
  47639. private _pointerObserver;
  47640. private _attachedMesh;
  47641. private _boundingBoxColor;
  47642. private _defaultUtilityLayer;
  47643. private _defaultKeepDepthUtilityLayer;
  47644. /**
  47645. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47646. */
  47647. boundingBoxDragBehavior: SixDofDragBehavior;
  47648. /**
  47649. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47650. */
  47651. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47652. /**
  47653. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47654. */
  47655. usePointerToAttachGizmos: boolean;
  47656. /**
  47657. * Utility layer that the bounding box gizmo belongs to
  47658. */
  47659. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  47660. /**
  47661. * Utility layer that all gizmos besides bounding box belong to
  47662. */
  47663. get utilityLayer(): UtilityLayerRenderer;
  47664. /**
  47665. * Instatiates a gizmo manager
  47666. * @param scene the scene to overlay the gizmos on top of
  47667. */
  47668. constructor(scene: Scene);
  47669. /**
  47670. * Attaches a set of gizmos to the specified mesh
  47671. * @param mesh The mesh the gizmo's should be attached to
  47672. */
  47673. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47674. /**
  47675. * If the position gizmo is enabled
  47676. */
  47677. set positionGizmoEnabled(value: boolean);
  47678. get positionGizmoEnabled(): boolean;
  47679. /**
  47680. * If the rotation gizmo is enabled
  47681. */
  47682. set rotationGizmoEnabled(value: boolean);
  47683. get rotationGizmoEnabled(): boolean;
  47684. /**
  47685. * If the scale gizmo is enabled
  47686. */
  47687. set scaleGizmoEnabled(value: boolean);
  47688. get scaleGizmoEnabled(): boolean;
  47689. /**
  47690. * If the boundingBox gizmo is enabled
  47691. */
  47692. set boundingBoxGizmoEnabled(value: boolean);
  47693. get boundingBoxGizmoEnabled(): boolean;
  47694. /**
  47695. * Disposes of the gizmo manager
  47696. */
  47697. dispose(): void;
  47698. }
  47699. }
  47700. declare module BABYLON {
  47701. /**
  47702. * A directional light is defined by a direction (what a surprise!).
  47703. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47704. * 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.
  47705. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47706. */
  47707. export class DirectionalLight extends ShadowLight {
  47708. private _shadowFrustumSize;
  47709. /**
  47710. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47711. */
  47712. get shadowFrustumSize(): number;
  47713. /**
  47714. * Specifies a fix frustum size for the shadow generation.
  47715. */
  47716. set shadowFrustumSize(value: number);
  47717. private _shadowOrthoScale;
  47718. /**
  47719. * Gets the shadow projection scale against the optimal computed one.
  47720. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47721. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47722. */
  47723. get shadowOrthoScale(): number;
  47724. /**
  47725. * Sets the shadow projection scale against the optimal computed one.
  47726. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47727. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47728. */
  47729. set shadowOrthoScale(value: number);
  47730. /**
  47731. * Automatically compute the projection matrix to best fit (including all the casters)
  47732. * on each frame.
  47733. */
  47734. autoUpdateExtends: boolean;
  47735. private _orthoLeft;
  47736. private _orthoRight;
  47737. private _orthoTop;
  47738. private _orthoBottom;
  47739. /**
  47740. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47741. * The directional light is emitted from everywhere in the given direction.
  47742. * It can cast shadows.
  47743. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47744. * @param name The friendly name of the light
  47745. * @param direction The direction of the light
  47746. * @param scene The scene the light belongs to
  47747. */
  47748. constructor(name: string, direction: Vector3, scene: Scene);
  47749. /**
  47750. * Returns the string "DirectionalLight".
  47751. * @return The class name
  47752. */
  47753. getClassName(): string;
  47754. /**
  47755. * Returns the integer 1.
  47756. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47757. */
  47758. getTypeID(): number;
  47759. /**
  47760. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47761. * Returns the DirectionalLight Shadow projection matrix.
  47762. */
  47763. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47764. /**
  47765. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47766. * Returns the DirectionalLight Shadow projection matrix.
  47767. */
  47768. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47769. /**
  47770. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47771. * Returns the DirectionalLight Shadow projection matrix.
  47772. */
  47773. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47774. protected _buildUniformLayout(): void;
  47775. /**
  47776. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47777. * @param effect The effect to update
  47778. * @param lightIndex The index of the light in the effect to update
  47779. * @returns The directional light
  47780. */
  47781. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47782. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47783. /**
  47784. * Gets the minZ used for shadow according to both the scene and the light.
  47785. *
  47786. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47787. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47788. * @param activeCamera The camera we are returning the min for
  47789. * @returns the depth min z
  47790. */
  47791. getDepthMinZ(activeCamera: Camera): number;
  47792. /**
  47793. * Gets the maxZ used for shadow according to both the scene and the light.
  47794. *
  47795. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47796. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47797. * @param activeCamera The camera we are returning the max for
  47798. * @returns the depth max z
  47799. */
  47800. getDepthMaxZ(activeCamera: Camera): number;
  47801. /**
  47802. * Prepares the list of defines specific to the light type.
  47803. * @param defines the list of defines
  47804. * @param lightIndex defines the index of the light for the effect
  47805. */
  47806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47807. }
  47808. }
  47809. declare module BABYLON {
  47810. /**
  47811. * Class containing static functions to help procedurally build meshes
  47812. */
  47813. export class HemisphereBuilder {
  47814. /**
  47815. * Creates a hemisphere mesh
  47816. * @param name defines the name of the mesh
  47817. * @param options defines the options used to create the mesh
  47818. * @param scene defines the hosting scene
  47819. * @returns the hemisphere mesh
  47820. */
  47821. static CreateHemisphere(name: string, options: {
  47822. segments?: number;
  47823. diameter?: number;
  47824. sideOrientation?: number;
  47825. }, scene: any): Mesh;
  47826. }
  47827. }
  47828. declare module BABYLON {
  47829. /**
  47830. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47831. * These values define a cone of light starting from the position, emitting toward the direction.
  47832. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47833. * and the exponent defines the speed of the decay of the light with distance (reach).
  47834. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47835. */
  47836. export class SpotLight extends ShadowLight {
  47837. private _angle;
  47838. private _innerAngle;
  47839. private _cosHalfAngle;
  47840. private _lightAngleScale;
  47841. private _lightAngleOffset;
  47842. /**
  47843. * Gets the cone angle of the spot light in Radians.
  47844. */
  47845. get angle(): number;
  47846. /**
  47847. * Sets the cone angle of the spot light in Radians.
  47848. */
  47849. set angle(value: number);
  47850. /**
  47851. * Only used in gltf falloff mode, this defines the angle where
  47852. * the directional falloff will start before cutting at angle which could be seen
  47853. * as outer angle.
  47854. */
  47855. get innerAngle(): number;
  47856. /**
  47857. * Only used in gltf falloff mode, this defines the angle where
  47858. * the directional falloff will start before cutting at angle which could be seen
  47859. * as outer angle.
  47860. */
  47861. set innerAngle(value: number);
  47862. private _shadowAngleScale;
  47863. /**
  47864. * Allows scaling the angle of the light for shadow generation only.
  47865. */
  47866. get shadowAngleScale(): number;
  47867. /**
  47868. * Allows scaling the angle of the light for shadow generation only.
  47869. */
  47870. set shadowAngleScale(value: number);
  47871. /**
  47872. * The light decay speed with the distance from the emission spot.
  47873. */
  47874. exponent: number;
  47875. private _projectionTextureMatrix;
  47876. /**
  47877. * Allows reading the projecton texture
  47878. */
  47879. get projectionTextureMatrix(): Matrix;
  47880. protected _projectionTextureLightNear: number;
  47881. /**
  47882. * Gets the near clip of the Spotlight for texture projection.
  47883. */
  47884. get projectionTextureLightNear(): number;
  47885. /**
  47886. * Sets the near clip of the Spotlight for texture projection.
  47887. */
  47888. set projectionTextureLightNear(value: number);
  47889. protected _projectionTextureLightFar: number;
  47890. /**
  47891. * Gets the far clip of the Spotlight for texture projection.
  47892. */
  47893. get projectionTextureLightFar(): number;
  47894. /**
  47895. * Sets the far clip of the Spotlight for texture projection.
  47896. */
  47897. set projectionTextureLightFar(value: number);
  47898. protected _projectionTextureUpDirection: Vector3;
  47899. /**
  47900. * Gets the Up vector of the Spotlight for texture projection.
  47901. */
  47902. get projectionTextureUpDirection(): Vector3;
  47903. /**
  47904. * Sets the Up vector of the Spotlight for texture projection.
  47905. */
  47906. set projectionTextureUpDirection(value: Vector3);
  47907. private _projectionTexture;
  47908. /**
  47909. * Gets the projection texture of the light.
  47910. */
  47911. get projectionTexture(): Nullable<BaseTexture>;
  47912. /**
  47913. * Sets the projection texture of the light.
  47914. */
  47915. set projectionTexture(value: Nullable<BaseTexture>);
  47916. private _projectionTextureViewLightDirty;
  47917. private _projectionTextureProjectionLightDirty;
  47918. private _projectionTextureDirty;
  47919. private _projectionTextureViewTargetVector;
  47920. private _projectionTextureViewLightMatrix;
  47921. private _projectionTextureProjectionLightMatrix;
  47922. private _projectionTextureScalingMatrix;
  47923. /**
  47924. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47925. * It can cast shadows.
  47926. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47927. * @param name The light friendly name
  47928. * @param position The position of the spot light in the scene
  47929. * @param direction The direction of the light in the scene
  47930. * @param angle The cone angle of the light in Radians
  47931. * @param exponent The light decay speed with the distance from the emission spot
  47932. * @param scene The scene the lights belongs to
  47933. */
  47934. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47935. /**
  47936. * Returns the string "SpotLight".
  47937. * @returns the class name
  47938. */
  47939. getClassName(): string;
  47940. /**
  47941. * Returns the integer 2.
  47942. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47943. */
  47944. getTypeID(): number;
  47945. /**
  47946. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47947. */
  47948. protected _setDirection(value: Vector3): void;
  47949. /**
  47950. * Overrides the position setter to recompute the projection texture view light Matrix.
  47951. */
  47952. protected _setPosition(value: Vector3): void;
  47953. /**
  47954. * 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.
  47955. * Returns the SpotLight.
  47956. */
  47957. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47958. protected _computeProjectionTextureViewLightMatrix(): void;
  47959. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47960. /**
  47961. * Main function for light texture projection matrix computing.
  47962. */
  47963. protected _computeProjectionTextureMatrix(): void;
  47964. protected _buildUniformLayout(): void;
  47965. private _computeAngleValues;
  47966. /**
  47967. * Sets the passed Effect "effect" with the Light textures.
  47968. * @param effect The effect to update
  47969. * @param lightIndex The index of the light in the effect to update
  47970. * @returns The light
  47971. */
  47972. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47973. /**
  47974. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47975. * @param effect The effect to update
  47976. * @param lightIndex The index of the light in the effect to update
  47977. * @returns The spot light
  47978. */
  47979. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47980. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47981. /**
  47982. * Disposes the light and the associated resources.
  47983. */
  47984. dispose(): void;
  47985. /**
  47986. * Prepares the list of defines specific to the light type.
  47987. * @param defines the list of defines
  47988. * @param lightIndex defines the index of the light for the effect
  47989. */
  47990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47991. }
  47992. }
  47993. declare module BABYLON {
  47994. /**
  47995. * Gizmo that enables viewing a light
  47996. */
  47997. export class LightGizmo extends Gizmo {
  47998. private _lightMesh;
  47999. private _material;
  48000. private _cachedPosition;
  48001. private _cachedForward;
  48002. private _attachedMeshParent;
  48003. /**
  48004. * Creates a LightGizmo
  48005. * @param gizmoLayer The utility layer the gizmo will be added to
  48006. */
  48007. constructor(gizmoLayer?: UtilityLayerRenderer);
  48008. private _light;
  48009. /**
  48010. * The light that the gizmo is attached to
  48011. */
  48012. set light(light: Nullable<Light>);
  48013. get light(): Nullable<Light>;
  48014. /**
  48015. * Gets the material used to render the light gizmo
  48016. */
  48017. get material(): StandardMaterial;
  48018. /**
  48019. * @hidden
  48020. * Updates the gizmo to match the attached mesh's position/rotation
  48021. */
  48022. protected _update(): void;
  48023. private static _Scale;
  48024. /**
  48025. * Creates the lines for a light mesh
  48026. */
  48027. private static _CreateLightLines;
  48028. /**
  48029. * Disposes of the light gizmo
  48030. */
  48031. dispose(): void;
  48032. private static _CreateHemisphericLightMesh;
  48033. private static _CreatePointLightMesh;
  48034. private static _CreateSpotLightMesh;
  48035. private static _CreateDirectionalLightMesh;
  48036. }
  48037. }
  48038. declare module BABYLON {
  48039. /** @hidden */
  48040. export var backgroundFragmentDeclaration: {
  48041. name: string;
  48042. shader: string;
  48043. };
  48044. }
  48045. declare module BABYLON {
  48046. /** @hidden */
  48047. export var backgroundUboDeclaration: {
  48048. name: string;
  48049. shader: string;
  48050. };
  48051. }
  48052. declare module BABYLON {
  48053. /** @hidden */
  48054. export var backgroundPixelShader: {
  48055. name: string;
  48056. shader: string;
  48057. };
  48058. }
  48059. declare module BABYLON {
  48060. /** @hidden */
  48061. export var backgroundVertexDeclaration: {
  48062. name: string;
  48063. shader: string;
  48064. };
  48065. }
  48066. declare module BABYLON {
  48067. /** @hidden */
  48068. export var backgroundVertexShader: {
  48069. name: string;
  48070. shader: string;
  48071. };
  48072. }
  48073. declare module BABYLON {
  48074. /**
  48075. * Background material used to create an efficient environement around your scene.
  48076. */
  48077. export class BackgroundMaterial extends PushMaterial {
  48078. /**
  48079. * Standard reflectance value at parallel view angle.
  48080. */
  48081. static StandardReflectance0: number;
  48082. /**
  48083. * Standard reflectance value at grazing angle.
  48084. */
  48085. static StandardReflectance90: number;
  48086. protected _primaryColor: Color3;
  48087. /**
  48088. * Key light Color (multiply against the environement texture)
  48089. */
  48090. primaryColor: Color3;
  48091. protected __perceptualColor: Nullable<Color3>;
  48092. /**
  48093. * Experimental Internal Use Only.
  48094. *
  48095. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48096. * This acts as a helper to set the primary color to a more "human friendly" value.
  48097. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48098. * output color as close as possible from the chosen value.
  48099. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48100. * part of lighting setup.)
  48101. */
  48102. get _perceptualColor(): Nullable<Color3>;
  48103. set _perceptualColor(value: Nullable<Color3>);
  48104. protected _primaryColorShadowLevel: float;
  48105. /**
  48106. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48107. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48108. */
  48109. get primaryColorShadowLevel(): float;
  48110. set primaryColorShadowLevel(value: float);
  48111. protected _primaryColorHighlightLevel: float;
  48112. /**
  48113. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48114. * The primary color is used at the level chosen to define what the white area would look.
  48115. */
  48116. get primaryColorHighlightLevel(): float;
  48117. set primaryColorHighlightLevel(value: float);
  48118. protected _reflectionTexture: Nullable<BaseTexture>;
  48119. /**
  48120. * Reflection Texture used in the material.
  48121. * Should be author in a specific way for the best result (refer to the documentation).
  48122. */
  48123. reflectionTexture: Nullable<BaseTexture>;
  48124. protected _reflectionBlur: float;
  48125. /**
  48126. * Reflection Texture level of blur.
  48127. *
  48128. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48129. * texture twice.
  48130. */
  48131. reflectionBlur: float;
  48132. protected _diffuseTexture: Nullable<BaseTexture>;
  48133. /**
  48134. * Diffuse Texture used in the material.
  48135. * Should be author in a specific way for the best result (refer to the documentation).
  48136. */
  48137. diffuseTexture: Nullable<BaseTexture>;
  48138. protected _shadowLights: Nullable<IShadowLight[]>;
  48139. /**
  48140. * Specify the list of lights casting shadow on the material.
  48141. * All scene shadow lights will be included if null.
  48142. */
  48143. shadowLights: Nullable<IShadowLight[]>;
  48144. protected _shadowLevel: float;
  48145. /**
  48146. * Helps adjusting the shadow to a softer level if required.
  48147. * 0 means black shadows and 1 means no shadows.
  48148. */
  48149. shadowLevel: float;
  48150. protected _sceneCenter: Vector3;
  48151. /**
  48152. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48153. * It is usually zero but might be interesting to modify according to your setup.
  48154. */
  48155. sceneCenter: Vector3;
  48156. protected _opacityFresnel: boolean;
  48157. /**
  48158. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48159. * This helps ensuring a nice transition when the camera goes under the ground.
  48160. */
  48161. opacityFresnel: boolean;
  48162. protected _reflectionFresnel: boolean;
  48163. /**
  48164. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48165. * This helps adding a mirror texture on the ground.
  48166. */
  48167. reflectionFresnel: boolean;
  48168. protected _reflectionFalloffDistance: number;
  48169. /**
  48170. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48171. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48172. */
  48173. reflectionFalloffDistance: number;
  48174. protected _reflectionAmount: number;
  48175. /**
  48176. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48177. */
  48178. reflectionAmount: number;
  48179. protected _reflectionReflectance0: number;
  48180. /**
  48181. * This specifies the weight of the reflection at grazing angle.
  48182. */
  48183. reflectionReflectance0: number;
  48184. protected _reflectionReflectance90: number;
  48185. /**
  48186. * This specifies the weight of the reflection at a perpendicular point of view.
  48187. */
  48188. reflectionReflectance90: number;
  48189. /**
  48190. * Sets the reflection reflectance fresnel values according to the default standard
  48191. * empirically know to work well :-)
  48192. */
  48193. set reflectionStandardFresnelWeight(value: number);
  48194. protected _useRGBColor: boolean;
  48195. /**
  48196. * Helps to directly use the maps channels instead of their level.
  48197. */
  48198. useRGBColor: boolean;
  48199. protected _enableNoise: boolean;
  48200. /**
  48201. * This helps reducing the banding effect that could occur on the background.
  48202. */
  48203. enableNoise: boolean;
  48204. /**
  48205. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48206. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48207. * Recommended to be keep at 1.0 except for special cases.
  48208. */
  48209. get fovMultiplier(): number;
  48210. set fovMultiplier(value: number);
  48211. private _fovMultiplier;
  48212. /**
  48213. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48214. */
  48215. useEquirectangularFOV: boolean;
  48216. private _maxSimultaneousLights;
  48217. /**
  48218. * Number of Simultaneous lights allowed on the material.
  48219. */
  48220. maxSimultaneousLights: int;
  48221. /**
  48222. * Default configuration related to image processing available in the Background Material.
  48223. */
  48224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48225. /**
  48226. * Keep track of the image processing observer to allow dispose and replace.
  48227. */
  48228. private _imageProcessingObserver;
  48229. /**
  48230. * Attaches a new image processing configuration to the PBR Material.
  48231. * @param configuration (if null the scene configuration will be use)
  48232. */
  48233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48234. /**
  48235. * Gets the image processing configuration used either in this material.
  48236. */
  48237. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48238. /**
  48239. * Sets the Default image processing configuration used either in the this material.
  48240. *
  48241. * If sets to null, the scene one is in use.
  48242. */
  48243. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48244. /**
  48245. * Gets wether the color curves effect is enabled.
  48246. */
  48247. get cameraColorCurvesEnabled(): boolean;
  48248. /**
  48249. * Sets wether the color curves effect is enabled.
  48250. */
  48251. set cameraColorCurvesEnabled(value: boolean);
  48252. /**
  48253. * Gets wether the color grading effect is enabled.
  48254. */
  48255. get cameraColorGradingEnabled(): boolean;
  48256. /**
  48257. * Gets wether the color grading effect is enabled.
  48258. */
  48259. set cameraColorGradingEnabled(value: boolean);
  48260. /**
  48261. * Gets wether tonemapping is enabled or not.
  48262. */
  48263. get cameraToneMappingEnabled(): boolean;
  48264. /**
  48265. * Sets wether tonemapping is enabled or not
  48266. */
  48267. set cameraToneMappingEnabled(value: boolean);
  48268. /**
  48269. * The camera exposure used on this material.
  48270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48271. * This corresponds to a photographic exposure.
  48272. */
  48273. get cameraExposure(): float;
  48274. /**
  48275. * The camera exposure used on this material.
  48276. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48277. * This corresponds to a photographic exposure.
  48278. */
  48279. set cameraExposure(value: float);
  48280. /**
  48281. * Gets The camera contrast used on this material.
  48282. */
  48283. get cameraContrast(): float;
  48284. /**
  48285. * Sets The camera contrast used on this material.
  48286. */
  48287. set cameraContrast(value: float);
  48288. /**
  48289. * Gets the Color Grading 2D Lookup Texture.
  48290. */
  48291. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  48292. /**
  48293. * Sets the Color Grading 2D Lookup Texture.
  48294. */
  48295. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  48296. /**
  48297. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48298. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48299. * 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;
  48300. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48301. */
  48302. get cameraColorCurves(): Nullable<ColorCurves>;
  48303. /**
  48304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48306. * 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;
  48307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48308. */
  48309. set cameraColorCurves(value: Nullable<ColorCurves>);
  48310. /**
  48311. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48312. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48313. */
  48314. switchToBGR: boolean;
  48315. private _renderTargets;
  48316. private _reflectionControls;
  48317. private _white;
  48318. private _primaryShadowColor;
  48319. private _primaryHighlightColor;
  48320. /**
  48321. * Instantiates a Background Material in the given scene
  48322. * @param name The friendly name of the material
  48323. * @param scene The scene to add the material to
  48324. */
  48325. constructor(name: string, scene: Scene);
  48326. /**
  48327. * Gets a boolean indicating that current material needs to register RTT
  48328. */
  48329. get hasRenderTargetTextures(): boolean;
  48330. /**
  48331. * The entire material has been created in order to prevent overdraw.
  48332. * @returns false
  48333. */
  48334. needAlphaTesting(): boolean;
  48335. /**
  48336. * The entire material has been created in order to prevent overdraw.
  48337. * @returns true if blending is enable
  48338. */
  48339. needAlphaBlending(): boolean;
  48340. /**
  48341. * Checks wether the material is ready to be rendered for a given mesh.
  48342. * @param mesh The mesh to render
  48343. * @param subMesh The submesh to check against
  48344. * @param useInstances Specify wether or not the material is used with instances
  48345. * @returns true if all the dependencies are ready (Textures, Effects...)
  48346. */
  48347. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48348. /**
  48349. * Compute the primary color according to the chosen perceptual color.
  48350. */
  48351. private _computePrimaryColorFromPerceptualColor;
  48352. /**
  48353. * Compute the highlights and shadow colors according to their chosen levels.
  48354. */
  48355. private _computePrimaryColors;
  48356. /**
  48357. * Build the uniform buffer used in the material.
  48358. */
  48359. buildUniformLayout(): void;
  48360. /**
  48361. * Unbind the material.
  48362. */
  48363. unbind(): void;
  48364. /**
  48365. * Bind only the world matrix to the material.
  48366. * @param world The world matrix to bind.
  48367. */
  48368. bindOnlyWorldMatrix(world: Matrix): void;
  48369. /**
  48370. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48371. * @param world The world matrix to bind.
  48372. * @param subMesh The submesh to bind for.
  48373. */
  48374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48375. /**
  48376. * Checks to see if a texture is used in the material.
  48377. * @param texture - Base texture to use.
  48378. * @returns - Boolean specifying if a texture is used in the material.
  48379. */
  48380. hasTexture(texture: BaseTexture): boolean;
  48381. /**
  48382. * Dispose the material.
  48383. * @param forceDisposeEffect Force disposal of the associated effect.
  48384. * @param forceDisposeTextures Force disposal of the associated textures.
  48385. */
  48386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48387. /**
  48388. * Clones the material.
  48389. * @param name The cloned name.
  48390. * @returns The cloned material.
  48391. */
  48392. clone(name: string): BackgroundMaterial;
  48393. /**
  48394. * Serializes the current material to its JSON representation.
  48395. * @returns The JSON representation.
  48396. */
  48397. serialize(): any;
  48398. /**
  48399. * Gets the class name of the material
  48400. * @returns "BackgroundMaterial"
  48401. */
  48402. getClassName(): string;
  48403. /**
  48404. * Parse a JSON input to create back a background material.
  48405. * @param source The JSON data to parse
  48406. * @param scene The scene to create the parsed material in
  48407. * @param rootUrl The root url of the assets the material depends upon
  48408. * @returns the instantiated BackgroundMaterial.
  48409. */
  48410. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48411. }
  48412. }
  48413. declare module BABYLON {
  48414. /**
  48415. * Represents the different options available during the creation of
  48416. * a Environment helper.
  48417. *
  48418. * This can control the default ground, skybox and image processing setup of your scene.
  48419. */
  48420. export interface IEnvironmentHelperOptions {
  48421. /**
  48422. * Specifies wether or not to create a ground.
  48423. * True by default.
  48424. */
  48425. createGround: boolean;
  48426. /**
  48427. * Specifies the ground size.
  48428. * 15 by default.
  48429. */
  48430. groundSize: number;
  48431. /**
  48432. * The texture used on the ground for the main color.
  48433. * Comes from the BabylonJS CDN by default.
  48434. *
  48435. * Remarks: Can be either a texture or a url.
  48436. */
  48437. groundTexture: string | BaseTexture;
  48438. /**
  48439. * The color mixed in the ground texture by default.
  48440. * BabylonJS clearColor by default.
  48441. */
  48442. groundColor: Color3;
  48443. /**
  48444. * Specifies the ground opacity.
  48445. * 1 by default.
  48446. */
  48447. groundOpacity: number;
  48448. /**
  48449. * Enables the ground to receive shadows.
  48450. * True by default.
  48451. */
  48452. enableGroundShadow: boolean;
  48453. /**
  48454. * Helps preventing the shadow to be fully black on the ground.
  48455. * 0.5 by default.
  48456. */
  48457. groundShadowLevel: number;
  48458. /**
  48459. * Creates a mirror texture attach to the ground.
  48460. * false by default.
  48461. */
  48462. enableGroundMirror: boolean;
  48463. /**
  48464. * Specifies the ground mirror size ratio.
  48465. * 0.3 by default as the default kernel is 64.
  48466. */
  48467. groundMirrorSizeRatio: number;
  48468. /**
  48469. * Specifies the ground mirror blur kernel size.
  48470. * 64 by default.
  48471. */
  48472. groundMirrorBlurKernel: number;
  48473. /**
  48474. * Specifies the ground mirror visibility amount.
  48475. * 1 by default
  48476. */
  48477. groundMirrorAmount: number;
  48478. /**
  48479. * Specifies the ground mirror reflectance weight.
  48480. * This uses the standard weight of the background material to setup the fresnel effect
  48481. * of the mirror.
  48482. * 1 by default.
  48483. */
  48484. groundMirrorFresnelWeight: number;
  48485. /**
  48486. * Specifies the ground mirror Falloff distance.
  48487. * This can helps reducing the size of the reflection.
  48488. * 0 by Default.
  48489. */
  48490. groundMirrorFallOffDistance: number;
  48491. /**
  48492. * Specifies the ground mirror texture type.
  48493. * Unsigned Int by Default.
  48494. */
  48495. groundMirrorTextureType: number;
  48496. /**
  48497. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48498. * the shown objects.
  48499. */
  48500. groundYBias: number;
  48501. /**
  48502. * Specifies wether or not to create a skybox.
  48503. * True by default.
  48504. */
  48505. createSkybox: boolean;
  48506. /**
  48507. * Specifies the skybox size.
  48508. * 20 by default.
  48509. */
  48510. skyboxSize: number;
  48511. /**
  48512. * The texture used on the skybox for the main color.
  48513. * Comes from the BabylonJS CDN by default.
  48514. *
  48515. * Remarks: Can be either a texture or a url.
  48516. */
  48517. skyboxTexture: string | BaseTexture;
  48518. /**
  48519. * The color mixed in the skybox texture by default.
  48520. * BabylonJS clearColor by default.
  48521. */
  48522. skyboxColor: Color3;
  48523. /**
  48524. * The background rotation around the Y axis of the scene.
  48525. * This helps aligning the key lights of your scene with the background.
  48526. * 0 by default.
  48527. */
  48528. backgroundYRotation: number;
  48529. /**
  48530. * Compute automatically the size of the elements to best fit with the scene.
  48531. */
  48532. sizeAuto: boolean;
  48533. /**
  48534. * Default position of the rootMesh if autoSize is not true.
  48535. */
  48536. rootPosition: Vector3;
  48537. /**
  48538. * Sets up the image processing in the scene.
  48539. * true by default.
  48540. */
  48541. setupImageProcessing: boolean;
  48542. /**
  48543. * The texture used as your environment texture in the scene.
  48544. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48545. *
  48546. * Remarks: Can be either a texture or a url.
  48547. */
  48548. environmentTexture: string | BaseTexture;
  48549. /**
  48550. * The value of the exposure to apply to the scene.
  48551. * 0.6 by default if setupImageProcessing is true.
  48552. */
  48553. cameraExposure: number;
  48554. /**
  48555. * The value of the contrast to apply to the scene.
  48556. * 1.6 by default if setupImageProcessing is true.
  48557. */
  48558. cameraContrast: number;
  48559. /**
  48560. * Specifies wether or not tonemapping should be enabled in the scene.
  48561. * true by default if setupImageProcessing is true.
  48562. */
  48563. toneMappingEnabled: boolean;
  48564. }
  48565. /**
  48566. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48567. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48568. * It also helps with the default setup of your imageProcessing configuration.
  48569. */
  48570. export class EnvironmentHelper {
  48571. /**
  48572. * Default ground texture URL.
  48573. */
  48574. private static _groundTextureCDNUrl;
  48575. /**
  48576. * Default skybox texture URL.
  48577. */
  48578. private static _skyboxTextureCDNUrl;
  48579. /**
  48580. * Default environment texture URL.
  48581. */
  48582. private static _environmentTextureCDNUrl;
  48583. /**
  48584. * Creates the default options for the helper.
  48585. */
  48586. private static _getDefaultOptions;
  48587. private _rootMesh;
  48588. /**
  48589. * Gets the root mesh created by the helper.
  48590. */
  48591. get rootMesh(): Mesh;
  48592. private _skybox;
  48593. /**
  48594. * Gets the skybox created by the helper.
  48595. */
  48596. get skybox(): Nullable<Mesh>;
  48597. private _skyboxTexture;
  48598. /**
  48599. * Gets the skybox texture created by the helper.
  48600. */
  48601. get skyboxTexture(): Nullable<BaseTexture>;
  48602. private _skyboxMaterial;
  48603. /**
  48604. * Gets the skybox material created by the helper.
  48605. */
  48606. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  48607. private _ground;
  48608. /**
  48609. * Gets the ground mesh created by the helper.
  48610. */
  48611. get ground(): Nullable<Mesh>;
  48612. private _groundTexture;
  48613. /**
  48614. * Gets the ground texture created by the helper.
  48615. */
  48616. get groundTexture(): Nullable<BaseTexture>;
  48617. private _groundMirror;
  48618. /**
  48619. * Gets the ground mirror created by the helper.
  48620. */
  48621. get groundMirror(): Nullable<MirrorTexture>;
  48622. /**
  48623. * Gets the ground mirror render list to helps pushing the meshes
  48624. * you wish in the ground reflection.
  48625. */
  48626. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  48627. private _groundMaterial;
  48628. /**
  48629. * Gets the ground material created by the helper.
  48630. */
  48631. get groundMaterial(): Nullable<BackgroundMaterial>;
  48632. /**
  48633. * Stores the creation options.
  48634. */
  48635. private readonly _scene;
  48636. private _options;
  48637. /**
  48638. * This observable will be notified with any error during the creation of the environment,
  48639. * mainly texture creation errors.
  48640. */
  48641. onErrorObservable: Observable<{
  48642. message?: string;
  48643. exception?: any;
  48644. }>;
  48645. /**
  48646. * constructor
  48647. * @param options Defines the options we want to customize the helper
  48648. * @param scene The scene to add the material to
  48649. */
  48650. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48651. /**
  48652. * Updates the background according to the new options
  48653. * @param options
  48654. */
  48655. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48656. /**
  48657. * Sets the primary color of all the available elements.
  48658. * @param color the main color to affect to the ground and the background
  48659. */
  48660. setMainColor(color: Color3): void;
  48661. /**
  48662. * Setup the image processing according to the specified options.
  48663. */
  48664. private _setupImageProcessing;
  48665. /**
  48666. * Setup the environment texture according to the specified options.
  48667. */
  48668. private _setupEnvironmentTexture;
  48669. /**
  48670. * Setup the background according to the specified options.
  48671. */
  48672. private _setupBackground;
  48673. /**
  48674. * Get the scene sizes according to the setup.
  48675. */
  48676. private _getSceneSize;
  48677. /**
  48678. * Setup the ground according to the specified options.
  48679. */
  48680. private _setupGround;
  48681. /**
  48682. * Setup the ground material according to the specified options.
  48683. */
  48684. private _setupGroundMaterial;
  48685. /**
  48686. * Setup the ground diffuse texture according to the specified options.
  48687. */
  48688. private _setupGroundDiffuseTexture;
  48689. /**
  48690. * Setup the ground mirror texture according to the specified options.
  48691. */
  48692. private _setupGroundMirrorTexture;
  48693. /**
  48694. * Setup the ground to receive the mirror texture.
  48695. */
  48696. private _setupMirrorInGroundMaterial;
  48697. /**
  48698. * Setup the skybox according to the specified options.
  48699. */
  48700. private _setupSkybox;
  48701. /**
  48702. * Setup the skybox material according to the specified options.
  48703. */
  48704. private _setupSkyboxMaterial;
  48705. /**
  48706. * Setup the skybox reflection texture according to the specified options.
  48707. */
  48708. private _setupSkyboxReflectionTexture;
  48709. private _errorHandler;
  48710. /**
  48711. * Dispose all the elements created by the Helper.
  48712. */
  48713. dispose(): void;
  48714. }
  48715. }
  48716. declare module BABYLON {
  48717. /**
  48718. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48719. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48720. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48721. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48722. */
  48723. export class PhotoDome extends TransformNode {
  48724. /**
  48725. * Define the image as a Monoscopic panoramic 360 image.
  48726. */
  48727. static readonly MODE_MONOSCOPIC: number;
  48728. /**
  48729. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48730. */
  48731. static readonly MODE_TOPBOTTOM: number;
  48732. /**
  48733. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48734. */
  48735. static readonly MODE_SIDEBYSIDE: number;
  48736. private _useDirectMapping;
  48737. /**
  48738. * The texture being displayed on the sphere
  48739. */
  48740. protected _photoTexture: Texture;
  48741. /**
  48742. * Gets or sets the texture being displayed on the sphere
  48743. */
  48744. get photoTexture(): Texture;
  48745. set photoTexture(value: Texture);
  48746. /**
  48747. * Observable raised when an error occured while loading the 360 image
  48748. */
  48749. onLoadErrorObservable: Observable<string>;
  48750. /**
  48751. * The skybox material
  48752. */
  48753. protected _material: BackgroundMaterial;
  48754. /**
  48755. * The surface used for the skybox
  48756. */
  48757. protected _mesh: Mesh;
  48758. /**
  48759. * Gets the mesh used for the skybox.
  48760. */
  48761. get mesh(): Mesh;
  48762. /**
  48763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48764. * Also see the options.resolution property.
  48765. */
  48766. get fovMultiplier(): number;
  48767. set fovMultiplier(value: number);
  48768. private _imageMode;
  48769. /**
  48770. * Gets or set the current video mode for the video. It can be:
  48771. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48772. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48773. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48774. */
  48775. get imageMode(): number;
  48776. set imageMode(value: number);
  48777. /**
  48778. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48779. * @param name Element's name, child elements will append suffixes for their own names.
  48780. * @param urlsOfPhoto defines the url of the photo to display
  48781. * @param options defines an object containing optional or exposed sub element properties
  48782. * @param onError defines a callback called when an error occured while loading the texture
  48783. */
  48784. constructor(name: string, urlOfPhoto: string, options: {
  48785. resolution?: number;
  48786. size?: number;
  48787. useDirectMapping?: boolean;
  48788. faceForward?: boolean;
  48789. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48790. private _onBeforeCameraRenderObserver;
  48791. private _changeImageMode;
  48792. /**
  48793. * Releases resources associated with this node.
  48794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48796. */
  48797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48798. }
  48799. }
  48800. declare module BABYLON {
  48801. /**
  48802. * Class used to host RGBD texture specific utilities
  48803. */
  48804. export class RGBDTextureTools {
  48805. /**
  48806. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48807. * @param texture the texture to expand.
  48808. */
  48809. static ExpandRGBDTexture(texture: Texture): void;
  48810. }
  48811. }
  48812. declare module BABYLON {
  48813. /**
  48814. * Class used to host texture specific utilities
  48815. */
  48816. export class BRDFTextureTools {
  48817. /**
  48818. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48819. * @param scene defines the hosting scene
  48820. * @returns the environment BRDF texture
  48821. */
  48822. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48823. private static _environmentBRDFBase64Texture;
  48824. }
  48825. }
  48826. declare module BABYLON {
  48827. /**
  48828. * @hidden
  48829. */
  48830. export interface IMaterialClearCoatDefines {
  48831. CLEARCOAT: boolean;
  48832. CLEARCOAT_DEFAULTIOR: boolean;
  48833. CLEARCOAT_TEXTURE: boolean;
  48834. CLEARCOAT_TEXTUREDIRECTUV: number;
  48835. CLEARCOAT_BUMP: boolean;
  48836. CLEARCOAT_BUMPDIRECTUV: number;
  48837. CLEARCOAT_TINT: boolean;
  48838. CLEARCOAT_TINT_TEXTURE: boolean;
  48839. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48840. /** @hidden */
  48841. _areTexturesDirty: boolean;
  48842. }
  48843. /**
  48844. * Define the code related to the clear coat parameters of the pbr material.
  48845. */
  48846. export class PBRClearCoatConfiguration {
  48847. /**
  48848. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48849. * The default fits with a polyurethane material.
  48850. */
  48851. private static readonly _DefaultIndexOfRefraction;
  48852. private _isEnabled;
  48853. /**
  48854. * Defines if the clear coat is enabled in the material.
  48855. */
  48856. isEnabled: boolean;
  48857. /**
  48858. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48859. */
  48860. intensity: number;
  48861. /**
  48862. * Defines the clear coat layer roughness.
  48863. */
  48864. roughness: number;
  48865. private _indexOfRefraction;
  48866. /**
  48867. * Defines the index of refraction of the clear coat.
  48868. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48869. * The default fits with a polyurethane material.
  48870. * Changing the default value is more performance intensive.
  48871. */
  48872. indexOfRefraction: number;
  48873. private _texture;
  48874. /**
  48875. * Stores the clear coat values in a texture.
  48876. */
  48877. texture: Nullable<BaseTexture>;
  48878. private _bumpTexture;
  48879. /**
  48880. * Define the clear coat specific bump texture.
  48881. */
  48882. bumpTexture: Nullable<BaseTexture>;
  48883. private _isTintEnabled;
  48884. /**
  48885. * Defines if the clear coat tint is enabled in the material.
  48886. */
  48887. isTintEnabled: boolean;
  48888. /**
  48889. * Defines the clear coat tint of the material.
  48890. * This is only use if tint is enabled
  48891. */
  48892. tintColor: Color3;
  48893. /**
  48894. * Defines the distance at which the tint color should be found in the
  48895. * clear coat media.
  48896. * This is only use if tint is enabled
  48897. */
  48898. tintColorAtDistance: number;
  48899. /**
  48900. * Defines the clear coat layer thickness.
  48901. * This is only use if tint is enabled
  48902. */
  48903. tintThickness: number;
  48904. private _tintTexture;
  48905. /**
  48906. * Stores the clear tint values in a texture.
  48907. * rgb is tint
  48908. * a is a thickness factor
  48909. */
  48910. tintTexture: Nullable<BaseTexture>;
  48911. /** @hidden */
  48912. private _internalMarkAllSubMeshesAsTexturesDirty;
  48913. /** @hidden */
  48914. _markAllSubMeshesAsTexturesDirty(): void;
  48915. /**
  48916. * Instantiate a new istance of clear coat configuration.
  48917. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48918. */
  48919. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48920. /**
  48921. * Gets wehter the submesh is ready to be used or not.
  48922. * @param defines the list of "defines" to update.
  48923. * @param scene defines the scene the material belongs to.
  48924. * @param engine defines the engine the material belongs to.
  48925. * @param disableBumpMap defines wether the material disables bump or not.
  48926. * @returns - boolean indicating that the submesh is ready or not.
  48927. */
  48928. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48929. /**
  48930. * Checks to see if a texture is used in the material.
  48931. * @param defines the list of "defines" to update.
  48932. * @param scene defines the scene to the material belongs to.
  48933. */
  48934. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48935. /**
  48936. * Binds the material data.
  48937. * @param uniformBuffer defines the Uniform buffer to fill in.
  48938. * @param scene defines the scene the material belongs to.
  48939. * @param engine defines the engine the material belongs to.
  48940. * @param disableBumpMap defines wether the material disables bump or not.
  48941. * @param isFrozen defines wether the material is frozen or not.
  48942. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48943. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48944. */
  48945. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48946. /**
  48947. * Checks to see if a texture is used in the material.
  48948. * @param texture - Base texture to use.
  48949. * @returns - Boolean specifying if a texture is used in the material.
  48950. */
  48951. hasTexture(texture: BaseTexture): boolean;
  48952. /**
  48953. * Returns an array of the actively used textures.
  48954. * @param activeTextures Array of BaseTextures
  48955. */
  48956. getActiveTextures(activeTextures: BaseTexture[]): void;
  48957. /**
  48958. * Returns the animatable textures.
  48959. * @param animatables Array of animatable textures.
  48960. */
  48961. getAnimatables(animatables: IAnimatable[]): void;
  48962. /**
  48963. * Disposes the resources of the material.
  48964. * @param forceDisposeTextures - Forces the disposal of all textures.
  48965. */
  48966. dispose(forceDisposeTextures?: boolean): void;
  48967. /**
  48968. * Get the current class name of the texture useful for serialization or dynamic coding.
  48969. * @returns "PBRClearCoatConfiguration"
  48970. */
  48971. getClassName(): string;
  48972. /**
  48973. * Add fallbacks to the effect fallbacks list.
  48974. * @param defines defines the Base texture to use.
  48975. * @param fallbacks defines the current fallback list.
  48976. * @param currentRank defines the current fallback rank.
  48977. * @returns the new fallback rank.
  48978. */
  48979. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48980. /**
  48981. * Add the required uniforms to the current list.
  48982. * @param uniforms defines the current uniform list.
  48983. */
  48984. static AddUniforms(uniforms: string[]): void;
  48985. /**
  48986. * Add the required samplers to the current list.
  48987. * @param samplers defines the current sampler list.
  48988. */
  48989. static AddSamplers(samplers: string[]): void;
  48990. /**
  48991. * Add the required uniforms to the current buffer.
  48992. * @param uniformBuffer defines the current uniform buffer.
  48993. */
  48994. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48995. /**
  48996. * Makes a duplicate of the current configuration into another one.
  48997. * @param clearCoatConfiguration define the config where to copy the info
  48998. */
  48999. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49000. /**
  49001. * Serializes this clear coat configuration.
  49002. * @returns - An object with the serialized config.
  49003. */
  49004. serialize(): any;
  49005. /**
  49006. * Parses a anisotropy Configuration from a serialized object.
  49007. * @param source - Serialized object.
  49008. * @param scene Defines the scene we are parsing for
  49009. * @param rootUrl Defines the rootUrl to load from
  49010. */
  49011. parse(source: any, scene: Scene, rootUrl: string): void;
  49012. }
  49013. }
  49014. declare module BABYLON {
  49015. /**
  49016. * @hidden
  49017. */
  49018. export interface IMaterialAnisotropicDefines {
  49019. ANISOTROPIC: boolean;
  49020. ANISOTROPIC_TEXTURE: boolean;
  49021. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49022. MAINUV1: boolean;
  49023. _areTexturesDirty: boolean;
  49024. _needUVs: boolean;
  49025. }
  49026. /**
  49027. * Define the code related to the anisotropic parameters of the pbr material.
  49028. */
  49029. export class PBRAnisotropicConfiguration {
  49030. private _isEnabled;
  49031. /**
  49032. * Defines if the anisotropy is enabled in the material.
  49033. */
  49034. isEnabled: boolean;
  49035. /**
  49036. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49037. */
  49038. intensity: number;
  49039. /**
  49040. * Defines if the effect is along the tangents, bitangents or in between.
  49041. * By default, the effect is "strectching" the highlights along the tangents.
  49042. */
  49043. direction: Vector2;
  49044. private _texture;
  49045. /**
  49046. * Stores the anisotropy values in a texture.
  49047. * rg is direction (like normal from -1 to 1)
  49048. * b is a intensity
  49049. */
  49050. texture: Nullable<BaseTexture>;
  49051. /** @hidden */
  49052. private _internalMarkAllSubMeshesAsTexturesDirty;
  49053. /** @hidden */
  49054. _markAllSubMeshesAsTexturesDirty(): void;
  49055. /**
  49056. * Instantiate a new istance of anisotropy configuration.
  49057. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49058. */
  49059. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49060. /**
  49061. * Specifies that the submesh is ready to be used.
  49062. * @param defines the list of "defines" to update.
  49063. * @param scene defines the scene the material belongs to.
  49064. * @returns - boolean indicating that the submesh is ready or not.
  49065. */
  49066. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49067. /**
  49068. * Checks to see if a texture is used in the material.
  49069. * @param defines the list of "defines" to update.
  49070. * @param mesh the mesh we are preparing the defines for.
  49071. * @param scene defines the scene the material belongs to.
  49072. */
  49073. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49074. /**
  49075. * Binds the material data.
  49076. * @param uniformBuffer defines the Uniform buffer to fill in.
  49077. * @param scene defines the scene the material belongs to.
  49078. * @param isFrozen defines wether the material is frozen or not.
  49079. */
  49080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49081. /**
  49082. * Checks to see if a texture is used in the material.
  49083. * @param texture - Base texture to use.
  49084. * @returns - Boolean specifying if a texture is used in the material.
  49085. */
  49086. hasTexture(texture: BaseTexture): boolean;
  49087. /**
  49088. * Returns an array of the actively used textures.
  49089. * @param activeTextures Array of BaseTextures
  49090. */
  49091. getActiveTextures(activeTextures: BaseTexture[]): void;
  49092. /**
  49093. * Returns the animatable textures.
  49094. * @param animatables Array of animatable textures.
  49095. */
  49096. getAnimatables(animatables: IAnimatable[]): void;
  49097. /**
  49098. * Disposes the resources of the material.
  49099. * @param forceDisposeTextures - Forces the disposal of all textures.
  49100. */
  49101. dispose(forceDisposeTextures?: boolean): void;
  49102. /**
  49103. * Get the current class name of the texture useful for serialization or dynamic coding.
  49104. * @returns "PBRAnisotropicConfiguration"
  49105. */
  49106. getClassName(): string;
  49107. /**
  49108. * Add fallbacks to the effect fallbacks list.
  49109. * @param defines defines the Base texture to use.
  49110. * @param fallbacks defines the current fallback list.
  49111. * @param currentRank defines the current fallback rank.
  49112. * @returns the new fallback rank.
  49113. */
  49114. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49115. /**
  49116. * Add the required uniforms to the current list.
  49117. * @param uniforms defines the current uniform list.
  49118. */
  49119. static AddUniforms(uniforms: string[]): void;
  49120. /**
  49121. * Add the required uniforms to the current buffer.
  49122. * @param uniformBuffer defines the current uniform buffer.
  49123. */
  49124. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49125. /**
  49126. * Add the required samplers to the current list.
  49127. * @param samplers defines the current sampler list.
  49128. */
  49129. static AddSamplers(samplers: string[]): void;
  49130. /**
  49131. * Makes a duplicate of the current configuration into another one.
  49132. * @param anisotropicConfiguration define the config where to copy the info
  49133. */
  49134. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49135. /**
  49136. * Serializes this anisotropy configuration.
  49137. * @returns - An object with the serialized config.
  49138. */
  49139. serialize(): any;
  49140. /**
  49141. * Parses a anisotropy Configuration from a serialized object.
  49142. * @param source - Serialized object.
  49143. * @param scene Defines the scene we are parsing for
  49144. * @param rootUrl Defines the rootUrl to load from
  49145. */
  49146. parse(source: any, scene: Scene, rootUrl: string): void;
  49147. }
  49148. }
  49149. declare module BABYLON {
  49150. /**
  49151. * @hidden
  49152. */
  49153. export interface IMaterialBRDFDefines {
  49154. BRDF_V_HEIGHT_CORRELATED: boolean;
  49155. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49156. SPHERICAL_HARMONICS: boolean;
  49157. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49158. /** @hidden */
  49159. _areMiscDirty: boolean;
  49160. }
  49161. /**
  49162. * Define the code related to the BRDF parameters of the pbr material.
  49163. */
  49164. export class PBRBRDFConfiguration {
  49165. /**
  49166. * Default value used for the energy conservation.
  49167. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49168. */
  49169. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49170. /**
  49171. * Default value used for the Smith Visibility Height Correlated mode.
  49172. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49173. */
  49174. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49175. /**
  49176. * Default value used for the IBL diffuse part.
  49177. * This can help switching back to the polynomials mode globally which is a tiny bit
  49178. * less GPU intensive at the drawback of a lower quality.
  49179. */
  49180. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49181. /**
  49182. * Default value used for activating energy conservation for the specular workflow.
  49183. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49184. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49185. */
  49186. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49187. private _useEnergyConservation;
  49188. /**
  49189. * Defines if the material uses energy conservation.
  49190. */
  49191. useEnergyConservation: boolean;
  49192. private _useSmithVisibilityHeightCorrelated;
  49193. /**
  49194. * LEGACY Mode set to false
  49195. * Defines if the material uses height smith correlated visibility term.
  49196. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49197. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49198. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49199. * Not relying on height correlated will also disable energy conservation.
  49200. */
  49201. useSmithVisibilityHeightCorrelated: boolean;
  49202. private _useSphericalHarmonics;
  49203. /**
  49204. * LEGACY Mode set to false
  49205. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49206. * diffuse part of the IBL.
  49207. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49208. * to the ground truth.
  49209. */
  49210. useSphericalHarmonics: boolean;
  49211. private _useSpecularGlossinessInputEnergyConservation;
  49212. /**
  49213. * Defines if the material uses energy conservation, when the specular workflow is active.
  49214. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49215. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49216. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49217. */
  49218. useSpecularGlossinessInputEnergyConservation: boolean;
  49219. /** @hidden */
  49220. private _internalMarkAllSubMeshesAsMiscDirty;
  49221. /** @hidden */
  49222. _markAllSubMeshesAsMiscDirty(): void;
  49223. /**
  49224. * Instantiate a new istance of clear coat configuration.
  49225. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49226. */
  49227. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49228. /**
  49229. * Checks to see if a texture is used in the material.
  49230. * @param defines the list of "defines" to update.
  49231. */
  49232. prepareDefines(defines: IMaterialBRDFDefines): void;
  49233. /**
  49234. * Get the current class name of the texture useful for serialization or dynamic coding.
  49235. * @returns "PBRClearCoatConfiguration"
  49236. */
  49237. getClassName(): string;
  49238. /**
  49239. * Makes a duplicate of the current configuration into another one.
  49240. * @param brdfConfiguration define the config where to copy the info
  49241. */
  49242. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49243. /**
  49244. * Serializes this BRDF configuration.
  49245. * @returns - An object with the serialized config.
  49246. */
  49247. serialize(): any;
  49248. /**
  49249. * Parses a anisotropy Configuration from a serialized object.
  49250. * @param source - Serialized object.
  49251. * @param scene Defines the scene we are parsing for
  49252. * @param rootUrl Defines the rootUrl to load from
  49253. */
  49254. parse(source: any, scene: Scene, rootUrl: string): void;
  49255. }
  49256. }
  49257. declare module BABYLON {
  49258. /**
  49259. * @hidden
  49260. */
  49261. export interface IMaterialSheenDefines {
  49262. SHEEN: boolean;
  49263. SHEEN_TEXTURE: boolean;
  49264. SHEEN_TEXTUREDIRECTUV: number;
  49265. SHEEN_LINKWITHALBEDO: boolean;
  49266. /** @hidden */
  49267. _areTexturesDirty: boolean;
  49268. }
  49269. /**
  49270. * Define the code related to the Sheen parameters of the pbr material.
  49271. */
  49272. export class PBRSheenConfiguration {
  49273. private _isEnabled;
  49274. /**
  49275. * Defines if the material uses sheen.
  49276. */
  49277. isEnabled: boolean;
  49278. private _linkSheenWithAlbedo;
  49279. /**
  49280. * Defines if the sheen is linked to the sheen color.
  49281. */
  49282. linkSheenWithAlbedo: boolean;
  49283. /**
  49284. * Defines the sheen intensity.
  49285. */
  49286. intensity: number;
  49287. /**
  49288. * Defines the sheen color.
  49289. */
  49290. color: Color3;
  49291. private _texture;
  49292. /**
  49293. * Stores the sheen tint values in a texture.
  49294. * rgb is tint
  49295. * a is a intensity
  49296. */
  49297. texture: Nullable<BaseTexture>;
  49298. /** @hidden */
  49299. private _internalMarkAllSubMeshesAsTexturesDirty;
  49300. /** @hidden */
  49301. _markAllSubMeshesAsTexturesDirty(): void;
  49302. /**
  49303. * Instantiate a new istance of clear coat configuration.
  49304. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49305. */
  49306. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49307. /**
  49308. * Specifies that the submesh is ready to be used.
  49309. * @param defines the list of "defines" to update.
  49310. * @param scene defines the scene the material belongs to.
  49311. * @returns - boolean indicating that the submesh is ready or not.
  49312. */
  49313. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49314. /**
  49315. * Checks to see if a texture is used in the material.
  49316. * @param defines the list of "defines" to update.
  49317. * @param scene defines the scene the material belongs to.
  49318. */
  49319. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49320. /**
  49321. * Binds the material data.
  49322. * @param uniformBuffer defines the Uniform buffer to fill in.
  49323. * @param scene defines the scene the material belongs to.
  49324. * @param isFrozen defines wether the material is frozen or not.
  49325. */
  49326. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49327. /**
  49328. * Checks to see if a texture is used in the material.
  49329. * @param texture - Base texture to use.
  49330. * @returns - Boolean specifying if a texture is used in the material.
  49331. */
  49332. hasTexture(texture: BaseTexture): boolean;
  49333. /**
  49334. * Returns an array of the actively used textures.
  49335. * @param activeTextures Array of BaseTextures
  49336. */
  49337. getActiveTextures(activeTextures: BaseTexture[]): void;
  49338. /**
  49339. * Returns the animatable textures.
  49340. * @param animatables Array of animatable textures.
  49341. */
  49342. getAnimatables(animatables: IAnimatable[]): void;
  49343. /**
  49344. * Disposes the resources of the material.
  49345. * @param forceDisposeTextures - Forces the disposal of all textures.
  49346. */
  49347. dispose(forceDisposeTextures?: boolean): void;
  49348. /**
  49349. * Get the current class name of the texture useful for serialization or dynamic coding.
  49350. * @returns "PBRSheenConfiguration"
  49351. */
  49352. getClassName(): string;
  49353. /**
  49354. * Add fallbacks to the effect fallbacks list.
  49355. * @param defines defines the Base texture to use.
  49356. * @param fallbacks defines the current fallback list.
  49357. * @param currentRank defines the current fallback rank.
  49358. * @returns the new fallback rank.
  49359. */
  49360. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49361. /**
  49362. * Add the required uniforms to the current list.
  49363. * @param uniforms defines the current uniform list.
  49364. */
  49365. static AddUniforms(uniforms: string[]): void;
  49366. /**
  49367. * Add the required uniforms to the current buffer.
  49368. * @param uniformBuffer defines the current uniform buffer.
  49369. */
  49370. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49371. /**
  49372. * Add the required samplers to the current list.
  49373. * @param samplers defines the current sampler list.
  49374. */
  49375. static AddSamplers(samplers: string[]): void;
  49376. /**
  49377. * Makes a duplicate of the current configuration into another one.
  49378. * @param sheenConfiguration define the config where to copy the info
  49379. */
  49380. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49381. /**
  49382. * Serializes this BRDF configuration.
  49383. * @returns - An object with the serialized config.
  49384. */
  49385. serialize(): any;
  49386. /**
  49387. * Parses a anisotropy Configuration from a serialized object.
  49388. * @param source - Serialized object.
  49389. * @param scene Defines the scene we are parsing for
  49390. * @param rootUrl Defines the rootUrl to load from
  49391. */
  49392. parse(source: any, scene: Scene, rootUrl: string): void;
  49393. }
  49394. }
  49395. declare module BABYLON {
  49396. /**
  49397. * @hidden
  49398. */
  49399. export interface IMaterialSubSurfaceDefines {
  49400. SUBSURFACE: boolean;
  49401. SS_REFRACTION: boolean;
  49402. SS_TRANSLUCENCY: boolean;
  49403. SS_SCATERRING: boolean;
  49404. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49405. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49406. SS_REFRACTIONMAP_3D: boolean;
  49407. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49408. SS_LODINREFRACTIONALPHA: boolean;
  49409. SS_GAMMAREFRACTION: boolean;
  49410. SS_RGBDREFRACTION: boolean;
  49411. SS_LINEARSPECULARREFRACTION: boolean;
  49412. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49413. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49414. /** @hidden */
  49415. _areTexturesDirty: boolean;
  49416. }
  49417. /**
  49418. * Define the code related to the sub surface parameters of the pbr material.
  49419. */
  49420. export class PBRSubSurfaceConfiguration {
  49421. private _isRefractionEnabled;
  49422. /**
  49423. * Defines if the refraction is enabled in the material.
  49424. */
  49425. isRefractionEnabled: boolean;
  49426. private _isTranslucencyEnabled;
  49427. /**
  49428. * Defines if the translucency is enabled in the material.
  49429. */
  49430. isTranslucencyEnabled: boolean;
  49431. private _isScatteringEnabled;
  49432. /**
  49433. * Defines the refraction intensity of the material.
  49434. * The refraction when enabled replaces the Diffuse part of the material.
  49435. * The intensity helps transitionning between diffuse and refraction.
  49436. */
  49437. refractionIntensity: number;
  49438. /**
  49439. * Defines the translucency intensity of the material.
  49440. * When translucency has been enabled, this defines how much of the "translucency"
  49441. * is addded to the diffuse part of the material.
  49442. */
  49443. translucencyIntensity: number;
  49444. /**
  49445. * Defines the scattering intensity of the material.
  49446. * When scattering has been enabled, this defines how much of the "scattered light"
  49447. * is addded to the diffuse part of the material.
  49448. */
  49449. scatteringIntensity: number;
  49450. private _thicknessTexture;
  49451. /**
  49452. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49453. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49454. * 0 would mean minimumThickness
  49455. * 1 would mean maximumThickness
  49456. * The other channels might be use as a mask to vary the different effects intensity.
  49457. */
  49458. thicknessTexture: Nullable<BaseTexture>;
  49459. private _refractionTexture;
  49460. /**
  49461. * Defines the texture to use for refraction.
  49462. */
  49463. refractionTexture: Nullable<BaseTexture>;
  49464. private _indexOfRefraction;
  49465. /**
  49466. * Defines the index of refraction used in the material.
  49467. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49468. */
  49469. indexOfRefraction: number;
  49470. private _invertRefractionY;
  49471. /**
  49472. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49473. */
  49474. invertRefractionY: boolean;
  49475. private _linkRefractionWithTransparency;
  49476. /**
  49477. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49478. * Materials half opaque for instance using refraction could benefit from this control.
  49479. */
  49480. linkRefractionWithTransparency: boolean;
  49481. /**
  49482. * Defines the minimum thickness stored in the thickness map.
  49483. * If no thickness map is defined, this value will be used to simulate thickness.
  49484. */
  49485. minimumThickness: number;
  49486. /**
  49487. * Defines the maximum thickness stored in the thickness map.
  49488. */
  49489. maximumThickness: number;
  49490. /**
  49491. * Defines the volume tint of the material.
  49492. * This is used for both translucency and scattering.
  49493. */
  49494. tintColor: Color3;
  49495. /**
  49496. * Defines the distance at which the tint color should be found in the media.
  49497. * This is used for refraction only.
  49498. */
  49499. tintColorAtDistance: number;
  49500. /**
  49501. * Defines how far each channel transmit through the media.
  49502. * It is defined as a color to simplify it selection.
  49503. */
  49504. diffusionDistance: Color3;
  49505. private _useMaskFromThicknessTexture;
  49506. /**
  49507. * Stores the intensity of the different subsurface effects in the thickness texture.
  49508. * * the green channel is the translucency intensity.
  49509. * * the blue channel is the scattering intensity.
  49510. * * the alpha channel is the refraction intensity.
  49511. */
  49512. useMaskFromThicknessTexture: boolean;
  49513. /** @hidden */
  49514. private _internalMarkAllSubMeshesAsTexturesDirty;
  49515. /** @hidden */
  49516. _markAllSubMeshesAsTexturesDirty(): void;
  49517. /**
  49518. * Instantiate a new istance of sub surface configuration.
  49519. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49520. */
  49521. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49522. /**
  49523. * Gets wehter the submesh is ready to be used or not.
  49524. * @param defines the list of "defines" to update.
  49525. * @param scene defines the scene the material belongs to.
  49526. * @returns - boolean indicating that the submesh is ready or not.
  49527. */
  49528. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49529. /**
  49530. * Checks to see if a texture is used in the material.
  49531. * @param defines the list of "defines" to update.
  49532. * @param scene defines the scene to the material belongs to.
  49533. */
  49534. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49535. /**
  49536. * Binds the material data.
  49537. * @param uniformBuffer defines the Uniform buffer to fill in.
  49538. * @param scene defines the scene the material belongs to.
  49539. * @param engine defines the engine the material belongs to.
  49540. * @param isFrozen defines wether the material is frozen or not.
  49541. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49542. */
  49543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49544. /**
  49545. * Unbinds the material from the mesh.
  49546. * @param activeEffect defines the effect that should be unbound from.
  49547. * @returns true if unbound, otherwise false
  49548. */
  49549. unbind(activeEffect: Effect): boolean;
  49550. /**
  49551. * Returns the texture used for refraction or null if none is used.
  49552. * @param scene defines the scene the material belongs to.
  49553. * @returns - Refraction texture if present. If no refraction texture and refraction
  49554. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49555. */
  49556. private _getRefractionTexture;
  49557. /**
  49558. * Returns true if alpha blending should be disabled.
  49559. */
  49560. get disableAlphaBlending(): boolean;
  49561. /**
  49562. * Fills the list of render target textures.
  49563. * @param renderTargets the list of render targets to update
  49564. */
  49565. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49566. /**
  49567. * Checks to see if a texture is used in the material.
  49568. * @param texture - Base texture to use.
  49569. * @returns - Boolean specifying if a texture is used in the material.
  49570. */
  49571. hasTexture(texture: BaseTexture): boolean;
  49572. /**
  49573. * Gets a boolean indicating that current material needs to register RTT
  49574. * @returns true if this uses a render target otherwise false.
  49575. */
  49576. hasRenderTargetTextures(): boolean;
  49577. /**
  49578. * Returns an array of the actively used textures.
  49579. * @param activeTextures Array of BaseTextures
  49580. */
  49581. getActiveTextures(activeTextures: BaseTexture[]): void;
  49582. /**
  49583. * Returns the animatable textures.
  49584. * @param animatables Array of animatable textures.
  49585. */
  49586. getAnimatables(animatables: IAnimatable[]): void;
  49587. /**
  49588. * Disposes the resources of the material.
  49589. * @param forceDisposeTextures - Forces the disposal of all textures.
  49590. */
  49591. dispose(forceDisposeTextures?: boolean): void;
  49592. /**
  49593. * Get the current class name of the texture useful for serialization or dynamic coding.
  49594. * @returns "PBRSubSurfaceConfiguration"
  49595. */
  49596. getClassName(): string;
  49597. /**
  49598. * Add fallbacks to the effect fallbacks list.
  49599. * @param defines defines the Base texture to use.
  49600. * @param fallbacks defines the current fallback list.
  49601. * @param currentRank defines the current fallback rank.
  49602. * @returns the new fallback rank.
  49603. */
  49604. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49605. /**
  49606. * Add the required uniforms to the current list.
  49607. * @param uniforms defines the current uniform list.
  49608. */
  49609. static AddUniforms(uniforms: string[]): void;
  49610. /**
  49611. * Add the required samplers to the current list.
  49612. * @param samplers defines the current sampler list.
  49613. */
  49614. static AddSamplers(samplers: string[]): void;
  49615. /**
  49616. * Add the required uniforms to the current buffer.
  49617. * @param uniformBuffer defines the current uniform buffer.
  49618. */
  49619. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49620. /**
  49621. * Makes a duplicate of the current configuration into another one.
  49622. * @param configuration define the config where to copy the info
  49623. */
  49624. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49625. /**
  49626. * Serializes this Sub Surface configuration.
  49627. * @returns - An object with the serialized config.
  49628. */
  49629. serialize(): any;
  49630. /**
  49631. * Parses a anisotropy Configuration from a serialized object.
  49632. * @param source - Serialized object.
  49633. * @param scene Defines the scene we are parsing for
  49634. * @param rootUrl Defines the rootUrl to load from
  49635. */
  49636. parse(source: any, scene: Scene, rootUrl: string): void;
  49637. }
  49638. }
  49639. declare module BABYLON {
  49640. /** @hidden */
  49641. export var pbrFragmentDeclaration: {
  49642. name: string;
  49643. shader: string;
  49644. };
  49645. }
  49646. declare module BABYLON {
  49647. /** @hidden */
  49648. export var pbrUboDeclaration: {
  49649. name: string;
  49650. shader: string;
  49651. };
  49652. }
  49653. declare module BABYLON {
  49654. /** @hidden */
  49655. export var pbrFragmentExtraDeclaration: {
  49656. name: string;
  49657. shader: string;
  49658. };
  49659. }
  49660. declare module BABYLON {
  49661. /** @hidden */
  49662. export var pbrFragmentSamplersDeclaration: {
  49663. name: string;
  49664. shader: string;
  49665. };
  49666. }
  49667. declare module BABYLON {
  49668. /** @hidden */
  49669. export var pbrHelperFunctions: {
  49670. name: string;
  49671. shader: string;
  49672. };
  49673. }
  49674. declare module BABYLON {
  49675. /** @hidden */
  49676. export var harmonicsFunctions: {
  49677. name: string;
  49678. shader: string;
  49679. };
  49680. }
  49681. declare module BABYLON {
  49682. /** @hidden */
  49683. export var pbrDirectLightingSetupFunctions: {
  49684. name: string;
  49685. shader: string;
  49686. };
  49687. }
  49688. declare module BABYLON {
  49689. /** @hidden */
  49690. export var pbrDirectLightingFalloffFunctions: {
  49691. name: string;
  49692. shader: string;
  49693. };
  49694. }
  49695. declare module BABYLON {
  49696. /** @hidden */
  49697. export var pbrBRDFFunctions: {
  49698. name: string;
  49699. shader: string;
  49700. };
  49701. }
  49702. declare module BABYLON {
  49703. /** @hidden */
  49704. export var pbrDirectLightingFunctions: {
  49705. name: string;
  49706. shader: string;
  49707. };
  49708. }
  49709. declare module BABYLON {
  49710. /** @hidden */
  49711. export var pbrIBLFunctions: {
  49712. name: string;
  49713. shader: string;
  49714. };
  49715. }
  49716. declare module BABYLON {
  49717. /** @hidden */
  49718. export var pbrDebug: {
  49719. name: string;
  49720. shader: string;
  49721. };
  49722. }
  49723. declare module BABYLON {
  49724. /** @hidden */
  49725. export var pbrPixelShader: {
  49726. name: string;
  49727. shader: string;
  49728. };
  49729. }
  49730. declare module BABYLON {
  49731. /** @hidden */
  49732. export var pbrVertexDeclaration: {
  49733. name: string;
  49734. shader: string;
  49735. };
  49736. }
  49737. declare module BABYLON {
  49738. /** @hidden */
  49739. export var pbrVertexShader: {
  49740. name: string;
  49741. shader: string;
  49742. };
  49743. }
  49744. declare module BABYLON {
  49745. /**
  49746. * Manages the defines for the PBR Material.
  49747. * @hidden
  49748. */
  49749. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49750. PBR: boolean;
  49751. MAINUV1: boolean;
  49752. MAINUV2: boolean;
  49753. UV1: boolean;
  49754. UV2: boolean;
  49755. ALBEDO: boolean;
  49756. ALBEDODIRECTUV: number;
  49757. VERTEXCOLOR: boolean;
  49758. AMBIENT: boolean;
  49759. AMBIENTDIRECTUV: number;
  49760. AMBIENTINGRAYSCALE: boolean;
  49761. OPACITY: boolean;
  49762. VERTEXALPHA: boolean;
  49763. OPACITYDIRECTUV: number;
  49764. OPACITYRGB: boolean;
  49765. ALPHATEST: boolean;
  49766. DEPTHPREPASS: boolean;
  49767. ALPHABLEND: boolean;
  49768. ALPHAFROMALBEDO: boolean;
  49769. ALPHATESTVALUE: string;
  49770. SPECULAROVERALPHA: boolean;
  49771. RADIANCEOVERALPHA: boolean;
  49772. ALPHAFRESNEL: boolean;
  49773. LINEARALPHAFRESNEL: boolean;
  49774. PREMULTIPLYALPHA: boolean;
  49775. EMISSIVE: boolean;
  49776. EMISSIVEDIRECTUV: number;
  49777. REFLECTIVITY: boolean;
  49778. REFLECTIVITYDIRECTUV: number;
  49779. SPECULARTERM: boolean;
  49780. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49781. MICROSURFACEAUTOMATIC: boolean;
  49782. LODBASEDMICROSFURACE: boolean;
  49783. MICROSURFACEMAP: boolean;
  49784. MICROSURFACEMAPDIRECTUV: number;
  49785. METALLICWORKFLOW: boolean;
  49786. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49787. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49788. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49789. AOSTOREINMETALMAPRED: boolean;
  49790. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49791. ENVIRONMENTBRDF: boolean;
  49792. ENVIRONMENTBRDF_RGBD: boolean;
  49793. NORMAL: boolean;
  49794. TANGENT: boolean;
  49795. BUMP: boolean;
  49796. BUMPDIRECTUV: number;
  49797. OBJECTSPACE_NORMALMAP: boolean;
  49798. PARALLAX: boolean;
  49799. PARALLAXOCCLUSION: boolean;
  49800. NORMALXYSCALE: boolean;
  49801. LIGHTMAP: boolean;
  49802. LIGHTMAPDIRECTUV: number;
  49803. USELIGHTMAPASSHADOWMAP: boolean;
  49804. GAMMALIGHTMAP: boolean;
  49805. RGBDLIGHTMAP: boolean;
  49806. REFLECTION: boolean;
  49807. REFLECTIONMAP_3D: boolean;
  49808. REFLECTIONMAP_SPHERICAL: boolean;
  49809. REFLECTIONMAP_PLANAR: boolean;
  49810. REFLECTIONMAP_CUBIC: boolean;
  49811. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49812. REFLECTIONMAP_PROJECTION: boolean;
  49813. REFLECTIONMAP_SKYBOX: boolean;
  49814. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49815. REFLECTIONMAP_EXPLICIT: boolean;
  49816. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49817. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49818. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49819. INVERTCUBICMAP: boolean;
  49820. USESPHERICALFROMREFLECTIONMAP: boolean;
  49821. USEIRRADIANCEMAP: boolean;
  49822. SPHERICAL_HARMONICS: boolean;
  49823. USESPHERICALINVERTEX: boolean;
  49824. REFLECTIONMAP_OPPOSITEZ: boolean;
  49825. LODINREFLECTIONALPHA: boolean;
  49826. GAMMAREFLECTION: boolean;
  49827. RGBDREFLECTION: boolean;
  49828. LINEARSPECULARREFLECTION: boolean;
  49829. RADIANCEOCCLUSION: boolean;
  49830. HORIZONOCCLUSION: boolean;
  49831. INSTANCES: boolean;
  49832. NUM_BONE_INFLUENCERS: number;
  49833. BonesPerMesh: number;
  49834. BONETEXTURE: boolean;
  49835. NONUNIFORMSCALING: boolean;
  49836. MORPHTARGETS: boolean;
  49837. MORPHTARGETS_NORMAL: boolean;
  49838. MORPHTARGETS_TANGENT: boolean;
  49839. MORPHTARGETS_UV: boolean;
  49840. NUM_MORPH_INFLUENCERS: number;
  49841. IMAGEPROCESSING: boolean;
  49842. VIGNETTE: boolean;
  49843. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49844. VIGNETTEBLENDMODEOPAQUE: boolean;
  49845. TONEMAPPING: boolean;
  49846. TONEMAPPING_ACES: boolean;
  49847. CONTRAST: boolean;
  49848. COLORCURVES: boolean;
  49849. COLORGRADING: boolean;
  49850. COLORGRADING3D: boolean;
  49851. SAMPLER3DGREENDEPTH: boolean;
  49852. SAMPLER3DBGRMAP: boolean;
  49853. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49854. EXPOSURE: boolean;
  49855. MULTIVIEW: boolean;
  49856. USEPHYSICALLIGHTFALLOFF: boolean;
  49857. USEGLTFLIGHTFALLOFF: boolean;
  49858. TWOSIDEDLIGHTING: boolean;
  49859. SHADOWFLOAT: boolean;
  49860. CLIPPLANE: boolean;
  49861. CLIPPLANE2: boolean;
  49862. CLIPPLANE3: boolean;
  49863. CLIPPLANE4: boolean;
  49864. CLIPPLANE5: boolean;
  49865. CLIPPLANE6: boolean;
  49866. POINTSIZE: boolean;
  49867. FOG: boolean;
  49868. LOGARITHMICDEPTH: boolean;
  49869. FORCENORMALFORWARD: boolean;
  49870. SPECULARAA: boolean;
  49871. CLEARCOAT: boolean;
  49872. CLEARCOAT_DEFAULTIOR: boolean;
  49873. CLEARCOAT_TEXTURE: boolean;
  49874. CLEARCOAT_TEXTUREDIRECTUV: number;
  49875. CLEARCOAT_BUMP: boolean;
  49876. CLEARCOAT_BUMPDIRECTUV: number;
  49877. CLEARCOAT_TINT: boolean;
  49878. CLEARCOAT_TINT_TEXTURE: boolean;
  49879. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49880. ANISOTROPIC: boolean;
  49881. ANISOTROPIC_TEXTURE: boolean;
  49882. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49883. BRDF_V_HEIGHT_CORRELATED: boolean;
  49884. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49885. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49886. SHEEN: boolean;
  49887. SHEEN_TEXTURE: boolean;
  49888. SHEEN_TEXTUREDIRECTUV: number;
  49889. SHEEN_LINKWITHALBEDO: boolean;
  49890. SUBSURFACE: boolean;
  49891. SS_REFRACTION: boolean;
  49892. SS_TRANSLUCENCY: boolean;
  49893. SS_SCATERRING: boolean;
  49894. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49895. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49896. SS_REFRACTIONMAP_3D: boolean;
  49897. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49898. SS_LODINREFRACTIONALPHA: boolean;
  49899. SS_GAMMAREFRACTION: boolean;
  49900. SS_RGBDREFRACTION: boolean;
  49901. SS_LINEARSPECULARREFRACTION: boolean;
  49902. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49903. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49904. UNLIT: boolean;
  49905. DEBUGMODE: number;
  49906. /**
  49907. * Initializes the PBR Material defines.
  49908. */
  49909. constructor();
  49910. /**
  49911. * Resets the PBR Material defines.
  49912. */
  49913. reset(): void;
  49914. }
  49915. /**
  49916. * The Physically based material base class of BJS.
  49917. *
  49918. * This offers the main features of a standard PBR material.
  49919. * For more information, please refer to the documentation :
  49920. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49921. */
  49922. export abstract class PBRBaseMaterial extends PushMaterial {
  49923. /**
  49924. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49925. */
  49926. static readonly PBRMATERIAL_OPAQUE: number;
  49927. /**
  49928. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49929. */
  49930. static readonly PBRMATERIAL_ALPHATEST: number;
  49931. /**
  49932. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49933. */
  49934. static readonly PBRMATERIAL_ALPHABLEND: number;
  49935. /**
  49936. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49937. * They are also discarded below the alpha cutoff threshold to improve performances.
  49938. */
  49939. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49940. /**
  49941. * Defines the default value of how much AO map is occluding the analytical lights
  49942. * (point spot...).
  49943. */
  49944. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49945. /**
  49946. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49947. */
  49948. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49949. /**
  49950. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49951. * to enhance interoperability with other engines.
  49952. */
  49953. static readonly LIGHTFALLOFF_GLTF: number;
  49954. /**
  49955. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49956. * to enhance interoperability with other materials.
  49957. */
  49958. static readonly LIGHTFALLOFF_STANDARD: number;
  49959. /**
  49960. * Intensity of the direct lights e.g. the four lights available in your scene.
  49961. * This impacts both the direct diffuse and specular highlights.
  49962. */
  49963. protected _directIntensity: number;
  49964. /**
  49965. * Intensity of the emissive part of the material.
  49966. * This helps controlling the emissive effect without modifying the emissive color.
  49967. */
  49968. protected _emissiveIntensity: number;
  49969. /**
  49970. * Intensity of the environment e.g. how much the environment will light the object
  49971. * either through harmonics for rough material or through the refelction for shiny ones.
  49972. */
  49973. protected _environmentIntensity: number;
  49974. /**
  49975. * This is a special control allowing the reduction of the specular highlights coming from the
  49976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49977. */
  49978. protected _specularIntensity: number;
  49979. /**
  49980. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49981. */
  49982. private _lightingInfos;
  49983. /**
  49984. * Debug Control allowing disabling the bump map on this material.
  49985. */
  49986. protected _disableBumpMap: boolean;
  49987. /**
  49988. * AKA Diffuse Texture in standard nomenclature.
  49989. */
  49990. protected _albedoTexture: Nullable<BaseTexture>;
  49991. /**
  49992. * AKA Occlusion Texture in other nomenclature.
  49993. */
  49994. protected _ambientTexture: Nullable<BaseTexture>;
  49995. /**
  49996. * AKA Occlusion Texture Intensity in other nomenclature.
  49997. */
  49998. protected _ambientTextureStrength: number;
  49999. /**
  50000. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50001. * 1 means it completely occludes it
  50002. * 0 mean it has no impact
  50003. */
  50004. protected _ambientTextureImpactOnAnalyticalLights: number;
  50005. /**
  50006. * Stores the alpha values in a texture.
  50007. */
  50008. protected _opacityTexture: Nullable<BaseTexture>;
  50009. /**
  50010. * Stores the reflection values in a texture.
  50011. */
  50012. protected _reflectionTexture: Nullable<BaseTexture>;
  50013. /**
  50014. * Stores the emissive values in a texture.
  50015. */
  50016. protected _emissiveTexture: Nullable<BaseTexture>;
  50017. /**
  50018. * AKA Specular texture in other nomenclature.
  50019. */
  50020. protected _reflectivityTexture: Nullable<BaseTexture>;
  50021. /**
  50022. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50023. */
  50024. protected _metallicTexture: Nullable<BaseTexture>;
  50025. /**
  50026. * Specifies the metallic scalar of the metallic/roughness workflow.
  50027. * Can also be used to scale the metalness values of the metallic texture.
  50028. */
  50029. protected _metallic: Nullable<number>;
  50030. /**
  50031. * Specifies the roughness scalar of the metallic/roughness workflow.
  50032. * Can also be used to scale the roughness values of the metallic texture.
  50033. */
  50034. protected _roughness: Nullable<number>;
  50035. /**
  50036. * Specifies the an F0 factor to help configuring the material F0.
  50037. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50038. * to 0.5 the previously hard coded value stays the same.
  50039. * Can also be used to scale the F0 values of the metallic texture.
  50040. */
  50041. protected _metallicF0Factor: number;
  50042. /**
  50043. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50044. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50045. * your expectation as it multiplies with the texture data.
  50046. */
  50047. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50048. /**
  50049. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50050. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50051. */
  50052. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50053. /**
  50054. * Stores surface normal data used to displace a mesh in a texture.
  50055. */
  50056. protected _bumpTexture: Nullable<BaseTexture>;
  50057. /**
  50058. * Stores the pre-calculated light information of a mesh in a texture.
  50059. */
  50060. protected _lightmapTexture: Nullable<BaseTexture>;
  50061. /**
  50062. * The color of a material in ambient lighting.
  50063. */
  50064. protected _ambientColor: Color3;
  50065. /**
  50066. * AKA Diffuse Color in other nomenclature.
  50067. */
  50068. protected _albedoColor: Color3;
  50069. /**
  50070. * AKA Specular Color in other nomenclature.
  50071. */
  50072. protected _reflectivityColor: Color3;
  50073. /**
  50074. * The color applied when light is reflected from a material.
  50075. */
  50076. protected _reflectionColor: Color3;
  50077. /**
  50078. * The color applied when light is emitted from a material.
  50079. */
  50080. protected _emissiveColor: Color3;
  50081. /**
  50082. * AKA Glossiness in other nomenclature.
  50083. */
  50084. protected _microSurface: number;
  50085. /**
  50086. * Specifies that the material will use the light map as a show map.
  50087. */
  50088. protected _useLightmapAsShadowmap: boolean;
  50089. /**
  50090. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50091. * makes the reflect vector face the model (under horizon).
  50092. */
  50093. protected _useHorizonOcclusion: boolean;
  50094. /**
  50095. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50096. * too much the area relying on ambient texture to define their ambient occlusion.
  50097. */
  50098. protected _useRadianceOcclusion: boolean;
  50099. /**
  50100. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50101. */
  50102. protected _useAlphaFromAlbedoTexture: boolean;
  50103. /**
  50104. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50105. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50106. */
  50107. protected _useSpecularOverAlpha: boolean;
  50108. /**
  50109. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50110. */
  50111. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50112. /**
  50113. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50114. */
  50115. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50116. /**
  50117. * Specifies if the metallic texture contains the roughness information in its green channel.
  50118. */
  50119. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50120. /**
  50121. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50122. */
  50123. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50124. /**
  50125. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50126. */
  50127. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50128. /**
  50129. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50130. */
  50131. protected _useAmbientInGrayScale: boolean;
  50132. /**
  50133. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50134. * The material will try to infer what glossiness each pixel should be.
  50135. */
  50136. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50137. /**
  50138. * Defines the falloff type used in this material.
  50139. * It by default is Physical.
  50140. */
  50141. protected _lightFalloff: number;
  50142. /**
  50143. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50144. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50145. */
  50146. protected _useRadianceOverAlpha: boolean;
  50147. /**
  50148. * Allows using an object space normal map (instead of tangent space).
  50149. */
  50150. protected _useObjectSpaceNormalMap: boolean;
  50151. /**
  50152. * Allows using the bump map in parallax mode.
  50153. */
  50154. protected _useParallax: boolean;
  50155. /**
  50156. * Allows using the bump map in parallax occlusion mode.
  50157. */
  50158. protected _useParallaxOcclusion: boolean;
  50159. /**
  50160. * Controls the scale bias of the parallax mode.
  50161. */
  50162. protected _parallaxScaleBias: number;
  50163. /**
  50164. * If sets to true, disables all the lights affecting the material.
  50165. */
  50166. protected _disableLighting: boolean;
  50167. /**
  50168. * Number of Simultaneous lights allowed on the material.
  50169. */
  50170. protected _maxSimultaneousLights: number;
  50171. /**
  50172. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50173. */
  50174. protected _invertNormalMapX: boolean;
  50175. /**
  50176. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50177. */
  50178. protected _invertNormalMapY: boolean;
  50179. /**
  50180. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50181. */
  50182. protected _twoSidedLighting: boolean;
  50183. /**
  50184. * Defines the alpha limits in alpha test mode.
  50185. */
  50186. protected _alphaCutOff: number;
  50187. /**
  50188. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50189. */
  50190. protected _forceAlphaTest: boolean;
  50191. /**
  50192. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50193. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50194. */
  50195. protected _useAlphaFresnel: boolean;
  50196. /**
  50197. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50198. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50199. */
  50200. protected _useLinearAlphaFresnel: boolean;
  50201. /**
  50202. * The transparency mode of the material.
  50203. */
  50204. protected _transparencyMode: Nullable<number>;
  50205. /**
  50206. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50207. * from cos thetav and roughness:
  50208. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50209. */
  50210. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50211. /**
  50212. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50213. */
  50214. protected _forceIrradianceInFragment: boolean;
  50215. /**
  50216. * Force normal to face away from face.
  50217. */
  50218. protected _forceNormalForward: boolean;
  50219. /**
  50220. * Enables specular anti aliasing in the PBR shader.
  50221. * It will both interacts on the Geometry for analytical and IBL lighting.
  50222. * It also prefilter the roughness map based on the bump values.
  50223. */
  50224. protected _enableSpecularAntiAliasing: boolean;
  50225. /**
  50226. * Default configuration related to image processing available in the PBR Material.
  50227. */
  50228. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50229. /**
  50230. * Keep track of the image processing observer to allow dispose and replace.
  50231. */
  50232. private _imageProcessingObserver;
  50233. /**
  50234. * Attaches a new image processing configuration to the PBR Material.
  50235. * @param configuration
  50236. */
  50237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50238. /**
  50239. * Stores the available render targets.
  50240. */
  50241. private _renderTargets;
  50242. /**
  50243. * Sets the global ambient color for the material used in lighting calculations.
  50244. */
  50245. private _globalAmbientColor;
  50246. /**
  50247. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50248. */
  50249. private _useLogarithmicDepth;
  50250. /**
  50251. * If set to true, no lighting calculations will be applied.
  50252. */
  50253. private _unlit;
  50254. private _debugMode;
  50255. /**
  50256. * @hidden
  50257. * This is reserved for the inspector.
  50258. * Defines the material debug mode.
  50259. * It helps seeing only some components of the material while troubleshooting.
  50260. */
  50261. debugMode: number;
  50262. /**
  50263. * @hidden
  50264. * This is reserved for the inspector.
  50265. * Specify from where on screen the debug mode should start.
  50266. * The value goes from -1 (full screen) to 1 (not visible)
  50267. * It helps with side by side comparison against the final render
  50268. * This defaults to -1
  50269. */
  50270. private debugLimit;
  50271. /**
  50272. * @hidden
  50273. * This is reserved for the inspector.
  50274. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50275. * You can use the factor to better multiply the final value.
  50276. */
  50277. private debugFactor;
  50278. /**
  50279. * Defines the clear coat layer parameters for the material.
  50280. */
  50281. readonly clearCoat: PBRClearCoatConfiguration;
  50282. /**
  50283. * Defines the anisotropic parameters for the material.
  50284. */
  50285. readonly anisotropy: PBRAnisotropicConfiguration;
  50286. /**
  50287. * Defines the BRDF parameters for the material.
  50288. */
  50289. readonly brdf: PBRBRDFConfiguration;
  50290. /**
  50291. * Defines the Sheen parameters for the material.
  50292. */
  50293. readonly sheen: PBRSheenConfiguration;
  50294. /**
  50295. * Defines the SubSurface parameters for the material.
  50296. */
  50297. readonly subSurface: PBRSubSurfaceConfiguration;
  50298. /**
  50299. * Custom callback helping to override the default shader used in the material.
  50300. */
  50301. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50302. protected _rebuildInParallel: boolean;
  50303. /**
  50304. * Instantiates a new PBRMaterial instance.
  50305. *
  50306. * @param name The material name
  50307. * @param scene The scene the material will be use in.
  50308. */
  50309. constructor(name: string, scene: Scene);
  50310. /**
  50311. * Gets a boolean indicating that current material needs to register RTT
  50312. */
  50313. get hasRenderTargetTextures(): boolean;
  50314. /**
  50315. * Gets the name of the material class.
  50316. */
  50317. getClassName(): string;
  50318. /**
  50319. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50320. */
  50321. get useLogarithmicDepth(): boolean;
  50322. /**
  50323. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50324. */
  50325. set useLogarithmicDepth(value: boolean);
  50326. /**
  50327. * Gets the current transparency mode.
  50328. */
  50329. get transparencyMode(): Nullable<number>;
  50330. /**
  50331. * Sets the transparency mode of the material.
  50332. *
  50333. * | Value | Type | Description |
  50334. * | ----- | ----------------------------------- | ----------- |
  50335. * | 0 | OPAQUE | |
  50336. * | 1 | ALPHATEST | |
  50337. * | 2 | ALPHABLEND | |
  50338. * | 3 | ALPHATESTANDBLEND | |
  50339. *
  50340. */
  50341. set transparencyMode(value: Nullable<number>);
  50342. /**
  50343. * Returns true if alpha blending should be disabled.
  50344. */
  50345. private get _disableAlphaBlending();
  50346. /**
  50347. * Specifies whether or not this material should be rendered in alpha blend mode.
  50348. */
  50349. needAlphaBlending(): boolean;
  50350. /**
  50351. * Specifies if the mesh will require alpha blending.
  50352. * @param mesh - BJS mesh.
  50353. */
  50354. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50355. /**
  50356. * Specifies whether or not this material should be rendered in alpha test mode.
  50357. */
  50358. needAlphaTesting(): boolean;
  50359. /**
  50360. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50361. */
  50362. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50363. /**
  50364. * Gets the texture used for the alpha test.
  50365. */
  50366. getAlphaTestTexture(): Nullable<BaseTexture>;
  50367. /**
  50368. * Specifies that the submesh is ready to be used.
  50369. * @param mesh - BJS mesh.
  50370. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50371. * @param useInstances - Specifies that instances should be used.
  50372. * @returns - boolean indicating that the submesh is ready or not.
  50373. */
  50374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50375. /**
  50376. * Specifies if the material uses metallic roughness workflow.
  50377. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50378. */
  50379. isMetallicWorkflow(): boolean;
  50380. private _prepareEffect;
  50381. private _prepareDefines;
  50382. /**
  50383. * Force shader compilation
  50384. */
  50385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50386. /**
  50387. * Initializes the uniform buffer layout for the shader.
  50388. */
  50389. buildUniformLayout(): void;
  50390. /**
  50391. * Unbinds the material from the mesh
  50392. */
  50393. unbind(): void;
  50394. /**
  50395. * Binds the submesh data.
  50396. * @param world - The world matrix.
  50397. * @param mesh - The BJS mesh.
  50398. * @param subMesh - A submesh of the BJS mesh.
  50399. */
  50400. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50401. /**
  50402. * Returns the animatable textures.
  50403. * @returns - Array of animatable textures.
  50404. */
  50405. getAnimatables(): IAnimatable[];
  50406. /**
  50407. * Returns the texture used for reflections.
  50408. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50409. */
  50410. private _getReflectionTexture;
  50411. /**
  50412. * Returns an array of the actively used textures.
  50413. * @returns - Array of BaseTextures
  50414. */
  50415. getActiveTextures(): BaseTexture[];
  50416. /**
  50417. * Checks to see if a texture is used in the material.
  50418. * @param texture - Base texture to use.
  50419. * @returns - Boolean specifying if a texture is used in the material.
  50420. */
  50421. hasTexture(texture: BaseTexture): boolean;
  50422. /**
  50423. * Disposes the resources of the material.
  50424. * @param forceDisposeEffect - Forces the disposal of effects.
  50425. * @param forceDisposeTextures - Forces the disposal of all textures.
  50426. */
  50427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50428. }
  50429. }
  50430. declare module BABYLON {
  50431. /**
  50432. * The Physically based material of BJS.
  50433. *
  50434. * This offers the main features of a standard PBR material.
  50435. * For more information, please refer to the documentation :
  50436. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50437. */
  50438. export class PBRMaterial extends PBRBaseMaterial {
  50439. /**
  50440. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50441. */
  50442. static readonly PBRMATERIAL_OPAQUE: number;
  50443. /**
  50444. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50445. */
  50446. static readonly PBRMATERIAL_ALPHATEST: number;
  50447. /**
  50448. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50449. */
  50450. static readonly PBRMATERIAL_ALPHABLEND: number;
  50451. /**
  50452. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50453. * They are also discarded below the alpha cutoff threshold to improve performances.
  50454. */
  50455. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50456. /**
  50457. * Defines the default value of how much AO map is occluding the analytical lights
  50458. * (point spot...).
  50459. */
  50460. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50461. /**
  50462. * Intensity of the direct lights e.g. the four lights available in your scene.
  50463. * This impacts both the direct diffuse and specular highlights.
  50464. */
  50465. directIntensity: number;
  50466. /**
  50467. * Intensity of the emissive part of the material.
  50468. * This helps controlling the emissive effect without modifying the emissive color.
  50469. */
  50470. emissiveIntensity: number;
  50471. /**
  50472. * Intensity of the environment e.g. how much the environment will light the object
  50473. * either through harmonics for rough material or through the refelction for shiny ones.
  50474. */
  50475. environmentIntensity: number;
  50476. /**
  50477. * This is a special control allowing the reduction of the specular highlights coming from the
  50478. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50479. */
  50480. specularIntensity: number;
  50481. /**
  50482. * Debug Control allowing disabling the bump map on this material.
  50483. */
  50484. disableBumpMap: boolean;
  50485. /**
  50486. * AKA Diffuse Texture in standard nomenclature.
  50487. */
  50488. albedoTexture: BaseTexture;
  50489. /**
  50490. * AKA Occlusion Texture in other nomenclature.
  50491. */
  50492. ambientTexture: BaseTexture;
  50493. /**
  50494. * AKA Occlusion Texture Intensity in other nomenclature.
  50495. */
  50496. ambientTextureStrength: number;
  50497. /**
  50498. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50499. * 1 means it completely occludes it
  50500. * 0 mean it has no impact
  50501. */
  50502. ambientTextureImpactOnAnalyticalLights: number;
  50503. /**
  50504. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  50505. */
  50506. opacityTexture: BaseTexture;
  50507. /**
  50508. * Stores the reflection values in a texture.
  50509. */
  50510. reflectionTexture: Nullable<BaseTexture>;
  50511. /**
  50512. * Stores the emissive values in a texture.
  50513. */
  50514. emissiveTexture: BaseTexture;
  50515. /**
  50516. * AKA Specular texture in other nomenclature.
  50517. */
  50518. reflectivityTexture: BaseTexture;
  50519. /**
  50520. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50521. */
  50522. metallicTexture: BaseTexture;
  50523. /**
  50524. * Specifies the metallic scalar of the metallic/roughness workflow.
  50525. * Can also be used to scale the metalness values of the metallic texture.
  50526. */
  50527. metallic: Nullable<number>;
  50528. /**
  50529. * Specifies the roughness scalar of the metallic/roughness workflow.
  50530. * Can also be used to scale the roughness values of the metallic texture.
  50531. */
  50532. roughness: Nullable<number>;
  50533. /**
  50534. * Specifies the an F0 factor to help configuring the material F0.
  50535. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50536. * to 0.5 the previously hard coded value stays the same.
  50537. * Can also be used to scale the F0 values of the metallic texture.
  50538. */
  50539. metallicF0Factor: number;
  50540. /**
  50541. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50542. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50543. * your expectation as it multiplies with the texture data.
  50544. */
  50545. useMetallicF0FactorFromMetallicTexture: boolean;
  50546. /**
  50547. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50548. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50549. */
  50550. microSurfaceTexture: BaseTexture;
  50551. /**
  50552. * Stores surface normal data used to displace a mesh in a texture.
  50553. */
  50554. bumpTexture: BaseTexture;
  50555. /**
  50556. * Stores the pre-calculated light information of a mesh in a texture.
  50557. */
  50558. lightmapTexture: BaseTexture;
  50559. /**
  50560. * Stores the refracted light information in a texture.
  50561. */
  50562. get refractionTexture(): Nullable<BaseTexture>;
  50563. set refractionTexture(value: Nullable<BaseTexture>);
  50564. /**
  50565. * The color of a material in ambient lighting.
  50566. */
  50567. ambientColor: Color3;
  50568. /**
  50569. * AKA Diffuse Color in other nomenclature.
  50570. */
  50571. albedoColor: Color3;
  50572. /**
  50573. * AKA Specular Color in other nomenclature.
  50574. */
  50575. reflectivityColor: Color3;
  50576. /**
  50577. * The color reflected from the material.
  50578. */
  50579. reflectionColor: Color3;
  50580. /**
  50581. * The color emitted from the material.
  50582. */
  50583. emissiveColor: Color3;
  50584. /**
  50585. * AKA Glossiness in other nomenclature.
  50586. */
  50587. microSurface: number;
  50588. /**
  50589. * source material index of refraction (IOR)' / 'destination material IOR.
  50590. */
  50591. get indexOfRefraction(): number;
  50592. set indexOfRefraction(value: number);
  50593. /**
  50594. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50595. */
  50596. get invertRefractionY(): boolean;
  50597. set invertRefractionY(value: boolean);
  50598. /**
  50599. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50600. * Materials half opaque for instance using refraction could benefit from this control.
  50601. */
  50602. get linkRefractionWithTransparency(): boolean;
  50603. set linkRefractionWithTransparency(value: boolean);
  50604. /**
  50605. * If true, the light map contains occlusion information instead of lighting info.
  50606. */
  50607. useLightmapAsShadowmap: boolean;
  50608. /**
  50609. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50610. */
  50611. useAlphaFromAlbedoTexture: boolean;
  50612. /**
  50613. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50614. */
  50615. forceAlphaTest: boolean;
  50616. /**
  50617. * Defines the alpha limits in alpha test mode.
  50618. */
  50619. alphaCutOff: number;
  50620. /**
  50621. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50622. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50623. */
  50624. useSpecularOverAlpha: boolean;
  50625. /**
  50626. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50627. */
  50628. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50629. /**
  50630. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50631. */
  50632. useRoughnessFromMetallicTextureAlpha: boolean;
  50633. /**
  50634. * Specifies if the metallic texture contains the roughness information in its green channel.
  50635. */
  50636. useRoughnessFromMetallicTextureGreen: boolean;
  50637. /**
  50638. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50639. */
  50640. useMetallnessFromMetallicTextureBlue: boolean;
  50641. /**
  50642. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50643. */
  50644. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50645. /**
  50646. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50647. */
  50648. useAmbientInGrayScale: boolean;
  50649. /**
  50650. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50651. * The material will try to infer what glossiness each pixel should be.
  50652. */
  50653. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50654. /**
  50655. * BJS is using an harcoded light falloff based on a manually sets up range.
  50656. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50657. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50658. */
  50659. get usePhysicalLightFalloff(): boolean;
  50660. /**
  50661. * BJS is using an harcoded light falloff based on a manually sets up range.
  50662. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50663. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50664. */
  50665. set usePhysicalLightFalloff(value: boolean);
  50666. /**
  50667. * In order to support the falloff compatibility with gltf, a special mode has been added
  50668. * to reproduce the gltf light falloff.
  50669. */
  50670. get useGLTFLightFalloff(): boolean;
  50671. /**
  50672. * In order to support the falloff compatibility with gltf, a special mode has been added
  50673. * to reproduce the gltf light falloff.
  50674. */
  50675. set useGLTFLightFalloff(value: boolean);
  50676. /**
  50677. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50678. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50679. */
  50680. useRadianceOverAlpha: boolean;
  50681. /**
  50682. * Allows using an object space normal map (instead of tangent space).
  50683. */
  50684. useObjectSpaceNormalMap: boolean;
  50685. /**
  50686. * Allows using the bump map in parallax mode.
  50687. */
  50688. useParallax: boolean;
  50689. /**
  50690. * Allows using the bump map in parallax occlusion mode.
  50691. */
  50692. useParallaxOcclusion: boolean;
  50693. /**
  50694. * Controls the scale bias of the parallax mode.
  50695. */
  50696. parallaxScaleBias: number;
  50697. /**
  50698. * If sets to true, disables all the lights affecting the material.
  50699. */
  50700. disableLighting: boolean;
  50701. /**
  50702. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50703. */
  50704. forceIrradianceInFragment: boolean;
  50705. /**
  50706. * Number of Simultaneous lights allowed on the material.
  50707. */
  50708. maxSimultaneousLights: number;
  50709. /**
  50710. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50711. */
  50712. invertNormalMapX: boolean;
  50713. /**
  50714. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50715. */
  50716. invertNormalMapY: boolean;
  50717. /**
  50718. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50719. */
  50720. twoSidedLighting: boolean;
  50721. /**
  50722. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50723. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50724. */
  50725. useAlphaFresnel: boolean;
  50726. /**
  50727. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50728. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50729. */
  50730. useLinearAlphaFresnel: boolean;
  50731. /**
  50732. * Let user defines the brdf lookup texture used for IBL.
  50733. * A default 8bit version is embedded but you could point at :
  50734. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50735. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50736. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50737. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50738. */
  50739. environmentBRDFTexture: Nullable<BaseTexture>;
  50740. /**
  50741. * Force normal to face away from face.
  50742. */
  50743. forceNormalForward: boolean;
  50744. /**
  50745. * Enables specular anti aliasing in the PBR shader.
  50746. * It will both interacts on the Geometry for analytical and IBL lighting.
  50747. * It also prefilter the roughness map based on the bump values.
  50748. */
  50749. enableSpecularAntiAliasing: boolean;
  50750. /**
  50751. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50752. * makes the reflect vector face the model (under horizon).
  50753. */
  50754. useHorizonOcclusion: boolean;
  50755. /**
  50756. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50757. * too much the area relying on ambient texture to define their ambient occlusion.
  50758. */
  50759. useRadianceOcclusion: boolean;
  50760. /**
  50761. * If set to true, no lighting calculations will be applied.
  50762. */
  50763. unlit: boolean;
  50764. /**
  50765. * Gets the image processing configuration used either in this material.
  50766. */
  50767. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  50768. /**
  50769. * Sets the Default image processing configuration used either in the this material.
  50770. *
  50771. * If sets to null, the scene one is in use.
  50772. */
  50773. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  50774. /**
  50775. * Gets wether the color curves effect is enabled.
  50776. */
  50777. get cameraColorCurvesEnabled(): boolean;
  50778. /**
  50779. * Sets wether the color curves effect is enabled.
  50780. */
  50781. set cameraColorCurvesEnabled(value: boolean);
  50782. /**
  50783. * Gets wether the color grading effect is enabled.
  50784. */
  50785. get cameraColorGradingEnabled(): boolean;
  50786. /**
  50787. * Gets wether the color grading effect is enabled.
  50788. */
  50789. set cameraColorGradingEnabled(value: boolean);
  50790. /**
  50791. * Gets wether tonemapping is enabled or not.
  50792. */
  50793. get cameraToneMappingEnabled(): boolean;
  50794. /**
  50795. * Sets wether tonemapping is enabled or not
  50796. */
  50797. set cameraToneMappingEnabled(value: boolean);
  50798. /**
  50799. * The camera exposure used on this material.
  50800. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50801. * This corresponds to a photographic exposure.
  50802. */
  50803. get cameraExposure(): number;
  50804. /**
  50805. * The camera exposure used on this material.
  50806. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50807. * This corresponds to a photographic exposure.
  50808. */
  50809. set cameraExposure(value: number);
  50810. /**
  50811. * Gets The camera contrast used on this material.
  50812. */
  50813. get cameraContrast(): number;
  50814. /**
  50815. * Sets The camera contrast used on this material.
  50816. */
  50817. set cameraContrast(value: number);
  50818. /**
  50819. * Gets the Color Grading 2D Lookup Texture.
  50820. */
  50821. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50822. /**
  50823. * Sets the Color Grading 2D Lookup Texture.
  50824. */
  50825. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50826. /**
  50827. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50828. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50829. * 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;
  50830. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50831. */
  50832. get cameraColorCurves(): Nullable<ColorCurves>;
  50833. /**
  50834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50836. * 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;
  50837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50838. */
  50839. set cameraColorCurves(value: Nullable<ColorCurves>);
  50840. /**
  50841. * Instantiates a new PBRMaterial instance.
  50842. *
  50843. * @param name The material name
  50844. * @param scene The scene the material will be use in.
  50845. */
  50846. constructor(name: string, scene: Scene);
  50847. /**
  50848. * Returns the name of this material class.
  50849. */
  50850. getClassName(): string;
  50851. /**
  50852. * Makes a duplicate of the current material.
  50853. * @param name - name to use for the new material.
  50854. */
  50855. clone(name: string): PBRMaterial;
  50856. /**
  50857. * Serializes this PBR Material.
  50858. * @returns - An object with the serialized material.
  50859. */
  50860. serialize(): any;
  50861. /**
  50862. * Parses a PBR Material from a serialized object.
  50863. * @param source - Serialized object.
  50864. * @param scene - BJS scene instance.
  50865. * @param rootUrl - url for the scene object
  50866. * @returns - PBRMaterial
  50867. */
  50868. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50869. }
  50870. }
  50871. declare module BABYLON {
  50872. /**
  50873. * Direct draw surface info
  50874. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50875. */
  50876. export interface DDSInfo {
  50877. /**
  50878. * Width of the texture
  50879. */
  50880. width: number;
  50881. /**
  50882. * Width of the texture
  50883. */
  50884. height: number;
  50885. /**
  50886. * Number of Mipmaps for the texture
  50887. * @see https://en.wikipedia.org/wiki/Mipmap
  50888. */
  50889. mipmapCount: number;
  50890. /**
  50891. * If the textures format is a known fourCC format
  50892. * @see https://www.fourcc.org/
  50893. */
  50894. isFourCC: boolean;
  50895. /**
  50896. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50897. */
  50898. isRGB: boolean;
  50899. /**
  50900. * If the texture is a lumincance format
  50901. */
  50902. isLuminance: boolean;
  50903. /**
  50904. * If this is a cube texture
  50905. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50906. */
  50907. isCube: boolean;
  50908. /**
  50909. * If the texture is a compressed format eg. FOURCC_DXT1
  50910. */
  50911. isCompressed: boolean;
  50912. /**
  50913. * The dxgiFormat of the texture
  50914. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50915. */
  50916. dxgiFormat: number;
  50917. /**
  50918. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50919. */
  50920. textureType: number;
  50921. /**
  50922. * Sphericle polynomial created for the dds texture
  50923. */
  50924. sphericalPolynomial?: SphericalPolynomial;
  50925. }
  50926. /**
  50927. * Class used to provide DDS decompression tools
  50928. */
  50929. export class DDSTools {
  50930. /**
  50931. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50932. */
  50933. static StoreLODInAlphaChannel: boolean;
  50934. /**
  50935. * Gets DDS information from an array buffer
  50936. * @param arrayBuffer defines the array buffer to read data from
  50937. * @returns the DDS information
  50938. */
  50939. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50940. private static _FloatView;
  50941. private static _Int32View;
  50942. private static _ToHalfFloat;
  50943. private static _FromHalfFloat;
  50944. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50945. private static _GetHalfFloatRGBAArrayBuffer;
  50946. private static _GetFloatRGBAArrayBuffer;
  50947. private static _GetFloatAsUIntRGBAArrayBuffer;
  50948. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50949. private static _GetRGBAArrayBuffer;
  50950. private static _ExtractLongWordOrder;
  50951. private static _GetRGBArrayBuffer;
  50952. private static _GetLuminanceArrayBuffer;
  50953. /**
  50954. * Uploads DDS Levels to a Babylon Texture
  50955. * @hidden
  50956. */
  50957. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50958. }
  50959. interface ThinEngine {
  50960. /**
  50961. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50962. * @param rootUrl defines the url where the file to load is located
  50963. * @param scene defines the current scene
  50964. * @param lodScale defines scale to apply to the mip map selection
  50965. * @param lodOffset defines offset to apply to the mip map selection
  50966. * @param onLoad defines an optional callback raised when the texture is loaded
  50967. * @param onError defines an optional callback raised if there is an issue to load the texture
  50968. * @param format defines the format of the data
  50969. * @param forcedExtension defines the extension to use to pick the right loader
  50970. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50971. * @returns the cube texture as an InternalTexture
  50972. */
  50973. 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;
  50974. }
  50975. }
  50976. declare module BABYLON {
  50977. /**
  50978. * Implementation of the DDS Texture Loader.
  50979. * @hidden
  50980. */
  50981. export class _DDSTextureLoader implements IInternalTextureLoader {
  50982. /**
  50983. * Defines wether the loader supports cascade loading the different faces.
  50984. */
  50985. readonly supportCascades: boolean;
  50986. /**
  50987. * This returns if the loader support the current file information.
  50988. * @param extension defines the file extension of the file being loaded
  50989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50990. * @param fallback defines the fallback internal texture if any
  50991. * @param isBase64 defines whether the texture is encoded as a base64
  50992. * @param isBuffer defines whether the texture data are stored as a buffer
  50993. * @returns true if the loader can load the specified file
  50994. */
  50995. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50996. /**
  50997. * Transform the url before loading if required.
  50998. * @param rootUrl the url of the texture
  50999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51000. * @returns the transformed texture
  51001. */
  51002. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51003. /**
  51004. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51005. * @param rootUrl the url of the texture
  51006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51007. * @returns the fallback texture
  51008. */
  51009. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51010. /**
  51011. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51012. * @param data contains the texture data
  51013. * @param texture defines the BabylonJS internal texture
  51014. * @param createPolynomials will be true if polynomials have been requested
  51015. * @param onLoad defines the callback to trigger once the texture is ready
  51016. * @param onError defines the callback to trigger in case of error
  51017. */
  51018. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51019. /**
  51020. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51021. * @param data contains the texture data
  51022. * @param texture defines the BabylonJS internal texture
  51023. * @param callback defines the method to call once ready to upload
  51024. */
  51025. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51026. }
  51027. }
  51028. declare module BABYLON {
  51029. /**
  51030. * Implementation of the ENV Texture Loader.
  51031. * @hidden
  51032. */
  51033. export class _ENVTextureLoader implements IInternalTextureLoader {
  51034. /**
  51035. * Defines wether the loader supports cascade loading the different faces.
  51036. */
  51037. readonly supportCascades: boolean;
  51038. /**
  51039. * This returns if the loader support the current file information.
  51040. * @param extension defines the file extension of the file being loaded
  51041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51042. * @param fallback defines the fallback internal texture if any
  51043. * @param isBase64 defines whether the texture is encoded as a base64
  51044. * @param isBuffer defines whether the texture data are stored as a buffer
  51045. * @returns true if the loader can load the specified file
  51046. */
  51047. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51048. /**
  51049. * Transform the url before loading if required.
  51050. * @param rootUrl the url of the texture
  51051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51052. * @returns the transformed texture
  51053. */
  51054. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51055. /**
  51056. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51057. * @param rootUrl the url of the texture
  51058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51059. * @returns the fallback texture
  51060. */
  51061. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51062. /**
  51063. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51064. * @param data contains the texture data
  51065. * @param texture defines the BabylonJS internal texture
  51066. * @param createPolynomials will be true if polynomials have been requested
  51067. * @param onLoad defines the callback to trigger once the texture is ready
  51068. * @param onError defines the callback to trigger in case of error
  51069. */
  51070. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51071. /**
  51072. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51073. * @param data contains the texture data
  51074. * @param texture defines the BabylonJS internal texture
  51075. * @param callback defines the method to call once ready to upload
  51076. */
  51077. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51078. }
  51079. }
  51080. declare module BABYLON {
  51081. /**
  51082. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51083. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51084. */
  51085. export class KhronosTextureContainer {
  51086. /** contents of the KTX container file */
  51087. arrayBuffer: any;
  51088. private static HEADER_LEN;
  51089. private static COMPRESSED_2D;
  51090. private static COMPRESSED_3D;
  51091. private static TEX_2D;
  51092. private static TEX_3D;
  51093. /**
  51094. * Gets the openGL type
  51095. */
  51096. glType: number;
  51097. /**
  51098. * Gets the openGL type size
  51099. */
  51100. glTypeSize: number;
  51101. /**
  51102. * Gets the openGL format
  51103. */
  51104. glFormat: number;
  51105. /**
  51106. * Gets the openGL internal format
  51107. */
  51108. glInternalFormat: number;
  51109. /**
  51110. * Gets the base internal format
  51111. */
  51112. glBaseInternalFormat: number;
  51113. /**
  51114. * Gets image width in pixel
  51115. */
  51116. pixelWidth: number;
  51117. /**
  51118. * Gets image height in pixel
  51119. */
  51120. pixelHeight: number;
  51121. /**
  51122. * Gets image depth in pixels
  51123. */
  51124. pixelDepth: number;
  51125. /**
  51126. * Gets the number of array elements
  51127. */
  51128. numberOfArrayElements: number;
  51129. /**
  51130. * Gets the number of faces
  51131. */
  51132. numberOfFaces: number;
  51133. /**
  51134. * Gets the number of mipmap levels
  51135. */
  51136. numberOfMipmapLevels: number;
  51137. /**
  51138. * Gets the bytes of key value data
  51139. */
  51140. bytesOfKeyValueData: number;
  51141. /**
  51142. * Gets the load type
  51143. */
  51144. loadType: number;
  51145. /**
  51146. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51147. */
  51148. isInvalid: boolean;
  51149. /**
  51150. * Creates a new KhronosTextureContainer
  51151. * @param arrayBuffer contents of the KTX container file
  51152. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51153. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51154. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51155. */
  51156. constructor(
  51157. /** contents of the KTX container file */
  51158. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51159. /**
  51160. * Uploads KTX content to a Babylon Texture.
  51161. * It is assumed that the texture has already been created & is currently bound
  51162. * @hidden
  51163. */
  51164. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51165. private _upload2DCompressedLevels;
  51166. }
  51167. }
  51168. declare module BABYLON {
  51169. /**
  51170. * Implementation of the KTX Texture Loader.
  51171. * @hidden
  51172. */
  51173. export class _KTXTextureLoader implements IInternalTextureLoader {
  51174. /**
  51175. * Defines wether the loader supports cascade loading the different faces.
  51176. */
  51177. readonly supportCascades: boolean;
  51178. /**
  51179. * This returns if the loader support the current file information.
  51180. * @param extension defines the file extension of the file being loaded
  51181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51182. * @param fallback defines the fallback internal texture if any
  51183. * @param isBase64 defines whether the texture is encoded as a base64
  51184. * @param isBuffer defines whether the texture data are stored as a buffer
  51185. * @returns true if the loader can load the specified file
  51186. */
  51187. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51188. /**
  51189. * Transform the url before loading if required.
  51190. * @param rootUrl the url of the texture
  51191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51192. * @returns the transformed texture
  51193. */
  51194. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51195. /**
  51196. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51197. * @param rootUrl the url of the texture
  51198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51199. * @returns the fallback texture
  51200. */
  51201. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51202. /**
  51203. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51204. * @param data contains the texture data
  51205. * @param texture defines the BabylonJS internal texture
  51206. * @param createPolynomials will be true if polynomials have been requested
  51207. * @param onLoad defines the callback to trigger once the texture is ready
  51208. * @param onError defines the callback to trigger in case of error
  51209. */
  51210. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51211. /**
  51212. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51213. * @param data contains the texture data
  51214. * @param texture defines the BabylonJS internal texture
  51215. * @param callback defines the method to call once ready to upload
  51216. */
  51217. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51218. }
  51219. }
  51220. declare module BABYLON {
  51221. /** @hidden */
  51222. export var _forceSceneHelpersToBundle: boolean;
  51223. interface Scene {
  51224. /**
  51225. * Creates a default light for the scene.
  51226. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51227. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51228. */
  51229. createDefaultLight(replace?: boolean): void;
  51230. /**
  51231. * Creates a default camera for the scene.
  51232. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51233. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51234. * @param replace has default false, when true replaces the active camera in the scene
  51235. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51236. */
  51237. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51238. /**
  51239. * Creates a default camera and a default light.
  51240. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51241. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51242. * @param replace has the default false, when true replaces the active camera/light in the scene
  51243. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51244. */
  51245. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51246. /**
  51247. * Creates a new sky box
  51248. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51249. * @param environmentTexture defines the texture to use as environment texture
  51250. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51251. * @param scale defines the overall scale of the skybox
  51252. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51253. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51254. * @returns a new mesh holding the sky box
  51255. */
  51256. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51257. /**
  51258. * Creates a new environment
  51259. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51260. * @param options defines the options you can use to configure the environment
  51261. * @returns the new EnvironmentHelper
  51262. */
  51263. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51264. /**
  51265. * Creates a new VREXperienceHelper
  51266. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51267. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51268. * @returns a new VREXperienceHelper
  51269. */
  51270. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51271. /**
  51272. * Creates a new WebXRDefaultExperience
  51273. * @see http://doc.babylonjs.com/how_to/webxr
  51274. * @param options experience options
  51275. * @returns a promise for a new WebXRDefaultExperience
  51276. */
  51277. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51278. }
  51279. }
  51280. declare module BABYLON {
  51281. /**
  51282. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51283. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51284. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51285. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51286. */
  51287. export class VideoDome extends TransformNode {
  51288. /**
  51289. * Define the video source as a Monoscopic panoramic 360 video.
  51290. */
  51291. static readonly MODE_MONOSCOPIC: number;
  51292. /**
  51293. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51294. */
  51295. static readonly MODE_TOPBOTTOM: number;
  51296. /**
  51297. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51298. */
  51299. static readonly MODE_SIDEBYSIDE: number;
  51300. private _halfDome;
  51301. private _useDirectMapping;
  51302. /**
  51303. * The video texture being displayed on the sphere
  51304. */
  51305. protected _videoTexture: VideoTexture;
  51306. /**
  51307. * Gets the video texture being displayed on the sphere
  51308. */
  51309. get videoTexture(): VideoTexture;
  51310. /**
  51311. * The skybox material
  51312. */
  51313. protected _material: BackgroundMaterial;
  51314. /**
  51315. * The surface used for the skybox
  51316. */
  51317. protected _mesh: Mesh;
  51318. /**
  51319. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51320. */
  51321. private _halfDomeMask;
  51322. /**
  51323. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51324. * Also see the options.resolution property.
  51325. */
  51326. get fovMultiplier(): number;
  51327. set fovMultiplier(value: number);
  51328. private _videoMode;
  51329. /**
  51330. * Gets or set the current video mode for the video. It can be:
  51331. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51332. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51333. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51334. */
  51335. get videoMode(): number;
  51336. set videoMode(value: number);
  51337. /**
  51338. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51339. *
  51340. */
  51341. get halfDome(): boolean;
  51342. /**
  51343. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51344. */
  51345. set halfDome(enabled: boolean);
  51346. /**
  51347. * Oberserver used in Stereoscopic VR Mode.
  51348. */
  51349. private _onBeforeCameraRenderObserver;
  51350. /**
  51351. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51352. * @param name Element's name, child elements will append suffixes for their own names.
  51353. * @param urlsOrVideo defines the url(s) or the video element to use
  51354. * @param options An object containing optional or exposed sub element properties
  51355. */
  51356. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51357. resolution?: number;
  51358. clickToPlay?: boolean;
  51359. autoPlay?: boolean;
  51360. loop?: boolean;
  51361. size?: number;
  51362. poster?: string;
  51363. faceForward?: boolean;
  51364. useDirectMapping?: boolean;
  51365. halfDomeMode?: boolean;
  51366. }, scene: Scene);
  51367. private _changeVideoMode;
  51368. /**
  51369. * Releases resources associated with this node.
  51370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51372. */
  51373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51374. }
  51375. }
  51376. declare module BABYLON {
  51377. /**
  51378. * This class can be used to get instrumentation data from a Babylon engine
  51379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51380. */
  51381. export class EngineInstrumentation implements IDisposable {
  51382. /**
  51383. * Define the instrumented engine.
  51384. */
  51385. engine: Engine;
  51386. private _captureGPUFrameTime;
  51387. private _gpuFrameTimeToken;
  51388. private _gpuFrameTime;
  51389. private _captureShaderCompilationTime;
  51390. private _shaderCompilationTime;
  51391. private _onBeginFrameObserver;
  51392. private _onEndFrameObserver;
  51393. private _onBeforeShaderCompilationObserver;
  51394. private _onAfterShaderCompilationObserver;
  51395. /**
  51396. * Gets the perf counter used for GPU frame time
  51397. */
  51398. get gpuFrameTimeCounter(): PerfCounter;
  51399. /**
  51400. * Gets the GPU frame time capture status
  51401. */
  51402. get captureGPUFrameTime(): boolean;
  51403. /**
  51404. * Enable or disable the GPU frame time capture
  51405. */
  51406. set captureGPUFrameTime(value: boolean);
  51407. /**
  51408. * Gets the perf counter used for shader compilation time
  51409. */
  51410. get shaderCompilationTimeCounter(): PerfCounter;
  51411. /**
  51412. * Gets the shader compilation time capture status
  51413. */
  51414. get captureShaderCompilationTime(): boolean;
  51415. /**
  51416. * Enable or disable the shader compilation time capture
  51417. */
  51418. set captureShaderCompilationTime(value: boolean);
  51419. /**
  51420. * Instantiates a new engine instrumentation.
  51421. * This class can be used to get instrumentation data from a Babylon engine
  51422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51423. * @param engine Defines the engine to instrument
  51424. */
  51425. constructor(
  51426. /**
  51427. * Define the instrumented engine.
  51428. */
  51429. engine: Engine);
  51430. /**
  51431. * Dispose and release associated resources.
  51432. */
  51433. dispose(): void;
  51434. }
  51435. }
  51436. declare module BABYLON {
  51437. /**
  51438. * This class can be used to get instrumentation data from a Babylon engine
  51439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51440. */
  51441. export class SceneInstrumentation implements IDisposable {
  51442. /**
  51443. * Defines the scene to instrument
  51444. */
  51445. scene: Scene;
  51446. private _captureActiveMeshesEvaluationTime;
  51447. private _activeMeshesEvaluationTime;
  51448. private _captureRenderTargetsRenderTime;
  51449. private _renderTargetsRenderTime;
  51450. private _captureFrameTime;
  51451. private _frameTime;
  51452. private _captureRenderTime;
  51453. private _renderTime;
  51454. private _captureInterFrameTime;
  51455. private _interFrameTime;
  51456. private _captureParticlesRenderTime;
  51457. private _particlesRenderTime;
  51458. private _captureSpritesRenderTime;
  51459. private _spritesRenderTime;
  51460. private _capturePhysicsTime;
  51461. private _physicsTime;
  51462. private _captureAnimationsTime;
  51463. private _animationsTime;
  51464. private _captureCameraRenderTime;
  51465. private _cameraRenderTime;
  51466. private _onBeforeActiveMeshesEvaluationObserver;
  51467. private _onAfterActiveMeshesEvaluationObserver;
  51468. private _onBeforeRenderTargetsRenderObserver;
  51469. private _onAfterRenderTargetsRenderObserver;
  51470. private _onAfterRenderObserver;
  51471. private _onBeforeDrawPhaseObserver;
  51472. private _onAfterDrawPhaseObserver;
  51473. private _onBeforeAnimationsObserver;
  51474. private _onBeforeParticlesRenderingObserver;
  51475. private _onAfterParticlesRenderingObserver;
  51476. private _onBeforeSpritesRenderingObserver;
  51477. private _onAfterSpritesRenderingObserver;
  51478. private _onBeforePhysicsObserver;
  51479. private _onAfterPhysicsObserver;
  51480. private _onAfterAnimationsObserver;
  51481. private _onBeforeCameraRenderObserver;
  51482. private _onAfterCameraRenderObserver;
  51483. /**
  51484. * Gets the perf counter used for active meshes evaluation time
  51485. */
  51486. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  51487. /**
  51488. * Gets the active meshes evaluation time capture status
  51489. */
  51490. get captureActiveMeshesEvaluationTime(): boolean;
  51491. /**
  51492. * Enable or disable the active meshes evaluation time capture
  51493. */
  51494. set captureActiveMeshesEvaluationTime(value: boolean);
  51495. /**
  51496. * Gets the perf counter used for render targets render time
  51497. */
  51498. get renderTargetsRenderTimeCounter(): PerfCounter;
  51499. /**
  51500. * Gets the render targets render time capture status
  51501. */
  51502. get captureRenderTargetsRenderTime(): boolean;
  51503. /**
  51504. * Enable or disable the render targets render time capture
  51505. */
  51506. set captureRenderTargetsRenderTime(value: boolean);
  51507. /**
  51508. * Gets the perf counter used for particles render time
  51509. */
  51510. get particlesRenderTimeCounter(): PerfCounter;
  51511. /**
  51512. * Gets the particles render time capture status
  51513. */
  51514. get captureParticlesRenderTime(): boolean;
  51515. /**
  51516. * Enable or disable the particles render time capture
  51517. */
  51518. set captureParticlesRenderTime(value: boolean);
  51519. /**
  51520. * Gets the perf counter used for sprites render time
  51521. */
  51522. get spritesRenderTimeCounter(): PerfCounter;
  51523. /**
  51524. * Gets the sprites render time capture status
  51525. */
  51526. get captureSpritesRenderTime(): boolean;
  51527. /**
  51528. * Enable or disable the sprites render time capture
  51529. */
  51530. set captureSpritesRenderTime(value: boolean);
  51531. /**
  51532. * Gets the perf counter used for physics time
  51533. */
  51534. get physicsTimeCounter(): PerfCounter;
  51535. /**
  51536. * Gets the physics time capture status
  51537. */
  51538. get capturePhysicsTime(): boolean;
  51539. /**
  51540. * Enable or disable the physics time capture
  51541. */
  51542. set capturePhysicsTime(value: boolean);
  51543. /**
  51544. * Gets the perf counter used for animations time
  51545. */
  51546. get animationsTimeCounter(): PerfCounter;
  51547. /**
  51548. * Gets the animations time capture status
  51549. */
  51550. get captureAnimationsTime(): boolean;
  51551. /**
  51552. * Enable or disable the animations time capture
  51553. */
  51554. set captureAnimationsTime(value: boolean);
  51555. /**
  51556. * Gets the perf counter used for frame time capture
  51557. */
  51558. get frameTimeCounter(): PerfCounter;
  51559. /**
  51560. * Gets the frame time capture status
  51561. */
  51562. get captureFrameTime(): boolean;
  51563. /**
  51564. * Enable or disable the frame time capture
  51565. */
  51566. set captureFrameTime(value: boolean);
  51567. /**
  51568. * Gets the perf counter used for inter-frames time capture
  51569. */
  51570. get interFrameTimeCounter(): PerfCounter;
  51571. /**
  51572. * Gets the inter-frames time capture status
  51573. */
  51574. get captureInterFrameTime(): boolean;
  51575. /**
  51576. * Enable or disable the inter-frames time capture
  51577. */
  51578. set captureInterFrameTime(value: boolean);
  51579. /**
  51580. * Gets the perf counter used for render time capture
  51581. */
  51582. get renderTimeCounter(): PerfCounter;
  51583. /**
  51584. * Gets the render time capture status
  51585. */
  51586. get captureRenderTime(): boolean;
  51587. /**
  51588. * Enable or disable the render time capture
  51589. */
  51590. set captureRenderTime(value: boolean);
  51591. /**
  51592. * Gets the perf counter used for camera render time capture
  51593. */
  51594. get cameraRenderTimeCounter(): PerfCounter;
  51595. /**
  51596. * Gets the camera render time capture status
  51597. */
  51598. get captureCameraRenderTime(): boolean;
  51599. /**
  51600. * Enable or disable the camera render time capture
  51601. */
  51602. set captureCameraRenderTime(value: boolean);
  51603. /**
  51604. * Gets the perf counter used for draw calls
  51605. */
  51606. get drawCallsCounter(): PerfCounter;
  51607. /**
  51608. * Instantiates a new scene instrumentation.
  51609. * This class can be used to get instrumentation data from a Babylon engine
  51610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51611. * @param scene Defines the scene to instrument
  51612. */
  51613. constructor(
  51614. /**
  51615. * Defines the scene to instrument
  51616. */
  51617. scene: Scene);
  51618. /**
  51619. * Dispose and release associated resources.
  51620. */
  51621. dispose(): void;
  51622. }
  51623. }
  51624. declare module BABYLON {
  51625. /** @hidden */
  51626. export var glowMapGenerationPixelShader: {
  51627. name: string;
  51628. shader: string;
  51629. };
  51630. }
  51631. declare module BABYLON {
  51632. /** @hidden */
  51633. export var glowMapGenerationVertexShader: {
  51634. name: string;
  51635. shader: string;
  51636. };
  51637. }
  51638. declare module BABYLON {
  51639. /**
  51640. * Effect layer options. This helps customizing the behaviour
  51641. * of the effect layer.
  51642. */
  51643. export interface IEffectLayerOptions {
  51644. /**
  51645. * Multiplication factor apply to the canvas size to compute the render target size
  51646. * used to generated the objects (the smaller the faster).
  51647. */
  51648. mainTextureRatio: number;
  51649. /**
  51650. * Enforces a fixed size texture to ensure effect stability across devices.
  51651. */
  51652. mainTextureFixedSize?: number;
  51653. /**
  51654. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51655. */
  51656. alphaBlendingMode: number;
  51657. /**
  51658. * The camera attached to the layer.
  51659. */
  51660. camera: Nullable<Camera>;
  51661. /**
  51662. * The rendering group to draw the layer in.
  51663. */
  51664. renderingGroupId: number;
  51665. }
  51666. /**
  51667. * The effect layer Helps adding post process effect blended with the main pass.
  51668. *
  51669. * This can be for instance use to generate glow or higlight effects on the scene.
  51670. *
  51671. * The effect layer class can not be used directly and is intented to inherited from to be
  51672. * customized per effects.
  51673. */
  51674. export abstract class EffectLayer {
  51675. private _vertexBuffers;
  51676. private _indexBuffer;
  51677. private _cachedDefines;
  51678. private _effectLayerMapGenerationEffect;
  51679. private _effectLayerOptions;
  51680. private _mergeEffect;
  51681. protected _scene: Scene;
  51682. protected _engine: Engine;
  51683. protected _maxSize: number;
  51684. protected _mainTextureDesiredSize: ISize;
  51685. protected _mainTexture: RenderTargetTexture;
  51686. protected _shouldRender: boolean;
  51687. protected _postProcesses: PostProcess[];
  51688. protected _textures: BaseTexture[];
  51689. protected _emissiveTextureAndColor: {
  51690. texture: Nullable<BaseTexture>;
  51691. color: Color4;
  51692. };
  51693. /**
  51694. * The name of the layer
  51695. */
  51696. name: string;
  51697. /**
  51698. * The clear color of the texture used to generate the glow map.
  51699. */
  51700. neutralColor: Color4;
  51701. /**
  51702. * Specifies wether the highlight layer is enabled or not.
  51703. */
  51704. isEnabled: boolean;
  51705. /**
  51706. * Gets the camera attached to the layer.
  51707. */
  51708. get camera(): Nullable<Camera>;
  51709. /**
  51710. * Gets the rendering group id the layer should render in.
  51711. */
  51712. get renderingGroupId(): number;
  51713. set renderingGroupId(renderingGroupId: number);
  51714. /**
  51715. * An event triggered when the effect layer has been disposed.
  51716. */
  51717. onDisposeObservable: Observable<EffectLayer>;
  51718. /**
  51719. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51720. */
  51721. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51722. /**
  51723. * An event triggered when the generated texture is being merged in the scene.
  51724. */
  51725. onBeforeComposeObservable: Observable<EffectLayer>;
  51726. /**
  51727. * An event triggered when the mesh is rendered into the effect render target.
  51728. */
  51729. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51730. /**
  51731. * An event triggered after the mesh has been rendered into the effect render target.
  51732. */
  51733. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51734. /**
  51735. * An event triggered when the generated texture has been merged in the scene.
  51736. */
  51737. onAfterComposeObservable: Observable<EffectLayer>;
  51738. /**
  51739. * An event triggered when the efffect layer changes its size.
  51740. */
  51741. onSizeChangedObservable: Observable<EffectLayer>;
  51742. /** @hidden */
  51743. static _SceneComponentInitialization: (scene: Scene) => void;
  51744. /**
  51745. * Instantiates a new effect Layer and references it in the scene.
  51746. * @param name The name of the layer
  51747. * @param scene The scene to use the layer in
  51748. */
  51749. constructor(
  51750. /** The Friendly of the effect in the scene */
  51751. name: string, scene: Scene);
  51752. /**
  51753. * Get the effect name of the layer.
  51754. * @return The effect name
  51755. */
  51756. abstract getEffectName(): string;
  51757. /**
  51758. * Checks for the readiness of the element composing the layer.
  51759. * @param subMesh the mesh to check for
  51760. * @param useInstances specify wether or not to use instances to render the mesh
  51761. * @return true if ready otherwise, false
  51762. */
  51763. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51764. /**
  51765. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51766. * @returns true if the effect requires stencil during the main canvas render pass.
  51767. */
  51768. abstract needStencil(): boolean;
  51769. /**
  51770. * Create the merge effect. This is the shader use to blit the information back
  51771. * to the main canvas at the end of the scene rendering.
  51772. * @returns The effect containing the shader used to merge the effect on the main canvas
  51773. */
  51774. protected abstract _createMergeEffect(): Effect;
  51775. /**
  51776. * Creates the render target textures and post processes used in the effect layer.
  51777. */
  51778. protected abstract _createTextureAndPostProcesses(): void;
  51779. /**
  51780. * Implementation specific of rendering the generating effect on the main canvas.
  51781. * @param effect The effect used to render through
  51782. */
  51783. protected abstract _internalRender(effect: Effect): void;
  51784. /**
  51785. * Sets the required values for both the emissive texture and and the main color.
  51786. */
  51787. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51788. /**
  51789. * Free any resources and references associated to a mesh.
  51790. * Internal use
  51791. * @param mesh The mesh to free.
  51792. */
  51793. abstract _disposeMesh(mesh: Mesh): void;
  51794. /**
  51795. * Serializes this layer (Glow or Highlight for example)
  51796. * @returns a serialized layer object
  51797. */
  51798. abstract serialize?(): any;
  51799. /**
  51800. * Initializes the effect layer with the required options.
  51801. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51802. */
  51803. protected _init(options: Partial<IEffectLayerOptions>): void;
  51804. /**
  51805. * Generates the index buffer of the full screen quad blending to the main canvas.
  51806. */
  51807. private _generateIndexBuffer;
  51808. /**
  51809. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51810. */
  51811. private _generateVertexBuffer;
  51812. /**
  51813. * Sets the main texture desired size which is the closest power of two
  51814. * of the engine canvas size.
  51815. */
  51816. private _setMainTextureSize;
  51817. /**
  51818. * Creates the main texture for the effect layer.
  51819. */
  51820. protected _createMainTexture(): void;
  51821. /**
  51822. * Adds specific effects defines.
  51823. * @param defines The defines to add specifics to.
  51824. */
  51825. protected _addCustomEffectDefines(defines: string[]): void;
  51826. /**
  51827. * Checks for the readiness of the element composing the layer.
  51828. * @param subMesh the mesh to check for
  51829. * @param useInstances specify wether or not to use instances to render the mesh
  51830. * @param emissiveTexture the associated emissive texture used to generate the glow
  51831. * @return true if ready otherwise, false
  51832. */
  51833. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51834. /**
  51835. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51836. */
  51837. render(): void;
  51838. /**
  51839. * Determine if a given mesh will be used in the current effect.
  51840. * @param mesh mesh to test
  51841. * @returns true if the mesh will be used
  51842. */
  51843. hasMesh(mesh: AbstractMesh): boolean;
  51844. /**
  51845. * Returns true if the layer contains information to display, otherwise false.
  51846. * @returns true if the glow layer should be rendered
  51847. */
  51848. shouldRender(): boolean;
  51849. /**
  51850. * Returns true if the mesh should render, otherwise false.
  51851. * @param mesh The mesh to render
  51852. * @returns true if it should render otherwise false
  51853. */
  51854. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51855. /**
  51856. * Returns true if the mesh can be rendered, otherwise false.
  51857. * @param mesh The mesh to render
  51858. * @param material The material used on the mesh
  51859. * @returns true if it can be rendered otherwise false
  51860. */
  51861. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51862. /**
  51863. * Returns true if the mesh should render, otherwise false.
  51864. * @param mesh The mesh to render
  51865. * @returns true if it should render otherwise false
  51866. */
  51867. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51868. /**
  51869. * Renders the submesh passed in parameter to the generation map.
  51870. */
  51871. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51872. /**
  51873. * Defines wether the current material of the mesh should be use to render the effect.
  51874. * @param mesh defines the current mesh to render
  51875. */
  51876. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51877. /**
  51878. * Rebuild the required buffers.
  51879. * @hidden Internal use only.
  51880. */
  51881. _rebuild(): void;
  51882. /**
  51883. * Dispose only the render target textures and post process.
  51884. */
  51885. private _disposeTextureAndPostProcesses;
  51886. /**
  51887. * Dispose the highlight layer and free resources.
  51888. */
  51889. dispose(): void;
  51890. /**
  51891. * Gets the class name of the effect layer
  51892. * @returns the string with the class name of the effect layer
  51893. */
  51894. getClassName(): string;
  51895. /**
  51896. * Creates an effect layer from parsed effect layer data
  51897. * @param parsedEffectLayer defines effect layer data
  51898. * @param scene defines the current scene
  51899. * @param rootUrl defines the root URL containing the effect layer information
  51900. * @returns a parsed effect Layer
  51901. */
  51902. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51903. }
  51904. }
  51905. declare module BABYLON {
  51906. interface AbstractScene {
  51907. /**
  51908. * The list of effect layers (highlights/glow) added to the scene
  51909. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51910. * @see http://doc.babylonjs.com/how_to/glow_layer
  51911. */
  51912. effectLayers: Array<EffectLayer>;
  51913. /**
  51914. * Removes the given effect layer from this scene.
  51915. * @param toRemove defines the effect layer to remove
  51916. * @returns the index of the removed effect layer
  51917. */
  51918. removeEffectLayer(toRemove: EffectLayer): number;
  51919. /**
  51920. * Adds the given effect layer to this scene
  51921. * @param newEffectLayer defines the effect layer to add
  51922. */
  51923. addEffectLayer(newEffectLayer: EffectLayer): void;
  51924. }
  51925. /**
  51926. * Defines the layer scene component responsible to manage any effect layers
  51927. * in a given scene.
  51928. */
  51929. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51930. /**
  51931. * The component name helpfull to identify the component in the list of scene components.
  51932. */
  51933. readonly name: string;
  51934. /**
  51935. * The scene the component belongs to.
  51936. */
  51937. scene: Scene;
  51938. private _engine;
  51939. private _renderEffects;
  51940. private _needStencil;
  51941. private _previousStencilState;
  51942. /**
  51943. * Creates a new instance of the component for the given scene
  51944. * @param scene Defines the scene to register the component in
  51945. */
  51946. constructor(scene: Scene);
  51947. /**
  51948. * Registers the component in a given scene
  51949. */
  51950. register(): void;
  51951. /**
  51952. * Rebuilds the elements related to this component in case of
  51953. * context lost for instance.
  51954. */
  51955. rebuild(): void;
  51956. /**
  51957. * Serializes the component data to the specified json object
  51958. * @param serializationObject The object to serialize to
  51959. */
  51960. serialize(serializationObject: any): void;
  51961. /**
  51962. * Adds all the elements from the container to the scene
  51963. * @param container the container holding the elements
  51964. */
  51965. addFromContainer(container: AbstractScene): void;
  51966. /**
  51967. * Removes all the elements in the container from the scene
  51968. * @param container contains the elements to remove
  51969. * @param dispose if the removed element should be disposed (default: false)
  51970. */
  51971. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51972. /**
  51973. * Disposes the component and the associated ressources.
  51974. */
  51975. dispose(): void;
  51976. private _isReadyForMesh;
  51977. private _renderMainTexture;
  51978. private _setStencil;
  51979. private _setStencilBack;
  51980. private _draw;
  51981. private _drawCamera;
  51982. private _drawRenderingGroup;
  51983. }
  51984. }
  51985. declare module BABYLON {
  51986. /** @hidden */
  51987. export var glowMapMergePixelShader: {
  51988. name: string;
  51989. shader: string;
  51990. };
  51991. }
  51992. declare module BABYLON {
  51993. /** @hidden */
  51994. export var glowMapMergeVertexShader: {
  51995. name: string;
  51996. shader: string;
  51997. };
  51998. }
  51999. declare module BABYLON {
  52000. interface AbstractScene {
  52001. /**
  52002. * Return a the first highlight layer of the scene with a given name.
  52003. * @param name The name of the highlight layer to look for.
  52004. * @return The highlight layer if found otherwise null.
  52005. */
  52006. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52007. }
  52008. /**
  52009. * Glow layer options. This helps customizing the behaviour
  52010. * of the glow layer.
  52011. */
  52012. export interface IGlowLayerOptions {
  52013. /**
  52014. * Multiplication factor apply to the canvas size to compute the render target size
  52015. * used to generated the glowing objects (the smaller the faster).
  52016. */
  52017. mainTextureRatio: number;
  52018. /**
  52019. * Enforces a fixed size texture to ensure resize independant blur.
  52020. */
  52021. mainTextureFixedSize?: number;
  52022. /**
  52023. * How big is the kernel of the blur texture.
  52024. */
  52025. blurKernelSize: number;
  52026. /**
  52027. * The camera attached to the layer.
  52028. */
  52029. camera: Nullable<Camera>;
  52030. /**
  52031. * Enable MSAA by chosing the number of samples.
  52032. */
  52033. mainTextureSamples?: number;
  52034. /**
  52035. * The rendering group to draw the layer in.
  52036. */
  52037. renderingGroupId: number;
  52038. }
  52039. /**
  52040. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52041. *
  52042. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52043. *
  52044. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52045. */
  52046. export class GlowLayer extends EffectLayer {
  52047. /**
  52048. * Effect Name of the layer.
  52049. */
  52050. static readonly EffectName: string;
  52051. /**
  52052. * The default blur kernel size used for the glow.
  52053. */
  52054. static DefaultBlurKernelSize: number;
  52055. /**
  52056. * The default texture size ratio used for the glow.
  52057. */
  52058. static DefaultTextureRatio: number;
  52059. /**
  52060. * Sets the kernel size of the blur.
  52061. */
  52062. set blurKernelSize(value: number);
  52063. /**
  52064. * Gets the kernel size of the blur.
  52065. */
  52066. get blurKernelSize(): number;
  52067. /**
  52068. * Sets the glow intensity.
  52069. */
  52070. set intensity(value: number);
  52071. /**
  52072. * Gets the glow intensity.
  52073. */
  52074. get intensity(): number;
  52075. private _options;
  52076. private _intensity;
  52077. private _horizontalBlurPostprocess1;
  52078. private _verticalBlurPostprocess1;
  52079. private _horizontalBlurPostprocess2;
  52080. private _verticalBlurPostprocess2;
  52081. private _blurTexture1;
  52082. private _blurTexture2;
  52083. private _postProcesses1;
  52084. private _postProcesses2;
  52085. private _includedOnlyMeshes;
  52086. private _excludedMeshes;
  52087. private _meshesUsingTheirOwnMaterials;
  52088. /**
  52089. * Callback used to let the user override the color selection on a per mesh basis
  52090. */
  52091. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52092. /**
  52093. * Callback used to let the user override the texture selection on a per mesh basis
  52094. */
  52095. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52096. /**
  52097. * Instantiates a new glow Layer and references it to the scene.
  52098. * @param name The name of the layer
  52099. * @param scene The scene to use the layer in
  52100. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52101. */
  52102. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52103. /**
  52104. * Get the effect name of the layer.
  52105. * @return The effect name
  52106. */
  52107. getEffectName(): string;
  52108. /**
  52109. * Create the merge effect. This is the shader use to blit the information back
  52110. * to the main canvas at the end of the scene rendering.
  52111. */
  52112. protected _createMergeEffect(): Effect;
  52113. /**
  52114. * Creates the render target textures and post processes used in the glow layer.
  52115. */
  52116. protected _createTextureAndPostProcesses(): void;
  52117. /**
  52118. * Checks for the readiness of the element composing the layer.
  52119. * @param subMesh the mesh to check for
  52120. * @param useInstances specify wether or not to use instances to render the mesh
  52121. * @param emissiveTexture the associated emissive texture used to generate the glow
  52122. * @return true if ready otherwise, false
  52123. */
  52124. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52125. /**
  52126. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52127. */
  52128. needStencil(): boolean;
  52129. /**
  52130. * Returns true if the mesh can be rendered, otherwise false.
  52131. * @param mesh The mesh to render
  52132. * @param material The material used on the mesh
  52133. * @returns true if it can be rendered otherwise false
  52134. */
  52135. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52136. /**
  52137. * Implementation specific of rendering the generating effect on the main canvas.
  52138. * @param effect The effect used to render through
  52139. */
  52140. protected _internalRender(effect: Effect): void;
  52141. /**
  52142. * Sets the required values for both the emissive texture and and the main color.
  52143. */
  52144. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52145. /**
  52146. * Returns true if the mesh should render, otherwise false.
  52147. * @param mesh The mesh to render
  52148. * @returns true if it should render otherwise false
  52149. */
  52150. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52151. /**
  52152. * Adds specific effects defines.
  52153. * @param defines The defines to add specifics to.
  52154. */
  52155. protected _addCustomEffectDefines(defines: string[]): void;
  52156. /**
  52157. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52158. * @param mesh The mesh to exclude from the glow layer
  52159. */
  52160. addExcludedMesh(mesh: Mesh): void;
  52161. /**
  52162. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52163. * @param mesh The mesh to remove
  52164. */
  52165. removeExcludedMesh(mesh: Mesh): void;
  52166. /**
  52167. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52168. * @param mesh The mesh to include in the glow layer
  52169. */
  52170. addIncludedOnlyMesh(mesh: Mesh): void;
  52171. /**
  52172. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52173. * @param mesh The mesh to remove
  52174. */
  52175. removeIncludedOnlyMesh(mesh: Mesh): void;
  52176. /**
  52177. * Determine if a given mesh will be used in the glow layer
  52178. * @param mesh The mesh to test
  52179. * @returns true if the mesh will be highlighted by the current glow layer
  52180. */
  52181. hasMesh(mesh: AbstractMesh): boolean;
  52182. /**
  52183. * Defines wether the current material of the mesh should be use to render the effect.
  52184. * @param mesh defines the current mesh to render
  52185. */
  52186. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52187. /**
  52188. * Add a mesh to be rendered through its own material and not with emissive only.
  52189. * @param mesh The mesh for which we need to use its material
  52190. */
  52191. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52192. /**
  52193. * Remove a mesh from being rendered through its own material and not with emissive only.
  52194. * @param mesh The mesh for which we need to not use its material
  52195. */
  52196. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52197. /**
  52198. * Free any resources and references associated to a mesh.
  52199. * Internal use
  52200. * @param mesh The mesh to free.
  52201. * @hidden
  52202. */
  52203. _disposeMesh(mesh: Mesh): void;
  52204. /**
  52205. * Gets the class name of the effect layer
  52206. * @returns the string with the class name of the effect layer
  52207. */
  52208. getClassName(): string;
  52209. /**
  52210. * Serializes this glow layer
  52211. * @returns a serialized glow layer object
  52212. */
  52213. serialize(): any;
  52214. /**
  52215. * Creates a Glow Layer from parsed glow layer data
  52216. * @param parsedGlowLayer defines glow layer data
  52217. * @param scene defines the current scene
  52218. * @param rootUrl defines the root URL containing the glow layer information
  52219. * @returns a parsed Glow Layer
  52220. */
  52221. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52222. }
  52223. }
  52224. declare module BABYLON {
  52225. /** @hidden */
  52226. export var glowBlurPostProcessPixelShader: {
  52227. name: string;
  52228. shader: string;
  52229. };
  52230. }
  52231. declare module BABYLON {
  52232. interface AbstractScene {
  52233. /**
  52234. * Return a the first highlight layer of the scene with a given name.
  52235. * @param name The name of the highlight layer to look for.
  52236. * @return The highlight layer if found otherwise null.
  52237. */
  52238. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52239. }
  52240. /**
  52241. * Highlight layer options. This helps customizing the behaviour
  52242. * of the highlight layer.
  52243. */
  52244. export interface IHighlightLayerOptions {
  52245. /**
  52246. * Multiplication factor apply to the canvas size to compute the render target size
  52247. * used to generated the glowing objects (the smaller the faster).
  52248. */
  52249. mainTextureRatio: number;
  52250. /**
  52251. * Enforces a fixed size texture to ensure resize independant blur.
  52252. */
  52253. mainTextureFixedSize?: number;
  52254. /**
  52255. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52256. * of the picture to blur (the smaller the faster).
  52257. */
  52258. blurTextureSizeRatio: number;
  52259. /**
  52260. * How big in texel of the blur texture is the vertical blur.
  52261. */
  52262. blurVerticalSize: number;
  52263. /**
  52264. * How big in texel of the blur texture is the horizontal blur.
  52265. */
  52266. blurHorizontalSize: number;
  52267. /**
  52268. * Alpha blending mode used to apply the blur. Default is combine.
  52269. */
  52270. alphaBlendingMode: number;
  52271. /**
  52272. * The camera attached to the layer.
  52273. */
  52274. camera: Nullable<Camera>;
  52275. /**
  52276. * Should we display highlight as a solid stroke?
  52277. */
  52278. isStroke?: boolean;
  52279. /**
  52280. * The rendering group to draw the layer in.
  52281. */
  52282. renderingGroupId: number;
  52283. }
  52284. /**
  52285. * The highlight layer Helps adding a glow effect around a mesh.
  52286. *
  52287. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52288. * glowy meshes to your scene.
  52289. *
  52290. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52291. */
  52292. export class HighlightLayer extends EffectLayer {
  52293. name: string;
  52294. /**
  52295. * Effect Name of the highlight layer.
  52296. */
  52297. static readonly EffectName: string;
  52298. /**
  52299. * The neutral color used during the preparation of the glow effect.
  52300. * This is black by default as the blend operation is a blend operation.
  52301. */
  52302. static NeutralColor: Color4;
  52303. /**
  52304. * Stencil value used for glowing meshes.
  52305. */
  52306. static GlowingMeshStencilReference: number;
  52307. /**
  52308. * Stencil value used for the other meshes in the scene.
  52309. */
  52310. static NormalMeshStencilReference: number;
  52311. /**
  52312. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52313. */
  52314. innerGlow: boolean;
  52315. /**
  52316. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52317. */
  52318. outerGlow: boolean;
  52319. /**
  52320. * Specifies the horizontal size of the blur.
  52321. */
  52322. set blurHorizontalSize(value: number);
  52323. /**
  52324. * Specifies the vertical size of the blur.
  52325. */
  52326. set blurVerticalSize(value: number);
  52327. /**
  52328. * Gets the horizontal size of the blur.
  52329. */
  52330. get blurHorizontalSize(): number;
  52331. /**
  52332. * Gets the vertical size of the blur.
  52333. */
  52334. get blurVerticalSize(): number;
  52335. /**
  52336. * An event triggered when the highlight layer is being blurred.
  52337. */
  52338. onBeforeBlurObservable: Observable<HighlightLayer>;
  52339. /**
  52340. * An event triggered when the highlight layer has been blurred.
  52341. */
  52342. onAfterBlurObservable: Observable<HighlightLayer>;
  52343. private _instanceGlowingMeshStencilReference;
  52344. private _options;
  52345. private _downSamplePostprocess;
  52346. private _horizontalBlurPostprocess;
  52347. private _verticalBlurPostprocess;
  52348. private _blurTexture;
  52349. private _meshes;
  52350. private _excludedMeshes;
  52351. /**
  52352. * Instantiates a new highlight Layer and references it to the scene..
  52353. * @param name The name of the layer
  52354. * @param scene The scene to use the layer in
  52355. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52356. */
  52357. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52358. /**
  52359. * Get the effect name of the layer.
  52360. * @return The effect name
  52361. */
  52362. getEffectName(): string;
  52363. /**
  52364. * Create the merge effect. This is the shader use to blit the information back
  52365. * to the main canvas at the end of the scene rendering.
  52366. */
  52367. protected _createMergeEffect(): Effect;
  52368. /**
  52369. * Creates the render target textures and post processes used in the highlight layer.
  52370. */
  52371. protected _createTextureAndPostProcesses(): void;
  52372. /**
  52373. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52374. */
  52375. needStencil(): boolean;
  52376. /**
  52377. * Checks for the readiness of the element composing the layer.
  52378. * @param subMesh the mesh to check for
  52379. * @param useInstances specify wether or not to use instances to render the mesh
  52380. * @param emissiveTexture the associated emissive texture used to generate the glow
  52381. * @return true if ready otherwise, false
  52382. */
  52383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52384. /**
  52385. * Implementation specific of rendering the generating effect on the main canvas.
  52386. * @param effect The effect used to render through
  52387. */
  52388. protected _internalRender(effect: Effect): void;
  52389. /**
  52390. * Returns true if the layer contains information to display, otherwise false.
  52391. */
  52392. shouldRender(): boolean;
  52393. /**
  52394. * Returns true if the mesh should render, otherwise false.
  52395. * @param mesh The mesh to render
  52396. * @returns true if it should render otherwise false
  52397. */
  52398. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52399. /**
  52400. * Sets the required values for both the emissive texture and and the main color.
  52401. */
  52402. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52403. /**
  52404. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52405. * @param mesh The mesh to exclude from the highlight layer
  52406. */
  52407. addExcludedMesh(mesh: Mesh): void;
  52408. /**
  52409. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52410. * @param mesh The mesh to highlight
  52411. */
  52412. removeExcludedMesh(mesh: Mesh): void;
  52413. /**
  52414. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52415. * @param mesh mesh to test
  52416. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52417. */
  52418. hasMesh(mesh: AbstractMesh): boolean;
  52419. /**
  52420. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52421. * @param mesh The mesh to highlight
  52422. * @param color The color of the highlight
  52423. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52424. */
  52425. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52426. /**
  52427. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52428. * @param mesh The mesh to highlight
  52429. */
  52430. removeMesh(mesh: Mesh): void;
  52431. /**
  52432. * Force the stencil to the normal expected value for none glowing parts
  52433. */
  52434. private _defaultStencilReference;
  52435. /**
  52436. * Free any resources and references associated to a mesh.
  52437. * Internal use
  52438. * @param mesh The mesh to free.
  52439. * @hidden
  52440. */
  52441. _disposeMesh(mesh: Mesh): void;
  52442. /**
  52443. * Dispose the highlight layer and free resources.
  52444. */
  52445. dispose(): void;
  52446. /**
  52447. * Gets the class name of the effect layer
  52448. * @returns the string with the class name of the effect layer
  52449. */
  52450. getClassName(): string;
  52451. /**
  52452. * Serializes this Highlight layer
  52453. * @returns a serialized Highlight layer object
  52454. */
  52455. serialize(): any;
  52456. /**
  52457. * Creates a Highlight layer from parsed Highlight layer data
  52458. * @param parsedHightlightLayer defines the Highlight layer data
  52459. * @param scene defines the current scene
  52460. * @param rootUrl defines the root URL containing the Highlight layer information
  52461. * @returns a parsed Highlight layer
  52462. */
  52463. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52464. }
  52465. }
  52466. declare module BABYLON {
  52467. interface AbstractScene {
  52468. /**
  52469. * The list of layers (background and foreground) of the scene
  52470. */
  52471. layers: Array<Layer>;
  52472. }
  52473. /**
  52474. * Defines the layer scene component responsible to manage any layers
  52475. * in a given scene.
  52476. */
  52477. export class LayerSceneComponent implements ISceneComponent {
  52478. /**
  52479. * The component name helpfull to identify the component in the list of scene components.
  52480. */
  52481. readonly name: string;
  52482. /**
  52483. * The scene the component belongs to.
  52484. */
  52485. scene: Scene;
  52486. private _engine;
  52487. /**
  52488. * Creates a new instance of the component for the given scene
  52489. * @param scene Defines the scene to register the component in
  52490. */
  52491. constructor(scene: Scene);
  52492. /**
  52493. * Registers the component in a given scene
  52494. */
  52495. register(): void;
  52496. /**
  52497. * Rebuilds the elements related to this component in case of
  52498. * context lost for instance.
  52499. */
  52500. rebuild(): void;
  52501. /**
  52502. * Disposes the component and the associated ressources.
  52503. */
  52504. dispose(): void;
  52505. private _draw;
  52506. private _drawCameraPredicate;
  52507. private _drawCameraBackground;
  52508. private _drawCameraForeground;
  52509. private _drawRenderTargetPredicate;
  52510. private _drawRenderTargetBackground;
  52511. private _drawRenderTargetForeground;
  52512. /**
  52513. * Adds all the elements from the container to the scene
  52514. * @param container the container holding the elements
  52515. */
  52516. addFromContainer(container: AbstractScene): void;
  52517. /**
  52518. * Removes all the elements in the container from the scene
  52519. * @param container contains the elements to remove
  52520. * @param dispose if the removed element should be disposed (default: false)
  52521. */
  52522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52523. }
  52524. }
  52525. declare module BABYLON {
  52526. /** @hidden */
  52527. export var layerPixelShader: {
  52528. name: string;
  52529. shader: string;
  52530. };
  52531. }
  52532. declare module BABYLON {
  52533. /** @hidden */
  52534. export var layerVertexShader: {
  52535. name: string;
  52536. shader: string;
  52537. };
  52538. }
  52539. declare module BABYLON {
  52540. /**
  52541. * This represents a full screen 2d layer.
  52542. * This can be useful to display a picture in the background of your scene for instance.
  52543. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52544. */
  52545. export class Layer {
  52546. /**
  52547. * Define the name of the layer.
  52548. */
  52549. name: string;
  52550. /**
  52551. * Define the texture the layer should display.
  52552. */
  52553. texture: Nullable<Texture>;
  52554. /**
  52555. * Is the layer in background or foreground.
  52556. */
  52557. isBackground: boolean;
  52558. /**
  52559. * Define the color of the layer (instead of texture).
  52560. */
  52561. color: Color4;
  52562. /**
  52563. * Define the scale of the layer in order to zoom in out of the texture.
  52564. */
  52565. scale: Vector2;
  52566. /**
  52567. * Define an offset for the layer in order to shift the texture.
  52568. */
  52569. offset: Vector2;
  52570. /**
  52571. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52572. */
  52573. alphaBlendingMode: number;
  52574. /**
  52575. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52576. * Alpha test will not mix with the background color in case of transparency.
  52577. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52578. */
  52579. alphaTest: boolean;
  52580. /**
  52581. * Define a mask to restrict the layer to only some of the scene cameras.
  52582. */
  52583. layerMask: number;
  52584. /**
  52585. * Define the list of render target the layer is visible into.
  52586. */
  52587. renderTargetTextures: RenderTargetTexture[];
  52588. /**
  52589. * Define if the layer is only used in renderTarget or if it also
  52590. * renders in the main frame buffer of the canvas.
  52591. */
  52592. renderOnlyInRenderTargetTextures: boolean;
  52593. private _scene;
  52594. private _vertexBuffers;
  52595. private _indexBuffer;
  52596. private _effect;
  52597. private _previousDefines;
  52598. /**
  52599. * An event triggered when the layer is disposed.
  52600. */
  52601. onDisposeObservable: Observable<Layer>;
  52602. private _onDisposeObserver;
  52603. /**
  52604. * Back compatibility with callback before the onDisposeObservable existed.
  52605. * The set callback will be triggered when the layer has been disposed.
  52606. */
  52607. set onDispose(callback: () => void);
  52608. /**
  52609. * An event triggered before rendering the scene
  52610. */
  52611. onBeforeRenderObservable: Observable<Layer>;
  52612. private _onBeforeRenderObserver;
  52613. /**
  52614. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52615. * The set callback will be triggered just before rendering the layer.
  52616. */
  52617. set onBeforeRender(callback: () => void);
  52618. /**
  52619. * An event triggered after rendering the scene
  52620. */
  52621. onAfterRenderObservable: Observable<Layer>;
  52622. private _onAfterRenderObserver;
  52623. /**
  52624. * Back compatibility with callback before the onAfterRenderObservable existed.
  52625. * The set callback will be triggered just after rendering the layer.
  52626. */
  52627. set onAfterRender(callback: () => void);
  52628. /**
  52629. * Instantiates a new layer.
  52630. * This represents a full screen 2d layer.
  52631. * This can be useful to display a picture in the background of your scene for instance.
  52632. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52633. * @param name Define the name of the layer in the scene
  52634. * @param imgUrl Define the url of the texture to display in the layer
  52635. * @param scene Define the scene the layer belongs to
  52636. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52637. * @param color Defines a color for the layer
  52638. */
  52639. constructor(
  52640. /**
  52641. * Define the name of the layer.
  52642. */
  52643. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52644. private _createIndexBuffer;
  52645. /** @hidden */
  52646. _rebuild(): void;
  52647. /**
  52648. * Renders the layer in the scene.
  52649. */
  52650. render(): void;
  52651. /**
  52652. * Disposes and releases the associated ressources.
  52653. */
  52654. dispose(): void;
  52655. }
  52656. }
  52657. declare module BABYLON {
  52658. /** @hidden */
  52659. export var lensFlarePixelShader: {
  52660. name: string;
  52661. shader: string;
  52662. };
  52663. }
  52664. declare module BABYLON {
  52665. /** @hidden */
  52666. export var lensFlareVertexShader: {
  52667. name: string;
  52668. shader: string;
  52669. };
  52670. }
  52671. declare module BABYLON {
  52672. /**
  52673. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52674. * It is usually composed of several `lensFlare`.
  52675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52676. */
  52677. export class LensFlareSystem {
  52678. /**
  52679. * Define the name of the lens flare system
  52680. */
  52681. name: string;
  52682. /**
  52683. * List of lens flares used in this system.
  52684. */
  52685. lensFlares: LensFlare[];
  52686. /**
  52687. * Define a limit from the border the lens flare can be visible.
  52688. */
  52689. borderLimit: number;
  52690. /**
  52691. * Define a viewport border we do not want to see the lens flare in.
  52692. */
  52693. viewportBorder: number;
  52694. /**
  52695. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52696. */
  52697. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52698. /**
  52699. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52700. */
  52701. layerMask: number;
  52702. /**
  52703. * Define the id of the lens flare system in the scene.
  52704. * (equal to name by default)
  52705. */
  52706. id: string;
  52707. private _scene;
  52708. private _emitter;
  52709. private _vertexBuffers;
  52710. private _indexBuffer;
  52711. private _effect;
  52712. private _positionX;
  52713. private _positionY;
  52714. private _isEnabled;
  52715. /** @hidden */
  52716. static _SceneComponentInitialization: (scene: Scene) => void;
  52717. /**
  52718. * Instantiates a lens flare system.
  52719. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52720. * It is usually composed of several `lensFlare`.
  52721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52722. * @param name Define the name of the lens flare system in the scene
  52723. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52724. * @param scene Define the scene the lens flare system belongs to
  52725. */
  52726. constructor(
  52727. /**
  52728. * Define the name of the lens flare system
  52729. */
  52730. name: string, emitter: any, scene: Scene);
  52731. /**
  52732. * Define if the lens flare system is enabled.
  52733. */
  52734. get isEnabled(): boolean;
  52735. set isEnabled(value: boolean);
  52736. /**
  52737. * Get the scene the effects belongs to.
  52738. * @returns the scene holding the lens flare system
  52739. */
  52740. getScene(): Scene;
  52741. /**
  52742. * Get the emitter of the lens flare system.
  52743. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52744. * @returns the emitter of the lens flare system
  52745. */
  52746. getEmitter(): any;
  52747. /**
  52748. * Set the emitter of the lens flare system.
  52749. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52750. * @param newEmitter Define the new emitter of the system
  52751. */
  52752. setEmitter(newEmitter: any): void;
  52753. /**
  52754. * Get the lens flare system emitter position.
  52755. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52756. * @returns the position
  52757. */
  52758. getEmitterPosition(): Vector3;
  52759. /**
  52760. * @hidden
  52761. */
  52762. computeEffectivePosition(globalViewport: Viewport): boolean;
  52763. /** @hidden */
  52764. _isVisible(): boolean;
  52765. /**
  52766. * @hidden
  52767. */
  52768. render(): boolean;
  52769. /**
  52770. * Dispose and release the lens flare with its associated resources.
  52771. */
  52772. dispose(): void;
  52773. /**
  52774. * Parse a lens flare system from a JSON repressentation
  52775. * @param parsedLensFlareSystem Define the JSON to parse
  52776. * @param scene Define the scene the parsed system should be instantiated in
  52777. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52778. * @returns the parsed system
  52779. */
  52780. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52781. /**
  52782. * Serialize the current Lens Flare System into a JSON representation.
  52783. * @returns the serialized JSON
  52784. */
  52785. serialize(): any;
  52786. }
  52787. }
  52788. declare module BABYLON {
  52789. /**
  52790. * This represents one of the lens effect in a `lensFlareSystem`.
  52791. * It controls one of the indiviual texture used in the effect.
  52792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52793. */
  52794. export class LensFlare {
  52795. /**
  52796. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52797. */
  52798. size: number;
  52799. /**
  52800. * 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.
  52801. */
  52802. position: number;
  52803. /**
  52804. * Define the lens color.
  52805. */
  52806. color: Color3;
  52807. /**
  52808. * Define the lens texture.
  52809. */
  52810. texture: Nullable<Texture>;
  52811. /**
  52812. * Define the alpha mode to render this particular lens.
  52813. */
  52814. alphaMode: number;
  52815. private _system;
  52816. /**
  52817. * Creates a new Lens Flare.
  52818. * This represents one of the lens effect in a `lensFlareSystem`.
  52819. * It controls one of the indiviual texture used in the effect.
  52820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52821. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52822. * @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.
  52823. * @param color Define the lens color
  52824. * @param imgUrl Define the lens texture url
  52825. * @param system Define the `lensFlareSystem` this flare is part of
  52826. * @returns The newly created Lens Flare
  52827. */
  52828. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52829. /**
  52830. * Instantiates a new Lens Flare.
  52831. * This represents one of the lens effect in a `lensFlareSystem`.
  52832. * It controls one of the indiviual texture used in the effect.
  52833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52834. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52835. * @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.
  52836. * @param color Define the lens color
  52837. * @param imgUrl Define the lens texture url
  52838. * @param system Define the `lensFlareSystem` this flare is part of
  52839. */
  52840. constructor(
  52841. /**
  52842. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52843. */
  52844. size: number,
  52845. /**
  52846. * 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.
  52847. */
  52848. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52849. /**
  52850. * Dispose and release the lens flare with its associated resources.
  52851. */
  52852. dispose(): void;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. interface AbstractScene {
  52857. /**
  52858. * The list of lens flare system added to the scene
  52859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52860. */
  52861. lensFlareSystems: Array<LensFlareSystem>;
  52862. /**
  52863. * Removes the given lens flare system from this scene.
  52864. * @param toRemove The lens flare system to remove
  52865. * @returns The index of the removed lens flare system
  52866. */
  52867. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52868. /**
  52869. * Adds the given lens flare system to this scene
  52870. * @param newLensFlareSystem The lens flare system to add
  52871. */
  52872. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52873. /**
  52874. * Gets a lens flare system using its name
  52875. * @param name defines the name to look for
  52876. * @returns the lens flare system or null if not found
  52877. */
  52878. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52879. /**
  52880. * Gets a lens flare system using its id
  52881. * @param id defines the id to look for
  52882. * @returns the lens flare system or null if not found
  52883. */
  52884. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52885. }
  52886. /**
  52887. * Defines the lens flare scene component responsible to manage any lens flares
  52888. * in a given scene.
  52889. */
  52890. export class LensFlareSystemSceneComponent 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. * Adds all the elements from the container to the scene
  52915. * @param container the container holding the elements
  52916. */
  52917. addFromContainer(container: AbstractScene): void;
  52918. /**
  52919. * Removes all the elements in the container from the scene
  52920. * @param container contains the elements to remove
  52921. * @param dispose if the removed element should be disposed (default: false)
  52922. */
  52923. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52924. /**
  52925. * Serializes the component data to the specified json object
  52926. * @param serializationObject The object to serialize to
  52927. */
  52928. serialize(serializationObject: any): void;
  52929. /**
  52930. * Disposes the component and the associated ressources.
  52931. */
  52932. dispose(): void;
  52933. private _draw;
  52934. }
  52935. }
  52936. declare module BABYLON {
  52937. /**
  52938. * Defines the shadow generator component responsible to manage any shadow generators
  52939. * in a given scene.
  52940. */
  52941. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52942. /**
  52943. * The component name helpfull to identify the component in the list of scene components.
  52944. */
  52945. readonly name: string;
  52946. /**
  52947. * The scene the component belongs to.
  52948. */
  52949. scene: Scene;
  52950. /**
  52951. * Creates a new instance of the component for the given scene
  52952. * @param scene Defines the scene to register the component in
  52953. */
  52954. constructor(scene: Scene);
  52955. /**
  52956. * Registers the component in a given scene
  52957. */
  52958. register(): void;
  52959. /**
  52960. * Rebuilds the elements related to this component in case of
  52961. * context lost for instance.
  52962. */
  52963. rebuild(): void;
  52964. /**
  52965. * Serializes the component data to the specified json object
  52966. * @param serializationObject The object to serialize to
  52967. */
  52968. serialize(serializationObject: any): void;
  52969. /**
  52970. * Adds all the elements from the container to the scene
  52971. * @param container the container holding the elements
  52972. */
  52973. addFromContainer(container: AbstractScene): void;
  52974. /**
  52975. * Removes all the elements in the container from the scene
  52976. * @param container contains the elements to remove
  52977. * @param dispose if the removed element should be disposed (default: false)
  52978. */
  52979. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52980. /**
  52981. * Rebuilds the elements related to this component in case of
  52982. * context lost for instance.
  52983. */
  52984. dispose(): void;
  52985. private _gatherRenderTargets;
  52986. }
  52987. }
  52988. declare module BABYLON {
  52989. /**
  52990. * A point light is a light defined by an unique point in world space.
  52991. * The light is emitted in every direction from this point.
  52992. * A good example of a point light is a standard light bulb.
  52993. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52994. */
  52995. export class PointLight extends ShadowLight {
  52996. private _shadowAngle;
  52997. /**
  52998. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52999. * This specifies what angle the shadow will use to be created.
  53000. *
  53001. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53002. */
  53003. get shadowAngle(): number;
  53004. /**
  53005. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53006. * This specifies what angle the shadow will use to be created.
  53007. *
  53008. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53009. */
  53010. set shadowAngle(value: number);
  53011. /**
  53012. * Gets the direction if it has been set.
  53013. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53014. */
  53015. get direction(): Vector3;
  53016. /**
  53017. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53018. */
  53019. set direction(value: Vector3);
  53020. /**
  53021. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53022. * A PointLight emits the light in every direction.
  53023. * It can cast shadows.
  53024. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53025. * ```javascript
  53026. * var pointLight = new PointLight("pl", camera.position, scene);
  53027. * ```
  53028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53029. * @param name The light friendly name
  53030. * @param position The position of the point light in the scene
  53031. * @param scene The scene the lights belongs to
  53032. */
  53033. constructor(name: string, position: Vector3, scene: Scene);
  53034. /**
  53035. * Returns the string "PointLight"
  53036. * @returns the class name
  53037. */
  53038. getClassName(): string;
  53039. /**
  53040. * Returns the integer 0.
  53041. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53042. */
  53043. getTypeID(): number;
  53044. /**
  53045. * Specifies wether or not the shadowmap should be a cube texture.
  53046. * @returns true if the shadowmap needs to be a cube texture.
  53047. */
  53048. needCube(): boolean;
  53049. /**
  53050. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53051. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53052. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53053. */
  53054. getShadowDirection(faceIndex?: number): Vector3;
  53055. /**
  53056. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53057. * - fov = PI / 2
  53058. * - aspect ratio : 1.0
  53059. * - z-near and far equal to the active camera minZ and maxZ.
  53060. * Returns the PointLight.
  53061. */
  53062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53063. protected _buildUniformLayout(): void;
  53064. /**
  53065. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53066. * @param effect The effect to update
  53067. * @param lightIndex The index of the light in the effect to update
  53068. * @returns The point light
  53069. */
  53070. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53071. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53072. /**
  53073. * Prepares the list of defines specific to the light type.
  53074. * @param defines the list of defines
  53075. * @param lightIndex defines the index of the light for the effect
  53076. */
  53077. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53078. }
  53079. }
  53080. declare module BABYLON {
  53081. /**
  53082. * Header information of HDR texture files.
  53083. */
  53084. export interface HDRInfo {
  53085. /**
  53086. * The height of the texture in pixels.
  53087. */
  53088. height: number;
  53089. /**
  53090. * The width of the texture in pixels.
  53091. */
  53092. width: number;
  53093. /**
  53094. * The index of the beginning of the data in the binary file.
  53095. */
  53096. dataPosition: number;
  53097. }
  53098. /**
  53099. * This groups tools to convert HDR texture to native colors array.
  53100. */
  53101. export class HDRTools {
  53102. private static Ldexp;
  53103. private static Rgbe2float;
  53104. private static readStringLine;
  53105. /**
  53106. * Reads header information from an RGBE texture stored in a native array.
  53107. * More information on this format are available here:
  53108. * https://en.wikipedia.org/wiki/RGBE_image_format
  53109. *
  53110. * @param uint8array The binary file stored in native array.
  53111. * @return The header information.
  53112. */
  53113. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53114. /**
  53115. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53116. * This RGBE texture needs to store the information as a panorama.
  53117. *
  53118. * More information on this format are available here:
  53119. * https://en.wikipedia.org/wiki/RGBE_image_format
  53120. *
  53121. * @param buffer The binary file stored in an array buffer.
  53122. * @param size The expected size of the extracted cubemap.
  53123. * @return The Cube Map information.
  53124. */
  53125. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53126. /**
  53127. * Returns the pixels data extracted from an RGBE texture.
  53128. * This pixels will be stored left to right up to down in the R G B order in one array.
  53129. *
  53130. * More information on this format are available here:
  53131. * https://en.wikipedia.org/wiki/RGBE_image_format
  53132. *
  53133. * @param uint8array The binary file stored in an array buffer.
  53134. * @param hdrInfo The header information of the file.
  53135. * @return The pixels data in RGB right to left up to down order.
  53136. */
  53137. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53138. private static RGBE_ReadPixels_RLE;
  53139. }
  53140. }
  53141. declare module BABYLON {
  53142. /**
  53143. * This represents a texture coming from an HDR input.
  53144. *
  53145. * The only supported format is currently panorama picture stored in RGBE format.
  53146. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53147. */
  53148. export class HDRCubeTexture extends BaseTexture {
  53149. private static _facesMapping;
  53150. private _generateHarmonics;
  53151. private _noMipmap;
  53152. private _textureMatrix;
  53153. private _size;
  53154. private _onLoad;
  53155. private _onError;
  53156. /**
  53157. * The texture URL.
  53158. */
  53159. url: string;
  53160. /**
  53161. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53162. */
  53163. coordinatesMode: number;
  53164. protected _isBlocking: boolean;
  53165. /**
  53166. * Sets wether or not the texture is blocking during loading.
  53167. */
  53168. set isBlocking(value: boolean);
  53169. /**
  53170. * Gets wether or not the texture is blocking during loading.
  53171. */
  53172. get isBlocking(): boolean;
  53173. protected _rotationY: number;
  53174. /**
  53175. * Sets texture matrix rotation angle around Y axis in radians.
  53176. */
  53177. set rotationY(value: number);
  53178. /**
  53179. * Gets texture matrix rotation angle around Y axis radians.
  53180. */
  53181. get rotationY(): number;
  53182. /**
  53183. * Gets or sets the center of the bounding box associated with the cube texture
  53184. * It must define where the camera used to render the texture was set
  53185. */
  53186. boundingBoxPosition: Vector3;
  53187. private _boundingBoxSize;
  53188. /**
  53189. * Gets or sets the size of the bounding box associated with the cube texture
  53190. * When defined, the cubemap will switch to local mode
  53191. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53192. * @example https://www.babylonjs-playground.com/#RNASML
  53193. */
  53194. set boundingBoxSize(value: Vector3);
  53195. get boundingBoxSize(): Vector3;
  53196. /**
  53197. * Instantiates an HDRTexture from the following parameters.
  53198. *
  53199. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53200. * @param scene The scene the texture will be used in
  53201. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53202. * @param noMipmap Forces to not generate the mipmap if true
  53203. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53204. * @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)
  53205. * @param reserved Reserved flag for internal use.
  53206. */
  53207. 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>);
  53208. /**
  53209. * Get the current class name of the texture useful for serialization or dynamic coding.
  53210. * @returns "HDRCubeTexture"
  53211. */
  53212. getClassName(): string;
  53213. /**
  53214. * Occurs when the file is raw .hdr file.
  53215. */
  53216. private loadTexture;
  53217. clone(): HDRCubeTexture;
  53218. delayLoad(): void;
  53219. /**
  53220. * Get the texture reflection matrix used to rotate/transform the reflection.
  53221. * @returns the reflection matrix
  53222. */
  53223. getReflectionTextureMatrix(): Matrix;
  53224. /**
  53225. * Set the texture reflection matrix used to rotate/transform the reflection.
  53226. * @param value Define the reflection matrix to set
  53227. */
  53228. setReflectionTextureMatrix(value: Matrix): void;
  53229. /**
  53230. * Parses a JSON representation of an HDR Texture in order to create the texture
  53231. * @param parsedTexture Define the JSON representation
  53232. * @param scene Define the scene the texture should be created in
  53233. * @param rootUrl Define the root url in case we need to load relative dependencies
  53234. * @returns the newly created texture after parsing
  53235. */
  53236. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53237. serialize(): any;
  53238. }
  53239. }
  53240. declare module BABYLON {
  53241. /**
  53242. * Class used to control physics engine
  53243. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53244. */
  53245. export class PhysicsEngine implements IPhysicsEngine {
  53246. private _physicsPlugin;
  53247. /**
  53248. * Global value used to control the smallest number supported by the simulation
  53249. */
  53250. static Epsilon: number;
  53251. private _impostors;
  53252. private _joints;
  53253. private _subTimeStep;
  53254. /**
  53255. * Gets the gravity vector used by the simulation
  53256. */
  53257. gravity: Vector3;
  53258. /**
  53259. * Factory used to create the default physics plugin.
  53260. * @returns The default physics plugin
  53261. */
  53262. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53263. /**
  53264. * Creates a new Physics Engine
  53265. * @param gravity defines the gravity vector used by the simulation
  53266. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53267. */
  53268. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53269. /**
  53270. * Sets the gravity vector used by the simulation
  53271. * @param gravity defines the gravity vector to use
  53272. */
  53273. setGravity(gravity: Vector3): void;
  53274. /**
  53275. * Set the time step of the physics engine.
  53276. * Default is 1/60.
  53277. * To slow it down, enter 1/600 for example.
  53278. * To speed it up, 1/30
  53279. * @param newTimeStep defines the new timestep to apply to this world.
  53280. */
  53281. setTimeStep(newTimeStep?: number): void;
  53282. /**
  53283. * Get the time step of the physics engine.
  53284. * @returns the current time step
  53285. */
  53286. getTimeStep(): number;
  53287. /**
  53288. * Set the sub time step of the physics engine.
  53289. * Default is 0 meaning there is no sub steps
  53290. * To increase physics resolution precision, set a small value (like 1 ms)
  53291. * @param subTimeStep defines the new sub timestep used for physics resolution.
  53292. */
  53293. setSubTimeStep(subTimeStep?: number): void;
  53294. /**
  53295. * Get the sub time step of the physics engine.
  53296. * @returns the current sub time step
  53297. */
  53298. getSubTimeStep(): number;
  53299. /**
  53300. * Release all resources
  53301. */
  53302. dispose(): void;
  53303. /**
  53304. * Gets the name of the current physics plugin
  53305. * @returns the name of the plugin
  53306. */
  53307. getPhysicsPluginName(): string;
  53308. /**
  53309. * Adding a new impostor for the impostor tracking.
  53310. * This will be done by the impostor itself.
  53311. * @param impostor the impostor to add
  53312. */
  53313. addImpostor(impostor: PhysicsImpostor): void;
  53314. /**
  53315. * Remove an impostor from the engine.
  53316. * This impostor and its mesh will not longer be updated by the physics engine.
  53317. * @param impostor the impostor to remove
  53318. */
  53319. removeImpostor(impostor: PhysicsImpostor): void;
  53320. /**
  53321. * Add a joint to the physics engine
  53322. * @param mainImpostor defines the main impostor to which the joint is added.
  53323. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53324. * @param joint defines the joint that will connect both impostors.
  53325. */
  53326. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53327. /**
  53328. * Removes a joint from the simulation
  53329. * @param mainImpostor defines the impostor used with the joint
  53330. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53331. * @param joint defines the joint to remove
  53332. */
  53333. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53334. /**
  53335. * Called by the scene. No need to call it.
  53336. * @param delta defines the timespam between frames
  53337. */
  53338. _step(delta: number): void;
  53339. /**
  53340. * Gets the current plugin used to run the simulation
  53341. * @returns current plugin
  53342. */
  53343. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53344. /**
  53345. * Gets the list of physic impostors
  53346. * @returns an array of PhysicsImpostor
  53347. */
  53348. getImpostors(): Array<PhysicsImpostor>;
  53349. /**
  53350. * Gets the impostor for a physics enabled object
  53351. * @param object defines the object impersonated by the impostor
  53352. * @returns the PhysicsImpostor or null if not found
  53353. */
  53354. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53355. /**
  53356. * Gets the impostor for a physics body object
  53357. * @param body defines physics body used by the impostor
  53358. * @returns the PhysicsImpostor or null if not found
  53359. */
  53360. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53361. /**
  53362. * Does a raycast in the physics world
  53363. * @param from when should the ray start?
  53364. * @param to when should the ray end?
  53365. * @returns PhysicsRaycastResult
  53366. */
  53367. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53368. }
  53369. }
  53370. declare module BABYLON {
  53371. /** @hidden */
  53372. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53373. private _useDeltaForWorldStep;
  53374. world: any;
  53375. name: string;
  53376. private _physicsMaterials;
  53377. private _fixedTimeStep;
  53378. private _cannonRaycastResult;
  53379. private _raycastResult;
  53380. private _physicsBodysToRemoveAfterStep;
  53381. BJSCANNON: any;
  53382. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53383. setGravity(gravity: Vector3): void;
  53384. setTimeStep(timeStep: number): void;
  53385. getTimeStep(): number;
  53386. executeStep(delta: number): void;
  53387. private _removeMarkedPhysicsBodiesFromWorld;
  53388. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53390. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53391. private _processChildMeshes;
  53392. removePhysicsBody(impostor: PhysicsImpostor): void;
  53393. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53394. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53395. private _addMaterial;
  53396. private _checkWithEpsilon;
  53397. private _createShape;
  53398. private _createHeightmap;
  53399. private _minus90X;
  53400. private _plus90X;
  53401. private _tmpPosition;
  53402. private _tmpDeltaPosition;
  53403. private _tmpUnityRotation;
  53404. private _updatePhysicsBodyTransformation;
  53405. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53406. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53407. isSupported(): boolean;
  53408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53413. getBodyMass(impostor: PhysicsImpostor): number;
  53414. getBodyFriction(impostor: PhysicsImpostor): number;
  53415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53416. getBodyRestitution(impostor: PhysicsImpostor): number;
  53417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53418. sleepBody(impostor: PhysicsImpostor): void;
  53419. wakeUpBody(impostor: PhysicsImpostor): void;
  53420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53424. getRadius(impostor: PhysicsImpostor): number;
  53425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53426. dispose(): void;
  53427. private _extendNamespace;
  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. /** @hidden */
  53439. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53440. world: any;
  53441. name: string;
  53442. BJSOIMO: any;
  53443. private _raycastResult;
  53444. constructor(iterations?: number, oimoInjection?: any);
  53445. setGravity(gravity: Vector3): void;
  53446. setTimeStep(timeStep: number): void;
  53447. getTimeStep(): number;
  53448. private _tmpImpostorsArray;
  53449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53451. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53453. private _tmpPositionVector;
  53454. removePhysicsBody(impostor: PhysicsImpostor): void;
  53455. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53456. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53457. isSupported(): boolean;
  53458. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53459. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53461. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53462. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53463. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53464. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53465. getBodyMass(impostor: PhysicsImpostor): number;
  53466. getBodyFriction(impostor: PhysicsImpostor): number;
  53467. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53468. getBodyRestitution(impostor: PhysicsImpostor): number;
  53469. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53470. sleepBody(impostor: PhysicsImpostor): void;
  53471. wakeUpBody(impostor: PhysicsImpostor): void;
  53472. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53473. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53474. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53476. getRadius(impostor: PhysicsImpostor): number;
  53477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53478. dispose(): void;
  53479. /**
  53480. * Does a raycast in the physics world
  53481. * @param from when should the ray start?
  53482. * @param to when should the ray end?
  53483. * @returns PhysicsRaycastResult
  53484. */
  53485. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53486. }
  53487. }
  53488. declare module BABYLON {
  53489. /**
  53490. * Class containing static functions to help procedurally build meshes
  53491. */
  53492. export class RibbonBuilder {
  53493. /**
  53494. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53495. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53496. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53497. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53498. * * 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
  53499. * * 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
  53500. * * 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
  53501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53502. * * 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
  53503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53504. * * 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
  53505. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53506. * * 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
  53507. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53509. * @param name defines the name of the mesh
  53510. * @param options defines the options used to create the mesh
  53511. * @param scene defines the hosting scene
  53512. * @returns the ribbon mesh
  53513. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53515. */
  53516. static CreateRibbon(name: string, options: {
  53517. pathArray: Vector3[][];
  53518. closeArray?: boolean;
  53519. closePath?: boolean;
  53520. offset?: number;
  53521. updatable?: boolean;
  53522. sideOrientation?: number;
  53523. frontUVs?: Vector4;
  53524. backUVs?: Vector4;
  53525. instance?: Mesh;
  53526. invertUV?: boolean;
  53527. uvs?: Vector2[];
  53528. colors?: Color4[];
  53529. }, scene?: Nullable<Scene>): Mesh;
  53530. }
  53531. }
  53532. declare module BABYLON {
  53533. /**
  53534. * Class containing static functions to help procedurally build meshes
  53535. */
  53536. export class ShapeBuilder {
  53537. /**
  53538. * 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.
  53539. * * 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.
  53540. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53541. * * 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.
  53542. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53543. * * 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
  53544. * * 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
  53545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53547. * * 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
  53548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53550. * @param name defines the name of the mesh
  53551. * @param options defines the options used to create the mesh
  53552. * @param scene defines the hosting scene
  53553. * @returns the extruded shape mesh
  53554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53556. */
  53557. static ExtrudeShape(name: string, options: {
  53558. shape: Vector3[];
  53559. path: Vector3[];
  53560. scale?: number;
  53561. rotation?: number;
  53562. cap?: number;
  53563. updatable?: boolean;
  53564. sideOrientation?: number;
  53565. frontUVs?: Vector4;
  53566. backUVs?: Vector4;
  53567. instance?: Mesh;
  53568. invertUV?: boolean;
  53569. }, scene?: Nullable<Scene>): Mesh;
  53570. /**
  53571. * Creates an custom extruded shape mesh.
  53572. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53573. * * 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.
  53574. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53575. * * 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
  53576. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53577. * * 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
  53578. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53579. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53580. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53581. * * 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
  53582. * * 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
  53583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53585. * * 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
  53586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53588. * @param name defines the name of the mesh
  53589. * @param options defines the options used to create the mesh
  53590. * @param scene defines the hosting scene
  53591. * @returns the custom extruded shape mesh
  53592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53595. */
  53596. static ExtrudeShapeCustom(name: string, options: {
  53597. shape: Vector3[];
  53598. path: Vector3[];
  53599. scaleFunction?: any;
  53600. rotationFunction?: any;
  53601. ribbonCloseArray?: boolean;
  53602. ribbonClosePath?: boolean;
  53603. cap?: number;
  53604. updatable?: boolean;
  53605. sideOrientation?: number;
  53606. frontUVs?: Vector4;
  53607. backUVs?: Vector4;
  53608. instance?: Mesh;
  53609. invertUV?: boolean;
  53610. }, scene?: Nullable<Scene>): Mesh;
  53611. private static _ExtrudeShapeGeneric;
  53612. }
  53613. }
  53614. declare module BABYLON {
  53615. /**
  53616. * AmmoJS Physics plugin
  53617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53618. * @see https://github.com/kripken/ammo.js/
  53619. */
  53620. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53621. private _useDeltaForWorldStep;
  53622. /**
  53623. * Reference to the Ammo library
  53624. */
  53625. bjsAMMO: any;
  53626. /**
  53627. * Created ammoJS world which physics bodies are added to
  53628. */
  53629. world: any;
  53630. /**
  53631. * Name of the plugin
  53632. */
  53633. name: string;
  53634. private _timeStep;
  53635. private _fixedTimeStep;
  53636. private _maxSteps;
  53637. private _tmpQuaternion;
  53638. private _tmpAmmoTransform;
  53639. private _tmpAmmoQuaternion;
  53640. private _tmpAmmoConcreteContactResultCallback;
  53641. private _collisionConfiguration;
  53642. private _dispatcher;
  53643. private _overlappingPairCache;
  53644. private _solver;
  53645. private _softBodySolver;
  53646. private _tmpAmmoVectorA;
  53647. private _tmpAmmoVectorB;
  53648. private _tmpAmmoVectorC;
  53649. private _tmpAmmoVectorD;
  53650. private _tmpContactCallbackResult;
  53651. private _tmpAmmoVectorRCA;
  53652. private _tmpAmmoVectorRCB;
  53653. private _raycastResult;
  53654. private static readonly DISABLE_COLLISION_FLAG;
  53655. private static readonly KINEMATIC_FLAG;
  53656. private static readonly DISABLE_DEACTIVATION_FLAG;
  53657. /**
  53658. * Initializes the ammoJS plugin
  53659. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53660. * @param ammoInjection can be used to inject your own ammo reference
  53661. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53662. */
  53663. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53664. /**
  53665. * Sets the gravity of the physics world (m/(s^2))
  53666. * @param gravity Gravity to set
  53667. */
  53668. setGravity(gravity: Vector3): void;
  53669. /**
  53670. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53671. * @param timeStep timestep to use in seconds
  53672. */
  53673. setTimeStep(timeStep: number): void;
  53674. /**
  53675. * 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)
  53676. * @param fixedTimeStep fixedTimeStep to use in seconds
  53677. */
  53678. setFixedTimeStep(fixedTimeStep: number): void;
  53679. /**
  53680. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53681. * @param maxSteps the maximum number of steps by the physics engine per frame
  53682. */
  53683. setMaxSteps(maxSteps: number): void;
  53684. /**
  53685. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53686. * @returns the current timestep in seconds
  53687. */
  53688. getTimeStep(): number;
  53689. /**
  53690. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53691. */
  53692. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53693. private _isImpostorInContact;
  53694. private _isImpostorPairInContact;
  53695. private _stepSimulation;
  53696. /**
  53697. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53698. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53699. * After the step the babylon meshes are set to the position of the physics imposters
  53700. * @param delta amount of time to step forward
  53701. * @param impostors array of imposters to update before/after the step
  53702. */
  53703. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53704. /**
  53705. * Update babylon mesh to match physics world object
  53706. * @param impostor imposter to match
  53707. */
  53708. private _afterSoftStep;
  53709. /**
  53710. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53711. * @param impostor imposter to match
  53712. */
  53713. private _ropeStep;
  53714. /**
  53715. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53716. * @param impostor imposter to match
  53717. */
  53718. private _softbodyOrClothStep;
  53719. private _tmpVector;
  53720. private _tmpMatrix;
  53721. /**
  53722. * Applies an impulse on the imposter
  53723. * @param impostor imposter to apply impulse to
  53724. * @param force amount of force to be applied to the imposter
  53725. * @param contactPoint the location to apply the impulse on the imposter
  53726. */
  53727. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53728. /**
  53729. * Applies a force on the imposter
  53730. * @param impostor imposter to apply force
  53731. * @param force amount of force to be applied to the imposter
  53732. * @param contactPoint the location to apply the force on the imposter
  53733. */
  53734. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53735. /**
  53736. * Creates a physics body using the plugin
  53737. * @param impostor the imposter to create the physics body on
  53738. */
  53739. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53740. /**
  53741. * Removes the physics body from the imposter and disposes of the body's memory
  53742. * @param impostor imposter to remove the physics body from
  53743. */
  53744. removePhysicsBody(impostor: PhysicsImpostor): void;
  53745. /**
  53746. * Generates a joint
  53747. * @param impostorJoint the imposter joint to create the joint with
  53748. */
  53749. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53750. /**
  53751. * Removes a joint
  53752. * @param impostorJoint the imposter joint to remove the joint from
  53753. */
  53754. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53755. private _addMeshVerts;
  53756. /**
  53757. * Initialise the soft body vertices to match its object's (mesh) vertices
  53758. * Softbody vertices (nodes) are in world space and to match this
  53759. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53760. * @param impostor to create the softbody for
  53761. */
  53762. private _softVertexData;
  53763. /**
  53764. * Create an impostor's soft body
  53765. * @param impostor to create the softbody for
  53766. */
  53767. private _createSoftbody;
  53768. /**
  53769. * Create cloth for an impostor
  53770. * @param impostor to create the softbody for
  53771. */
  53772. private _createCloth;
  53773. /**
  53774. * Create rope for an impostor
  53775. * @param impostor to create the softbody for
  53776. */
  53777. private _createRope;
  53778. /**
  53779. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53780. * @param impostor to create the custom physics shape for
  53781. */
  53782. private _createCustom;
  53783. private _addHullVerts;
  53784. private _createShape;
  53785. /**
  53786. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53787. * @param impostor imposter containing the physics body and babylon object
  53788. */
  53789. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53790. /**
  53791. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53792. * @param impostor imposter containing the physics body and babylon object
  53793. * @param newPosition new position
  53794. * @param newRotation new rotation
  53795. */
  53796. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53797. /**
  53798. * If this plugin is supported
  53799. * @returns true if its supported
  53800. */
  53801. isSupported(): boolean;
  53802. /**
  53803. * Sets the linear velocity of the physics body
  53804. * @param impostor imposter to set the velocity on
  53805. * @param velocity velocity to set
  53806. */
  53807. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53808. /**
  53809. * Sets the angular velocity of the physics body
  53810. * @param impostor imposter to set the velocity on
  53811. * @param velocity velocity to set
  53812. */
  53813. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53814. /**
  53815. * gets the linear velocity
  53816. * @param impostor imposter to get linear velocity from
  53817. * @returns linear velocity
  53818. */
  53819. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53820. /**
  53821. * gets the angular velocity
  53822. * @param impostor imposter to get angular velocity from
  53823. * @returns angular velocity
  53824. */
  53825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53826. /**
  53827. * Sets the mass of physics body
  53828. * @param impostor imposter to set the mass on
  53829. * @param mass mass to set
  53830. */
  53831. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53832. /**
  53833. * Gets the mass of the physics body
  53834. * @param impostor imposter to get the mass from
  53835. * @returns mass
  53836. */
  53837. getBodyMass(impostor: PhysicsImpostor): number;
  53838. /**
  53839. * Gets friction of the impostor
  53840. * @param impostor impostor to get friction from
  53841. * @returns friction value
  53842. */
  53843. getBodyFriction(impostor: PhysicsImpostor): number;
  53844. /**
  53845. * Sets friction of the impostor
  53846. * @param impostor impostor to set friction on
  53847. * @param friction friction value
  53848. */
  53849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53850. /**
  53851. * Gets restitution of the impostor
  53852. * @param impostor impostor to get restitution from
  53853. * @returns restitution value
  53854. */
  53855. getBodyRestitution(impostor: PhysicsImpostor): number;
  53856. /**
  53857. * Sets resitution of the impostor
  53858. * @param impostor impostor to set resitution on
  53859. * @param restitution resitution value
  53860. */
  53861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53862. /**
  53863. * Gets pressure inside the impostor
  53864. * @param impostor impostor to get pressure from
  53865. * @returns pressure value
  53866. */
  53867. getBodyPressure(impostor: PhysicsImpostor): number;
  53868. /**
  53869. * Sets pressure inside a soft body impostor
  53870. * Cloth and rope must remain 0 pressure
  53871. * @param impostor impostor to set pressure on
  53872. * @param pressure pressure value
  53873. */
  53874. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53875. /**
  53876. * Gets stiffness of the impostor
  53877. * @param impostor impostor to get stiffness from
  53878. * @returns pressure value
  53879. */
  53880. getBodyStiffness(impostor: PhysicsImpostor): number;
  53881. /**
  53882. * Sets stiffness of the impostor
  53883. * @param impostor impostor to set stiffness on
  53884. * @param stiffness stiffness value from 0 to 1
  53885. */
  53886. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53887. /**
  53888. * Gets velocityIterations of the impostor
  53889. * @param impostor impostor to get velocity iterations from
  53890. * @returns velocityIterations value
  53891. */
  53892. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53893. /**
  53894. * Sets velocityIterations of the impostor
  53895. * @param impostor impostor to set velocity iterations on
  53896. * @param velocityIterations velocityIterations value
  53897. */
  53898. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53899. /**
  53900. * Gets positionIterations of the impostor
  53901. * @param impostor impostor to get position iterations from
  53902. * @returns positionIterations value
  53903. */
  53904. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53905. /**
  53906. * Sets positionIterations of the impostor
  53907. * @param impostor impostor to set position on
  53908. * @param positionIterations positionIterations value
  53909. */
  53910. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53911. /**
  53912. * Append an anchor to a cloth object
  53913. * @param impostor is the cloth impostor to add anchor to
  53914. * @param otherImpostor is the rigid impostor to anchor to
  53915. * @param width ratio across width from 0 to 1
  53916. * @param height ratio up height from 0 to 1
  53917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53919. */
  53920. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53921. /**
  53922. * Append an hook to a rope object
  53923. * @param impostor is the rope impostor to add hook to
  53924. * @param otherImpostor is the rigid impostor to hook to
  53925. * @param length ratio along the rope from 0 to 1
  53926. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53928. */
  53929. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53930. /**
  53931. * Sleeps the physics body and stops it from being active
  53932. * @param impostor impostor to sleep
  53933. */
  53934. sleepBody(impostor: PhysicsImpostor): void;
  53935. /**
  53936. * Activates the physics body
  53937. * @param impostor impostor to activate
  53938. */
  53939. wakeUpBody(impostor: PhysicsImpostor): void;
  53940. /**
  53941. * Updates the distance parameters of the joint
  53942. * @param joint joint to update
  53943. * @param maxDistance maximum distance of the joint
  53944. * @param minDistance minimum distance of the joint
  53945. */
  53946. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53947. /**
  53948. * Sets a motor on the joint
  53949. * @param joint joint to set motor on
  53950. * @param speed speed of the motor
  53951. * @param maxForce maximum force of the motor
  53952. * @param motorIndex index of the motor
  53953. */
  53954. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53955. /**
  53956. * Sets the motors limit
  53957. * @param joint joint to set limit on
  53958. * @param upperLimit upper limit
  53959. * @param lowerLimit lower limit
  53960. */
  53961. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53962. /**
  53963. * Syncs the position and rotation of a mesh with the impostor
  53964. * @param mesh mesh to sync
  53965. * @param impostor impostor to update the mesh with
  53966. */
  53967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53968. /**
  53969. * Gets the radius of the impostor
  53970. * @param impostor impostor to get radius from
  53971. * @returns the radius
  53972. */
  53973. getRadius(impostor: PhysicsImpostor): number;
  53974. /**
  53975. * Gets the box size of the impostor
  53976. * @param impostor impostor to get box size from
  53977. * @param result the resulting box size
  53978. */
  53979. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53980. /**
  53981. * Disposes of the impostor
  53982. */
  53983. dispose(): void;
  53984. /**
  53985. * Does a raycast in the physics world
  53986. * @param from when should the ray start?
  53987. * @param to when should the ray end?
  53988. * @returns PhysicsRaycastResult
  53989. */
  53990. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53991. }
  53992. }
  53993. declare module BABYLON {
  53994. interface AbstractScene {
  53995. /**
  53996. * The list of reflection probes added to the scene
  53997. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53998. */
  53999. reflectionProbes: Array<ReflectionProbe>;
  54000. /**
  54001. * Removes the given reflection probe from this scene.
  54002. * @param toRemove The reflection probe to remove
  54003. * @returns The index of the removed reflection probe
  54004. */
  54005. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54006. /**
  54007. * Adds the given reflection probe to this scene.
  54008. * @param newReflectionProbe The reflection probe to add
  54009. */
  54010. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54011. }
  54012. /**
  54013. * Class used to generate realtime reflection / refraction cube textures
  54014. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54015. */
  54016. export class ReflectionProbe {
  54017. /** defines the name of the probe */
  54018. name: string;
  54019. private _scene;
  54020. private _renderTargetTexture;
  54021. private _projectionMatrix;
  54022. private _viewMatrix;
  54023. private _target;
  54024. private _add;
  54025. private _attachedMesh;
  54026. private _invertYAxis;
  54027. /** Gets or sets probe position (center of the cube map) */
  54028. position: Vector3;
  54029. /**
  54030. * Creates a new reflection probe
  54031. * @param name defines the name of the probe
  54032. * @param size defines the texture resolution (for each face)
  54033. * @param scene defines the hosting scene
  54034. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54035. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54036. */
  54037. constructor(
  54038. /** defines the name of the probe */
  54039. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54040. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54041. get samples(): number;
  54042. set samples(value: number);
  54043. /** Gets or sets the refresh rate to use (on every frame by default) */
  54044. get refreshRate(): number;
  54045. set refreshRate(value: number);
  54046. /**
  54047. * Gets the hosting scene
  54048. * @returns a Scene
  54049. */
  54050. getScene(): Scene;
  54051. /** Gets the internal CubeTexture used to render to */
  54052. get cubeTexture(): RenderTargetTexture;
  54053. /** Gets the list of meshes to render */
  54054. get renderList(): Nullable<AbstractMesh[]>;
  54055. /**
  54056. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54057. * @param mesh defines the mesh to attach to
  54058. */
  54059. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54060. /**
  54061. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54062. * @param renderingGroupId The rendering group id corresponding to its index
  54063. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54064. */
  54065. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54066. /**
  54067. * Clean all associated resources
  54068. */
  54069. dispose(): void;
  54070. /**
  54071. * Converts the reflection probe information to a readable string for debug purpose.
  54072. * @param fullDetails Supports for multiple levels of logging within scene loading
  54073. * @returns the human readable reflection probe info
  54074. */
  54075. toString(fullDetails?: boolean): string;
  54076. /**
  54077. * Get the class name of the relfection probe.
  54078. * @returns "ReflectionProbe"
  54079. */
  54080. getClassName(): string;
  54081. /**
  54082. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54083. * @returns The JSON representation of the texture
  54084. */
  54085. serialize(): any;
  54086. /**
  54087. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54088. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54089. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54090. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54091. * @returns The parsed reflection probe if successful
  54092. */
  54093. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54094. }
  54095. }
  54096. declare module BABYLON {
  54097. /** @hidden */
  54098. export var _BabylonLoaderRegistered: boolean;
  54099. /**
  54100. * Helps setting up some configuration for the babylon file loader.
  54101. */
  54102. export class BabylonFileLoaderConfiguration {
  54103. /**
  54104. * The loader does not allow injecting custom physix engine into the plugins.
  54105. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54106. * So you could set this variable to your engine import to make it work.
  54107. */
  54108. static LoaderInjectedPhysicsEngine: any;
  54109. }
  54110. }
  54111. declare module BABYLON {
  54112. /**
  54113. * The Physically based simple base material of BJS.
  54114. *
  54115. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54116. * It is used as the base class for both the specGloss and metalRough conventions.
  54117. */
  54118. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54119. /**
  54120. * Number of Simultaneous lights allowed on the material.
  54121. */
  54122. maxSimultaneousLights: number;
  54123. /**
  54124. * If sets to true, disables all the lights affecting the material.
  54125. */
  54126. disableLighting: boolean;
  54127. /**
  54128. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54129. */
  54130. environmentTexture: BaseTexture;
  54131. /**
  54132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54133. */
  54134. invertNormalMapX: boolean;
  54135. /**
  54136. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54137. */
  54138. invertNormalMapY: boolean;
  54139. /**
  54140. * Normal map used in the model.
  54141. */
  54142. normalTexture: BaseTexture;
  54143. /**
  54144. * Emissivie color used to self-illuminate the model.
  54145. */
  54146. emissiveColor: Color3;
  54147. /**
  54148. * Emissivie texture used to self-illuminate the model.
  54149. */
  54150. emissiveTexture: BaseTexture;
  54151. /**
  54152. * Occlusion Channel Strenght.
  54153. */
  54154. occlusionStrength: number;
  54155. /**
  54156. * Occlusion Texture of the material (adding extra occlusion effects).
  54157. */
  54158. occlusionTexture: BaseTexture;
  54159. /**
  54160. * Defines the alpha limits in alpha test mode.
  54161. */
  54162. alphaCutOff: number;
  54163. /**
  54164. * Gets the current double sided mode.
  54165. */
  54166. get doubleSided(): boolean;
  54167. /**
  54168. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54169. */
  54170. set doubleSided(value: boolean);
  54171. /**
  54172. * Stores the pre-calculated light information of a mesh in a texture.
  54173. */
  54174. lightmapTexture: BaseTexture;
  54175. /**
  54176. * If true, the light map contains occlusion information instead of lighting info.
  54177. */
  54178. useLightmapAsShadowmap: boolean;
  54179. /**
  54180. * Instantiates a new PBRMaterial instance.
  54181. *
  54182. * @param name The material name
  54183. * @param scene The scene the material will be use in.
  54184. */
  54185. constructor(name: string, scene: Scene);
  54186. getClassName(): string;
  54187. }
  54188. }
  54189. declare module BABYLON {
  54190. /**
  54191. * The PBR material of BJS following the metal roughness convention.
  54192. *
  54193. * This fits to the PBR convention in the GLTF definition:
  54194. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54195. */
  54196. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54197. /**
  54198. * The base color has two different interpretations depending on the value of metalness.
  54199. * When the material is a metal, the base color is the specific measured reflectance value
  54200. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54201. * of the material.
  54202. */
  54203. baseColor: Color3;
  54204. /**
  54205. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54206. * well as opacity information in the alpha channel.
  54207. */
  54208. baseTexture: BaseTexture;
  54209. /**
  54210. * Specifies the metallic scalar value of the material.
  54211. * Can also be used to scale the metalness values of the metallic texture.
  54212. */
  54213. metallic: number;
  54214. /**
  54215. * Specifies the roughness scalar value of the material.
  54216. * Can also be used to scale the roughness values of the metallic texture.
  54217. */
  54218. roughness: number;
  54219. /**
  54220. * Texture containing both the metallic value in the B channel and the
  54221. * roughness value in the G channel to keep better precision.
  54222. */
  54223. metallicRoughnessTexture: BaseTexture;
  54224. /**
  54225. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54226. *
  54227. * @param name The material name
  54228. * @param scene The scene the material will be use in.
  54229. */
  54230. constructor(name: string, scene: Scene);
  54231. /**
  54232. * Return the currrent class name of the material.
  54233. */
  54234. getClassName(): string;
  54235. /**
  54236. * Makes a duplicate of the current material.
  54237. * @param name - name to use for the new material.
  54238. */
  54239. clone(name: string): PBRMetallicRoughnessMaterial;
  54240. /**
  54241. * Serialize the material to a parsable JSON object.
  54242. */
  54243. serialize(): any;
  54244. /**
  54245. * Parses a JSON object correponding to the serialize function.
  54246. */
  54247. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54248. }
  54249. }
  54250. declare module BABYLON {
  54251. /**
  54252. * The PBR material of BJS following the specular glossiness convention.
  54253. *
  54254. * This fits to the PBR convention in the GLTF definition:
  54255. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54256. */
  54257. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54258. /**
  54259. * Specifies the diffuse color of the material.
  54260. */
  54261. diffuseColor: Color3;
  54262. /**
  54263. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54264. * channel.
  54265. */
  54266. diffuseTexture: BaseTexture;
  54267. /**
  54268. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54269. */
  54270. specularColor: Color3;
  54271. /**
  54272. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54273. */
  54274. glossiness: number;
  54275. /**
  54276. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54277. */
  54278. specularGlossinessTexture: BaseTexture;
  54279. /**
  54280. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54281. *
  54282. * @param name The material name
  54283. * @param scene The scene the material will be use in.
  54284. */
  54285. constructor(name: string, scene: Scene);
  54286. /**
  54287. * Return the currrent class name of the material.
  54288. */
  54289. getClassName(): string;
  54290. /**
  54291. * Makes a duplicate of the current material.
  54292. * @param name - name to use for the new material.
  54293. */
  54294. clone(name: string): PBRSpecularGlossinessMaterial;
  54295. /**
  54296. * Serialize the material to a parsable JSON object.
  54297. */
  54298. serialize(): any;
  54299. /**
  54300. * Parses a JSON object correponding to the serialize function.
  54301. */
  54302. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54303. }
  54304. }
  54305. declare module BABYLON {
  54306. /**
  54307. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54308. * It can help converting any input color in a desired output one. This can then be used to create effects
  54309. * from sepia, black and white to sixties or futuristic rendering...
  54310. *
  54311. * The only supported format is currently 3dl.
  54312. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54313. */
  54314. export class ColorGradingTexture extends BaseTexture {
  54315. /**
  54316. * The current texture matrix. (will always be identity in color grading texture)
  54317. */
  54318. private _textureMatrix;
  54319. /**
  54320. * The texture URL.
  54321. */
  54322. url: string;
  54323. /**
  54324. * Empty line regex stored for GC.
  54325. */
  54326. private static _noneEmptyLineRegex;
  54327. private _engine;
  54328. /**
  54329. * Instantiates a ColorGradingTexture from the following parameters.
  54330. *
  54331. * @param url The location of the color gradind data (currently only supporting 3dl)
  54332. * @param scene The scene the texture will be used in
  54333. */
  54334. constructor(url: string, scene: Scene);
  54335. /**
  54336. * Returns the texture matrix used in most of the material.
  54337. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54338. */
  54339. getTextureMatrix(): Matrix;
  54340. /**
  54341. * Occurs when the file being loaded is a .3dl LUT file.
  54342. */
  54343. private load3dlTexture;
  54344. /**
  54345. * Starts the loading process of the texture.
  54346. */
  54347. private loadTexture;
  54348. /**
  54349. * Clones the color gradind texture.
  54350. */
  54351. clone(): ColorGradingTexture;
  54352. /**
  54353. * Called during delayed load for textures.
  54354. */
  54355. delayLoad(): void;
  54356. /**
  54357. * Parses a color grading texture serialized by Babylon.
  54358. * @param parsedTexture The texture information being parsedTexture
  54359. * @param scene The scene to load the texture in
  54360. * @param rootUrl The root url of the data assets to load
  54361. * @return A color gradind texture
  54362. */
  54363. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54364. /**
  54365. * Serializes the LUT texture to json format.
  54366. */
  54367. serialize(): any;
  54368. }
  54369. }
  54370. declare module BABYLON {
  54371. /**
  54372. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54373. */
  54374. export class EquiRectangularCubeTexture extends BaseTexture {
  54375. /** The six faces of the cube. */
  54376. private static _FacesMapping;
  54377. private _noMipmap;
  54378. private _onLoad;
  54379. private _onError;
  54380. /** The size of the cubemap. */
  54381. private _size;
  54382. /** The buffer of the image. */
  54383. private _buffer;
  54384. /** The width of the input image. */
  54385. private _width;
  54386. /** The height of the input image. */
  54387. private _height;
  54388. /** The URL to the image. */
  54389. url: string;
  54390. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54391. coordinatesMode: number;
  54392. /**
  54393. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54394. * @param url The location of the image
  54395. * @param scene The scene the texture will be used in
  54396. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54397. * @param noMipmap Forces to not generate the mipmap if true
  54398. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54399. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54400. * @param onLoad — defines a callback called when texture is loaded
  54401. * @param onError — defines a callback called if there is an error
  54402. */
  54403. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54404. /**
  54405. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54406. */
  54407. private loadImage;
  54408. /**
  54409. * Convert the image buffer into a cubemap and create a CubeTexture.
  54410. */
  54411. private loadTexture;
  54412. /**
  54413. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54414. * @param buffer The ArrayBuffer that should be converted.
  54415. * @returns The buffer as Float32Array.
  54416. */
  54417. private getFloat32ArrayFromArrayBuffer;
  54418. /**
  54419. * Get the current class name of the texture useful for serialization or dynamic coding.
  54420. * @returns "EquiRectangularCubeTexture"
  54421. */
  54422. getClassName(): string;
  54423. /**
  54424. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54425. * @returns A clone of the current EquiRectangularCubeTexture.
  54426. */
  54427. clone(): EquiRectangularCubeTexture;
  54428. }
  54429. }
  54430. declare module BABYLON {
  54431. /**
  54432. * Based on jsTGALoader - Javascript loader for TGA file
  54433. * By Vincent Thibault
  54434. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54435. */
  54436. export class TGATools {
  54437. private static _TYPE_INDEXED;
  54438. private static _TYPE_RGB;
  54439. private static _TYPE_GREY;
  54440. private static _TYPE_RLE_INDEXED;
  54441. private static _TYPE_RLE_RGB;
  54442. private static _TYPE_RLE_GREY;
  54443. private static _ORIGIN_MASK;
  54444. private static _ORIGIN_SHIFT;
  54445. private static _ORIGIN_BL;
  54446. private static _ORIGIN_BR;
  54447. private static _ORIGIN_UL;
  54448. private static _ORIGIN_UR;
  54449. /**
  54450. * Gets the header of a TGA file
  54451. * @param data defines the TGA data
  54452. * @returns the header
  54453. */
  54454. static GetTGAHeader(data: Uint8Array): any;
  54455. /**
  54456. * Uploads TGA content to a Babylon Texture
  54457. * @hidden
  54458. */
  54459. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54460. /** @hidden */
  54461. 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;
  54462. /** @hidden */
  54463. 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;
  54464. /** @hidden */
  54465. 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;
  54466. /** @hidden */
  54467. 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;
  54468. /** @hidden */
  54469. 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;
  54470. /** @hidden */
  54471. 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;
  54472. }
  54473. }
  54474. declare module BABYLON {
  54475. /**
  54476. * Implementation of the TGA Texture Loader.
  54477. * @hidden
  54478. */
  54479. export class _TGATextureLoader implements IInternalTextureLoader {
  54480. /**
  54481. * Defines wether the loader supports cascade loading the different faces.
  54482. */
  54483. readonly supportCascades: boolean;
  54484. /**
  54485. * This returns if the loader support the current file information.
  54486. * @param extension defines the file extension of the file being loaded
  54487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54488. * @param fallback defines the fallback internal texture if any
  54489. * @param isBase64 defines whether the texture is encoded as a base64
  54490. * @param isBuffer defines whether the texture data are stored as a buffer
  54491. * @returns true if the loader can load the specified file
  54492. */
  54493. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54494. /**
  54495. * Transform the url before loading if required.
  54496. * @param rootUrl the url of the texture
  54497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54498. * @returns the transformed texture
  54499. */
  54500. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54501. /**
  54502. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54503. * @param rootUrl the url of the texture
  54504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54505. * @returns the fallback texture
  54506. */
  54507. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54508. /**
  54509. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54510. * @param data contains the texture data
  54511. * @param texture defines the BabylonJS internal texture
  54512. * @param createPolynomials will be true if polynomials have been requested
  54513. * @param onLoad defines the callback to trigger once the texture is ready
  54514. * @param onError defines the callback to trigger in case of error
  54515. */
  54516. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54517. /**
  54518. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54519. * @param data contains the texture data
  54520. * @param texture defines the BabylonJS internal texture
  54521. * @param callback defines the method to call once ready to upload
  54522. */
  54523. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54524. }
  54525. }
  54526. declare module BABYLON {
  54527. /**
  54528. * Info about the .basis files
  54529. */
  54530. class BasisFileInfo {
  54531. /**
  54532. * If the file has alpha
  54533. */
  54534. hasAlpha: boolean;
  54535. /**
  54536. * Info about each image of the basis file
  54537. */
  54538. images: Array<{
  54539. levels: Array<{
  54540. width: number;
  54541. height: number;
  54542. transcodedPixels: ArrayBufferView;
  54543. }>;
  54544. }>;
  54545. }
  54546. /**
  54547. * Result of transcoding a basis file
  54548. */
  54549. class TranscodeResult {
  54550. /**
  54551. * Info about the .basis file
  54552. */
  54553. fileInfo: BasisFileInfo;
  54554. /**
  54555. * Format to use when loading the file
  54556. */
  54557. format: number;
  54558. }
  54559. /**
  54560. * Configuration options for the Basis transcoder
  54561. */
  54562. export class BasisTranscodeConfiguration {
  54563. /**
  54564. * Supported compression formats used to determine the supported output format of the transcoder
  54565. */
  54566. supportedCompressionFormats?: {
  54567. /**
  54568. * etc1 compression format
  54569. */
  54570. etc1?: boolean;
  54571. /**
  54572. * s3tc compression format
  54573. */
  54574. s3tc?: boolean;
  54575. /**
  54576. * pvrtc compression format
  54577. */
  54578. pvrtc?: boolean;
  54579. /**
  54580. * etc2 compression format
  54581. */
  54582. etc2?: boolean;
  54583. };
  54584. /**
  54585. * If mipmap levels should be loaded for transcoded images (Default: true)
  54586. */
  54587. loadMipmapLevels?: boolean;
  54588. /**
  54589. * Index of a single image to load (Default: all images)
  54590. */
  54591. loadSingleImage?: number;
  54592. }
  54593. /**
  54594. * Used to load .Basis files
  54595. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54596. */
  54597. export class BasisTools {
  54598. private static _IgnoreSupportedFormats;
  54599. /**
  54600. * URL to use when loading the basis transcoder
  54601. */
  54602. static JSModuleURL: string;
  54603. /**
  54604. * URL to use when loading the wasm module for the transcoder
  54605. */
  54606. static WasmModuleURL: string;
  54607. /**
  54608. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54609. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54610. * @returns internal format corresponding to the Basis format
  54611. */
  54612. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54613. private static _WorkerPromise;
  54614. private static _Worker;
  54615. private static _actionId;
  54616. private static _CreateWorkerAsync;
  54617. /**
  54618. * Transcodes a loaded image file to compressed pixel data
  54619. * @param imageData image data to transcode
  54620. * @param config configuration options for the transcoding
  54621. * @returns a promise resulting in the transcoded image
  54622. */
  54623. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54624. /**
  54625. * Loads a texture from the transcode result
  54626. * @param texture texture load to
  54627. * @param transcodeResult the result of transcoding the basis file to load from
  54628. */
  54629. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54630. }
  54631. }
  54632. declare module BABYLON {
  54633. /**
  54634. * Loader for .basis file format
  54635. */
  54636. export class _BasisTextureLoader implements IInternalTextureLoader {
  54637. /**
  54638. * Defines whether the loader supports cascade loading the different faces.
  54639. */
  54640. readonly supportCascades: boolean;
  54641. /**
  54642. * This returns if the loader support the current file information.
  54643. * @param extension defines the file extension of the file being loaded
  54644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54645. * @param fallback defines the fallback internal texture if any
  54646. * @param isBase64 defines whether the texture is encoded as a base64
  54647. * @param isBuffer defines whether the texture data are stored as a buffer
  54648. * @returns true if the loader can load the specified file
  54649. */
  54650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54651. /**
  54652. * Transform the url before loading if required.
  54653. * @param rootUrl the url of the texture
  54654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54655. * @returns the transformed texture
  54656. */
  54657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54658. /**
  54659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54660. * @param rootUrl the url of the texture
  54661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54662. * @returns the fallback texture
  54663. */
  54664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54665. /**
  54666. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54667. * @param data contains the texture data
  54668. * @param texture defines the BabylonJS internal texture
  54669. * @param createPolynomials will be true if polynomials have been requested
  54670. * @param onLoad defines the callback to trigger once the texture is ready
  54671. * @param onError defines the callback to trigger in case of error
  54672. */
  54673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54674. /**
  54675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54676. * @param data contains the texture data
  54677. * @param texture defines the BabylonJS internal texture
  54678. * @param callback defines the method to call once ready to upload
  54679. */
  54680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54681. }
  54682. }
  54683. declare module BABYLON {
  54684. /**
  54685. * 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.
  54686. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54687. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54688. */
  54689. export class CustomProceduralTexture extends ProceduralTexture {
  54690. private _animate;
  54691. private _time;
  54692. private _config;
  54693. private _texturePath;
  54694. /**
  54695. * Instantiates a new Custom Procedural Texture.
  54696. * 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.
  54697. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54698. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54699. * @param name Define the name of the texture
  54700. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54701. * @param size Define the size of the texture to create
  54702. * @param scene Define the scene the texture belongs to
  54703. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54704. * @param generateMipMaps Define if the texture should creates mip maps or not
  54705. */
  54706. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54707. private _loadJson;
  54708. /**
  54709. * Is the texture ready to be used ? (rendered at least once)
  54710. * @returns true if ready, otherwise, false.
  54711. */
  54712. isReady(): boolean;
  54713. /**
  54714. * Render the texture to its associated render target.
  54715. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54716. */
  54717. render(useCameraPostProcess?: boolean): void;
  54718. /**
  54719. * Update the list of dependant textures samplers in the shader.
  54720. */
  54721. updateTextures(): void;
  54722. /**
  54723. * Update the uniform values of the procedural texture in the shader.
  54724. */
  54725. updateShaderUniforms(): void;
  54726. /**
  54727. * Define if the texture animates or not.
  54728. */
  54729. get animate(): boolean;
  54730. set animate(value: boolean);
  54731. }
  54732. }
  54733. declare module BABYLON {
  54734. /** @hidden */
  54735. export var noisePixelShader: {
  54736. name: string;
  54737. shader: string;
  54738. };
  54739. }
  54740. declare module BABYLON {
  54741. /**
  54742. * Class used to generate noise procedural textures
  54743. */
  54744. export class NoiseProceduralTexture extends ProceduralTexture {
  54745. private _time;
  54746. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54747. brightness: number;
  54748. /** Defines the number of octaves to process */
  54749. octaves: number;
  54750. /** Defines the level of persistence (0.8 by default) */
  54751. persistence: number;
  54752. /** Gets or sets animation speed factor (default is 1) */
  54753. animationSpeedFactor: number;
  54754. /**
  54755. * Creates a new NoiseProceduralTexture
  54756. * @param name defines the name fo the texture
  54757. * @param size defines the size of the texture (default is 256)
  54758. * @param scene defines the hosting scene
  54759. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54760. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54761. */
  54762. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54763. private _updateShaderUniforms;
  54764. protected _getDefines(): string;
  54765. /** Generate the current state of the procedural texture */
  54766. render(useCameraPostProcess?: boolean): void;
  54767. /**
  54768. * Serializes this noise procedural texture
  54769. * @returns a serialized noise procedural texture object
  54770. */
  54771. serialize(): any;
  54772. /**
  54773. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54774. * @param parsedTexture defines parsed texture data
  54775. * @param scene defines the current scene
  54776. * @param rootUrl defines the root URL containing noise procedural texture information
  54777. * @returns a parsed NoiseProceduralTexture
  54778. */
  54779. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54780. }
  54781. }
  54782. declare module BABYLON {
  54783. /**
  54784. * Raw cube texture where the raw buffers are passed in
  54785. */
  54786. export class RawCubeTexture extends CubeTexture {
  54787. /**
  54788. * Creates a cube texture where the raw buffers are passed in.
  54789. * @param scene defines the scene the texture is attached to
  54790. * @param data defines the array of data to use to create each face
  54791. * @param size defines the size of the textures
  54792. * @param format defines the format of the data
  54793. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54794. * @param generateMipMaps defines if the engine should generate the mip levels
  54795. * @param invertY defines if data must be stored with Y axis inverted
  54796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54797. * @param compression defines the compression used (null by default)
  54798. */
  54799. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54800. /**
  54801. * Updates the raw cube texture.
  54802. * @param data defines the data to store
  54803. * @param format defines the data format
  54804. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54805. * @param invertY defines if data must be stored with Y axis inverted
  54806. * @param compression defines the compression used (null by default)
  54807. * @param level defines which level of the texture to update
  54808. */
  54809. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54810. /**
  54811. * Updates a raw cube texture with RGBD encoded data.
  54812. * @param data defines the array of data [mipmap][face] to use to create each face
  54813. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54816. * @returns a promsie that resolves when the operation is complete
  54817. */
  54818. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54819. /**
  54820. * Clones the raw cube texture.
  54821. * @return a new cube texture
  54822. */
  54823. clone(): CubeTexture;
  54824. /** @hidden */
  54825. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54826. }
  54827. }
  54828. declare module BABYLON {
  54829. /**
  54830. * Class used to store 3D textures containing user data
  54831. */
  54832. export class RawTexture3D extends Texture {
  54833. /** Gets or sets the texture format to use */
  54834. format: number;
  54835. private _engine;
  54836. /**
  54837. * Create a new RawTexture3D
  54838. * @param data defines the data of the texture
  54839. * @param width defines the width of the texture
  54840. * @param height defines the height of the texture
  54841. * @param depth defines the depth of the texture
  54842. * @param format defines the texture format to use
  54843. * @param scene defines the hosting scene
  54844. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54845. * @param invertY defines if texture must be stored with Y axis inverted
  54846. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54847. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54848. */
  54849. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54850. /** Gets or sets the texture format to use */
  54851. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54852. /**
  54853. * Update the texture with new data
  54854. * @param data defines the data to store in the texture
  54855. */
  54856. update(data: ArrayBufferView): void;
  54857. }
  54858. }
  54859. declare module BABYLON {
  54860. /**
  54861. * Class used to store 2D array textures containing user data
  54862. */
  54863. export class RawTexture2DArray extends Texture {
  54864. /** Gets or sets the texture format to use */
  54865. format: number;
  54866. private _engine;
  54867. /**
  54868. * Create a new RawTexture2DArray
  54869. * @param data defines the data of the texture
  54870. * @param width defines the width of the texture
  54871. * @param height defines the height of the texture
  54872. * @param depth defines the number of layers of the texture
  54873. * @param format defines the texture format to use
  54874. * @param scene defines the hosting scene
  54875. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54876. * @param invertY defines if texture must be stored with Y axis inverted
  54877. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54878. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54879. */
  54880. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54881. /** Gets or sets the texture format to use */
  54882. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54883. /**
  54884. * Update the texture with new data
  54885. * @param data defines the data to store in the texture
  54886. */
  54887. update(data: ArrayBufferView): void;
  54888. }
  54889. }
  54890. declare module BABYLON {
  54891. /**
  54892. * Creates a refraction texture used by refraction channel of the standard material.
  54893. * It is like a mirror but to see through a material.
  54894. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54895. */
  54896. export class RefractionTexture extends RenderTargetTexture {
  54897. /**
  54898. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54899. * 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.
  54900. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54901. */
  54902. refractionPlane: Plane;
  54903. /**
  54904. * Define how deep under the surface we should see.
  54905. */
  54906. depth: number;
  54907. /**
  54908. * Creates a refraction texture used by refraction channel of the standard material.
  54909. * It is like a mirror but to see through a material.
  54910. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54911. * @param name Define the texture name
  54912. * @param size Define the size of the underlying texture
  54913. * @param scene Define the scene the refraction belongs to
  54914. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54915. */
  54916. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54917. /**
  54918. * Clone the refraction texture.
  54919. * @returns the cloned texture
  54920. */
  54921. clone(): RefractionTexture;
  54922. /**
  54923. * Serialize the texture to a JSON representation you could use in Parse later on
  54924. * @returns the serialized JSON representation
  54925. */
  54926. serialize(): any;
  54927. }
  54928. }
  54929. declare module BABYLON {
  54930. /**
  54931. * Defines the options related to the creation of an HtmlElementTexture
  54932. */
  54933. export interface IHtmlElementTextureOptions {
  54934. /**
  54935. * Defines wether mip maps should be created or not.
  54936. */
  54937. generateMipMaps?: boolean;
  54938. /**
  54939. * Defines the sampling mode of the texture.
  54940. */
  54941. samplingMode?: number;
  54942. /**
  54943. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54944. */
  54945. engine: Nullable<ThinEngine>;
  54946. /**
  54947. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54948. */
  54949. scene: Nullable<Scene>;
  54950. }
  54951. /**
  54952. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54953. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54954. * is automatically managed.
  54955. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54956. * in your application.
  54957. *
  54958. * As the update is not automatic, you need to call them manually.
  54959. */
  54960. export class HtmlElementTexture extends BaseTexture {
  54961. /**
  54962. * The texture URL.
  54963. */
  54964. element: HTMLVideoElement | HTMLCanvasElement;
  54965. private static readonly DefaultOptions;
  54966. private _textureMatrix;
  54967. private _engine;
  54968. private _isVideo;
  54969. private _generateMipMaps;
  54970. private _samplingMode;
  54971. /**
  54972. * Instantiates a HtmlElementTexture from the following parameters.
  54973. *
  54974. * @param name Defines the name of the texture
  54975. * @param element Defines the video or canvas the texture is filled with
  54976. * @param options Defines the other none mandatory texture creation options
  54977. */
  54978. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54979. private _createInternalTexture;
  54980. /**
  54981. * Returns the texture matrix used in most of the material.
  54982. */
  54983. getTextureMatrix(): Matrix;
  54984. /**
  54985. * Updates the content of the texture.
  54986. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54987. */
  54988. update(invertY?: Nullable<boolean>): void;
  54989. }
  54990. }
  54991. declare module BABYLON {
  54992. /**
  54993. * Enum used to define the target of a block
  54994. */
  54995. export enum NodeMaterialBlockTargets {
  54996. /** Vertex shader */
  54997. Vertex = 1,
  54998. /** Fragment shader */
  54999. Fragment = 2,
  55000. /** Neutral */
  55001. Neutral = 4,
  55002. /** Vertex and Fragment */
  55003. VertexAndFragment = 3
  55004. }
  55005. }
  55006. declare module BABYLON {
  55007. /**
  55008. * Defines the kind of connection point for node based material
  55009. */
  55010. export enum NodeMaterialBlockConnectionPointTypes {
  55011. /** Float */
  55012. Float = 1,
  55013. /** Int */
  55014. Int = 2,
  55015. /** Vector2 */
  55016. Vector2 = 4,
  55017. /** Vector3 */
  55018. Vector3 = 8,
  55019. /** Vector4 */
  55020. Vector4 = 16,
  55021. /** Color3 */
  55022. Color3 = 32,
  55023. /** Color4 */
  55024. Color4 = 64,
  55025. /** Matrix */
  55026. Matrix = 128,
  55027. /** Detect type based on connection */
  55028. AutoDetect = 1024,
  55029. /** Output type that will be defined by input type */
  55030. BasedOnInput = 2048
  55031. }
  55032. }
  55033. declare module BABYLON {
  55034. /**
  55035. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55036. */
  55037. export enum NodeMaterialBlockConnectionPointMode {
  55038. /** Value is an uniform */
  55039. Uniform = 0,
  55040. /** Value is a mesh attribute */
  55041. Attribute = 1,
  55042. /** Value is a varying between vertex and fragment shaders */
  55043. Varying = 2,
  55044. /** Mode is undefined */
  55045. Undefined = 3
  55046. }
  55047. }
  55048. declare module BABYLON {
  55049. /**
  55050. * Enum used to define system values e.g. values automatically provided by the system
  55051. */
  55052. export enum NodeMaterialSystemValues {
  55053. /** World */
  55054. World = 1,
  55055. /** View */
  55056. View = 2,
  55057. /** Projection */
  55058. Projection = 3,
  55059. /** ViewProjection */
  55060. ViewProjection = 4,
  55061. /** WorldView */
  55062. WorldView = 5,
  55063. /** WorldViewProjection */
  55064. WorldViewProjection = 6,
  55065. /** CameraPosition */
  55066. CameraPosition = 7,
  55067. /** Fog Color */
  55068. FogColor = 8,
  55069. /** Delta time */
  55070. DeltaTime = 9
  55071. }
  55072. }
  55073. declare module BABYLON {
  55074. /**
  55075. * Root class for all node material optimizers
  55076. */
  55077. export class NodeMaterialOptimizer {
  55078. /**
  55079. * Function used to optimize a NodeMaterial graph
  55080. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55081. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55082. */
  55083. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55084. }
  55085. }
  55086. declare module BABYLON {
  55087. /**
  55088. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55089. */
  55090. export class TransformBlock extends NodeMaterialBlock {
  55091. /**
  55092. * Defines the value to use to complement W value to transform it to a Vector4
  55093. */
  55094. complementW: number;
  55095. /**
  55096. * Defines the value to use to complement z value to transform it to a Vector4
  55097. */
  55098. complementZ: number;
  55099. /**
  55100. * Creates a new TransformBlock
  55101. * @param name defines the block name
  55102. */
  55103. constructor(name: string);
  55104. /**
  55105. * Gets the current class name
  55106. * @returns the class name
  55107. */
  55108. getClassName(): string;
  55109. /**
  55110. * Gets the vector input
  55111. */
  55112. get vector(): NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the output component
  55115. */
  55116. get output(): NodeMaterialConnectionPoint;
  55117. /**
  55118. * Gets the matrix transform input
  55119. */
  55120. get transform(): NodeMaterialConnectionPoint;
  55121. protected _buildBlock(state: NodeMaterialBuildState): this;
  55122. serialize(): any;
  55123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55124. protected _dumpPropertiesCode(): string;
  55125. }
  55126. }
  55127. declare module BABYLON {
  55128. /**
  55129. * Block used to output the vertex position
  55130. */
  55131. export class VertexOutputBlock extends NodeMaterialBlock {
  55132. /**
  55133. * Creates a new VertexOutputBlock
  55134. * @param name defines the block name
  55135. */
  55136. constructor(name: string);
  55137. /**
  55138. * Gets the current class name
  55139. * @returns the class name
  55140. */
  55141. getClassName(): string;
  55142. /**
  55143. * Gets the vector input component
  55144. */
  55145. get vector(): NodeMaterialConnectionPoint;
  55146. protected _buildBlock(state: NodeMaterialBuildState): this;
  55147. }
  55148. }
  55149. declare module BABYLON {
  55150. /**
  55151. * Block used to output the final color
  55152. */
  55153. export class FragmentOutputBlock extends NodeMaterialBlock {
  55154. /**
  55155. * Create a new FragmentOutputBlock
  55156. * @param name defines the block name
  55157. */
  55158. constructor(name: string);
  55159. /**
  55160. * Gets the current class name
  55161. * @returns the class name
  55162. */
  55163. getClassName(): string;
  55164. /**
  55165. * Gets the rgba input component
  55166. */
  55167. get rgba(): NodeMaterialConnectionPoint;
  55168. /**
  55169. * Gets the rgb input component
  55170. */
  55171. get rgb(): NodeMaterialConnectionPoint;
  55172. /**
  55173. * Gets the a input component
  55174. */
  55175. get a(): NodeMaterialConnectionPoint;
  55176. protected _buildBlock(state: NodeMaterialBuildState): this;
  55177. }
  55178. }
  55179. declare module BABYLON {
  55180. /**
  55181. * Block used to read a reflection texture from a sampler
  55182. */
  55183. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55184. private _define3DName;
  55185. private _defineCubicName;
  55186. private _defineExplicitName;
  55187. private _defineProjectionName;
  55188. private _defineLocalCubicName;
  55189. private _defineSphericalName;
  55190. private _definePlanarName;
  55191. private _defineEquirectangularName;
  55192. private _defineMirroredEquirectangularFixedName;
  55193. private _defineEquirectangularFixedName;
  55194. private _defineSkyboxName;
  55195. private _cubeSamplerName;
  55196. private _2DSamplerName;
  55197. private _positionUVWName;
  55198. private _directionWName;
  55199. private _reflectionCoordsName;
  55200. private _reflection2DCoordsName;
  55201. private _reflectionColorName;
  55202. private _reflectionMatrixName;
  55203. /**
  55204. * Gets or sets the texture associated with the node
  55205. */
  55206. texture: Nullable<BaseTexture>;
  55207. /**
  55208. * Create a new TextureBlock
  55209. * @param name defines the block name
  55210. */
  55211. constructor(name: string);
  55212. /**
  55213. * Gets the current class name
  55214. * @returns the class name
  55215. */
  55216. getClassName(): string;
  55217. /**
  55218. * Gets the world position input component
  55219. */
  55220. get position(): NodeMaterialConnectionPoint;
  55221. /**
  55222. * Gets the world position input component
  55223. */
  55224. get worldPosition(): NodeMaterialConnectionPoint;
  55225. /**
  55226. * Gets the world normal input component
  55227. */
  55228. get worldNormal(): NodeMaterialConnectionPoint;
  55229. /**
  55230. * Gets the world input component
  55231. */
  55232. get world(): NodeMaterialConnectionPoint;
  55233. /**
  55234. * Gets the camera (or eye) position component
  55235. */
  55236. get cameraPosition(): NodeMaterialConnectionPoint;
  55237. /**
  55238. * Gets the view input component
  55239. */
  55240. get view(): NodeMaterialConnectionPoint;
  55241. /**
  55242. * Gets the rgb output component
  55243. */
  55244. get rgb(): NodeMaterialConnectionPoint;
  55245. /**
  55246. * Gets the r output component
  55247. */
  55248. get r(): NodeMaterialConnectionPoint;
  55249. /**
  55250. * Gets the g output component
  55251. */
  55252. get g(): NodeMaterialConnectionPoint;
  55253. /**
  55254. * Gets the b output component
  55255. */
  55256. get b(): NodeMaterialConnectionPoint;
  55257. autoConfigure(material: NodeMaterial): void;
  55258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55259. isReady(): boolean;
  55260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55261. private _injectVertexCode;
  55262. private _writeOutput;
  55263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55264. protected _dumpPropertiesCode(): string;
  55265. serialize(): any;
  55266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55267. }
  55268. }
  55269. declare module BABYLON {
  55270. /**
  55271. * Interface used to configure the node material editor
  55272. */
  55273. export interface INodeMaterialEditorOptions {
  55274. /** Define the URl to load node editor script */
  55275. editorURL?: string;
  55276. }
  55277. /** @hidden */
  55278. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55279. /** BONES */
  55280. NUM_BONE_INFLUENCERS: number;
  55281. BonesPerMesh: number;
  55282. BONETEXTURE: boolean;
  55283. /** MORPH TARGETS */
  55284. MORPHTARGETS: boolean;
  55285. MORPHTARGETS_NORMAL: boolean;
  55286. MORPHTARGETS_TANGENT: boolean;
  55287. MORPHTARGETS_UV: boolean;
  55288. NUM_MORPH_INFLUENCERS: number;
  55289. /** IMAGE PROCESSING */
  55290. IMAGEPROCESSING: boolean;
  55291. VIGNETTE: boolean;
  55292. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55293. VIGNETTEBLENDMODEOPAQUE: boolean;
  55294. TONEMAPPING: boolean;
  55295. TONEMAPPING_ACES: boolean;
  55296. CONTRAST: boolean;
  55297. EXPOSURE: boolean;
  55298. COLORCURVES: boolean;
  55299. COLORGRADING: boolean;
  55300. COLORGRADING3D: boolean;
  55301. SAMPLER3DGREENDEPTH: boolean;
  55302. SAMPLER3DBGRMAP: boolean;
  55303. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55304. /** MISC. */
  55305. BUMPDIRECTUV: number;
  55306. constructor();
  55307. setValue(name: string, value: boolean): void;
  55308. }
  55309. /**
  55310. * Class used to configure NodeMaterial
  55311. */
  55312. export interface INodeMaterialOptions {
  55313. /**
  55314. * Defines if blocks should emit comments
  55315. */
  55316. emitComments: boolean;
  55317. }
  55318. /**
  55319. * Class used to create a node based material built by assembling shader blocks
  55320. */
  55321. export class NodeMaterial extends PushMaterial {
  55322. private static _BuildIdGenerator;
  55323. private _options;
  55324. private _vertexCompilationState;
  55325. private _fragmentCompilationState;
  55326. private _sharedData;
  55327. private _buildId;
  55328. private _buildWasSuccessful;
  55329. private _cachedWorldViewMatrix;
  55330. private _cachedWorldViewProjectionMatrix;
  55331. private _optimizers;
  55332. private _animationFrame;
  55333. /** Define the URl to load node editor script */
  55334. static EditorURL: string;
  55335. private BJSNODEMATERIALEDITOR;
  55336. /** Get the inspector from bundle or global */
  55337. private _getGlobalNodeMaterialEditor;
  55338. /**
  55339. * Gets or sets data used by visual editor
  55340. * @see https://nme.babylonjs.com
  55341. */
  55342. editorData: any;
  55343. /**
  55344. * 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)
  55345. */
  55346. ignoreAlpha: boolean;
  55347. /**
  55348. * Defines the maximum number of lights that can be used in the material
  55349. */
  55350. maxSimultaneousLights: number;
  55351. /**
  55352. * Observable raised when the material is built
  55353. */
  55354. onBuildObservable: Observable<NodeMaterial>;
  55355. /**
  55356. * Gets or sets the root nodes of the material vertex shader
  55357. */
  55358. _vertexOutputNodes: NodeMaterialBlock[];
  55359. /**
  55360. * Gets or sets the root nodes of the material fragment (pixel) shader
  55361. */
  55362. _fragmentOutputNodes: NodeMaterialBlock[];
  55363. /** Gets or sets options to control the node material overall behavior */
  55364. get options(): INodeMaterialOptions;
  55365. set options(options: INodeMaterialOptions);
  55366. /**
  55367. * Default configuration related to image processing available in the standard Material.
  55368. */
  55369. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55370. /**
  55371. * Gets the image processing configuration used either in this material.
  55372. */
  55373. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55374. /**
  55375. * Sets the Default image processing configuration used either in the this material.
  55376. *
  55377. * If sets to null, the scene one is in use.
  55378. */
  55379. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55380. /**
  55381. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55382. */
  55383. attachedBlocks: NodeMaterialBlock[];
  55384. /**
  55385. * Create a new node based material
  55386. * @param name defines the material name
  55387. * @param scene defines the hosting scene
  55388. * @param options defines creation option
  55389. */
  55390. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55391. /**
  55392. * Gets the current class name of the material e.g. "NodeMaterial"
  55393. * @returns the class name
  55394. */
  55395. getClassName(): string;
  55396. /**
  55397. * Keep track of the image processing observer to allow dispose and replace.
  55398. */
  55399. private _imageProcessingObserver;
  55400. /**
  55401. * Attaches a new image processing configuration to the Standard Material.
  55402. * @param configuration
  55403. */
  55404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55405. /**
  55406. * Get a block by its name
  55407. * @param name defines the name of the block to retrieve
  55408. * @returns the required block or null if not found
  55409. */
  55410. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55411. /**
  55412. * Get a block by its name
  55413. * @param predicate defines the predicate used to find the good candidate
  55414. * @returns the required block or null if not found
  55415. */
  55416. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55417. /**
  55418. * Get an input block by its name
  55419. * @param predicate defines the predicate used to find the good candidate
  55420. * @returns the required input block or null if not found
  55421. */
  55422. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55423. /**
  55424. * Gets the list of input blocks attached to this material
  55425. * @returns an array of InputBlocks
  55426. */
  55427. getInputBlocks(): InputBlock[];
  55428. /**
  55429. * Adds a new optimizer to the list of optimizers
  55430. * @param optimizer defines the optimizers to add
  55431. * @returns the current material
  55432. */
  55433. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55434. /**
  55435. * Remove an optimizer from the list of optimizers
  55436. * @param optimizer defines the optimizers to remove
  55437. * @returns the current material
  55438. */
  55439. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55440. /**
  55441. * Add a new block to the list of output nodes
  55442. * @param node defines the node to add
  55443. * @returns the current material
  55444. */
  55445. addOutputNode(node: NodeMaterialBlock): this;
  55446. /**
  55447. * Remove a block from the list of root nodes
  55448. * @param node defines the node to remove
  55449. * @returns the current material
  55450. */
  55451. removeOutputNode(node: NodeMaterialBlock): this;
  55452. private _addVertexOutputNode;
  55453. private _removeVertexOutputNode;
  55454. private _addFragmentOutputNode;
  55455. private _removeFragmentOutputNode;
  55456. /**
  55457. * Specifies if the material will require alpha blending
  55458. * @returns a boolean specifying if alpha blending is needed
  55459. */
  55460. needAlphaBlending(): boolean;
  55461. /**
  55462. * Specifies if this material should be rendered in alpha test mode
  55463. * @returns a boolean specifying if an alpha test is needed.
  55464. */
  55465. needAlphaTesting(): boolean;
  55466. private _initializeBlock;
  55467. private _resetDualBlocks;
  55468. /**
  55469. * Remove a block from the current node material
  55470. * @param block defines the block to remove
  55471. */
  55472. removeBlock(block: NodeMaterialBlock): void;
  55473. /**
  55474. * Build the material and generates the inner effect
  55475. * @param verbose defines if the build should log activity
  55476. */
  55477. build(verbose?: boolean): void;
  55478. /**
  55479. * Runs an otpimization phase to try to improve the shader code
  55480. */
  55481. optimize(): void;
  55482. private _prepareDefinesForAttributes;
  55483. /**
  55484. * Get if the submesh is ready to be used and all its information available.
  55485. * Child classes can use it to update shaders
  55486. * @param mesh defines the mesh to check
  55487. * @param subMesh defines which submesh to check
  55488. * @param useInstances specifies that instances should be used
  55489. * @returns a boolean indicating that the submesh is ready or not
  55490. */
  55491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55492. /**
  55493. * Get a string representing the shaders built by the current node graph
  55494. */
  55495. get compiledShaders(): string;
  55496. /**
  55497. * Binds the world matrix to the material
  55498. * @param world defines the world transformation matrix
  55499. */
  55500. bindOnlyWorldMatrix(world: Matrix): void;
  55501. /**
  55502. * Binds the submesh to this material by preparing the effect and shader to draw
  55503. * @param world defines the world transformation matrix
  55504. * @param mesh defines the mesh containing the submesh
  55505. * @param subMesh defines the submesh to bind the material to
  55506. */
  55507. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55508. /**
  55509. * Gets the active textures from the material
  55510. * @returns an array of textures
  55511. */
  55512. getActiveTextures(): BaseTexture[];
  55513. /**
  55514. * Gets the list of texture blocks
  55515. * @returns an array of texture blocks
  55516. */
  55517. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55518. /**
  55519. * Specifies if the material uses a texture
  55520. * @param texture defines the texture to check against the material
  55521. * @returns a boolean specifying if the material uses the texture
  55522. */
  55523. hasTexture(texture: BaseTexture): boolean;
  55524. /**
  55525. * Disposes the material
  55526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55528. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55529. */
  55530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55531. /** Creates the node editor window. */
  55532. private _createNodeEditor;
  55533. /**
  55534. * Launch the node material editor
  55535. * @param config Define the configuration of the editor
  55536. * @return a promise fulfilled when the node editor is visible
  55537. */
  55538. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55539. /**
  55540. * Clear the current material
  55541. */
  55542. clear(): void;
  55543. /**
  55544. * Clear the current material and set it to a default state
  55545. */
  55546. setToDefault(): void;
  55547. /**
  55548. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55549. * @param url defines the url to load from
  55550. * @returns a promise that will fullfil when the material is fully loaded
  55551. */
  55552. loadAsync(url: string): Promise<void>;
  55553. private _gatherBlocks;
  55554. /**
  55555. * Generate a string containing the code declaration required to create an equivalent of this material
  55556. * @returns a string
  55557. */
  55558. generateCode(): string;
  55559. /**
  55560. * Serializes this material in a JSON representation
  55561. * @returns the serialized material object
  55562. */
  55563. serialize(): any;
  55564. private _restoreConnections;
  55565. /**
  55566. * Clear the current graph and load a new one from a serialization object
  55567. * @param source defines the JSON representation of the material
  55568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55569. */
  55570. loadFromSerialization(source: any, rootUrl?: string): void;
  55571. /**
  55572. * Creates a node material from parsed material data
  55573. * @param source defines the JSON representation of the material
  55574. * @param scene defines the hosting scene
  55575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55576. * @returns a new node material
  55577. */
  55578. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55579. /**
  55580. * Creates a new node material set to default basic configuration
  55581. * @param name defines the name of the material
  55582. * @param scene defines the hosting scene
  55583. * @returns a new NodeMaterial
  55584. */
  55585. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55586. }
  55587. }
  55588. declare module BABYLON {
  55589. /**
  55590. * Block used to read a texture from a sampler
  55591. */
  55592. export class TextureBlock extends NodeMaterialBlock {
  55593. private _defineName;
  55594. private _linearDefineName;
  55595. private _tempTextureRead;
  55596. private _samplerName;
  55597. private _transformedUVName;
  55598. private _textureTransformName;
  55599. private _textureInfoName;
  55600. private _mainUVName;
  55601. private _mainUVDefineName;
  55602. /**
  55603. * Gets or sets the texture associated with the node
  55604. */
  55605. texture: Nullable<Texture>;
  55606. /**
  55607. * Create a new TextureBlock
  55608. * @param name defines the block name
  55609. */
  55610. constructor(name: string);
  55611. /**
  55612. * Gets the current class name
  55613. * @returns the class name
  55614. */
  55615. getClassName(): string;
  55616. /**
  55617. * Gets the uv input component
  55618. */
  55619. get uv(): NodeMaterialConnectionPoint;
  55620. /**
  55621. * Gets the rgba output component
  55622. */
  55623. get rgba(): NodeMaterialConnectionPoint;
  55624. /**
  55625. * Gets the rgb output component
  55626. */
  55627. get rgb(): NodeMaterialConnectionPoint;
  55628. /**
  55629. * Gets the r output component
  55630. */
  55631. get r(): NodeMaterialConnectionPoint;
  55632. /**
  55633. * Gets the g output component
  55634. */
  55635. get g(): NodeMaterialConnectionPoint;
  55636. /**
  55637. * Gets the b output component
  55638. */
  55639. get b(): NodeMaterialConnectionPoint;
  55640. /**
  55641. * Gets the a output component
  55642. */
  55643. get a(): NodeMaterialConnectionPoint;
  55644. get target(): NodeMaterialBlockTargets;
  55645. autoConfigure(material: NodeMaterial): void;
  55646. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55648. private _getTextureBase;
  55649. isReady(): boolean;
  55650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55651. private get _isMixed();
  55652. private _injectVertexCode;
  55653. private _writeTextureRead;
  55654. private _writeOutput;
  55655. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55656. protected _dumpPropertiesCode(): string;
  55657. serialize(): any;
  55658. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55659. }
  55660. }
  55661. declare module BABYLON {
  55662. /**
  55663. * Class used to store shared data between 2 NodeMaterialBuildState
  55664. */
  55665. export class NodeMaterialBuildStateSharedData {
  55666. /**
  55667. * Gets the list of emitted varyings
  55668. */
  55669. temps: string[];
  55670. /**
  55671. * Gets the list of emitted varyings
  55672. */
  55673. varyings: string[];
  55674. /**
  55675. * Gets the varying declaration string
  55676. */
  55677. varyingDeclaration: string;
  55678. /**
  55679. * Input blocks
  55680. */
  55681. inputBlocks: InputBlock[];
  55682. /**
  55683. * Input blocks
  55684. */
  55685. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55686. /**
  55687. * Bindable blocks (Blocks that need to set data to the effect)
  55688. */
  55689. bindableBlocks: NodeMaterialBlock[];
  55690. /**
  55691. * List of blocks that can provide a compilation fallback
  55692. */
  55693. blocksWithFallbacks: NodeMaterialBlock[];
  55694. /**
  55695. * List of blocks that can provide a define update
  55696. */
  55697. blocksWithDefines: NodeMaterialBlock[];
  55698. /**
  55699. * List of blocks that can provide a repeatable content
  55700. */
  55701. repeatableContentBlocks: NodeMaterialBlock[];
  55702. /**
  55703. * List of blocks that can provide a dynamic list of uniforms
  55704. */
  55705. dynamicUniformBlocks: NodeMaterialBlock[];
  55706. /**
  55707. * List of blocks that can block the isReady function for the material
  55708. */
  55709. blockingBlocks: NodeMaterialBlock[];
  55710. /**
  55711. * Gets the list of animated inputs
  55712. */
  55713. animatedInputs: InputBlock[];
  55714. /**
  55715. * Build Id used to avoid multiple recompilations
  55716. */
  55717. buildId: number;
  55718. /** List of emitted variables */
  55719. variableNames: {
  55720. [key: string]: number;
  55721. };
  55722. /** List of emitted defines */
  55723. defineNames: {
  55724. [key: string]: number;
  55725. };
  55726. /** Should emit comments? */
  55727. emitComments: boolean;
  55728. /** Emit build activity */
  55729. verbose: boolean;
  55730. /** Gets or sets the hosting scene */
  55731. scene: Scene;
  55732. /**
  55733. * Gets the compilation hints emitted at compilation time
  55734. */
  55735. hints: {
  55736. needWorldViewMatrix: boolean;
  55737. needWorldViewProjectionMatrix: boolean;
  55738. needAlphaBlending: boolean;
  55739. needAlphaTesting: boolean;
  55740. };
  55741. /**
  55742. * List of compilation checks
  55743. */
  55744. checks: {
  55745. emitVertex: boolean;
  55746. emitFragment: boolean;
  55747. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55748. };
  55749. /** Creates a new shared data */
  55750. constructor();
  55751. /**
  55752. * Emits console errors and exceptions if there is a failing check
  55753. */
  55754. emitErrors(): void;
  55755. }
  55756. }
  55757. declare module BABYLON {
  55758. /**
  55759. * Class used to store node based material build state
  55760. */
  55761. export class NodeMaterialBuildState {
  55762. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55763. supportUniformBuffers: boolean;
  55764. /**
  55765. * Gets the list of emitted attributes
  55766. */
  55767. attributes: string[];
  55768. /**
  55769. * Gets the list of emitted uniforms
  55770. */
  55771. uniforms: string[];
  55772. /**
  55773. * Gets the list of emitted constants
  55774. */
  55775. constants: string[];
  55776. /**
  55777. * Gets the list of emitted samplers
  55778. */
  55779. samplers: string[];
  55780. /**
  55781. * Gets the list of emitted functions
  55782. */
  55783. functions: {
  55784. [key: string]: string;
  55785. };
  55786. /**
  55787. * Gets the list of emitted extensions
  55788. */
  55789. extensions: {
  55790. [key: string]: string;
  55791. };
  55792. /**
  55793. * Gets the target of the compilation state
  55794. */
  55795. target: NodeMaterialBlockTargets;
  55796. /**
  55797. * Gets the list of emitted counters
  55798. */
  55799. counters: {
  55800. [key: string]: number;
  55801. };
  55802. /**
  55803. * Shared data between multiple NodeMaterialBuildState instances
  55804. */
  55805. sharedData: NodeMaterialBuildStateSharedData;
  55806. /** @hidden */
  55807. _vertexState: NodeMaterialBuildState;
  55808. /** @hidden */
  55809. _attributeDeclaration: string;
  55810. /** @hidden */
  55811. _uniformDeclaration: string;
  55812. /** @hidden */
  55813. _constantDeclaration: string;
  55814. /** @hidden */
  55815. _samplerDeclaration: string;
  55816. /** @hidden */
  55817. _varyingTransfer: string;
  55818. private _repeatableContentAnchorIndex;
  55819. /** @hidden */
  55820. _builtCompilationString: string;
  55821. /**
  55822. * Gets the emitted compilation strings
  55823. */
  55824. compilationString: string;
  55825. /**
  55826. * Finalize the compilation strings
  55827. * @param state defines the current compilation state
  55828. */
  55829. finalize(state: NodeMaterialBuildState): void;
  55830. /** @hidden */
  55831. get _repeatableContentAnchor(): string;
  55832. /** @hidden */
  55833. _getFreeVariableName(prefix: string): string;
  55834. /** @hidden */
  55835. _getFreeDefineName(prefix: string): string;
  55836. /** @hidden */
  55837. _excludeVariableName(name: string): void;
  55838. /** @hidden */
  55839. _emit2DSampler(name: string): void;
  55840. /** @hidden */
  55841. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55842. /** @hidden */
  55843. _emitExtension(name: string, extension: string): void;
  55844. /** @hidden */
  55845. _emitFunction(name: string, code: string, comments: string): void;
  55846. /** @hidden */
  55847. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55848. replaceStrings?: {
  55849. search: RegExp;
  55850. replace: string;
  55851. }[];
  55852. repeatKey?: string;
  55853. }): string;
  55854. /** @hidden */
  55855. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55856. repeatKey?: string;
  55857. removeAttributes?: boolean;
  55858. removeUniforms?: boolean;
  55859. removeVaryings?: boolean;
  55860. removeIfDef?: boolean;
  55861. replaceStrings?: {
  55862. search: RegExp;
  55863. replace: string;
  55864. }[];
  55865. }, storeKey?: string): void;
  55866. /** @hidden */
  55867. _registerTempVariable(name: string): boolean;
  55868. /** @hidden */
  55869. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55870. /** @hidden */
  55871. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55872. /** @hidden */
  55873. _emitFloat(value: number): string;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * Defines a block that can be used inside a node based material
  55879. */
  55880. export class NodeMaterialBlock {
  55881. private _buildId;
  55882. private _buildTarget;
  55883. private _target;
  55884. private _isFinalMerger;
  55885. private _isInput;
  55886. protected _isUnique: boolean;
  55887. /** @hidden */
  55888. _codeVariableName: string;
  55889. /** @hidden */
  55890. _inputs: NodeMaterialConnectionPoint[];
  55891. /** @hidden */
  55892. _outputs: NodeMaterialConnectionPoint[];
  55893. /** @hidden */
  55894. _preparationId: number;
  55895. /**
  55896. * Gets or sets the name of the block
  55897. */
  55898. name: string;
  55899. /**
  55900. * Gets or sets the unique id of the node
  55901. */
  55902. uniqueId: number;
  55903. /**
  55904. * Gets or sets the comments associated with this block
  55905. */
  55906. comments: string;
  55907. /**
  55908. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55909. */
  55910. get isUnique(): boolean;
  55911. /**
  55912. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55913. */
  55914. get isFinalMerger(): boolean;
  55915. /**
  55916. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55917. */
  55918. get isInput(): boolean;
  55919. /**
  55920. * Gets or sets the build Id
  55921. */
  55922. get buildId(): number;
  55923. set buildId(value: number);
  55924. /**
  55925. * Gets or sets the target of the block
  55926. */
  55927. get target(): NodeMaterialBlockTargets;
  55928. set target(value: NodeMaterialBlockTargets);
  55929. /**
  55930. * Gets the list of input points
  55931. */
  55932. get inputs(): NodeMaterialConnectionPoint[];
  55933. /** Gets the list of output points */
  55934. get outputs(): NodeMaterialConnectionPoint[];
  55935. /**
  55936. * Find an input by its name
  55937. * @param name defines the name of the input to look for
  55938. * @returns the input or null if not found
  55939. */
  55940. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55941. /**
  55942. * Find an output by its name
  55943. * @param name defines the name of the outputto look for
  55944. * @returns the output or null if not found
  55945. */
  55946. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55947. /**
  55948. * Creates a new NodeMaterialBlock
  55949. * @param name defines the block name
  55950. * @param target defines the target of that block (Vertex by default)
  55951. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55952. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55953. */
  55954. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55955. /**
  55956. * Initialize the block and prepare the context for build
  55957. * @param state defines the state that will be used for the build
  55958. */
  55959. initialize(state: NodeMaterialBuildState): void;
  55960. /**
  55961. * Bind data to effect. Will only be called for blocks with isBindable === true
  55962. * @param effect defines the effect to bind data to
  55963. * @param nodeMaterial defines the hosting NodeMaterial
  55964. * @param mesh defines the mesh that will be rendered
  55965. */
  55966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55967. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55968. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55969. protected _writeFloat(value: number): string;
  55970. /**
  55971. * Gets the current class name e.g. "NodeMaterialBlock"
  55972. * @returns the class name
  55973. */
  55974. getClassName(): string;
  55975. /**
  55976. * Register a new input. Must be called inside a block constructor
  55977. * @param name defines the connection point name
  55978. * @param type defines the connection point type
  55979. * @param isOptional defines a boolean indicating that this input can be omitted
  55980. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55981. * @returns the current block
  55982. */
  55983. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55984. /**
  55985. * Register a new output. Must be called inside a block constructor
  55986. * @param name defines the connection point name
  55987. * @param type defines the connection point type
  55988. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55989. * @returns the current block
  55990. */
  55991. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55992. /**
  55993. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55994. * @param forOutput defines an optional connection point to check compatibility with
  55995. * @returns the first available input or null
  55996. */
  55997. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55998. /**
  55999. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56000. * @param forBlock defines an optional block to check compatibility with
  56001. * @returns the first available input or null
  56002. */
  56003. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56004. /**
  56005. * Gets the sibling of the given output
  56006. * @param current defines the current output
  56007. * @returns the next output in the list or null
  56008. */
  56009. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56010. /**
  56011. * Connect current block with another block
  56012. * @param other defines the block to connect with
  56013. * @param options define the various options to help pick the right connections
  56014. * @returns the current block
  56015. */
  56016. connectTo(other: NodeMaterialBlock, options?: {
  56017. input?: string;
  56018. output?: string;
  56019. outputSwizzle?: string;
  56020. }): this | undefined;
  56021. protected _buildBlock(state: NodeMaterialBuildState): void;
  56022. /**
  56023. * Add uniforms, samplers and uniform buffers at compilation time
  56024. * @param state defines the state to update
  56025. * @param nodeMaterial defines the node material requesting the update
  56026. * @param defines defines the material defines to update
  56027. * @param uniformBuffers defines the list of uniform buffer names
  56028. */
  56029. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56030. /**
  56031. * Add potential fallbacks if shader compilation fails
  56032. * @param mesh defines the mesh to be rendered
  56033. * @param fallbacks defines the current prioritized list of fallbacks
  56034. */
  56035. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56036. /**
  56037. * Initialize defines for shader compilation
  56038. * @param mesh defines the mesh to be rendered
  56039. * @param nodeMaterial defines the node material requesting the update
  56040. * @param defines defines the material defines to update
  56041. * @param useInstances specifies that instances should be used
  56042. */
  56043. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56044. /**
  56045. * Update defines for shader compilation
  56046. * @param mesh defines the mesh to be rendered
  56047. * @param nodeMaterial defines the node material requesting the update
  56048. * @param defines defines the material defines to update
  56049. * @param useInstances specifies that instances should be used
  56050. */
  56051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56052. /**
  56053. * Lets the block try to connect some inputs automatically
  56054. * @param material defines the hosting NodeMaterial
  56055. */
  56056. autoConfigure(material: NodeMaterial): void;
  56057. /**
  56058. * Function called when a block is declared as repeatable content generator
  56059. * @param vertexShaderState defines the current compilation state for the vertex shader
  56060. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56061. * @param mesh defines the mesh to be rendered
  56062. * @param defines defines the material defines to update
  56063. */
  56064. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56065. /**
  56066. * Checks if the block is ready
  56067. * @param mesh defines the mesh to be rendered
  56068. * @param nodeMaterial defines the node material requesting the update
  56069. * @param defines defines the material defines to update
  56070. * @param useInstances specifies that instances should be used
  56071. * @returns true if the block is ready
  56072. */
  56073. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56074. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56075. private _processBuild;
  56076. /**
  56077. * Compile the current node and generate the shader code
  56078. * @param state defines the current compilation state (uniforms, samplers, current string)
  56079. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56080. * @returns true if already built
  56081. */
  56082. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56083. protected _inputRename(name: string): string;
  56084. protected _outputRename(name: string): string;
  56085. protected _dumpPropertiesCode(): string;
  56086. /** @hidden */
  56087. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56088. /** @hidden */
  56089. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56090. /**
  56091. * Clone the current block to a new identical block
  56092. * @param scene defines the hosting scene
  56093. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56094. * @returns a copy of the current block
  56095. */
  56096. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56097. /**
  56098. * Serializes this block in a JSON representation
  56099. * @returns the serialized block object
  56100. */
  56101. serialize(): any;
  56102. /** @hidden */
  56103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56104. /**
  56105. * Release resources
  56106. */
  56107. dispose(): void;
  56108. }
  56109. }
  56110. declare module BABYLON {
  56111. /**
  56112. * Enum defining the type of animations supported by InputBlock
  56113. */
  56114. export enum AnimatedInputBlockTypes {
  56115. /** No animation */
  56116. None = 0,
  56117. /** Time based animation. Will only work for floats */
  56118. Time = 1
  56119. }
  56120. }
  56121. declare module BABYLON {
  56122. /**
  56123. * Block used to expose an input value
  56124. */
  56125. export class InputBlock extends NodeMaterialBlock {
  56126. private _mode;
  56127. private _associatedVariableName;
  56128. private _storedValue;
  56129. private _valueCallback;
  56130. private _type;
  56131. private _animationType;
  56132. /** Gets or set a value used to limit the range of float values */
  56133. min: number;
  56134. /** Gets or set a value used to limit the range of float values */
  56135. max: number;
  56136. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56137. matrixMode: number;
  56138. /** @hidden */
  56139. _systemValue: Nullable<NodeMaterialSystemValues>;
  56140. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56141. visibleInInspector: boolean;
  56142. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56143. isConstant: boolean;
  56144. /** Gets or sets the group to use to display this block in the Inspector */
  56145. groupInInspector: string;
  56146. /**
  56147. * Gets or sets the connection point type (default is float)
  56148. */
  56149. get type(): NodeMaterialBlockConnectionPointTypes;
  56150. /**
  56151. * Creates a new InputBlock
  56152. * @param name defines the block name
  56153. * @param target defines the target of that block (Vertex by default)
  56154. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56155. */
  56156. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56157. /**
  56158. * Gets the output component
  56159. */
  56160. get output(): NodeMaterialConnectionPoint;
  56161. /**
  56162. * Set the source of this connection point to a vertex attribute
  56163. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56164. * @returns the current connection point
  56165. */
  56166. setAsAttribute(attributeName?: string): InputBlock;
  56167. /**
  56168. * Set the source of this connection point to a system value
  56169. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56170. * @returns the current connection point
  56171. */
  56172. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56173. /**
  56174. * Gets or sets the value of that point.
  56175. * Please note that this value will be ignored if valueCallback is defined
  56176. */
  56177. get value(): any;
  56178. set value(value: any);
  56179. /**
  56180. * Gets or sets a callback used to get the value of that point.
  56181. * Please note that setting this value will force the connection point to ignore the value property
  56182. */
  56183. get valueCallback(): () => any;
  56184. set valueCallback(value: () => any);
  56185. /**
  56186. * Gets or sets the associated variable name in the shader
  56187. */
  56188. get associatedVariableName(): string;
  56189. set associatedVariableName(value: string);
  56190. /** Gets or sets the type of animation applied to the input */
  56191. get animationType(): AnimatedInputBlockTypes;
  56192. set animationType(value: AnimatedInputBlockTypes);
  56193. /**
  56194. * Gets a boolean indicating that this connection point not defined yet
  56195. */
  56196. get isUndefined(): boolean;
  56197. /**
  56198. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56199. * In this case the connection point name must be the name of the uniform to use.
  56200. * Can only be set on inputs
  56201. */
  56202. get isUniform(): boolean;
  56203. set isUniform(value: boolean);
  56204. /**
  56205. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56206. * In this case the connection point name must be the name of the attribute to use
  56207. * Can only be set on inputs
  56208. */
  56209. get isAttribute(): boolean;
  56210. set isAttribute(value: boolean);
  56211. /**
  56212. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56213. * Can only be set on exit points
  56214. */
  56215. get isVarying(): boolean;
  56216. set isVarying(value: boolean);
  56217. /**
  56218. * Gets a boolean indicating that the current connection point is a system value
  56219. */
  56220. get isSystemValue(): boolean;
  56221. /**
  56222. * Gets or sets the current well known value or null if not defined as a system value
  56223. */
  56224. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56225. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56226. /**
  56227. * Gets the current class name
  56228. * @returns the class name
  56229. */
  56230. getClassName(): string;
  56231. /**
  56232. * Animate the input if animationType !== None
  56233. * @param scene defines the rendering scene
  56234. */
  56235. animate(scene: Scene): void;
  56236. private _emitDefine;
  56237. initialize(state: NodeMaterialBuildState): void;
  56238. /**
  56239. * Set the input block to its default value (based on its type)
  56240. */
  56241. setDefaultValue(): void;
  56242. private _emitConstant;
  56243. private _emit;
  56244. /** @hidden */
  56245. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56246. /** @hidden */
  56247. _transmit(effect: Effect, scene: Scene): void;
  56248. protected _buildBlock(state: NodeMaterialBuildState): void;
  56249. protected _dumpPropertiesCode(): string;
  56250. serialize(): any;
  56251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56252. }
  56253. }
  56254. declare module BABYLON {
  56255. /**
  56256. * Enum used to define the compatibility state between two connection points
  56257. */
  56258. export enum NodeMaterialConnectionPointCompatibilityStates {
  56259. /** Points are compatibles */
  56260. Compatible = 0,
  56261. /** Points are incompatible because of their types */
  56262. TypeIncompatible = 1,
  56263. /** Points are incompatible because of their targets (vertex vs fragment) */
  56264. TargetIncompatible = 2
  56265. }
  56266. /**
  56267. * Defines the direction of a connection point
  56268. */
  56269. export enum NodeMaterialConnectionPointDirection {
  56270. /** Input */
  56271. Input = 0,
  56272. /** Output */
  56273. Output = 1
  56274. }
  56275. /**
  56276. * Defines a connection point for a block
  56277. */
  56278. export class NodeMaterialConnectionPoint {
  56279. /** @hidden */
  56280. _ownerBlock: NodeMaterialBlock;
  56281. /** @hidden */
  56282. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56283. private _endpoints;
  56284. private _associatedVariableName;
  56285. private _direction;
  56286. /** @hidden */
  56287. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56288. /** @hidden */
  56289. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56290. private _type;
  56291. /** @hidden */
  56292. _enforceAssociatedVariableName: boolean;
  56293. /** Gets the direction of the point */
  56294. get direction(): NodeMaterialConnectionPointDirection;
  56295. /**
  56296. * Gets or sets the additional types supported by this connection point
  56297. */
  56298. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56299. /**
  56300. * Gets or sets the additional types excluded by this connection point
  56301. */
  56302. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56303. /**
  56304. * Observable triggered when this point is connected
  56305. */
  56306. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56307. /**
  56308. * Gets or sets the associated variable name in the shader
  56309. */
  56310. get associatedVariableName(): string;
  56311. set associatedVariableName(value: string);
  56312. /**
  56313. * Gets or sets the connection point type (default is float)
  56314. */
  56315. get type(): NodeMaterialBlockConnectionPointTypes;
  56316. set type(value: NodeMaterialBlockConnectionPointTypes);
  56317. /**
  56318. * Gets or sets the connection point name
  56319. */
  56320. name: string;
  56321. /**
  56322. * Gets or sets a boolean indicating that this connection point can be omitted
  56323. */
  56324. isOptional: boolean;
  56325. /**
  56326. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56327. */
  56328. define: string;
  56329. /** @hidden */
  56330. _prioritizeVertex: boolean;
  56331. private _target;
  56332. /** Gets or sets the target of that connection point */
  56333. get target(): NodeMaterialBlockTargets;
  56334. set target(value: NodeMaterialBlockTargets);
  56335. /**
  56336. * Gets a boolean indicating that the current point is connected
  56337. */
  56338. get isConnected(): boolean;
  56339. /**
  56340. * Gets a boolean indicating that the current point is connected to an input block
  56341. */
  56342. get isConnectedToInputBlock(): boolean;
  56343. /**
  56344. * Gets a the connected input block (if any)
  56345. */
  56346. get connectInputBlock(): Nullable<InputBlock>;
  56347. /** Get the other side of the connection (if any) */
  56348. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  56349. /** Get the block that owns this connection point */
  56350. get ownerBlock(): NodeMaterialBlock;
  56351. /** Get the block connected on the other side of this connection (if any) */
  56352. get sourceBlock(): Nullable<NodeMaterialBlock>;
  56353. /** Get the block connected on the endpoints of this connection (if any) */
  56354. get connectedBlocks(): Array<NodeMaterialBlock>;
  56355. /** Gets the list of connected endpoints */
  56356. get endpoints(): NodeMaterialConnectionPoint[];
  56357. /** Gets a boolean indicating if that output point is connected to at least one input */
  56358. get hasEndpoints(): boolean;
  56359. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56360. get isConnectedInVertexShader(): boolean;
  56361. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56362. get isConnectedInFragmentShader(): boolean;
  56363. /**
  56364. * Creates a new connection point
  56365. * @param name defines the connection point name
  56366. * @param ownerBlock defines the block hosting this connection point
  56367. * @param direction defines the direction of the connection point
  56368. */
  56369. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  56370. /**
  56371. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56372. * @returns the class name
  56373. */
  56374. getClassName(): string;
  56375. /**
  56376. * Gets a boolean indicating if the current point can be connected to another point
  56377. * @param connectionPoint defines the other connection point
  56378. * @returns a boolean
  56379. */
  56380. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56381. /**
  56382. * Gets a number indicating if the current point can be connected to another point
  56383. * @param connectionPoint defines the other connection point
  56384. * @returns a number defining the compatibility state
  56385. */
  56386. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  56387. /**
  56388. * Connect this point to another connection point
  56389. * @param connectionPoint defines the other connection point
  56390. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56391. * @returns the current connection point
  56392. */
  56393. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56394. /**
  56395. * Disconnect this point from one of his endpoint
  56396. * @param endpoint defines the other connection point
  56397. * @returns the current connection point
  56398. */
  56399. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56400. /**
  56401. * Serializes this point in a JSON representation
  56402. * @returns the serialized point object
  56403. */
  56404. serialize(): any;
  56405. /**
  56406. * Release resources
  56407. */
  56408. dispose(): void;
  56409. }
  56410. }
  56411. declare module BABYLON {
  56412. /**
  56413. * Block used to add support for vertex skinning (bones)
  56414. */
  56415. export class BonesBlock extends NodeMaterialBlock {
  56416. /**
  56417. * Creates a new BonesBlock
  56418. * @param name defines the block name
  56419. */
  56420. constructor(name: string);
  56421. /**
  56422. * Initialize the block and prepare the context for build
  56423. * @param state defines the state that will be used for the build
  56424. */
  56425. initialize(state: NodeMaterialBuildState): void;
  56426. /**
  56427. * Gets the current class name
  56428. * @returns the class name
  56429. */
  56430. getClassName(): string;
  56431. /**
  56432. * Gets the matrix indices input component
  56433. */
  56434. get matricesIndices(): NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the matrix weights input component
  56437. */
  56438. get matricesWeights(): NodeMaterialConnectionPoint;
  56439. /**
  56440. * Gets the extra matrix indices input component
  56441. */
  56442. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  56443. /**
  56444. * Gets the extra matrix weights input component
  56445. */
  56446. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  56447. /**
  56448. * Gets the world input component
  56449. */
  56450. get world(): NodeMaterialConnectionPoint;
  56451. /**
  56452. * Gets the output component
  56453. */
  56454. get output(): NodeMaterialConnectionPoint;
  56455. autoConfigure(material: NodeMaterial): void;
  56456. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56459. protected _buildBlock(state: NodeMaterialBuildState): this;
  56460. }
  56461. }
  56462. declare module BABYLON {
  56463. /**
  56464. * Block used to add support for instances
  56465. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56466. */
  56467. export class InstancesBlock extends NodeMaterialBlock {
  56468. /**
  56469. * Creates a new InstancesBlock
  56470. * @param name defines the block name
  56471. */
  56472. constructor(name: string);
  56473. /**
  56474. * Gets the current class name
  56475. * @returns the class name
  56476. */
  56477. getClassName(): string;
  56478. /**
  56479. * Gets the first world row input component
  56480. */
  56481. get world0(): NodeMaterialConnectionPoint;
  56482. /**
  56483. * Gets the second world row input component
  56484. */
  56485. get world1(): NodeMaterialConnectionPoint;
  56486. /**
  56487. * Gets the third world row input component
  56488. */
  56489. get world2(): NodeMaterialConnectionPoint;
  56490. /**
  56491. * Gets the forth world row input component
  56492. */
  56493. get world3(): NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the world input component
  56496. */
  56497. get world(): NodeMaterialConnectionPoint;
  56498. /**
  56499. * Gets the output component
  56500. */
  56501. get output(): NodeMaterialConnectionPoint;
  56502. autoConfigure(material: NodeMaterial): void;
  56503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56504. protected _buildBlock(state: NodeMaterialBuildState): this;
  56505. }
  56506. }
  56507. declare module BABYLON {
  56508. /**
  56509. * Block used to add morph targets support to vertex shader
  56510. */
  56511. export class MorphTargetsBlock extends NodeMaterialBlock {
  56512. private _repeatableContentAnchor;
  56513. private _repeatebleContentGenerated;
  56514. /**
  56515. * Create a new MorphTargetsBlock
  56516. * @param name defines the block name
  56517. */
  56518. constructor(name: string);
  56519. /**
  56520. * Gets the current class name
  56521. * @returns the class name
  56522. */
  56523. getClassName(): string;
  56524. /**
  56525. * Gets the position input component
  56526. */
  56527. get position(): NodeMaterialConnectionPoint;
  56528. /**
  56529. * Gets the normal input component
  56530. */
  56531. get normal(): NodeMaterialConnectionPoint;
  56532. /**
  56533. * Gets the tangent input component
  56534. */
  56535. get tangent(): NodeMaterialConnectionPoint;
  56536. /**
  56537. * Gets the tangent input component
  56538. */
  56539. get uv(): NodeMaterialConnectionPoint;
  56540. /**
  56541. * Gets the position output component
  56542. */
  56543. get positionOutput(): NodeMaterialConnectionPoint;
  56544. /**
  56545. * Gets the normal output component
  56546. */
  56547. get normalOutput(): NodeMaterialConnectionPoint;
  56548. /**
  56549. * Gets the tangent output component
  56550. */
  56551. get tangentOutput(): NodeMaterialConnectionPoint;
  56552. /**
  56553. * Gets the tangent output component
  56554. */
  56555. get uvOutput(): NodeMaterialConnectionPoint;
  56556. initialize(state: NodeMaterialBuildState): void;
  56557. autoConfigure(material: NodeMaterial): void;
  56558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56560. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56561. protected _buildBlock(state: NodeMaterialBuildState): this;
  56562. }
  56563. }
  56564. declare module BABYLON {
  56565. /**
  56566. * Block used to get data information from a light
  56567. */
  56568. export class LightInformationBlock extends NodeMaterialBlock {
  56569. private _lightDataUniformName;
  56570. private _lightColorUniformName;
  56571. private _lightTypeDefineName;
  56572. /**
  56573. * Gets or sets the light associated with this block
  56574. */
  56575. light: Nullable<Light>;
  56576. /**
  56577. * Creates a new LightInformationBlock
  56578. * @param name defines the block name
  56579. */
  56580. constructor(name: string);
  56581. /**
  56582. * Gets the current class name
  56583. * @returns the class name
  56584. */
  56585. getClassName(): string;
  56586. /**
  56587. * Gets the world position input component
  56588. */
  56589. get worldPosition(): NodeMaterialConnectionPoint;
  56590. /**
  56591. * Gets the direction output component
  56592. */
  56593. get direction(): NodeMaterialConnectionPoint;
  56594. /**
  56595. * Gets the direction output component
  56596. */
  56597. get color(): NodeMaterialConnectionPoint;
  56598. /**
  56599. * Gets the direction output component
  56600. */
  56601. get intensity(): NodeMaterialConnectionPoint;
  56602. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56604. protected _buildBlock(state: NodeMaterialBuildState): this;
  56605. serialize(): any;
  56606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56607. }
  56608. }
  56609. declare module BABYLON {
  56610. /**
  56611. * Block used to add image processing support to fragment shader
  56612. */
  56613. export class ImageProcessingBlock extends NodeMaterialBlock {
  56614. /**
  56615. * Create a new ImageProcessingBlock
  56616. * @param name defines the block name
  56617. */
  56618. constructor(name: string);
  56619. /**
  56620. * Gets the current class name
  56621. * @returns the class name
  56622. */
  56623. getClassName(): string;
  56624. /**
  56625. * Gets the color input component
  56626. */
  56627. get color(): NodeMaterialConnectionPoint;
  56628. /**
  56629. * Gets the output component
  56630. */
  56631. get output(): NodeMaterialConnectionPoint;
  56632. /**
  56633. * Initialize the block and prepare the context for build
  56634. * @param state defines the state that will be used for the build
  56635. */
  56636. initialize(state: NodeMaterialBuildState): void;
  56637. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56640. protected _buildBlock(state: NodeMaterialBuildState): this;
  56641. }
  56642. }
  56643. declare module BABYLON {
  56644. /**
  56645. * Block used to pertub normals based on a normal map
  56646. */
  56647. export class PerturbNormalBlock extends NodeMaterialBlock {
  56648. private _tangentSpaceParameterName;
  56649. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56650. invertX: boolean;
  56651. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56652. invertY: boolean;
  56653. /**
  56654. * Create a new PerturbNormalBlock
  56655. * @param name defines the block name
  56656. */
  56657. constructor(name: string);
  56658. /**
  56659. * Gets the current class name
  56660. * @returns the class name
  56661. */
  56662. getClassName(): string;
  56663. /**
  56664. * Gets the world position input component
  56665. */
  56666. get worldPosition(): NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the world normal input component
  56669. */
  56670. get worldNormal(): NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the uv input component
  56673. */
  56674. get uv(): NodeMaterialConnectionPoint;
  56675. /**
  56676. * Gets the normal map color input component
  56677. */
  56678. get normalMapColor(): NodeMaterialConnectionPoint;
  56679. /**
  56680. * Gets the strength input component
  56681. */
  56682. get strength(): NodeMaterialConnectionPoint;
  56683. /**
  56684. * Gets the output component
  56685. */
  56686. get output(): NodeMaterialConnectionPoint;
  56687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56688. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56689. autoConfigure(material: NodeMaterial): void;
  56690. protected _buildBlock(state: NodeMaterialBuildState): this;
  56691. protected _dumpPropertiesCode(): string;
  56692. serialize(): any;
  56693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56694. }
  56695. }
  56696. declare module BABYLON {
  56697. /**
  56698. * Block used to discard a pixel if a value is smaller than a cutoff
  56699. */
  56700. export class DiscardBlock extends NodeMaterialBlock {
  56701. /**
  56702. * Create a new DiscardBlock
  56703. * @param name defines the block name
  56704. */
  56705. constructor(name: string);
  56706. /**
  56707. * Gets the current class name
  56708. * @returns the class name
  56709. */
  56710. getClassName(): string;
  56711. /**
  56712. * Gets the color input component
  56713. */
  56714. get value(): NodeMaterialConnectionPoint;
  56715. /**
  56716. * Gets the cutoff input component
  56717. */
  56718. get cutoff(): NodeMaterialConnectionPoint;
  56719. protected _buildBlock(state: NodeMaterialBuildState): this;
  56720. }
  56721. }
  56722. declare module BABYLON {
  56723. /**
  56724. * Block used to test if the fragment shader is front facing
  56725. */
  56726. export class FrontFacingBlock extends NodeMaterialBlock {
  56727. /**
  56728. * Creates a new FrontFacingBlock
  56729. * @param name defines the block name
  56730. */
  56731. constructor(name: string);
  56732. /**
  56733. * Gets the current class name
  56734. * @returns the class name
  56735. */
  56736. getClassName(): string;
  56737. /**
  56738. * Gets the output component
  56739. */
  56740. get output(): NodeMaterialConnectionPoint;
  56741. protected _buildBlock(state: NodeMaterialBuildState): this;
  56742. }
  56743. }
  56744. declare module BABYLON {
  56745. /**
  56746. * Block used to get the derivative value on x and y of a given input
  56747. */
  56748. export class DerivativeBlock extends NodeMaterialBlock {
  56749. /**
  56750. * Create a new DerivativeBlock
  56751. * @param name defines the block name
  56752. */
  56753. constructor(name: string);
  56754. /**
  56755. * Gets the current class name
  56756. * @returns the class name
  56757. */
  56758. getClassName(): string;
  56759. /**
  56760. * Gets the input component
  56761. */
  56762. get input(): NodeMaterialConnectionPoint;
  56763. /**
  56764. * Gets the derivative output on x
  56765. */
  56766. get dx(): NodeMaterialConnectionPoint;
  56767. /**
  56768. * Gets the derivative output on y
  56769. */
  56770. get dy(): NodeMaterialConnectionPoint;
  56771. protected _buildBlock(state: NodeMaterialBuildState): this;
  56772. }
  56773. }
  56774. declare module BABYLON {
  56775. /**
  56776. * Block used to add support for scene fog
  56777. */
  56778. export class FogBlock extends NodeMaterialBlock {
  56779. private _fogDistanceName;
  56780. private _fogParameters;
  56781. /**
  56782. * Create a new FogBlock
  56783. * @param name defines the block name
  56784. */
  56785. constructor(name: string);
  56786. /**
  56787. * Gets the current class name
  56788. * @returns the class name
  56789. */
  56790. getClassName(): string;
  56791. /**
  56792. * Gets the world position input component
  56793. */
  56794. get worldPosition(): NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the view input component
  56797. */
  56798. get view(): NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the color input component
  56801. */
  56802. get input(): NodeMaterialConnectionPoint;
  56803. /**
  56804. * Gets the fog color input component
  56805. */
  56806. get fogColor(): NodeMaterialConnectionPoint;
  56807. /**
  56808. * Gets the output component
  56809. */
  56810. get output(): NodeMaterialConnectionPoint;
  56811. autoConfigure(material: NodeMaterial): void;
  56812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56813. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56814. protected _buildBlock(state: NodeMaterialBuildState): this;
  56815. }
  56816. }
  56817. declare module BABYLON {
  56818. /**
  56819. * Block used to add light in the fragment shader
  56820. */
  56821. export class LightBlock extends NodeMaterialBlock {
  56822. private _lightId;
  56823. /**
  56824. * Gets or sets the light associated with this block
  56825. */
  56826. light: Nullable<Light>;
  56827. /**
  56828. * Create a new LightBlock
  56829. * @param name defines the block name
  56830. */
  56831. constructor(name: string);
  56832. /**
  56833. * Gets the current class name
  56834. * @returns the class name
  56835. */
  56836. getClassName(): string;
  56837. /**
  56838. * Gets the world position input component
  56839. */
  56840. get worldPosition(): NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the world normal input component
  56843. */
  56844. get worldNormal(): NodeMaterialConnectionPoint;
  56845. /**
  56846. * Gets the camera (or eye) position component
  56847. */
  56848. get cameraPosition(): NodeMaterialConnectionPoint;
  56849. /**
  56850. * Gets the glossiness component
  56851. */
  56852. get glossiness(): NodeMaterialConnectionPoint;
  56853. /**
  56854. * Gets the glossinness power component
  56855. */
  56856. get glossPower(): NodeMaterialConnectionPoint;
  56857. /**
  56858. * Gets the diffuse color component
  56859. */
  56860. get diffuseColor(): NodeMaterialConnectionPoint;
  56861. /**
  56862. * Gets the specular color component
  56863. */
  56864. get specularColor(): NodeMaterialConnectionPoint;
  56865. /**
  56866. * Gets the diffuse output component
  56867. */
  56868. get diffuseOutput(): NodeMaterialConnectionPoint;
  56869. /**
  56870. * Gets the specular output component
  56871. */
  56872. get specularOutput(): NodeMaterialConnectionPoint;
  56873. /**
  56874. * Gets the shadow output component
  56875. */
  56876. get shadow(): NodeMaterialConnectionPoint;
  56877. autoConfigure(material: NodeMaterial): void;
  56878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56879. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56881. private _injectVertexCode;
  56882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56883. serialize(): any;
  56884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56885. }
  56886. }
  56887. declare module BABYLON {
  56888. /**
  56889. * Block used to multiply 2 values
  56890. */
  56891. export class MultiplyBlock extends NodeMaterialBlock {
  56892. /**
  56893. * Creates a new MultiplyBlock
  56894. * @param name defines the block name
  56895. */
  56896. constructor(name: string);
  56897. /**
  56898. * Gets the current class name
  56899. * @returns the class name
  56900. */
  56901. getClassName(): string;
  56902. /**
  56903. * Gets the left operand input component
  56904. */
  56905. get left(): NodeMaterialConnectionPoint;
  56906. /**
  56907. * Gets the right operand input component
  56908. */
  56909. get right(): NodeMaterialConnectionPoint;
  56910. /**
  56911. * Gets the output component
  56912. */
  56913. get output(): NodeMaterialConnectionPoint;
  56914. protected _buildBlock(state: NodeMaterialBuildState): this;
  56915. }
  56916. }
  56917. declare module BABYLON {
  56918. /**
  56919. * Block used to add 2 vectors
  56920. */
  56921. export class AddBlock extends NodeMaterialBlock {
  56922. /**
  56923. * Creates a new AddBlock
  56924. * @param name defines the block name
  56925. */
  56926. constructor(name: string);
  56927. /**
  56928. * Gets the current class name
  56929. * @returns the class name
  56930. */
  56931. getClassName(): string;
  56932. /**
  56933. * Gets the left operand input component
  56934. */
  56935. get left(): NodeMaterialConnectionPoint;
  56936. /**
  56937. * Gets the right operand input component
  56938. */
  56939. get right(): NodeMaterialConnectionPoint;
  56940. /**
  56941. * Gets the output component
  56942. */
  56943. get output(): NodeMaterialConnectionPoint;
  56944. protected _buildBlock(state: NodeMaterialBuildState): this;
  56945. }
  56946. }
  56947. declare module BABYLON {
  56948. /**
  56949. * Block used to scale a vector by a float
  56950. */
  56951. export class ScaleBlock extends NodeMaterialBlock {
  56952. /**
  56953. * Creates a new ScaleBlock
  56954. * @param name defines the block name
  56955. */
  56956. constructor(name: string);
  56957. /**
  56958. * Gets the current class name
  56959. * @returns the class name
  56960. */
  56961. getClassName(): string;
  56962. /**
  56963. * Gets the input component
  56964. */
  56965. get input(): NodeMaterialConnectionPoint;
  56966. /**
  56967. * Gets the factor input component
  56968. */
  56969. get factor(): NodeMaterialConnectionPoint;
  56970. /**
  56971. * Gets the output component
  56972. */
  56973. get output(): NodeMaterialConnectionPoint;
  56974. protected _buildBlock(state: NodeMaterialBuildState): this;
  56975. }
  56976. }
  56977. declare module BABYLON {
  56978. /**
  56979. * Block used to clamp a float
  56980. */
  56981. export class ClampBlock extends NodeMaterialBlock {
  56982. /** Gets or sets the minimum range */
  56983. minimum: number;
  56984. /** Gets or sets the maximum range */
  56985. maximum: number;
  56986. /**
  56987. * Creates a new ClampBlock
  56988. * @param name defines the block name
  56989. */
  56990. constructor(name: string);
  56991. /**
  56992. * Gets the current class name
  56993. * @returns the class name
  56994. */
  56995. getClassName(): string;
  56996. /**
  56997. * Gets the value input component
  56998. */
  56999. get value(): NodeMaterialConnectionPoint;
  57000. /**
  57001. * Gets the output component
  57002. */
  57003. get output(): NodeMaterialConnectionPoint;
  57004. protected _buildBlock(state: NodeMaterialBuildState): this;
  57005. protected _dumpPropertiesCode(): string;
  57006. serialize(): any;
  57007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57008. }
  57009. }
  57010. declare module BABYLON {
  57011. /**
  57012. * Block used to apply a cross product between 2 vectors
  57013. */
  57014. export class CrossBlock extends NodeMaterialBlock {
  57015. /**
  57016. * Creates a new CrossBlock
  57017. * @param name defines the block name
  57018. */
  57019. constructor(name: string);
  57020. /**
  57021. * Gets the current class name
  57022. * @returns the class name
  57023. */
  57024. getClassName(): string;
  57025. /**
  57026. * Gets the left operand input component
  57027. */
  57028. get left(): NodeMaterialConnectionPoint;
  57029. /**
  57030. * Gets the right operand input component
  57031. */
  57032. get right(): NodeMaterialConnectionPoint;
  57033. /**
  57034. * Gets the output component
  57035. */
  57036. get output(): NodeMaterialConnectionPoint;
  57037. protected _buildBlock(state: NodeMaterialBuildState): this;
  57038. }
  57039. }
  57040. declare module BABYLON {
  57041. /**
  57042. * Block used to apply a dot product between 2 vectors
  57043. */
  57044. export class DotBlock extends NodeMaterialBlock {
  57045. /**
  57046. * Creates a new DotBlock
  57047. * @param name defines the block name
  57048. */
  57049. constructor(name: string);
  57050. /**
  57051. * Gets the current class name
  57052. * @returns the class name
  57053. */
  57054. getClassName(): string;
  57055. /**
  57056. * Gets the left operand input component
  57057. */
  57058. get left(): NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the right operand input component
  57061. */
  57062. get right(): NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the output component
  57065. */
  57066. get output(): NodeMaterialConnectionPoint;
  57067. protected _buildBlock(state: NodeMaterialBuildState): this;
  57068. }
  57069. }
  57070. declare module BABYLON {
  57071. /**
  57072. * Block used to remap a float from a range to a new one
  57073. */
  57074. export class RemapBlock extends NodeMaterialBlock {
  57075. /**
  57076. * Gets or sets the source range
  57077. */
  57078. sourceRange: Vector2;
  57079. /**
  57080. * Gets or sets the target range
  57081. */
  57082. targetRange: Vector2;
  57083. /**
  57084. * Creates a new RemapBlock
  57085. * @param name defines the block name
  57086. */
  57087. constructor(name: string);
  57088. /**
  57089. * Gets the current class name
  57090. * @returns the class name
  57091. */
  57092. getClassName(): string;
  57093. /**
  57094. * Gets the input component
  57095. */
  57096. get input(): NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the source min input component
  57099. */
  57100. get sourceMin(): NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the source max input component
  57103. */
  57104. get sourceMax(): NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the target min input component
  57107. */
  57108. get targetMin(): NodeMaterialConnectionPoint;
  57109. /**
  57110. * Gets the target max input component
  57111. */
  57112. get targetMax(): NodeMaterialConnectionPoint;
  57113. /**
  57114. * Gets the output component
  57115. */
  57116. get output(): NodeMaterialConnectionPoint;
  57117. protected _buildBlock(state: NodeMaterialBuildState): this;
  57118. protected _dumpPropertiesCode(): string;
  57119. serialize(): any;
  57120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57121. }
  57122. }
  57123. declare module BABYLON {
  57124. /**
  57125. * Block used to normalize a vector
  57126. */
  57127. export class NormalizeBlock extends NodeMaterialBlock {
  57128. /**
  57129. * Creates a new NormalizeBlock
  57130. * @param name defines the block name
  57131. */
  57132. constructor(name: string);
  57133. /**
  57134. * Gets the current class name
  57135. * @returns the class name
  57136. */
  57137. getClassName(): string;
  57138. /**
  57139. * Gets the input component
  57140. */
  57141. get input(): NodeMaterialConnectionPoint;
  57142. /**
  57143. * Gets the output component
  57144. */
  57145. get output(): NodeMaterialConnectionPoint;
  57146. protected _buildBlock(state: NodeMaterialBuildState): this;
  57147. }
  57148. }
  57149. declare module BABYLON {
  57150. /**
  57151. * Operations supported by the Trigonometry block
  57152. */
  57153. export enum TrigonometryBlockOperations {
  57154. /** Cos */
  57155. Cos = 0,
  57156. /** Sin */
  57157. Sin = 1,
  57158. /** Abs */
  57159. Abs = 2,
  57160. /** Exp */
  57161. Exp = 3,
  57162. /** Exp2 */
  57163. Exp2 = 4,
  57164. /** Round */
  57165. Round = 5,
  57166. /** Floor */
  57167. Floor = 6,
  57168. /** Ceiling */
  57169. Ceiling = 7,
  57170. /** Square root */
  57171. Sqrt = 8,
  57172. /** Log */
  57173. Log = 9,
  57174. /** Tangent */
  57175. Tan = 10,
  57176. /** Arc tangent */
  57177. ArcTan = 11,
  57178. /** Arc cosinus */
  57179. ArcCos = 12,
  57180. /** Arc sinus */
  57181. ArcSin = 13,
  57182. /** Fraction */
  57183. Fract = 14,
  57184. /** Sign */
  57185. Sign = 15,
  57186. /** To radians (from degrees) */
  57187. Radians = 16,
  57188. /** To degrees (from radians) */
  57189. Degrees = 17
  57190. }
  57191. /**
  57192. * Block used to apply trigonometry operation to floats
  57193. */
  57194. export class TrigonometryBlock extends NodeMaterialBlock {
  57195. /**
  57196. * Gets or sets the operation applied by the block
  57197. */
  57198. operation: TrigonometryBlockOperations;
  57199. /**
  57200. * Creates a new TrigonometryBlock
  57201. * @param name defines the block name
  57202. */
  57203. constructor(name: string);
  57204. /**
  57205. * Gets the current class name
  57206. * @returns the class name
  57207. */
  57208. getClassName(): string;
  57209. /**
  57210. * Gets the input component
  57211. */
  57212. get input(): NodeMaterialConnectionPoint;
  57213. /**
  57214. * Gets the output component
  57215. */
  57216. get output(): NodeMaterialConnectionPoint;
  57217. protected _buildBlock(state: NodeMaterialBuildState): this;
  57218. serialize(): any;
  57219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57220. protected _dumpPropertiesCode(): string;
  57221. }
  57222. }
  57223. declare module BABYLON {
  57224. /**
  57225. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57226. */
  57227. export class ColorMergerBlock extends NodeMaterialBlock {
  57228. /**
  57229. * Create a new ColorMergerBlock
  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 rgb component (input)
  57240. */
  57241. get rgbIn(): NodeMaterialConnectionPoint;
  57242. /**
  57243. * Gets the r component (input)
  57244. */
  57245. get r(): NodeMaterialConnectionPoint;
  57246. /**
  57247. * Gets the g component (input)
  57248. */
  57249. get g(): NodeMaterialConnectionPoint;
  57250. /**
  57251. * Gets the b component (input)
  57252. */
  57253. get b(): NodeMaterialConnectionPoint;
  57254. /**
  57255. * Gets the a component (input)
  57256. */
  57257. get a(): NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the rgba component (output)
  57260. */
  57261. get rgba(): NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the rgb component (output)
  57264. */
  57265. get rgbOut(): NodeMaterialConnectionPoint;
  57266. /**
  57267. * Gets the rgb component (output)
  57268. * @deprecated Please use rgbOut instead.
  57269. */
  57270. get rgb(): NodeMaterialConnectionPoint;
  57271. protected _buildBlock(state: NodeMaterialBuildState): this;
  57272. }
  57273. }
  57274. declare module BABYLON {
  57275. /**
  57276. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57277. */
  57278. export class VectorMergerBlock extends NodeMaterialBlock {
  57279. /**
  57280. * Create a new VectorMergerBlock
  57281. * @param name defines the block name
  57282. */
  57283. constructor(name: string);
  57284. /**
  57285. * Gets the current class name
  57286. * @returns the class name
  57287. */
  57288. getClassName(): string;
  57289. /**
  57290. * Gets the xyz component (input)
  57291. */
  57292. get xyzIn(): NodeMaterialConnectionPoint;
  57293. /**
  57294. * Gets the xy component (input)
  57295. */
  57296. get xyIn(): NodeMaterialConnectionPoint;
  57297. /**
  57298. * Gets the x component (input)
  57299. */
  57300. get x(): NodeMaterialConnectionPoint;
  57301. /**
  57302. * Gets the y component (input)
  57303. */
  57304. get y(): NodeMaterialConnectionPoint;
  57305. /**
  57306. * Gets the z component (input)
  57307. */
  57308. get z(): NodeMaterialConnectionPoint;
  57309. /**
  57310. * Gets the w component (input)
  57311. */
  57312. get w(): NodeMaterialConnectionPoint;
  57313. /**
  57314. * Gets the xyzw component (output)
  57315. */
  57316. get xyzw(): NodeMaterialConnectionPoint;
  57317. /**
  57318. * Gets the xyz component (output)
  57319. */
  57320. get xyzOut(): NodeMaterialConnectionPoint;
  57321. /**
  57322. * Gets the xy component (output)
  57323. */
  57324. get xyOut(): NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the xy component (output)
  57327. * @deprecated Please use xyOut instead.
  57328. */
  57329. get xy(): NodeMaterialConnectionPoint;
  57330. /**
  57331. * Gets the xyz component (output)
  57332. * @deprecated Please use xyzOut instead.
  57333. */
  57334. get xyz(): NodeMaterialConnectionPoint;
  57335. protected _buildBlock(state: NodeMaterialBuildState): this;
  57336. }
  57337. }
  57338. declare module BABYLON {
  57339. /**
  57340. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57341. */
  57342. export class ColorSplitterBlock extends NodeMaterialBlock {
  57343. /**
  57344. * Create a new ColorSplitterBlock
  57345. * @param name defines the block name
  57346. */
  57347. constructor(name: string);
  57348. /**
  57349. * Gets the current class name
  57350. * @returns the class name
  57351. */
  57352. getClassName(): string;
  57353. /**
  57354. * Gets the rgba component (input)
  57355. */
  57356. get rgba(): NodeMaterialConnectionPoint;
  57357. /**
  57358. * Gets the rgb component (input)
  57359. */
  57360. get rgbIn(): NodeMaterialConnectionPoint;
  57361. /**
  57362. * Gets the rgb component (output)
  57363. */
  57364. get rgbOut(): NodeMaterialConnectionPoint;
  57365. /**
  57366. * Gets the r component (output)
  57367. */
  57368. get r(): NodeMaterialConnectionPoint;
  57369. /**
  57370. * Gets the g component (output)
  57371. */
  57372. get g(): NodeMaterialConnectionPoint;
  57373. /**
  57374. * Gets the b component (output)
  57375. */
  57376. get b(): NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the a component (output)
  57379. */
  57380. get a(): NodeMaterialConnectionPoint;
  57381. protected _inputRename(name: string): string;
  57382. protected _outputRename(name: string): string;
  57383. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57384. }
  57385. }
  57386. declare module BABYLON {
  57387. /**
  57388. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57389. */
  57390. export class VectorSplitterBlock extends NodeMaterialBlock {
  57391. /**
  57392. * Create a new VectorSplitterBlock
  57393. * @param name defines the block name
  57394. */
  57395. constructor(name: string);
  57396. /**
  57397. * Gets the current class name
  57398. * @returns the class name
  57399. */
  57400. getClassName(): string;
  57401. /**
  57402. * Gets the xyzw component (input)
  57403. */
  57404. get xyzw(): NodeMaterialConnectionPoint;
  57405. /**
  57406. * Gets the xyz component (input)
  57407. */
  57408. get xyzIn(): NodeMaterialConnectionPoint;
  57409. /**
  57410. * Gets the xy component (input)
  57411. */
  57412. get xyIn(): NodeMaterialConnectionPoint;
  57413. /**
  57414. * Gets the xyz component (output)
  57415. */
  57416. get xyzOut(): NodeMaterialConnectionPoint;
  57417. /**
  57418. * Gets the xy component (output)
  57419. */
  57420. get xyOut(): NodeMaterialConnectionPoint;
  57421. /**
  57422. * Gets the x component (output)
  57423. */
  57424. get x(): NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the y component (output)
  57427. */
  57428. get y(): NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the z component (output)
  57431. */
  57432. get z(): NodeMaterialConnectionPoint;
  57433. /**
  57434. * Gets the w component (output)
  57435. */
  57436. get w(): NodeMaterialConnectionPoint;
  57437. protected _inputRename(name: string): string;
  57438. protected _outputRename(name: string): string;
  57439. protected _buildBlock(state: NodeMaterialBuildState): this;
  57440. }
  57441. }
  57442. declare module BABYLON {
  57443. /**
  57444. * Block used to lerp between 2 values
  57445. */
  57446. export class LerpBlock extends NodeMaterialBlock {
  57447. /**
  57448. * Creates a new LerpBlock
  57449. * @param name defines the block name
  57450. */
  57451. constructor(name: string);
  57452. /**
  57453. * Gets the current class name
  57454. * @returns the class name
  57455. */
  57456. getClassName(): string;
  57457. /**
  57458. * Gets the left operand input component
  57459. */
  57460. get left(): NodeMaterialConnectionPoint;
  57461. /**
  57462. * Gets the right operand input component
  57463. */
  57464. get right(): NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the gradient operand input component
  57467. */
  57468. get gradient(): NodeMaterialConnectionPoint;
  57469. /**
  57470. * Gets the output component
  57471. */
  57472. get output(): NodeMaterialConnectionPoint;
  57473. protected _buildBlock(state: NodeMaterialBuildState): this;
  57474. }
  57475. }
  57476. declare module BABYLON {
  57477. /**
  57478. * Block used to divide 2 vectors
  57479. */
  57480. export class DivideBlock extends NodeMaterialBlock {
  57481. /**
  57482. * Creates a new DivideBlock
  57483. * @param name defines the block name
  57484. */
  57485. constructor(name: string);
  57486. /**
  57487. * Gets the current class name
  57488. * @returns the class name
  57489. */
  57490. getClassName(): string;
  57491. /**
  57492. * Gets the left operand input component
  57493. */
  57494. get left(): NodeMaterialConnectionPoint;
  57495. /**
  57496. * Gets the right operand input component
  57497. */
  57498. get right(): NodeMaterialConnectionPoint;
  57499. /**
  57500. * Gets the output component
  57501. */
  57502. get output(): NodeMaterialConnectionPoint;
  57503. protected _buildBlock(state: NodeMaterialBuildState): this;
  57504. }
  57505. }
  57506. declare module BABYLON {
  57507. /**
  57508. * Block used to subtract 2 vectors
  57509. */
  57510. export class SubtractBlock extends NodeMaterialBlock {
  57511. /**
  57512. * Creates a new SubtractBlock
  57513. * @param name defines the block name
  57514. */
  57515. constructor(name: string);
  57516. /**
  57517. * Gets the current class name
  57518. * @returns the class name
  57519. */
  57520. getClassName(): string;
  57521. /**
  57522. * Gets the left operand input component
  57523. */
  57524. get left(): NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the right operand input component
  57527. */
  57528. get right(): NodeMaterialConnectionPoint;
  57529. /**
  57530. * Gets the output component
  57531. */
  57532. get output(): NodeMaterialConnectionPoint;
  57533. protected _buildBlock(state: NodeMaterialBuildState): this;
  57534. }
  57535. }
  57536. declare module BABYLON {
  57537. /**
  57538. * Block used to step a value
  57539. */
  57540. export class StepBlock extends NodeMaterialBlock {
  57541. /**
  57542. * Creates a new StepBlock
  57543. * @param name defines the block name
  57544. */
  57545. constructor(name: string);
  57546. /**
  57547. * Gets the current class name
  57548. * @returns the class name
  57549. */
  57550. getClassName(): string;
  57551. /**
  57552. * Gets the value operand input component
  57553. */
  57554. get value(): NodeMaterialConnectionPoint;
  57555. /**
  57556. * Gets the edge operand input component
  57557. */
  57558. get edge(): NodeMaterialConnectionPoint;
  57559. /**
  57560. * Gets the output component
  57561. */
  57562. get output(): NodeMaterialConnectionPoint;
  57563. protected _buildBlock(state: NodeMaterialBuildState): this;
  57564. }
  57565. }
  57566. declare module BABYLON {
  57567. /**
  57568. * Block used to get the opposite (1 - x) of a value
  57569. */
  57570. export class OneMinusBlock extends NodeMaterialBlock {
  57571. /**
  57572. * Creates a new OneMinusBlock
  57573. * @param name defines the block name
  57574. */
  57575. constructor(name: string);
  57576. /**
  57577. * Gets the current class name
  57578. * @returns the class name
  57579. */
  57580. getClassName(): string;
  57581. /**
  57582. * Gets the input component
  57583. */
  57584. get input(): NodeMaterialConnectionPoint;
  57585. /**
  57586. * Gets the output component
  57587. */
  57588. get output(): NodeMaterialConnectionPoint;
  57589. protected _buildBlock(state: NodeMaterialBuildState): this;
  57590. }
  57591. }
  57592. declare module BABYLON {
  57593. /**
  57594. * Block used to get the view direction
  57595. */
  57596. export class ViewDirectionBlock extends NodeMaterialBlock {
  57597. /**
  57598. * Creates a new ViewDirectionBlock
  57599. * @param name defines the block name
  57600. */
  57601. constructor(name: string);
  57602. /**
  57603. * Gets the current class name
  57604. * @returns the class name
  57605. */
  57606. getClassName(): string;
  57607. /**
  57608. * Gets the world position component
  57609. */
  57610. get worldPosition(): NodeMaterialConnectionPoint;
  57611. /**
  57612. * Gets the camera position component
  57613. */
  57614. get cameraPosition(): NodeMaterialConnectionPoint;
  57615. /**
  57616. * Gets the output component
  57617. */
  57618. get output(): NodeMaterialConnectionPoint;
  57619. autoConfigure(material: NodeMaterial): void;
  57620. protected _buildBlock(state: NodeMaterialBuildState): this;
  57621. }
  57622. }
  57623. declare module BABYLON {
  57624. /**
  57625. * Block used to compute fresnel value
  57626. */
  57627. export class FresnelBlock extends NodeMaterialBlock {
  57628. /**
  57629. * Create a new FresnelBlock
  57630. * @param name defines the block name
  57631. */
  57632. constructor(name: string);
  57633. /**
  57634. * Gets the current class name
  57635. * @returns the class name
  57636. */
  57637. getClassName(): string;
  57638. /**
  57639. * Gets the world normal input component
  57640. */
  57641. get worldNormal(): NodeMaterialConnectionPoint;
  57642. /**
  57643. * Gets the view direction input component
  57644. */
  57645. get viewDirection(): NodeMaterialConnectionPoint;
  57646. /**
  57647. * Gets the bias input component
  57648. */
  57649. get bias(): NodeMaterialConnectionPoint;
  57650. /**
  57651. * Gets the camera (or eye) position component
  57652. */
  57653. get power(): NodeMaterialConnectionPoint;
  57654. /**
  57655. * Gets the fresnel output component
  57656. */
  57657. get fresnel(): NodeMaterialConnectionPoint;
  57658. autoConfigure(material: NodeMaterial): void;
  57659. protected _buildBlock(state: NodeMaterialBuildState): this;
  57660. }
  57661. }
  57662. declare module BABYLON {
  57663. /**
  57664. * Block used to get the max of 2 values
  57665. */
  57666. export class MaxBlock extends NodeMaterialBlock {
  57667. /**
  57668. * Creates a new MaxBlock
  57669. * @param name defines the block name
  57670. */
  57671. constructor(name: string);
  57672. /**
  57673. * Gets the current class name
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Gets the left operand input component
  57679. */
  57680. get left(): NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the right operand input component
  57683. */
  57684. get right(): NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the output component
  57687. */
  57688. get output(): NodeMaterialConnectionPoint;
  57689. protected _buildBlock(state: NodeMaterialBuildState): this;
  57690. }
  57691. }
  57692. declare module BABYLON {
  57693. /**
  57694. * Block used to get the min of 2 values
  57695. */
  57696. export class MinBlock extends NodeMaterialBlock {
  57697. /**
  57698. * Creates a new MinBlock
  57699. * @param name defines the block name
  57700. */
  57701. constructor(name: string);
  57702. /**
  57703. * Gets the current class name
  57704. * @returns the class name
  57705. */
  57706. getClassName(): string;
  57707. /**
  57708. * Gets the left operand input component
  57709. */
  57710. get left(): NodeMaterialConnectionPoint;
  57711. /**
  57712. * Gets the right operand input component
  57713. */
  57714. get right(): NodeMaterialConnectionPoint;
  57715. /**
  57716. * Gets the output component
  57717. */
  57718. get output(): NodeMaterialConnectionPoint;
  57719. protected _buildBlock(state: NodeMaterialBuildState): this;
  57720. }
  57721. }
  57722. declare module BABYLON {
  57723. /**
  57724. * Block used to get the distance between 2 values
  57725. */
  57726. export class DistanceBlock extends NodeMaterialBlock {
  57727. /**
  57728. * Creates a new DistanceBlock
  57729. * @param name defines the block name
  57730. */
  57731. constructor(name: string);
  57732. /**
  57733. * Gets the current class name
  57734. * @returns the class name
  57735. */
  57736. getClassName(): string;
  57737. /**
  57738. * Gets the left operand input component
  57739. */
  57740. get left(): NodeMaterialConnectionPoint;
  57741. /**
  57742. * Gets the right operand input component
  57743. */
  57744. get right(): NodeMaterialConnectionPoint;
  57745. /**
  57746. * Gets the output component
  57747. */
  57748. get output(): NodeMaterialConnectionPoint;
  57749. protected _buildBlock(state: NodeMaterialBuildState): this;
  57750. }
  57751. }
  57752. declare module BABYLON {
  57753. /**
  57754. * Block used to get the length of a vector
  57755. */
  57756. export class LengthBlock extends NodeMaterialBlock {
  57757. /**
  57758. * Creates a new LengthBlock
  57759. * @param name defines the block name
  57760. */
  57761. constructor(name: string);
  57762. /**
  57763. * Gets the current class name
  57764. * @returns the class name
  57765. */
  57766. getClassName(): string;
  57767. /**
  57768. * Gets the value input component
  57769. */
  57770. get value(): NodeMaterialConnectionPoint;
  57771. /**
  57772. * Gets the output component
  57773. */
  57774. get output(): NodeMaterialConnectionPoint;
  57775. protected _buildBlock(state: NodeMaterialBuildState): this;
  57776. }
  57777. }
  57778. declare module BABYLON {
  57779. /**
  57780. * Block used to get negative version of a value (i.e. x * -1)
  57781. */
  57782. export class NegateBlock extends NodeMaterialBlock {
  57783. /**
  57784. * Creates a new NegateBlock
  57785. * @param name defines the block name
  57786. */
  57787. constructor(name: string);
  57788. /**
  57789. * Gets the current class name
  57790. * @returns the class name
  57791. */
  57792. getClassName(): string;
  57793. /**
  57794. * Gets the value input component
  57795. */
  57796. get value(): NodeMaterialConnectionPoint;
  57797. /**
  57798. * Gets the output component
  57799. */
  57800. get output(): NodeMaterialConnectionPoint;
  57801. protected _buildBlock(state: NodeMaterialBuildState): this;
  57802. }
  57803. }
  57804. declare module BABYLON {
  57805. /**
  57806. * Block used to get the value of the first parameter raised to the power of the second
  57807. */
  57808. export class PowBlock extends NodeMaterialBlock {
  57809. /**
  57810. * Creates a new PowBlock
  57811. * @param name defines the block name
  57812. */
  57813. constructor(name: string);
  57814. /**
  57815. * Gets the current class name
  57816. * @returns the class name
  57817. */
  57818. getClassName(): string;
  57819. /**
  57820. * Gets the value operand input component
  57821. */
  57822. get value(): NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the power operand input component
  57825. */
  57826. get power(): NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the output component
  57829. */
  57830. get output(): NodeMaterialConnectionPoint;
  57831. protected _buildBlock(state: NodeMaterialBuildState): this;
  57832. }
  57833. }
  57834. declare module BABYLON {
  57835. /**
  57836. * Block used to get a random number
  57837. */
  57838. export class RandomNumberBlock extends NodeMaterialBlock {
  57839. /**
  57840. * Creates a new RandomNumberBlock
  57841. * @param name defines the block name
  57842. */
  57843. constructor(name: string);
  57844. /**
  57845. * Gets the current class name
  57846. * @returns the class name
  57847. */
  57848. getClassName(): string;
  57849. /**
  57850. * Gets the seed input component
  57851. */
  57852. get seed(): NodeMaterialConnectionPoint;
  57853. /**
  57854. * Gets the output component
  57855. */
  57856. get output(): NodeMaterialConnectionPoint;
  57857. protected _buildBlock(state: NodeMaterialBuildState): this;
  57858. }
  57859. }
  57860. declare module BABYLON {
  57861. /**
  57862. * Block used to compute arc tangent of 2 values
  57863. */
  57864. export class ArcTan2Block extends NodeMaterialBlock {
  57865. /**
  57866. * Creates a new ArcTan2Block
  57867. * @param name defines the block name
  57868. */
  57869. constructor(name: string);
  57870. /**
  57871. * Gets the current class name
  57872. * @returns the class name
  57873. */
  57874. getClassName(): string;
  57875. /**
  57876. * Gets the x operand input component
  57877. */
  57878. get x(): NodeMaterialConnectionPoint;
  57879. /**
  57880. * Gets the y operand input component
  57881. */
  57882. get y(): NodeMaterialConnectionPoint;
  57883. /**
  57884. * Gets the output component
  57885. */
  57886. get output(): NodeMaterialConnectionPoint;
  57887. protected _buildBlock(state: NodeMaterialBuildState): this;
  57888. }
  57889. }
  57890. declare module BABYLON {
  57891. /**
  57892. * Block used to smooth step a value
  57893. */
  57894. export class SmoothStepBlock extends NodeMaterialBlock {
  57895. /**
  57896. * Creates a new SmoothStepBlock
  57897. * @param name defines the block name
  57898. */
  57899. constructor(name: string);
  57900. /**
  57901. * Gets the current class name
  57902. * @returns the class name
  57903. */
  57904. getClassName(): string;
  57905. /**
  57906. * Gets the value operand input component
  57907. */
  57908. get value(): NodeMaterialConnectionPoint;
  57909. /**
  57910. * Gets the first edge operand input component
  57911. */
  57912. get edge0(): NodeMaterialConnectionPoint;
  57913. /**
  57914. * Gets the second edge operand input component
  57915. */
  57916. get edge1(): NodeMaterialConnectionPoint;
  57917. /**
  57918. * Gets the output component
  57919. */
  57920. get output(): NodeMaterialConnectionPoint;
  57921. protected _buildBlock(state: NodeMaterialBuildState): this;
  57922. }
  57923. }
  57924. declare module BABYLON {
  57925. /**
  57926. * Block used to get the reciprocal (1 / x) of a value
  57927. */
  57928. export class ReciprocalBlock extends NodeMaterialBlock {
  57929. /**
  57930. * Creates a new ReciprocalBlock
  57931. * @param name defines the block name
  57932. */
  57933. constructor(name: string);
  57934. /**
  57935. * Gets the current class name
  57936. * @returns the class name
  57937. */
  57938. getClassName(): string;
  57939. /**
  57940. * Gets the input component
  57941. */
  57942. get input(): NodeMaterialConnectionPoint;
  57943. /**
  57944. * Gets the output component
  57945. */
  57946. get output(): NodeMaterialConnectionPoint;
  57947. protected _buildBlock(state: NodeMaterialBuildState): this;
  57948. }
  57949. }
  57950. declare module BABYLON {
  57951. /**
  57952. * Block used to replace a color by another one
  57953. */
  57954. export class ReplaceColorBlock extends NodeMaterialBlock {
  57955. /**
  57956. * Creates a new ReplaceColorBlock
  57957. * @param name defines the block name
  57958. */
  57959. constructor(name: string);
  57960. /**
  57961. * Gets the current class name
  57962. * @returns the class name
  57963. */
  57964. getClassName(): string;
  57965. /**
  57966. * Gets the value input component
  57967. */
  57968. get value(): NodeMaterialConnectionPoint;
  57969. /**
  57970. * Gets the reference input component
  57971. */
  57972. get reference(): NodeMaterialConnectionPoint;
  57973. /**
  57974. * Gets the distance input component
  57975. */
  57976. get distance(): NodeMaterialConnectionPoint;
  57977. /**
  57978. * Gets the replacement input component
  57979. */
  57980. get replacement(): NodeMaterialConnectionPoint;
  57981. /**
  57982. * Gets the output component
  57983. */
  57984. get output(): NodeMaterialConnectionPoint;
  57985. protected _buildBlock(state: NodeMaterialBuildState): this;
  57986. }
  57987. }
  57988. declare module BABYLON {
  57989. /**
  57990. * Block used to posterize a value
  57991. * @see https://en.wikipedia.org/wiki/Posterization
  57992. */
  57993. export class PosterizeBlock extends NodeMaterialBlock {
  57994. /**
  57995. * Creates a new PosterizeBlock
  57996. * @param name defines the block name
  57997. */
  57998. constructor(name: string);
  57999. /**
  58000. * Gets the current class name
  58001. * @returns the class name
  58002. */
  58003. getClassName(): string;
  58004. /**
  58005. * Gets the value input component
  58006. */
  58007. get value(): NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the steps input component
  58010. */
  58011. get steps(): NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the output component
  58014. */
  58015. get output(): NodeMaterialConnectionPoint;
  58016. protected _buildBlock(state: NodeMaterialBuildState): this;
  58017. }
  58018. }
  58019. declare module BABYLON {
  58020. /**
  58021. * Operations supported by the Wave block
  58022. */
  58023. export enum WaveBlockKind {
  58024. /** SawTooth */
  58025. SawTooth = 0,
  58026. /** Square */
  58027. Square = 1,
  58028. /** Triangle */
  58029. Triangle = 2
  58030. }
  58031. /**
  58032. * Block used to apply wave operation to floats
  58033. */
  58034. export class WaveBlock extends NodeMaterialBlock {
  58035. /**
  58036. * Gets or sets the kibnd of wave to be applied by the block
  58037. */
  58038. kind: WaveBlockKind;
  58039. /**
  58040. * Creates a new WaveBlock
  58041. * @param name defines the block name
  58042. */
  58043. constructor(name: string);
  58044. /**
  58045. * Gets the current class name
  58046. * @returns the class name
  58047. */
  58048. getClassName(): string;
  58049. /**
  58050. * Gets the input component
  58051. */
  58052. get input(): NodeMaterialConnectionPoint;
  58053. /**
  58054. * Gets the output component
  58055. */
  58056. get output(): NodeMaterialConnectionPoint;
  58057. protected _buildBlock(state: NodeMaterialBuildState): this;
  58058. serialize(): any;
  58059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58060. }
  58061. }
  58062. declare module BABYLON {
  58063. /**
  58064. * Class used to store a color step for the GradientBlock
  58065. */
  58066. export class GradientBlockColorStep {
  58067. /**
  58068. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58069. */
  58070. step: number;
  58071. /**
  58072. * Gets or sets the color associated with this step
  58073. */
  58074. color: Color3;
  58075. /**
  58076. * Creates a new GradientBlockColorStep
  58077. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58078. * @param color defines the color associated with this step
  58079. */
  58080. constructor(
  58081. /**
  58082. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58083. */
  58084. step: number,
  58085. /**
  58086. * Gets or sets the color associated with this step
  58087. */
  58088. color: Color3);
  58089. }
  58090. /**
  58091. * Block used to return a color from a gradient based on an input value between 0 and 1
  58092. */
  58093. export class GradientBlock extends NodeMaterialBlock {
  58094. /**
  58095. * Gets or sets the list of color steps
  58096. */
  58097. colorSteps: GradientBlockColorStep[];
  58098. /**
  58099. * Creates a new GradientBlock
  58100. * @param name defines the block name
  58101. */
  58102. constructor(name: string);
  58103. /**
  58104. * Gets the current class name
  58105. * @returns the class name
  58106. */
  58107. getClassName(): string;
  58108. /**
  58109. * Gets the gradient input component
  58110. */
  58111. get gradient(): NodeMaterialConnectionPoint;
  58112. /**
  58113. * Gets the output component
  58114. */
  58115. get output(): NodeMaterialConnectionPoint;
  58116. private _writeColorConstant;
  58117. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58118. serialize(): any;
  58119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58120. protected _dumpPropertiesCode(): string;
  58121. }
  58122. }
  58123. declare module BABYLON {
  58124. /**
  58125. * Block used to normalize lerp between 2 values
  58126. */
  58127. export class NLerpBlock extends NodeMaterialBlock {
  58128. /**
  58129. * Creates a new NLerpBlock
  58130. * @param name defines the block name
  58131. */
  58132. constructor(name: string);
  58133. /**
  58134. * Gets the current class name
  58135. * @returns the class name
  58136. */
  58137. getClassName(): string;
  58138. /**
  58139. * Gets the left operand input component
  58140. */
  58141. get left(): NodeMaterialConnectionPoint;
  58142. /**
  58143. * Gets the right operand input component
  58144. */
  58145. get right(): NodeMaterialConnectionPoint;
  58146. /**
  58147. * Gets the gradient operand input component
  58148. */
  58149. get gradient(): NodeMaterialConnectionPoint;
  58150. /**
  58151. * Gets the output component
  58152. */
  58153. get output(): NodeMaterialConnectionPoint;
  58154. protected _buildBlock(state: NodeMaterialBuildState): this;
  58155. }
  58156. }
  58157. declare module BABYLON {
  58158. /**
  58159. * block used to Generate a Worley Noise 3D Noise Pattern
  58160. */
  58161. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58162. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58163. manhattanDistance: boolean;
  58164. /**
  58165. * Creates a new WorleyNoise3DBlock
  58166. * @param name defines the block name
  58167. */
  58168. constructor(name: string);
  58169. /**
  58170. * Gets the current class name
  58171. * @returns the class name
  58172. */
  58173. getClassName(): string;
  58174. /**
  58175. * Gets the seed input component
  58176. */
  58177. get seed(): NodeMaterialConnectionPoint;
  58178. /**
  58179. * Gets the jitter input component
  58180. */
  58181. get jitter(): NodeMaterialConnectionPoint;
  58182. /**
  58183. * Gets the output component
  58184. */
  58185. get output(): NodeMaterialConnectionPoint;
  58186. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58187. /**
  58188. * Exposes the properties to the UI?
  58189. */
  58190. protected _dumpPropertiesCode(): string;
  58191. /**
  58192. * Exposes the properties to the Seralize?
  58193. */
  58194. serialize(): any;
  58195. /**
  58196. * Exposes the properties to the deseralize?
  58197. */
  58198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58199. }
  58200. }
  58201. declare module BABYLON {
  58202. /**
  58203. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58204. */
  58205. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58206. /**
  58207. * Creates a new SimplexPerlin3DBlock
  58208. * @param name defines the block name
  58209. */
  58210. constructor(name: string);
  58211. /**
  58212. * Gets the current class name
  58213. * @returns the class name
  58214. */
  58215. getClassName(): string;
  58216. /**
  58217. * Gets the seed operand input component
  58218. */
  58219. get seed(): NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the output component
  58222. */
  58223. get output(): NodeMaterialConnectionPoint;
  58224. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58225. }
  58226. }
  58227. declare module BABYLON {
  58228. /**
  58229. * Block used to blend normals
  58230. */
  58231. export class NormalBlendBlock extends NodeMaterialBlock {
  58232. /**
  58233. * Creates a new NormalBlendBlock
  58234. * @param name defines the block name
  58235. */
  58236. constructor(name: string);
  58237. /**
  58238. * Gets the current class name
  58239. * @returns the class name
  58240. */
  58241. getClassName(): string;
  58242. /**
  58243. * Gets the first input component
  58244. */
  58245. get normalMap0(): NodeMaterialConnectionPoint;
  58246. /**
  58247. * Gets the second input component
  58248. */
  58249. get normalMap1(): NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the output component
  58252. */
  58253. get output(): NodeMaterialConnectionPoint;
  58254. protected _buildBlock(state: NodeMaterialBuildState): this;
  58255. }
  58256. }
  58257. declare module BABYLON {
  58258. /**
  58259. * Block used to rotate a 2d vector by a given angle
  58260. */
  58261. export class Rotate2dBlock extends NodeMaterialBlock {
  58262. /**
  58263. * Creates a new Rotate2dBlock
  58264. * @param name defines the block name
  58265. */
  58266. constructor(name: string);
  58267. /**
  58268. * Gets the current class name
  58269. * @returns the class name
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Gets the input vector
  58274. */
  58275. get input(): NodeMaterialConnectionPoint;
  58276. /**
  58277. * Gets the input angle
  58278. */
  58279. get angle(): NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the output component
  58282. */
  58283. get output(): NodeMaterialConnectionPoint;
  58284. autoConfigure(material: NodeMaterial): void;
  58285. protected _buildBlock(state: NodeMaterialBuildState): this;
  58286. }
  58287. }
  58288. declare module BABYLON {
  58289. /**
  58290. * Block used to get the reflected vector from a direction and a normal
  58291. */
  58292. export class ReflectBlock extends NodeMaterialBlock {
  58293. /**
  58294. * Creates a new ReflectBlock
  58295. * @param name defines the block name
  58296. */
  58297. constructor(name: string);
  58298. /**
  58299. * Gets the current class name
  58300. * @returns the class name
  58301. */
  58302. getClassName(): string;
  58303. /**
  58304. * Gets the incident component
  58305. */
  58306. get incident(): NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the normal component
  58309. */
  58310. get normal(): NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the output component
  58313. */
  58314. get output(): NodeMaterialConnectionPoint;
  58315. protected _buildBlock(state: NodeMaterialBuildState): this;
  58316. }
  58317. }
  58318. declare module BABYLON {
  58319. /**
  58320. * Block used to get the refracted vector from a direction and a normal
  58321. */
  58322. export class RefractBlock extends NodeMaterialBlock {
  58323. /**
  58324. * Creates a new RefractBlock
  58325. * @param name defines the block name
  58326. */
  58327. constructor(name: string);
  58328. /**
  58329. * Gets the current class name
  58330. * @returns the class name
  58331. */
  58332. getClassName(): string;
  58333. /**
  58334. * Gets the incident component
  58335. */
  58336. get incident(): NodeMaterialConnectionPoint;
  58337. /**
  58338. * Gets the normal component
  58339. */
  58340. get normal(): NodeMaterialConnectionPoint;
  58341. /**
  58342. * Gets the index of refraction component
  58343. */
  58344. get ior(): NodeMaterialConnectionPoint;
  58345. /**
  58346. * Gets the output component
  58347. */
  58348. get output(): NodeMaterialConnectionPoint;
  58349. protected _buildBlock(state: NodeMaterialBuildState): this;
  58350. }
  58351. }
  58352. declare module BABYLON {
  58353. /**
  58354. * Block used to desaturate a color
  58355. */
  58356. export class DesaturateBlock extends NodeMaterialBlock {
  58357. /**
  58358. * Creates a new DesaturateBlock
  58359. * @param name defines the block name
  58360. */
  58361. constructor(name: string);
  58362. /**
  58363. * Gets the current class name
  58364. * @returns the class name
  58365. */
  58366. getClassName(): string;
  58367. /**
  58368. * Gets the color operand input component
  58369. */
  58370. get color(): NodeMaterialConnectionPoint;
  58371. /**
  58372. * Gets the level operand input component
  58373. */
  58374. get level(): NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the output component
  58377. */
  58378. get output(): NodeMaterialConnectionPoint;
  58379. protected _buildBlock(state: NodeMaterialBuildState): this;
  58380. }
  58381. }
  58382. declare module BABYLON {
  58383. /**
  58384. * Effect Render Options
  58385. */
  58386. export interface IEffectRendererOptions {
  58387. /**
  58388. * Defines the vertices positions.
  58389. */
  58390. positions?: number[];
  58391. /**
  58392. * Defines the indices.
  58393. */
  58394. indices?: number[];
  58395. }
  58396. /**
  58397. * Helper class to render one or more effects
  58398. */
  58399. export class EffectRenderer {
  58400. private engine;
  58401. private static _DefaultOptions;
  58402. private _vertexBuffers;
  58403. private _indexBuffer;
  58404. private _ringBufferIndex;
  58405. private _ringScreenBuffer;
  58406. private _fullscreenViewport;
  58407. private _getNextFrameBuffer;
  58408. /**
  58409. * Creates an effect renderer
  58410. * @param engine the engine to use for rendering
  58411. * @param options defines the options of the effect renderer
  58412. */
  58413. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58414. /**
  58415. * Sets the current viewport in normalized coordinates 0-1
  58416. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58417. */
  58418. setViewport(viewport?: Viewport): void;
  58419. /**
  58420. * Binds the embedded attributes buffer to the effect.
  58421. * @param effect Defines the effect to bind the attributes for
  58422. */
  58423. bindBuffers(effect: Effect): void;
  58424. /**
  58425. * Sets the current effect wrapper to use during draw.
  58426. * The effect needs to be ready before calling this api.
  58427. * This also sets the default full screen position attribute.
  58428. * @param effectWrapper Defines the effect to draw with
  58429. */
  58430. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58431. /**
  58432. * Draws a full screen quad.
  58433. */
  58434. draw(): void;
  58435. /**
  58436. * renders one or more effects to a specified texture
  58437. * @param effectWrappers list of effects to renderer
  58438. * @param outputTexture texture to draw to, if null it will render to the screen
  58439. */
  58440. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58441. /**
  58442. * Disposes of the effect renderer
  58443. */
  58444. dispose(): void;
  58445. }
  58446. /**
  58447. * Options to create an EffectWrapper
  58448. */
  58449. interface EffectWrapperCreationOptions {
  58450. /**
  58451. * Engine to use to create the effect
  58452. */
  58453. engine: ThinEngine;
  58454. /**
  58455. * Fragment shader for the effect
  58456. */
  58457. fragmentShader: string;
  58458. /**
  58459. * Vertex shader for the effect
  58460. */
  58461. vertexShader?: string;
  58462. /**
  58463. * Attributes to use in the shader
  58464. */
  58465. attributeNames?: Array<string>;
  58466. /**
  58467. * Uniforms to use in the shader
  58468. */
  58469. uniformNames?: Array<string>;
  58470. /**
  58471. * Texture sampler names to use in the shader
  58472. */
  58473. samplerNames?: Array<string>;
  58474. /**
  58475. * The friendly name of the effect displayed in Spector.
  58476. */
  58477. name?: string;
  58478. }
  58479. /**
  58480. * Wraps an effect to be used for rendering
  58481. */
  58482. export class EffectWrapper {
  58483. /**
  58484. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58485. */
  58486. onApplyObservable: Observable<{}>;
  58487. /**
  58488. * The underlying effect
  58489. */
  58490. effect: Effect;
  58491. /**
  58492. * Creates an effect to be renderer
  58493. * @param creationOptions options to create the effect
  58494. */
  58495. constructor(creationOptions: EffectWrapperCreationOptions);
  58496. /**
  58497. * Disposes of the effect wrapper
  58498. */
  58499. dispose(): void;
  58500. }
  58501. }
  58502. declare module BABYLON {
  58503. /**
  58504. * Helper class to push actions to a pool of workers.
  58505. */
  58506. export class WorkerPool implements IDisposable {
  58507. private _workerInfos;
  58508. private _pendingActions;
  58509. /**
  58510. * Constructor
  58511. * @param workers Array of workers to use for actions
  58512. */
  58513. constructor(workers: Array<Worker>);
  58514. /**
  58515. * Terminates all workers and clears any pending actions.
  58516. */
  58517. dispose(): void;
  58518. /**
  58519. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58520. * pended until a worker has completed its action.
  58521. * @param action The action to perform. Call onComplete when the action is complete.
  58522. */
  58523. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58524. private _execute;
  58525. }
  58526. }
  58527. declare module BABYLON {
  58528. /**
  58529. * Configuration for Draco compression
  58530. */
  58531. export interface IDracoCompressionConfiguration {
  58532. /**
  58533. * Configuration for the decoder.
  58534. */
  58535. decoder: {
  58536. /**
  58537. * The url to the WebAssembly module.
  58538. */
  58539. wasmUrl?: string;
  58540. /**
  58541. * The url to the WebAssembly binary.
  58542. */
  58543. wasmBinaryUrl?: string;
  58544. /**
  58545. * The url to the fallback JavaScript module.
  58546. */
  58547. fallbackUrl?: string;
  58548. };
  58549. }
  58550. /**
  58551. * Draco compression (https://google.github.io/draco/)
  58552. *
  58553. * This class wraps the Draco module.
  58554. *
  58555. * **Encoder**
  58556. *
  58557. * The encoder is not currently implemented.
  58558. *
  58559. * **Decoder**
  58560. *
  58561. * 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.
  58562. *
  58563. * To update the configuration, use the following code:
  58564. * ```javascript
  58565. * DracoCompression.Configuration = {
  58566. * decoder: {
  58567. * wasmUrl: "<url to the WebAssembly library>",
  58568. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58569. * fallbackUrl: "<url to the fallback JavaScript library>",
  58570. * }
  58571. * };
  58572. * ```
  58573. *
  58574. * 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.
  58575. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58576. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58577. *
  58578. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58579. * ```javascript
  58580. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58581. * ```
  58582. *
  58583. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58584. */
  58585. export class DracoCompression implements IDisposable {
  58586. private _workerPoolPromise?;
  58587. private _decoderModulePromise?;
  58588. /**
  58589. * The configuration. Defaults to the following urls:
  58590. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58591. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58592. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58593. */
  58594. static Configuration: IDracoCompressionConfiguration;
  58595. /**
  58596. * Returns true if the decoder configuration is available.
  58597. */
  58598. static get DecoderAvailable(): boolean;
  58599. /**
  58600. * Default number of workers to create when creating the draco compression object.
  58601. */
  58602. static DefaultNumWorkers: number;
  58603. private static GetDefaultNumWorkers;
  58604. private static _Default;
  58605. /**
  58606. * Default instance for the draco compression object.
  58607. */
  58608. static get Default(): DracoCompression;
  58609. /**
  58610. * Constructor
  58611. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58612. */
  58613. constructor(numWorkers?: number);
  58614. /**
  58615. * Stop all async operations and release resources.
  58616. */
  58617. dispose(): void;
  58618. /**
  58619. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58620. * @returns a promise that resolves when ready
  58621. */
  58622. whenReadyAsync(): Promise<void>;
  58623. /**
  58624. * Decode Draco compressed mesh data to vertex data.
  58625. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58626. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58627. * @returns A promise that resolves with the decoded vertex data
  58628. */
  58629. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58630. [kind: string]: number;
  58631. }): Promise<VertexData>;
  58632. }
  58633. }
  58634. declare module BABYLON {
  58635. /**
  58636. * Class for building Constructive Solid Geometry
  58637. */
  58638. export class CSG {
  58639. private polygons;
  58640. /**
  58641. * The world matrix
  58642. */
  58643. matrix: Matrix;
  58644. /**
  58645. * Stores the position
  58646. */
  58647. position: Vector3;
  58648. /**
  58649. * Stores the rotation
  58650. */
  58651. rotation: Vector3;
  58652. /**
  58653. * Stores the rotation quaternion
  58654. */
  58655. rotationQuaternion: Nullable<Quaternion>;
  58656. /**
  58657. * Stores the scaling vector
  58658. */
  58659. scaling: Vector3;
  58660. /**
  58661. * Convert the Mesh to CSG
  58662. * @param mesh The Mesh to convert to CSG
  58663. * @returns A new CSG from the Mesh
  58664. */
  58665. static FromMesh(mesh: Mesh): CSG;
  58666. /**
  58667. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58668. * @param polygons Polygons used to construct a CSG solid
  58669. */
  58670. private static FromPolygons;
  58671. /**
  58672. * Clones, or makes a deep copy, of the CSG
  58673. * @returns A new CSG
  58674. */
  58675. clone(): CSG;
  58676. /**
  58677. * Unions this CSG with another CSG
  58678. * @param csg The CSG to union against this CSG
  58679. * @returns The unioned CSG
  58680. */
  58681. union(csg: CSG): CSG;
  58682. /**
  58683. * Unions this CSG with another CSG in place
  58684. * @param csg The CSG to union against this CSG
  58685. */
  58686. unionInPlace(csg: CSG): void;
  58687. /**
  58688. * Subtracts this CSG with another CSG
  58689. * @param csg The CSG to subtract against this CSG
  58690. * @returns A new CSG
  58691. */
  58692. subtract(csg: CSG): CSG;
  58693. /**
  58694. * Subtracts this CSG with another CSG in place
  58695. * @param csg The CSG to subtact against this CSG
  58696. */
  58697. subtractInPlace(csg: CSG): void;
  58698. /**
  58699. * Intersect this CSG with another CSG
  58700. * @param csg The CSG to intersect against this CSG
  58701. * @returns A new CSG
  58702. */
  58703. intersect(csg: CSG): CSG;
  58704. /**
  58705. * Intersects this CSG with another CSG in place
  58706. * @param csg The CSG to intersect against this CSG
  58707. */
  58708. intersectInPlace(csg: CSG): void;
  58709. /**
  58710. * Return a new CSG solid with solid and empty space switched. This solid is
  58711. * not modified.
  58712. * @returns A new CSG solid with solid and empty space switched
  58713. */
  58714. inverse(): CSG;
  58715. /**
  58716. * Inverses the CSG in place
  58717. */
  58718. inverseInPlace(): void;
  58719. /**
  58720. * This is used to keep meshes transformations so they can be restored
  58721. * when we build back a Babylon Mesh
  58722. * NB : All CSG operations are performed in world coordinates
  58723. * @param csg The CSG to copy the transform attributes from
  58724. * @returns This CSG
  58725. */
  58726. copyTransformAttributes(csg: CSG): CSG;
  58727. /**
  58728. * Build Raw mesh from CSG
  58729. * Coordinates here are in world space
  58730. * @param name The name of the mesh geometry
  58731. * @param scene The Scene
  58732. * @param keepSubMeshes Specifies if the submeshes should be kept
  58733. * @returns A new Mesh
  58734. */
  58735. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58736. /**
  58737. * Build Mesh from CSG taking material and transforms into account
  58738. * @param name The name of the Mesh
  58739. * @param material The material of the Mesh
  58740. * @param scene The Scene
  58741. * @param keepSubMeshes Specifies if submeshes should be kept
  58742. * @returns The new Mesh
  58743. */
  58744. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58745. }
  58746. }
  58747. declare module BABYLON {
  58748. /**
  58749. * Class used to create a trail following a mesh
  58750. */
  58751. export class TrailMesh extends Mesh {
  58752. private _generator;
  58753. private _autoStart;
  58754. private _running;
  58755. private _diameter;
  58756. private _length;
  58757. private _sectionPolygonPointsCount;
  58758. private _sectionVectors;
  58759. private _sectionNormalVectors;
  58760. private _beforeRenderObserver;
  58761. /**
  58762. * @constructor
  58763. * @param name The value used by scene.getMeshByName() to do a lookup.
  58764. * @param generator The mesh to generate a trail.
  58765. * @param scene The scene to add this mesh to.
  58766. * @param diameter Diameter of trailing mesh. Default is 1.
  58767. * @param length Length of trailing mesh. Default is 60.
  58768. * @param autoStart Automatically start trailing mesh. Default true.
  58769. */
  58770. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58771. /**
  58772. * "TrailMesh"
  58773. * @returns "TrailMesh"
  58774. */
  58775. getClassName(): string;
  58776. private _createMesh;
  58777. /**
  58778. * Start trailing mesh.
  58779. */
  58780. start(): void;
  58781. /**
  58782. * Stop trailing mesh.
  58783. */
  58784. stop(): void;
  58785. /**
  58786. * Update trailing mesh geometry.
  58787. */
  58788. update(): void;
  58789. /**
  58790. * Returns a new TrailMesh object.
  58791. * @param name is a string, the name given to the new mesh
  58792. * @param newGenerator use new generator object for cloned trail mesh
  58793. * @returns a new mesh
  58794. */
  58795. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58796. /**
  58797. * Serializes this trail mesh
  58798. * @param serializationObject object to write serialization to
  58799. */
  58800. serialize(serializationObject: any): void;
  58801. /**
  58802. * Parses a serialized trail mesh
  58803. * @param parsedMesh the serialized mesh
  58804. * @param scene the scene to create the trail mesh in
  58805. * @returns the created trail mesh
  58806. */
  58807. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58808. }
  58809. }
  58810. declare module BABYLON {
  58811. /**
  58812. * Class containing static functions to help procedurally build meshes
  58813. */
  58814. export class TiledBoxBuilder {
  58815. /**
  58816. * Creates a box mesh
  58817. * 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)
  58818. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58820. * * 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
  58821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58822. * @param name defines the name of the mesh
  58823. * @param options defines the options used to create the mesh
  58824. * @param scene defines the hosting scene
  58825. * @returns the box mesh
  58826. */
  58827. static CreateTiledBox(name: string, options: {
  58828. pattern?: number;
  58829. width?: number;
  58830. height?: number;
  58831. depth?: number;
  58832. tileSize?: number;
  58833. tileWidth?: number;
  58834. tileHeight?: number;
  58835. alignHorizontal?: number;
  58836. alignVertical?: number;
  58837. faceUV?: Vector4[];
  58838. faceColors?: Color4[];
  58839. sideOrientation?: number;
  58840. updatable?: boolean;
  58841. }, scene?: Nullable<Scene>): Mesh;
  58842. }
  58843. }
  58844. declare module BABYLON {
  58845. /**
  58846. * Class containing static functions to help procedurally build meshes
  58847. */
  58848. export class TorusKnotBuilder {
  58849. /**
  58850. * Creates a torus knot mesh
  58851. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58852. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58853. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58854. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58856. * * 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
  58857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58858. * @param name defines the name of the mesh
  58859. * @param options defines the options used to create the mesh
  58860. * @param scene defines the hosting scene
  58861. * @returns the torus knot mesh
  58862. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58863. */
  58864. static CreateTorusKnot(name: string, options: {
  58865. radius?: number;
  58866. tube?: number;
  58867. radialSegments?: number;
  58868. tubularSegments?: number;
  58869. p?: number;
  58870. q?: number;
  58871. updatable?: boolean;
  58872. sideOrientation?: number;
  58873. frontUVs?: Vector4;
  58874. backUVs?: Vector4;
  58875. }, scene: any): Mesh;
  58876. }
  58877. }
  58878. declare module BABYLON {
  58879. /**
  58880. * Polygon
  58881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58882. */
  58883. export class Polygon {
  58884. /**
  58885. * Creates a rectangle
  58886. * @param xmin bottom X coord
  58887. * @param ymin bottom Y coord
  58888. * @param xmax top X coord
  58889. * @param ymax top Y coord
  58890. * @returns points that make the resulting rectation
  58891. */
  58892. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58893. /**
  58894. * Creates a circle
  58895. * @param radius radius of circle
  58896. * @param cx scale in x
  58897. * @param cy scale in y
  58898. * @param numberOfSides number of sides that make up the circle
  58899. * @returns points that make the resulting circle
  58900. */
  58901. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58902. /**
  58903. * Creates a polygon from input string
  58904. * @param input Input polygon data
  58905. * @returns the parsed points
  58906. */
  58907. static Parse(input: string): Vector2[];
  58908. /**
  58909. * Starts building a polygon from x and y coordinates
  58910. * @param x x coordinate
  58911. * @param y y coordinate
  58912. * @returns the started path2
  58913. */
  58914. static StartingAt(x: number, y: number): Path2;
  58915. }
  58916. /**
  58917. * Builds a polygon
  58918. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58919. */
  58920. export class PolygonMeshBuilder {
  58921. private _points;
  58922. private _outlinepoints;
  58923. private _holes;
  58924. private _name;
  58925. private _scene;
  58926. private _epoints;
  58927. private _eholes;
  58928. private _addToepoint;
  58929. /**
  58930. * Babylon reference to the earcut plugin.
  58931. */
  58932. bjsEarcut: any;
  58933. /**
  58934. * Creates a PolygonMeshBuilder
  58935. * @param name name of the builder
  58936. * @param contours Path of the polygon
  58937. * @param scene scene to add to when creating the mesh
  58938. * @param earcutInjection can be used to inject your own earcut reference
  58939. */
  58940. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58941. /**
  58942. * Adds a whole within the polygon
  58943. * @param hole Array of points defining the hole
  58944. * @returns this
  58945. */
  58946. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58947. /**
  58948. * Creates the polygon
  58949. * @param updatable If the mesh should be updatable
  58950. * @param depth The depth of the mesh created
  58951. * @returns the created mesh
  58952. */
  58953. build(updatable?: boolean, depth?: number): Mesh;
  58954. /**
  58955. * Creates the polygon
  58956. * @param depth The depth of the mesh created
  58957. * @returns the created VertexData
  58958. */
  58959. buildVertexData(depth?: number): VertexData;
  58960. /**
  58961. * Adds a side to the polygon
  58962. * @param positions points that make the polygon
  58963. * @param normals normals of the polygon
  58964. * @param uvs uvs of the polygon
  58965. * @param indices indices of the polygon
  58966. * @param bounds bounds of the polygon
  58967. * @param points points of the polygon
  58968. * @param depth depth of the polygon
  58969. * @param flip flip of the polygon
  58970. */
  58971. private addSide;
  58972. }
  58973. }
  58974. declare module BABYLON {
  58975. /**
  58976. * Class containing static functions to help procedurally build meshes
  58977. */
  58978. export class PolygonBuilder {
  58979. /**
  58980. * Creates a polygon mesh
  58981. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58982. * * 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
  58983. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58985. * * 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)
  58986. * * Remember you can only change the shape positions, not their number when updating a polygon
  58987. * @param name defines the name of the mesh
  58988. * @param options defines the options used to create the mesh
  58989. * @param scene defines the hosting scene
  58990. * @param earcutInjection can be used to inject your own earcut reference
  58991. * @returns the polygon mesh
  58992. */
  58993. static CreatePolygon(name: string, options: {
  58994. shape: Vector3[];
  58995. holes?: Vector3[][];
  58996. depth?: number;
  58997. faceUV?: Vector4[];
  58998. faceColors?: Color4[];
  58999. updatable?: boolean;
  59000. sideOrientation?: number;
  59001. frontUVs?: Vector4;
  59002. backUVs?: Vector4;
  59003. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59004. /**
  59005. * Creates an extruded polygon mesh, with depth in the Y direction.
  59006. * * 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)
  59007. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59008. * @param name defines the name of the mesh
  59009. * @param options defines the options used to create the mesh
  59010. * @param scene defines the hosting scene
  59011. * @param earcutInjection can be used to inject your own earcut reference
  59012. * @returns the polygon mesh
  59013. */
  59014. static ExtrudePolygon(name: string, options: {
  59015. shape: Vector3[];
  59016. holes?: Vector3[][];
  59017. depth?: number;
  59018. faceUV?: Vector4[];
  59019. faceColors?: Color4[];
  59020. updatable?: boolean;
  59021. sideOrientation?: number;
  59022. frontUVs?: Vector4;
  59023. backUVs?: Vector4;
  59024. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59025. }
  59026. }
  59027. declare module BABYLON {
  59028. /**
  59029. * Class containing static functions to help procedurally build meshes
  59030. */
  59031. export class LatheBuilder {
  59032. /**
  59033. * Creates lathe mesh.
  59034. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59035. * * 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
  59036. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59037. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59038. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59039. * * 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
  59040. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59041. * * 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
  59042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59043. * * 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
  59044. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59046. * @param name defines the name of the mesh
  59047. * @param options defines the options used to create the mesh
  59048. * @param scene defines the hosting scene
  59049. * @returns the lathe mesh
  59050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59051. */
  59052. static CreateLathe(name: string, options: {
  59053. shape: Vector3[];
  59054. radius?: number;
  59055. tessellation?: number;
  59056. clip?: number;
  59057. arc?: number;
  59058. closed?: boolean;
  59059. updatable?: boolean;
  59060. sideOrientation?: number;
  59061. frontUVs?: Vector4;
  59062. backUVs?: Vector4;
  59063. cap?: number;
  59064. invertUV?: boolean;
  59065. }, scene?: Nullable<Scene>): Mesh;
  59066. }
  59067. }
  59068. declare module BABYLON {
  59069. /**
  59070. * Class containing static functions to help procedurally build meshes
  59071. */
  59072. export class TiledPlaneBuilder {
  59073. /**
  59074. * Creates a tiled plane mesh
  59075. * * The parameter `pattern` will, depending on value, do nothing or
  59076. * * * flip (reflect about central vertical) alternate tiles across and up
  59077. * * * flip every tile on alternate rows
  59078. * * * rotate (180 degs) alternate tiles across and up
  59079. * * * rotate every tile on alternate rows
  59080. * * * flip and rotate alternate tiles across and up
  59081. * * * flip and rotate every tile on alternate rows
  59082. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59083. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59084. * * 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
  59085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59086. * * 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)
  59087. * * 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)
  59088. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59089. * @param name defines the name of the mesh
  59090. * @param options defines the options used to create the mesh
  59091. * @param scene defines the hosting scene
  59092. * @returns the box mesh
  59093. */
  59094. static CreateTiledPlane(name: string, options: {
  59095. pattern?: number;
  59096. tileSize?: number;
  59097. tileWidth?: number;
  59098. tileHeight?: number;
  59099. size?: number;
  59100. width?: number;
  59101. height?: number;
  59102. alignHorizontal?: number;
  59103. alignVertical?: number;
  59104. sideOrientation?: number;
  59105. frontUVs?: Vector4;
  59106. backUVs?: Vector4;
  59107. updatable?: boolean;
  59108. }, scene?: Nullable<Scene>): Mesh;
  59109. }
  59110. }
  59111. declare module BABYLON {
  59112. /**
  59113. * Class containing static functions to help procedurally build meshes
  59114. */
  59115. export class TubeBuilder {
  59116. /**
  59117. * Creates a tube mesh.
  59118. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59119. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59120. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59121. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59122. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59123. * * 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)
  59124. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59125. * * 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
  59126. * * 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
  59127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59128. * * 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
  59129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59131. * @param name defines the name of the mesh
  59132. * @param options defines the options used to create the mesh
  59133. * @param scene defines the hosting scene
  59134. * @returns the tube mesh
  59135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59136. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59137. */
  59138. static CreateTube(name: string, options: {
  59139. path: Vector3[];
  59140. radius?: number;
  59141. tessellation?: number;
  59142. radiusFunction?: {
  59143. (i: number, distance: number): number;
  59144. };
  59145. cap?: number;
  59146. arc?: number;
  59147. updatable?: boolean;
  59148. sideOrientation?: number;
  59149. frontUVs?: Vector4;
  59150. backUVs?: Vector4;
  59151. instance?: Mesh;
  59152. invertUV?: boolean;
  59153. }, scene?: Nullable<Scene>): Mesh;
  59154. }
  59155. }
  59156. declare module BABYLON {
  59157. /**
  59158. * Class containing static functions to help procedurally build meshes
  59159. */
  59160. export class IcoSphereBuilder {
  59161. /**
  59162. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59163. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59164. * * 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`)
  59165. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59166. * * 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
  59167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59168. * * 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
  59169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59170. * @param name defines the name of the mesh
  59171. * @param options defines the options used to create the mesh
  59172. * @param scene defines the hosting scene
  59173. * @returns the icosahedron mesh
  59174. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59175. */
  59176. static CreateIcoSphere(name: string, options: {
  59177. radius?: number;
  59178. radiusX?: number;
  59179. radiusY?: number;
  59180. radiusZ?: number;
  59181. flat?: boolean;
  59182. subdivisions?: number;
  59183. sideOrientation?: number;
  59184. frontUVs?: Vector4;
  59185. backUVs?: Vector4;
  59186. updatable?: boolean;
  59187. }, scene?: Nullable<Scene>): Mesh;
  59188. }
  59189. }
  59190. declare module BABYLON {
  59191. /**
  59192. * Class containing static functions to help procedurally build meshes
  59193. */
  59194. export class DecalBuilder {
  59195. /**
  59196. * Creates a decal mesh.
  59197. * 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
  59198. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59199. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59200. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59201. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59202. * @param name defines the name of the mesh
  59203. * @param sourceMesh defines the mesh where the decal must be applied
  59204. * @param options defines the options used to create the mesh
  59205. * @param scene defines the hosting scene
  59206. * @returns the decal mesh
  59207. * @see https://doc.babylonjs.com/how_to/decals
  59208. */
  59209. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59210. position?: Vector3;
  59211. normal?: Vector3;
  59212. size?: Vector3;
  59213. angle?: number;
  59214. }): Mesh;
  59215. }
  59216. }
  59217. declare module BABYLON {
  59218. /**
  59219. * Class containing static functions to help procedurally build meshes
  59220. */
  59221. export class MeshBuilder {
  59222. /**
  59223. * Creates a box mesh
  59224. * * The parameter `size` sets the size (float) of each box side (default 1)
  59225. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59226. * * 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)
  59227. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59229. * * 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
  59230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59231. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59232. * @param name defines the name of the mesh
  59233. * @param options defines the options used to create the mesh
  59234. * @param scene defines the hosting scene
  59235. * @returns the box mesh
  59236. */
  59237. static CreateBox(name: string, options: {
  59238. size?: number;
  59239. width?: number;
  59240. height?: number;
  59241. depth?: number;
  59242. faceUV?: Vector4[];
  59243. faceColors?: Color4[];
  59244. sideOrientation?: number;
  59245. frontUVs?: Vector4;
  59246. backUVs?: Vector4;
  59247. updatable?: boolean;
  59248. }, scene?: Nullable<Scene>): Mesh;
  59249. /**
  59250. * Creates a tiled box mesh
  59251. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59253. * @param name defines the name of the mesh
  59254. * @param options defines the options used to create the mesh
  59255. * @param scene defines the hosting scene
  59256. * @returns the tiled box mesh
  59257. */
  59258. static CreateTiledBox(name: string, options: {
  59259. pattern?: number;
  59260. size?: number;
  59261. width?: number;
  59262. height?: number;
  59263. depth: number;
  59264. tileSize?: number;
  59265. tileWidth?: number;
  59266. tileHeight?: number;
  59267. faceUV?: Vector4[];
  59268. faceColors?: Color4[];
  59269. alignHorizontal?: number;
  59270. alignVertical?: number;
  59271. sideOrientation?: number;
  59272. updatable?: boolean;
  59273. }, scene?: Nullable<Scene>): Mesh;
  59274. /**
  59275. * Creates a sphere mesh
  59276. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59277. * * 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`)
  59278. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59279. * * 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
  59280. * * 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)
  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 sphere mesh
  59288. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59289. */
  59290. static CreateSphere(name: string, options: {
  59291. segments?: number;
  59292. diameter?: number;
  59293. diameterX?: number;
  59294. diameterY?: number;
  59295. diameterZ?: number;
  59296. arc?: number;
  59297. slice?: number;
  59298. sideOrientation?: number;
  59299. frontUVs?: Vector4;
  59300. backUVs?: Vector4;
  59301. updatable?: boolean;
  59302. }, scene?: Nullable<Scene>): Mesh;
  59303. /**
  59304. * Creates a plane polygonal mesh. By default, this is a disc
  59305. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59306. * * 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
  59307. * * 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
  59308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59309. * * 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
  59310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59311. * @param name defines the name of the mesh
  59312. * @param options defines the options used to create the mesh
  59313. * @param scene defines the hosting scene
  59314. * @returns the plane polygonal mesh
  59315. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59316. */
  59317. static CreateDisc(name: string, options: {
  59318. radius?: number;
  59319. tessellation?: number;
  59320. arc?: number;
  59321. updatable?: boolean;
  59322. sideOrientation?: number;
  59323. frontUVs?: Vector4;
  59324. backUVs?: Vector4;
  59325. }, scene?: Nullable<Scene>): Mesh;
  59326. /**
  59327. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59328. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59329. * * 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`)
  59330. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59331. * * 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
  59332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59333. * * 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
  59334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59335. * @param name defines the name of the mesh
  59336. * @param options defines the options used to create the mesh
  59337. * @param scene defines the hosting scene
  59338. * @returns the icosahedron mesh
  59339. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59340. */
  59341. static CreateIcoSphere(name: string, options: {
  59342. radius?: number;
  59343. radiusX?: number;
  59344. radiusY?: number;
  59345. radiusZ?: number;
  59346. flat?: boolean;
  59347. subdivisions?: number;
  59348. sideOrientation?: number;
  59349. frontUVs?: Vector4;
  59350. backUVs?: Vector4;
  59351. updatable?: boolean;
  59352. }, scene?: Nullable<Scene>): Mesh;
  59353. /**
  59354. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59355. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59356. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59357. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59358. * * 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
  59359. * * 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
  59360. * * 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
  59361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59362. * * 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
  59363. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59364. * * 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
  59365. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59366. * * 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
  59367. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59369. * @param name defines the name of the mesh
  59370. * @param options defines the options used to create the mesh
  59371. * @param scene defines the hosting scene
  59372. * @returns the ribbon mesh
  59373. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59374. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59375. */
  59376. static CreateRibbon(name: string, options: {
  59377. pathArray: Vector3[][];
  59378. closeArray?: boolean;
  59379. closePath?: boolean;
  59380. offset?: number;
  59381. updatable?: boolean;
  59382. sideOrientation?: number;
  59383. frontUVs?: Vector4;
  59384. backUVs?: Vector4;
  59385. instance?: Mesh;
  59386. invertUV?: boolean;
  59387. uvs?: Vector2[];
  59388. colors?: Color4[];
  59389. }, scene?: Nullable<Scene>): Mesh;
  59390. /**
  59391. * Creates a cylinder or a cone mesh
  59392. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59393. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59394. * * 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.
  59395. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59396. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59397. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59398. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59399. * * 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).
  59400. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59401. * * 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).
  59402. * * 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
  59403. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59404. * * 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
  59405. * * 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.
  59406. * * If `enclose` is false, a ring surface is one element.
  59407. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59408. * * 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
  59409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59410. * * 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
  59411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59412. * @param name defines the name of the mesh
  59413. * @param options defines the options used to create the mesh
  59414. * @param scene defines the hosting scene
  59415. * @returns the cylinder mesh
  59416. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59417. */
  59418. static CreateCylinder(name: string, options: {
  59419. height?: number;
  59420. diameterTop?: number;
  59421. diameterBottom?: number;
  59422. diameter?: number;
  59423. tessellation?: number;
  59424. subdivisions?: number;
  59425. arc?: number;
  59426. faceColors?: Color4[];
  59427. faceUV?: Vector4[];
  59428. updatable?: boolean;
  59429. hasRings?: boolean;
  59430. enclose?: boolean;
  59431. cap?: number;
  59432. sideOrientation?: number;
  59433. frontUVs?: Vector4;
  59434. backUVs?: Vector4;
  59435. }, scene?: Nullable<Scene>): Mesh;
  59436. /**
  59437. * Creates a torus mesh
  59438. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59439. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59440. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59442. * * 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
  59443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59444. * @param name defines the name of the mesh
  59445. * @param options defines the options used to create the mesh
  59446. * @param scene defines the hosting scene
  59447. * @returns the torus mesh
  59448. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59449. */
  59450. static CreateTorus(name: string, options: {
  59451. diameter?: number;
  59452. thickness?: number;
  59453. tessellation?: number;
  59454. updatable?: boolean;
  59455. sideOrientation?: number;
  59456. frontUVs?: Vector4;
  59457. backUVs?: Vector4;
  59458. }, scene?: Nullable<Scene>): Mesh;
  59459. /**
  59460. * Creates a torus knot mesh
  59461. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59462. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59463. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59464. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59466. * * 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
  59467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59468. * @param name defines the name of the mesh
  59469. * @param options defines the options used to create the mesh
  59470. * @param scene defines the hosting scene
  59471. * @returns the torus knot mesh
  59472. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59473. */
  59474. static CreateTorusKnot(name: string, options: {
  59475. radius?: number;
  59476. tube?: number;
  59477. radialSegments?: number;
  59478. tubularSegments?: number;
  59479. p?: number;
  59480. q?: number;
  59481. updatable?: boolean;
  59482. sideOrientation?: number;
  59483. frontUVs?: Vector4;
  59484. backUVs?: Vector4;
  59485. }, scene?: Nullable<Scene>): Mesh;
  59486. /**
  59487. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59488. * * 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
  59489. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59490. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59491. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59492. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59493. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59494. * * 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
  59495. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59498. * @param name defines the name of the new line system
  59499. * @param options defines the options used to create the line system
  59500. * @param scene defines the hosting scene
  59501. * @returns a new line system mesh
  59502. */
  59503. static CreateLineSystem(name: string, options: {
  59504. lines: Vector3[][];
  59505. updatable?: boolean;
  59506. instance?: Nullable<LinesMesh>;
  59507. colors?: Nullable<Color4[][]>;
  59508. useVertexAlpha?: boolean;
  59509. }, scene: Nullable<Scene>): LinesMesh;
  59510. /**
  59511. * Creates a line mesh
  59512. * 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
  59513. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59514. * * The parameter `points` is an array successive Vector3
  59515. * * 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
  59516. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59517. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59518. * * When updating an instance, remember that only point positions can change, not the number of points
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59521. * @param name defines the name of the new line system
  59522. * @param options defines the options used to create the line system
  59523. * @param scene defines the hosting scene
  59524. * @returns a new line mesh
  59525. */
  59526. static CreateLines(name: string, options: {
  59527. points: Vector3[];
  59528. updatable?: boolean;
  59529. instance?: Nullable<LinesMesh>;
  59530. colors?: Color4[];
  59531. useVertexAlpha?: boolean;
  59532. }, scene?: Nullable<Scene>): LinesMesh;
  59533. /**
  59534. * Creates a dashed line mesh
  59535. * * 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
  59536. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59537. * * The parameter `points` is an array successive Vector3
  59538. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59539. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59540. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59541. * * 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
  59542. * * When updating an instance, remember that only point positions can change, not the number of points
  59543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59544. * @param name defines the name of the mesh
  59545. * @param options defines the options used to create the mesh
  59546. * @param scene defines the hosting scene
  59547. * @returns the dashed line mesh
  59548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59549. */
  59550. static CreateDashedLines(name: string, options: {
  59551. points: Vector3[];
  59552. dashSize?: number;
  59553. gapSize?: number;
  59554. dashNb?: number;
  59555. updatable?: boolean;
  59556. instance?: LinesMesh;
  59557. }, scene?: Nullable<Scene>): LinesMesh;
  59558. /**
  59559. * 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.
  59560. * * 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.
  59561. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59562. * * 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.
  59563. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59564. * * 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
  59565. * * 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
  59566. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59568. * * 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
  59569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59571. * @param name defines the name of the mesh
  59572. * @param options defines the options used to create the mesh
  59573. * @param scene defines the hosting scene
  59574. * @returns the extruded shape mesh
  59575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59577. */
  59578. static ExtrudeShape(name: string, options: {
  59579. shape: Vector3[];
  59580. path: Vector3[];
  59581. scale?: number;
  59582. rotation?: number;
  59583. cap?: number;
  59584. updatable?: boolean;
  59585. sideOrientation?: number;
  59586. frontUVs?: Vector4;
  59587. backUVs?: Vector4;
  59588. instance?: Mesh;
  59589. invertUV?: boolean;
  59590. }, scene?: Nullable<Scene>): Mesh;
  59591. /**
  59592. * Creates an custom extruded shape mesh.
  59593. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59594. * * 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.
  59595. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59596. * * 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
  59597. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59598. * * 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
  59599. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59600. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59601. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59602. * * 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
  59603. * * 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
  59604. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59606. * * 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
  59607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59609. * @param name defines the name of the mesh
  59610. * @param options defines the options used to create the mesh
  59611. * @param scene defines the hosting scene
  59612. * @returns the custom extruded shape mesh
  59613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59616. */
  59617. static ExtrudeShapeCustom(name: string, options: {
  59618. shape: Vector3[];
  59619. path: Vector3[];
  59620. scaleFunction?: any;
  59621. rotationFunction?: any;
  59622. ribbonCloseArray?: boolean;
  59623. ribbonClosePath?: boolean;
  59624. cap?: number;
  59625. updatable?: boolean;
  59626. sideOrientation?: number;
  59627. frontUVs?: Vector4;
  59628. backUVs?: Vector4;
  59629. instance?: Mesh;
  59630. invertUV?: boolean;
  59631. }, scene?: Nullable<Scene>): Mesh;
  59632. /**
  59633. * Creates lathe mesh.
  59634. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59635. * * 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
  59636. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59637. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59638. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59639. * * 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
  59640. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59641. * * 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
  59642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59643. * * 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
  59644. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59646. * @param name defines the name of the mesh
  59647. * @param options defines the options used to create the mesh
  59648. * @param scene defines the hosting scene
  59649. * @returns the lathe mesh
  59650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59651. */
  59652. static CreateLathe(name: string, options: {
  59653. shape: Vector3[];
  59654. radius?: number;
  59655. tessellation?: number;
  59656. clip?: number;
  59657. arc?: number;
  59658. closed?: boolean;
  59659. updatable?: boolean;
  59660. sideOrientation?: number;
  59661. frontUVs?: Vector4;
  59662. backUVs?: Vector4;
  59663. cap?: number;
  59664. invertUV?: boolean;
  59665. }, scene?: Nullable<Scene>): Mesh;
  59666. /**
  59667. * Creates a tiled plane mesh
  59668. * * You can set a limited pattern arrangement with the tiles
  59669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59670. * * 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
  59671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59672. * @param name defines the name of the mesh
  59673. * @param options defines the options used to create the mesh
  59674. * @param scene defines the hosting scene
  59675. * @returns the plane mesh
  59676. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59677. */
  59678. static CreateTiledPlane(name: string, options: {
  59679. pattern?: number;
  59680. tileSize?: number;
  59681. tileWidth?: number;
  59682. tileHeight?: number;
  59683. size?: number;
  59684. width?: number;
  59685. height?: number;
  59686. alignHorizontal?: number;
  59687. alignVertical?: number;
  59688. sideOrientation?: number;
  59689. frontUVs?: Vector4;
  59690. backUVs?: Vector4;
  59691. updatable?: boolean;
  59692. }, scene?: Nullable<Scene>): Mesh;
  59693. /**
  59694. * Creates a plane mesh
  59695. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59696. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59697. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59699. * * 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
  59700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59701. * @param name defines the name of the mesh
  59702. * @param options defines the options used to create the mesh
  59703. * @param scene defines the hosting scene
  59704. * @returns the plane mesh
  59705. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59706. */
  59707. static CreatePlane(name: string, options: {
  59708. size?: number;
  59709. width?: number;
  59710. height?: number;
  59711. sideOrientation?: number;
  59712. frontUVs?: Vector4;
  59713. backUVs?: Vector4;
  59714. updatable?: boolean;
  59715. sourcePlane?: Plane;
  59716. }, scene?: Nullable<Scene>): Mesh;
  59717. /**
  59718. * Creates a ground mesh
  59719. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59720. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59722. * @param name defines the name of the mesh
  59723. * @param options defines the options used to create the mesh
  59724. * @param scene defines the hosting scene
  59725. * @returns the ground mesh
  59726. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59727. */
  59728. static CreateGround(name: string, options: {
  59729. width?: number;
  59730. height?: number;
  59731. subdivisions?: number;
  59732. subdivisionsX?: number;
  59733. subdivisionsY?: number;
  59734. updatable?: boolean;
  59735. }, scene?: Nullable<Scene>): Mesh;
  59736. /**
  59737. * Creates a tiled ground mesh
  59738. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59739. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59740. * * 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
  59741. * * 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
  59742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59743. * @param name defines the name of the mesh
  59744. * @param options defines the options used to create the mesh
  59745. * @param scene defines the hosting scene
  59746. * @returns the tiled ground mesh
  59747. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59748. */
  59749. static CreateTiledGround(name: string, options: {
  59750. xmin: number;
  59751. zmin: number;
  59752. xmax: number;
  59753. zmax: number;
  59754. subdivisions?: {
  59755. w: number;
  59756. h: number;
  59757. };
  59758. precision?: {
  59759. w: number;
  59760. h: number;
  59761. };
  59762. updatable?: boolean;
  59763. }, scene?: Nullable<Scene>): Mesh;
  59764. /**
  59765. * Creates a ground mesh from a height map
  59766. * * The parameter `url` sets the URL of the height map image resource.
  59767. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59768. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59769. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59770. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59771. * * 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.
  59772. * * 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).
  59773. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59775. * @param name defines the name of the mesh
  59776. * @param url defines the url to the height map
  59777. * @param options defines the options used to create the mesh
  59778. * @param scene defines the hosting scene
  59779. * @returns the ground mesh
  59780. * @see https://doc.babylonjs.com/babylon101/height_map
  59781. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59782. */
  59783. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59784. width?: number;
  59785. height?: number;
  59786. subdivisions?: number;
  59787. minHeight?: number;
  59788. maxHeight?: number;
  59789. colorFilter?: Color3;
  59790. alphaFilter?: number;
  59791. updatable?: boolean;
  59792. onReady?: (mesh: GroundMesh) => void;
  59793. }, scene?: Nullable<Scene>): GroundMesh;
  59794. /**
  59795. * Creates a polygon mesh
  59796. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59797. * * 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
  59798. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59800. * * 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)
  59801. * * Remember you can only change the shape positions, not their number when updating a polygon
  59802. * @param name defines the name of the mesh
  59803. * @param options defines the options used to create the mesh
  59804. * @param scene defines the hosting scene
  59805. * @param earcutInjection can be used to inject your own earcut reference
  59806. * @returns the polygon mesh
  59807. */
  59808. static CreatePolygon(name: string, options: {
  59809. shape: Vector3[];
  59810. holes?: Vector3[][];
  59811. depth?: number;
  59812. faceUV?: Vector4[];
  59813. faceColors?: Color4[];
  59814. updatable?: boolean;
  59815. sideOrientation?: number;
  59816. frontUVs?: Vector4;
  59817. backUVs?: Vector4;
  59818. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59819. /**
  59820. * Creates an extruded polygon mesh, with depth in the Y direction.
  59821. * * 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)
  59822. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59823. * @param name defines the name of the mesh
  59824. * @param options defines the options used to create the mesh
  59825. * @param scene defines the hosting scene
  59826. * @param earcutInjection can be used to inject your own earcut reference
  59827. * @returns the polygon mesh
  59828. */
  59829. static ExtrudePolygon(name: string, options: {
  59830. shape: Vector3[];
  59831. holes?: Vector3[][];
  59832. depth?: number;
  59833. faceUV?: Vector4[];
  59834. faceColors?: Color4[];
  59835. updatable?: boolean;
  59836. sideOrientation?: number;
  59837. frontUVs?: Vector4;
  59838. backUVs?: Vector4;
  59839. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59840. /**
  59841. * Creates a tube mesh.
  59842. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59843. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59844. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59845. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59846. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59847. * * 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)
  59848. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59849. * * 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
  59850. * * 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
  59851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59852. * * 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
  59853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59855. * @param name defines the name of the mesh
  59856. * @param options defines the options used to create the mesh
  59857. * @param scene defines the hosting scene
  59858. * @returns the tube mesh
  59859. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59860. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59861. */
  59862. static CreateTube(name: string, options: {
  59863. path: Vector3[];
  59864. radius?: number;
  59865. tessellation?: number;
  59866. radiusFunction?: {
  59867. (i: number, distance: number): number;
  59868. };
  59869. cap?: number;
  59870. arc?: number;
  59871. updatable?: boolean;
  59872. sideOrientation?: number;
  59873. frontUVs?: Vector4;
  59874. backUVs?: Vector4;
  59875. instance?: Mesh;
  59876. invertUV?: boolean;
  59877. }, scene?: Nullable<Scene>): Mesh;
  59878. /**
  59879. * Creates a polyhedron mesh
  59880. * * 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
  59881. * * The parameter `size` (positive float, default 1) sets the polygon size
  59882. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59883. * * 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`
  59884. * * 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
  59885. * * 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)`)
  59886. * * 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
  59887. * * 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
  59888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59889. * * 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
  59890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59891. * @param name defines the name of the mesh
  59892. * @param options defines the options used to create the mesh
  59893. * @param scene defines the hosting scene
  59894. * @returns the polyhedron mesh
  59895. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59896. */
  59897. static CreatePolyhedron(name: string, options: {
  59898. type?: number;
  59899. size?: number;
  59900. sizeX?: number;
  59901. sizeY?: number;
  59902. sizeZ?: number;
  59903. custom?: any;
  59904. faceUV?: Vector4[];
  59905. faceColors?: Color4[];
  59906. flat?: boolean;
  59907. updatable?: boolean;
  59908. sideOrientation?: number;
  59909. frontUVs?: Vector4;
  59910. backUVs?: Vector4;
  59911. }, scene?: Nullable<Scene>): Mesh;
  59912. /**
  59913. * Creates a decal mesh.
  59914. * 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
  59915. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59916. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59917. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59918. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59919. * @param name defines the name of the mesh
  59920. * @param sourceMesh defines the mesh where the decal must be applied
  59921. * @param options defines the options used to create the mesh
  59922. * @param scene defines the hosting scene
  59923. * @returns the decal mesh
  59924. * @see https://doc.babylonjs.com/how_to/decals
  59925. */
  59926. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59927. position?: Vector3;
  59928. normal?: Vector3;
  59929. size?: Vector3;
  59930. angle?: number;
  59931. }): Mesh;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /**
  59936. * A simplifier interface for future simplification implementations
  59937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59938. */
  59939. export interface ISimplifier {
  59940. /**
  59941. * Simplification of a given mesh according to the given settings.
  59942. * Since this requires computation, it is assumed that the function runs async.
  59943. * @param settings The settings of the simplification, including quality and distance
  59944. * @param successCallback A callback that will be called after the mesh was simplified.
  59945. * @param errorCallback in case of an error, this callback will be called. optional.
  59946. */
  59947. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59948. }
  59949. /**
  59950. * Expected simplification settings.
  59951. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59952. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59953. */
  59954. export interface ISimplificationSettings {
  59955. /**
  59956. * Gets or sets the expected quality
  59957. */
  59958. quality: number;
  59959. /**
  59960. * Gets or sets the distance when this optimized version should be used
  59961. */
  59962. distance: number;
  59963. /**
  59964. * Gets an already optimized mesh
  59965. */
  59966. optimizeMesh?: boolean;
  59967. }
  59968. /**
  59969. * Class used to specify simplification options
  59970. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59971. */
  59972. export class SimplificationSettings implements ISimplificationSettings {
  59973. /** expected quality */
  59974. quality: number;
  59975. /** distance when this optimized version should be used */
  59976. distance: number;
  59977. /** already optimized mesh */
  59978. optimizeMesh?: boolean | undefined;
  59979. /**
  59980. * Creates a SimplificationSettings
  59981. * @param quality expected quality
  59982. * @param distance distance when this optimized version should be used
  59983. * @param optimizeMesh already optimized mesh
  59984. */
  59985. constructor(
  59986. /** expected quality */
  59987. quality: number,
  59988. /** distance when this optimized version should be used */
  59989. distance: number,
  59990. /** already optimized mesh */
  59991. optimizeMesh?: boolean | undefined);
  59992. }
  59993. /**
  59994. * Interface used to define a simplification task
  59995. */
  59996. export interface ISimplificationTask {
  59997. /**
  59998. * Array of settings
  59999. */
  60000. settings: Array<ISimplificationSettings>;
  60001. /**
  60002. * Simplification type
  60003. */
  60004. simplificationType: SimplificationType;
  60005. /**
  60006. * Mesh to simplify
  60007. */
  60008. mesh: Mesh;
  60009. /**
  60010. * Callback called on success
  60011. */
  60012. successCallback?: () => void;
  60013. /**
  60014. * Defines if parallel processing can be used
  60015. */
  60016. parallelProcessing: boolean;
  60017. }
  60018. /**
  60019. * Queue used to order the simplification tasks
  60020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60021. */
  60022. export class SimplificationQueue {
  60023. private _simplificationArray;
  60024. /**
  60025. * Gets a boolean indicating that the process is still running
  60026. */
  60027. running: boolean;
  60028. /**
  60029. * Creates a new queue
  60030. */
  60031. constructor();
  60032. /**
  60033. * Adds a new simplification task
  60034. * @param task defines a task to add
  60035. */
  60036. addTask(task: ISimplificationTask): void;
  60037. /**
  60038. * Execute next task
  60039. */
  60040. executeNext(): void;
  60041. /**
  60042. * Execute a simplification task
  60043. * @param task defines the task to run
  60044. */
  60045. runSimplification(task: ISimplificationTask): void;
  60046. private getSimplifier;
  60047. }
  60048. /**
  60049. * The implemented types of simplification
  60050. * At the moment only Quadratic Error Decimation is implemented
  60051. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60052. */
  60053. export enum SimplificationType {
  60054. /** Quadratic error decimation */
  60055. QUADRATIC = 0
  60056. }
  60057. }
  60058. declare module BABYLON {
  60059. interface Scene {
  60060. /** @hidden (Backing field) */
  60061. _simplificationQueue: SimplificationQueue;
  60062. /**
  60063. * Gets or sets the simplification queue attached to the scene
  60064. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60065. */
  60066. simplificationQueue: SimplificationQueue;
  60067. }
  60068. interface Mesh {
  60069. /**
  60070. * Simplify the mesh according to the given array of settings.
  60071. * Function will return immediately and will simplify async
  60072. * @param settings a collection of simplification settings
  60073. * @param parallelProcessing should all levels calculate parallel or one after the other
  60074. * @param simplificationType the type of simplification to run
  60075. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60076. * @returns the current mesh
  60077. */
  60078. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60079. }
  60080. /**
  60081. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60082. * created in a scene
  60083. */
  60084. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60085. /**
  60086. * The component name helpfull to identify the component in the list of scene components.
  60087. */
  60088. readonly name: string;
  60089. /**
  60090. * The scene the component belongs to.
  60091. */
  60092. scene: Scene;
  60093. /**
  60094. * Creates a new instance of the component for the given scene
  60095. * @param scene Defines the scene to register the component in
  60096. */
  60097. constructor(scene: Scene);
  60098. /**
  60099. * Registers the component in a given scene
  60100. */
  60101. register(): void;
  60102. /**
  60103. * Rebuilds the elements related to this component in case of
  60104. * context lost for instance.
  60105. */
  60106. rebuild(): void;
  60107. /**
  60108. * Disposes the component and the associated ressources
  60109. */
  60110. dispose(): void;
  60111. private _beforeCameraUpdate;
  60112. }
  60113. }
  60114. declare module BABYLON {
  60115. /**
  60116. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60117. */
  60118. export interface INavigationEnginePlugin {
  60119. /**
  60120. * plugin name
  60121. */
  60122. name: string;
  60123. /**
  60124. * Creates a navigation mesh
  60125. * @param meshes array of all the geometry used to compute the navigatio mesh
  60126. * @param parameters bunch of parameters used to filter geometry
  60127. */
  60128. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60129. /**
  60130. * Create a navigation mesh debug mesh
  60131. * @param scene is where the mesh will be added
  60132. * @returns debug display mesh
  60133. */
  60134. createDebugNavMesh(scene: Scene): Mesh;
  60135. /**
  60136. * Get a navigation mesh constrained position, closest to the parameter position
  60137. * @param position world position
  60138. * @returns the closest point to position constrained by the navigation mesh
  60139. */
  60140. getClosestPoint(position: Vector3): Vector3;
  60141. /**
  60142. * Get a navigation mesh constrained position, within a particular radius
  60143. * @param position world position
  60144. * @param maxRadius the maximum distance to the constrained world position
  60145. * @returns the closest point to position constrained by the navigation mesh
  60146. */
  60147. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60148. /**
  60149. * Compute the final position from a segment made of destination-position
  60150. * @param position world position
  60151. * @param destination world position
  60152. * @returns the resulting point along the navmesh
  60153. */
  60154. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60155. /**
  60156. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60157. * @param start world position
  60158. * @param end world position
  60159. * @returns array containing world position composing the path
  60160. */
  60161. computePath(start: Vector3, end: Vector3): Vector3[];
  60162. /**
  60163. * If this plugin is supported
  60164. * @returns true if plugin is supported
  60165. */
  60166. isSupported(): boolean;
  60167. /**
  60168. * Create a new Crowd so you can add agents
  60169. * @param maxAgents the maximum agent count in the crowd
  60170. * @param maxAgentRadius the maximum radius an agent can have
  60171. * @param scene to attach the crowd to
  60172. * @returns the crowd you can add agents to
  60173. */
  60174. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60175. /**
  60176. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60177. * The queries will try to find a solution within those bounds
  60178. * default is (1,1,1)
  60179. * @param extent x,y,z value that define the extent around the queries point of reference
  60180. */
  60181. setDefaultQueryExtent(extent: Vector3): void;
  60182. /**
  60183. * Get the Bounding box extent specified by setDefaultQueryExtent
  60184. * @returns the box extent values
  60185. */
  60186. getDefaultQueryExtent(): Vector3;
  60187. /**
  60188. * Release all resources
  60189. */
  60190. dispose(): void;
  60191. }
  60192. /**
  60193. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60194. */
  60195. export interface ICrowd {
  60196. /**
  60197. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60198. * You can attach anything to that node. The node position is updated in the scene update tick.
  60199. * @param pos world position that will be constrained by the navigation mesh
  60200. * @param parameters agent parameters
  60201. * @param transform hooked to the agent that will be update by the scene
  60202. * @returns agent index
  60203. */
  60204. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60205. /**
  60206. * Returns the agent position in world space
  60207. * @param index agent index returned by addAgent
  60208. * @returns world space position
  60209. */
  60210. getAgentPosition(index: number): Vector3;
  60211. /**
  60212. * Gets the agent velocity in world space
  60213. * @param index agent index returned by addAgent
  60214. * @returns world space velocity
  60215. */
  60216. getAgentVelocity(index: number): Vector3;
  60217. /**
  60218. * remove a particular agent previously created
  60219. * @param index agent index returned by addAgent
  60220. */
  60221. removeAgent(index: number): void;
  60222. /**
  60223. * get the list of all agents attached to this crowd
  60224. * @returns list of agent indices
  60225. */
  60226. getAgents(): number[];
  60227. /**
  60228. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60229. * @param deltaTime in seconds
  60230. */
  60231. update(deltaTime: number): void;
  60232. /**
  60233. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60234. * @param index agent index returned by addAgent
  60235. * @param destination targeted world position
  60236. */
  60237. agentGoto(index: number, destination: Vector3): void;
  60238. /**
  60239. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60240. * The queries will try to find a solution within those bounds
  60241. * default is (1,1,1)
  60242. * @param extent x,y,z value that define the extent around the queries point of reference
  60243. */
  60244. setDefaultQueryExtent(extent: Vector3): void;
  60245. /**
  60246. * Get the Bounding box extent specified by setDefaultQueryExtent
  60247. * @returns the box extent values
  60248. */
  60249. getDefaultQueryExtent(): Vector3;
  60250. /**
  60251. * Release all resources
  60252. */
  60253. dispose(): void;
  60254. }
  60255. /**
  60256. * Configures an agent
  60257. */
  60258. export interface IAgentParameters {
  60259. /**
  60260. * Agent radius. [Limit: >= 0]
  60261. */
  60262. radius: number;
  60263. /**
  60264. * Agent height. [Limit: > 0]
  60265. */
  60266. height: number;
  60267. /**
  60268. * Maximum allowed acceleration. [Limit: >= 0]
  60269. */
  60270. maxAcceleration: number;
  60271. /**
  60272. * Maximum allowed speed. [Limit: >= 0]
  60273. */
  60274. maxSpeed: number;
  60275. /**
  60276. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60277. */
  60278. collisionQueryRange: number;
  60279. /**
  60280. * The path visibility optimization range. [Limit: > 0]
  60281. */
  60282. pathOptimizationRange: number;
  60283. /**
  60284. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60285. */
  60286. separationWeight: number;
  60287. }
  60288. /**
  60289. * Configures the navigation mesh creation
  60290. */
  60291. export interface INavMeshParameters {
  60292. /**
  60293. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60294. */
  60295. cs: number;
  60296. /**
  60297. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60298. */
  60299. ch: number;
  60300. /**
  60301. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60302. */
  60303. walkableSlopeAngle: number;
  60304. /**
  60305. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60306. * be considered walkable. [Limit: >= 3] [Units: vx]
  60307. */
  60308. walkableHeight: number;
  60309. /**
  60310. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60311. */
  60312. walkableClimb: number;
  60313. /**
  60314. * The distance to erode/shrink the walkable area of the heightfield away from
  60315. * obstructions. [Limit: >=0] [Units: vx]
  60316. */
  60317. walkableRadius: number;
  60318. /**
  60319. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60320. */
  60321. maxEdgeLen: number;
  60322. /**
  60323. * The maximum distance a simplfied contour's border edges should deviate
  60324. * the original raw contour. [Limit: >=0] [Units: vx]
  60325. */
  60326. maxSimplificationError: number;
  60327. /**
  60328. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60329. */
  60330. minRegionArea: number;
  60331. /**
  60332. * Any regions with a span count smaller than this value will, if possible,
  60333. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60334. */
  60335. mergeRegionArea: number;
  60336. /**
  60337. * The maximum number of vertices allowed for polygons generated during the
  60338. * contour to polygon conversion process. [Limit: >= 3]
  60339. */
  60340. maxVertsPerPoly: number;
  60341. /**
  60342. * Sets the sampling distance to use when generating the detail mesh.
  60343. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60344. */
  60345. detailSampleDist: number;
  60346. /**
  60347. * The maximum distance the detail mesh surface should deviate from heightfield
  60348. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60349. */
  60350. detailSampleMaxError: number;
  60351. }
  60352. }
  60353. declare module BABYLON {
  60354. /**
  60355. * RecastJS navigation plugin
  60356. */
  60357. export class RecastJSPlugin implements INavigationEnginePlugin {
  60358. /**
  60359. * Reference to the Recast library
  60360. */
  60361. bjsRECAST: any;
  60362. /**
  60363. * plugin name
  60364. */
  60365. name: string;
  60366. /**
  60367. * the first navmesh created. We might extend this to support multiple navmeshes
  60368. */
  60369. navMesh: any;
  60370. /**
  60371. * Initializes the recastJS plugin
  60372. * @param recastInjection can be used to inject your own recast reference
  60373. */
  60374. constructor(recastInjection?: any);
  60375. /**
  60376. * Creates a navigation mesh
  60377. * @param meshes array of all the geometry used to compute the navigatio mesh
  60378. * @param parameters bunch of parameters used to filter geometry
  60379. */
  60380. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60381. /**
  60382. * Create a navigation mesh debug mesh
  60383. * @param scene is where the mesh will be added
  60384. * @returns debug display mesh
  60385. */
  60386. createDebugNavMesh(scene: Scene): Mesh;
  60387. /**
  60388. * Get a navigation mesh constrained position, closest to the parameter position
  60389. * @param position world position
  60390. * @returns the closest point to position constrained by the navigation mesh
  60391. */
  60392. getClosestPoint(position: Vector3): Vector3;
  60393. /**
  60394. * Get a navigation mesh constrained position, within a particular radius
  60395. * @param position world position
  60396. * @param maxRadius the maximum distance to the constrained world position
  60397. * @returns the closest point to position constrained by the navigation mesh
  60398. */
  60399. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60400. /**
  60401. * Compute the final position from a segment made of destination-position
  60402. * @param position world position
  60403. * @param destination world position
  60404. * @returns the resulting point along the navmesh
  60405. */
  60406. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60407. /**
  60408. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60409. * @param start world position
  60410. * @param end world position
  60411. * @returns array containing world position composing the path
  60412. */
  60413. computePath(start: Vector3, end: Vector3): Vector3[];
  60414. /**
  60415. * Create a new Crowd so you can add agents
  60416. * @param maxAgents the maximum agent count in the crowd
  60417. * @param maxAgentRadius the maximum radius an agent can have
  60418. * @param scene to attach the crowd to
  60419. * @returns the crowd you can add agents to
  60420. */
  60421. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60422. /**
  60423. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60424. * The queries will try to find a solution within those bounds
  60425. * default is (1,1,1)
  60426. * @param extent x,y,z value that define the extent around the queries point of reference
  60427. */
  60428. setDefaultQueryExtent(extent: Vector3): void;
  60429. /**
  60430. * Get the Bounding box extent specified by setDefaultQueryExtent
  60431. * @returns the box extent values
  60432. */
  60433. getDefaultQueryExtent(): Vector3;
  60434. /**
  60435. * Disposes
  60436. */
  60437. dispose(): void;
  60438. /**
  60439. * If this plugin is supported
  60440. * @returns true if plugin is supported
  60441. */
  60442. isSupported(): boolean;
  60443. }
  60444. /**
  60445. * Recast detour crowd implementation
  60446. */
  60447. export class RecastJSCrowd implements ICrowd {
  60448. /**
  60449. * Recast/detour plugin
  60450. */
  60451. bjsRECASTPlugin: RecastJSPlugin;
  60452. /**
  60453. * Link to the detour crowd
  60454. */
  60455. recastCrowd: any;
  60456. /**
  60457. * One transform per agent
  60458. */
  60459. transforms: TransformNode[];
  60460. /**
  60461. * All agents created
  60462. */
  60463. agents: number[];
  60464. /**
  60465. * Link to the scene is kept to unregister the crowd from the scene
  60466. */
  60467. private _scene;
  60468. /**
  60469. * Observer for crowd updates
  60470. */
  60471. private _onBeforeAnimationsObserver;
  60472. /**
  60473. * Constructor
  60474. * @param plugin recastJS plugin
  60475. * @param maxAgents the maximum agent count in the crowd
  60476. * @param maxAgentRadius the maximum radius an agent can have
  60477. * @param scene to attach the crowd to
  60478. * @returns the crowd you can add agents to
  60479. */
  60480. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60481. /**
  60482. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60483. * You can attach anything to that node. The node position is updated in the scene update tick.
  60484. * @param pos world position that will be constrained by the navigation mesh
  60485. * @param parameters agent parameters
  60486. * @param transform hooked to the agent that will be update by the scene
  60487. * @returns agent index
  60488. */
  60489. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60490. /**
  60491. * Returns the agent position in world space
  60492. * @param index agent index returned by addAgent
  60493. * @returns world space position
  60494. */
  60495. getAgentPosition(index: number): Vector3;
  60496. /**
  60497. * Returns the agent velocity in world space
  60498. * @param index agent index returned by addAgent
  60499. * @returns world space velocity
  60500. */
  60501. getAgentVelocity(index: number): Vector3;
  60502. /**
  60503. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60504. * @param index agent index returned by addAgent
  60505. * @param destination targeted world position
  60506. */
  60507. agentGoto(index: number, destination: Vector3): void;
  60508. /**
  60509. * remove a particular agent previously created
  60510. * @param index agent index returned by addAgent
  60511. */
  60512. removeAgent(index: number): void;
  60513. /**
  60514. * get the list of all agents attached to this crowd
  60515. * @returns list of agent indices
  60516. */
  60517. getAgents(): number[];
  60518. /**
  60519. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60520. * @param deltaTime in seconds
  60521. */
  60522. update(deltaTime: number): void;
  60523. /**
  60524. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60525. * The queries will try to find a solution within those bounds
  60526. * default is (1,1,1)
  60527. * @param extent x,y,z value that define the extent around the queries point of reference
  60528. */
  60529. setDefaultQueryExtent(extent: Vector3): void;
  60530. /**
  60531. * Get the Bounding box extent specified by setDefaultQueryExtent
  60532. * @returns the box extent values
  60533. */
  60534. getDefaultQueryExtent(): Vector3;
  60535. /**
  60536. * Release all resources
  60537. */
  60538. dispose(): void;
  60539. }
  60540. }
  60541. declare module BABYLON {
  60542. /**
  60543. * Class used to enable access to IndexedDB
  60544. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60545. */
  60546. export class Database implements IOfflineProvider {
  60547. private _callbackManifestChecked;
  60548. private _currentSceneUrl;
  60549. private _db;
  60550. private _enableSceneOffline;
  60551. private _enableTexturesOffline;
  60552. private _manifestVersionFound;
  60553. private _mustUpdateRessources;
  60554. private _hasReachedQuota;
  60555. private _isSupported;
  60556. private _idbFactory;
  60557. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60558. private static IsUASupportingBlobStorage;
  60559. /**
  60560. * Gets a boolean indicating if Database storate is enabled (off by default)
  60561. */
  60562. static IDBStorageEnabled: boolean;
  60563. /**
  60564. * Gets a boolean indicating if scene must be saved in the database
  60565. */
  60566. get enableSceneOffline(): boolean;
  60567. /**
  60568. * Gets a boolean indicating if textures must be saved in the database
  60569. */
  60570. get enableTexturesOffline(): boolean;
  60571. /**
  60572. * Creates a new Database
  60573. * @param urlToScene defines the url to load the scene
  60574. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60575. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60576. */
  60577. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60578. private static _ParseURL;
  60579. private static _ReturnFullUrlLocation;
  60580. private _checkManifestFile;
  60581. /**
  60582. * Open the database and make it available
  60583. * @param successCallback defines the callback to call on success
  60584. * @param errorCallback defines the callback to call on error
  60585. */
  60586. open(successCallback: () => void, errorCallback: () => void): void;
  60587. /**
  60588. * Loads an image from the database
  60589. * @param url defines the url to load from
  60590. * @param image defines the target DOM image
  60591. */
  60592. loadImage(url: string, image: HTMLImageElement): void;
  60593. private _loadImageFromDBAsync;
  60594. private _saveImageIntoDBAsync;
  60595. private _checkVersionFromDB;
  60596. private _loadVersionFromDBAsync;
  60597. private _saveVersionIntoDBAsync;
  60598. /**
  60599. * Loads a file from database
  60600. * @param url defines the URL to load from
  60601. * @param sceneLoaded defines a callback to call on success
  60602. * @param progressCallBack defines a callback to call when progress changed
  60603. * @param errorCallback defines a callback to call on error
  60604. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60605. */
  60606. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60607. private _loadFileAsync;
  60608. private _saveFileAsync;
  60609. /**
  60610. * Validates if xhr data is correct
  60611. * @param xhr defines the request to validate
  60612. * @param dataType defines the expected data type
  60613. * @returns true if data is correct
  60614. */
  60615. private static _ValidateXHRData;
  60616. }
  60617. }
  60618. declare module BABYLON {
  60619. /** @hidden */
  60620. export var gpuUpdateParticlesPixelShader: {
  60621. name: string;
  60622. shader: string;
  60623. };
  60624. }
  60625. declare module BABYLON {
  60626. /** @hidden */
  60627. export var gpuUpdateParticlesVertexShader: {
  60628. name: string;
  60629. shader: string;
  60630. };
  60631. }
  60632. declare module BABYLON {
  60633. /** @hidden */
  60634. export var clipPlaneFragmentDeclaration2: {
  60635. name: string;
  60636. shader: string;
  60637. };
  60638. }
  60639. declare module BABYLON {
  60640. /** @hidden */
  60641. export var gpuRenderParticlesPixelShader: {
  60642. name: string;
  60643. shader: string;
  60644. };
  60645. }
  60646. declare module BABYLON {
  60647. /** @hidden */
  60648. export var clipPlaneVertexDeclaration2: {
  60649. name: string;
  60650. shader: string;
  60651. };
  60652. }
  60653. declare module BABYLON {
  60654. /** @hidden */
  60655. export var gpuRenderParticlesVertexShader: {
  60656. name: string;
  60657. shader: string;
  60658. };
  60659. }
  60660. declare module BABYLON {
  60661. /**
  60662. * This represents a GPU particle system in Babylon
  60663. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60664. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60665. */
  60666. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60667. /**
  60668. * The layer mask we are rendering the particles through.
  60669. */
  60670. layerMask: number;
  60671. private _capacity;
  60672. private _activeCount;
  60673. private _currentActiveCount;
  60674. private _accumulatedCount;
  60675. private _renderEffect;
  60676. private _updateEffect;
  60677. private _buffer0;
  60678. private _buffer1;
  60679. private _spriteBuffer;
  60680. private _updateVAO;
  60681. private _renderVAO;
  60682. private _targetIndex;
  60683. private _sourceBuffer;
  60684. private _targetBuffer;
  60685. private _engine;
  60686. private _currentRenderId;
  60687. private _started;
  60688. private _stopped;
  60689. private _timeDelta;
  60690. private _randomTexture;
  60691. private _randomTexture2;
  60692. private _attributesStrideSize;
  60693. private _updateEffectOptions;
  60694. private _randomTextureSize;
  60695. private _actualFrame;
  60696. private readonly _rawTextureWidth;
  60697. /**
  60698. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60699. */
  60700. static get IsSupported(): boolean;
  60701. /**
  60702. * An event triggered when the system is disposed.
  60703. */
  60704. onDisposeObservable: Observable<GPUParticleSystem>;
  60705. /**
  60706. * Gets the maximum number of particles active at the same time.
  60707. * @returns The max number of active particles.
  60708. */
  60709. getCapacity(): number;
  60710. /**
  60711. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60712. * to override the particles.
  60713. */
  60714. forceDepthWrite: boolean;
  60715. /**
  60716. * Gets or set the number of active particles
  60717. */
  60718. get activeParticleCount(): number;
  60719. set activeParticleCount(value: number);
  60720. private _preWarmDone;
  60721. /**
  60722. * Is this system ready to be used/rendered
  60723. * @return true if the system is ready
  60724. */
  60725. isReady(): boolean;
  60726. /**
  60727. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60728. * @returns True if it has been started, otherwise false.
  60729. */
  60730. isStarted(): boolean;
  60731. /**
  60732. * Starts the particle system and begins to emit
  60733. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60734. */
  60735. start(delay?: number): void;
  60736. /**
  60737. * Stops the particle system.
  60738. */
  60739. stop(): void;
  60740. /**
  60741. * Remove all active particles
  60742. */
  60743. reset(): void;
  60744. /**
  60745. * Returns the string "GPUParticleSystem"
  60746. * @returns a string containing the class name
  60747. */
  60748. getClassName(): string;
  60749. private _colorGradientsTexture;
  60750. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60751. /**
  60752. * Adds a new color gradient
  60753. * @param gradient defines the gradient to use (between 0 and 1)
  60754. * @param color1 defines the color to affect to the specified gradient
  60755. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60756. * @returns the current particle system
  60757. */
  60758. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60759. /**
  60760. * Remove a specific color gradient
  60761. * @param gradient defines the gradient to remove
  60762. * @returns the current particle system
  60763. */
  60764. removeColorGradient(gradient: number): GPUParticleSystem;
  60765. private _angularSpeedGradientsTexture;
  60766. private _sizeGradientsTexture;
  60767. private _velocityGradientsTexture;
  60768. private _limitVelocityGradientsTexture;
  60769. private _dragGradientsTexture;
  60770. private _addFactorGradient;
  60771. /**
  60772. * Adds a new size gradient
  60773. * @param gradient defines the gradient to use (between 0 and 1)
  60774. * @param factor defines the size factor to affect to the specified gradient
  60775. * @returns the current particle system
  60776. */
  60777. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60778. /**
  60779. * Remove a specific size gradient
  60780. * @param gradient defines the gradient to remove
  60781. * @returns the current particle system
  60782. */
  60783. removeSizeGradient(gradient: number): GPUParticleSystem;
  60784. /**
  60785. * Adds a new angular speed gradient
  60786. * @param gradient defines the gradient to use (between 0 and 1)
  60787. * @param factor defines the angular speed to affect to the specified gradient
  60788. * @returns the current particle system
  60789. */
  60790. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60791. /**
  60792. * Remove a specific angular speed gradient
  60793. * @param gradient defines the gradient to remove
  60794. * @returns the current particle system
  60795. */
  60796. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60797. /**
  60798. * Adds a new velocity gradient
  60799. * @param gradient defines the gradient to use (between 0 and 1)
  60800. * @param factor defines the velocity to affect to the specified gradient
  60801. * @returns the current particle system
  60802. */
  60803. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60804. /**
  60805. * Remove a specific velocity gradient
  60806. * @param gradient defines the gradient to remove
  60807. * @returns the current particle system
  60808. */
  60809. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60810. /**
  60811. * Adds a new limit velocity gradient
  60812. * @param gradient defines the gradient to use (between 0 and 1)
  60813. * @param factor defines the limit velocity value to affect to the specified gradient
  60814. * @returns the current particle system
  60815. */
  60816. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60817. /**
  60818. * Remove a specific limit velocity gradient
  60819. * @param gradient defines the gradient to remove
  60820. * @returns the current particle system
  60821. */
  60822. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60823. /**
  60824. * Adds a new drag gradient
  60825. * @param gradient defines the gradient to use (between 0 and 1)
  60826. * @param factor defines the drag value to affect to the specified gradient
  60827. * @returns the current particle system
  60828. */
  60829. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60830. /**
  60831. * Remove a specific drag gradient
  60832. * @param gradient defines the gradient to remove
  60833. * @returns the current particle system
  60834. */
  60835. removeDragGradient(gradient: number): GPUParticleSystem;
  60836. /**
  60837. * Not supported by GPUParticleSystem
  60838. * @param gradient defines the gradient to use (between 0 and 1)
  60839. * @param factor defines the emit rate value to affect to the specified gradient
  60840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60841. * @returns the current particle system
  60842. */
  60843. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60844. /**
  60845. * Not supported by GPUParticleSystem
  60846. * @param gradient defines the gradient to remove
  60847. * @returns the current particle system
  60848. */
  60849. removeEmitRateGradient(gradient: number): IParticleSystem;
  60850. /**
  60851. * Not supported by GPUParticleSystem
  60852. * @param gradient defines the gradient to use (between 0 and 1)
  60853. * @param factor defines the start size value to affect to the specified gradient
  60854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60855. * @returns the current particle system
  60856. */
  60857. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60858. /**
  60859. * Not supported by GPUParticleSystem
  60860. * @param gradient defines the gradient to remove
  60861. * @returns the current particle system
  60862. */
  60863. removeStartSizeGradient(gradient: number): IParticleSystem;
  60864. /**
  60865. * Not supported by GPUParticleSystem
  60866. * @param gradient defines the gradient to use (between 0 and 1)
  60867. * @param min defines the color remap minimal range
  60868. * @param max defines the color remap maximal range
  60869. * @returns the current particle system
  60870. */
  60871. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60872. /**
  60873. * Not supported by GPUParticleSystem
  60874. * @param gradient defines the gradient to remove
  60875. * @returns the current particle system
  60876. */
  60877. removeColorRemapGradient(): IParticleSystem;
  60878. /**
  60879. * Not supported by GPUParticleSystem
  60880. * @param gradient defines the gradient to use (between 0 and 1)
  60881. * @param min defines the alpha remap minimal range
  60882. * @param max defines the alpha remap maximal range
  60883. * @returns the current particle system
  60884. */
  60885. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60886. /**
  60887. * Not supported by GPUParticleSystem
  60888. * @param gradient defines the gradient to remove
  60889. * @returns the current particle system
  60890. */
  60891. removeAlphaRemapGradient(): IParticleSystem;
  60892. /**
  60893. * Not supported by GPUParticleSystem
  60894. * @param gradient defines the gradient to use (between 0 and 1)
  60895. * @param color defines the color to affect to the specified gradient
  60896. * @returns the current particle system
  60897. */
  60898. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60899. /**
  60900. * Not supported by GPUParticleSystem
  60901. * @param gradient defines the gradient to remove
  60902. * @returns the current particle system
  60903. */
  60904. removeRampGradient(): IParticleSystem;
  60905. /**
  60906. * Not supported by GPUParticleSystem
  60907. * @returns the list of ramp gradients
  60908. */
  60909. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60910. /**
  60911. * Not supported by GPUParticleSystem
  60912. * Gets or sets a boolean indicating that ramp gradients must be used
  60913. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60914. */
  60915. get useRampGradients(): boolean;
  60916. set useRampGradients(value: boolean);
  60917. /**
  60918. * Not supported by GPUParticleSystem
  60919. * @param gradient defines the gradient to use (between 0 and 1)
  60920. * @param factor defines the life time factor to affect to the specified gradient
  60921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60922. * @returns the current particle system
  60923. */
  60924. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60925. /**
  60926. * Not supported by GPUParticleSystem
  60927. * @param gradient defines the gradient to remove
  60928. * @returns the current particle system
  60929. */
  60930. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60931. /**
  60932. * Instantiates a GPU particle system.
  60933. * 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.
  60934. * @param name The name of the particle system
  60935. * @param options The options used to create the system
  60936. * @param scene The scene the particle system belongs to
  60937. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60938. */
  60939. constructor(name: string, options: Partial<{
  60940. capacity: number;
  60941. randomTextureSize: number;
  60942. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60943. protected _reset(): void;
  60944. private _createUpdateVAO;
  60945. private _createRenderVAO;
  60946. private _initialize;
  60947. /** @hidden */
  60948. _recreateUpdateEffect(): void;
  60949. /** @hidden */
  60950. _recreateRenderEffect(): void;
  60951. /**
  60952. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60953. * @param preWarm defines if we are in the pre-warmimg phase
  60954. */
  60955. animate(preWarm?: boolean): void;
  60956. private _createFactorGradientTexture;
  60957. private _createSizeGradientTexture;
  60958. private _createAngularSpeedGradientTexture;
  60959. private _createVelocityGradientTexture;
  60960. private _createLimitVelocityGradientTexture;
  60961. private _createDragGradientTexture;
  60962. private _createColorGradientTexture;
  60963. /**
  60964. * Renders the particle system in its current state
  60965. * @param preWarm defines if the system should only update the particles but not render them
  60966. * @returns the current number of particles
  60967. */
  60968. render(preWarm?: boolean): number;
  60969. /**
  60970. * Rebuilds the particle system
  60971. */
  60972. rebuild(): void;
  60973. private _releaseBuffers;
  60974. private _releaseVAOs;
  60975. /**
  60976. * Disposes the particle system and free the associated resources
  60977. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60978. */
  60979. dispose(disposeTexture?: boolean): void;
  60980. /**
  60981. * Clones the particle system.
  60982. * @param name The name of the cloned object
  60983. * @param newEmitter The new emitter to use
  60984. * @returns the cloned particle system
  60985. */
  60986. clone(name: string, newEmitter: any): GPUParticleSystem;
  60987. /**
  60988. * Serializes the particle system to a JSON object.
  60989. * @returns the JSON object
  60990. */
  60991. serialize(): any;
  60992. /**
  60993. * Parses a JSON object to create a GPU particle system.
  60994. * @param parsedParticleSystem The JSON object to parse
  60995. * @param scene The scene to create the particle system in
  60996. * @param rootUrl The root url to use to load external dependencies like texture
  60997. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60998. * @returns the parsed GPU particle system
  60999. */
  61000. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61001. }
  61002. }
  61003. declare module BABYLON {
  61004. /**
  61005. * Represents a set of particle systems working together to create a specific effect
  61006. */
  61007. export class ParticleSystemSet implements IDisposable {
  61008. /**
  61009. * Gets or sets base Assets URL
  61010. */
  61011. static BaseAssetsUrl: string;
  61012. private _emitterCreationOptions;
  61013. private _emitterNode;
  61014. /**
  61015. * Gets the particle system list
  61016. */
  61017. systems: IParticleSystem[];
  61018. /**
  61019. * Gets the emitter node used with this set
  61020. */
  61021. get emitterNode(): Nullable<TransformNode>;
  61022. /**
  61023. * Creates a new emitter mesh as a sphere
  61024. * @param options defines the options used to create the sphere
  61025. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61026. * @param scene defines the hosting scene
  61027. */
  61028. setEmitterAsSphere(options: {
  61029. diameter: number;
  61030. segments: number;
  61031. color: Color3;
  61032. }, renderingGroupId: number, scene: Scene): void;
  61033. /**
  61034. * Starts all particle systems of the set
  61035. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61036. */
  61037. start(emitter?: AbstractMesh): void;
  61038. /**
  61039. * Release all associated resources
  61040. */
  61041. dispose(): void;
  61042. /**
  61043. * Serialize the set into a JSON compatible object
  61044. * @returns a JSON compatible representation of the set
  61045. */
  61046. serialize(): any;
  61047. /**
  61048. * Parse a new ParticleSystemSet from a serialized source
  61049. * @param data defines a JSON compatible representation of the set
  61050. * @param scene defines the hosting scene
  61051. * @param gpu defines if we want GPU particles or CPU particles
  61052. * @returns a new ParticleSystemSet
  61053. */
  61054. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61055. }
  61056. }
  61057. declare module BABYLON {
  61058. /**
  61059. * This class is made for on one-liner static method to help creating particle system set.
  61060. */
  61061. export class ParticleHelper {
  61062. /**
  61063. * Gets or sets base Assets URL
  61064. */
  61065. static BaseAssetsUrl: string;
  61066. /**
  61067. * Create a default particle system that you can tweak
  61068. * @param emitter defines the emitter to use
  61069. * @param capacity defines the system capacity (default is 500 particles)
  61070. * @param scene defines the hosting scene
  61071. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61072. * @returns the new Particle system
  61073. */
  61074. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61075. /**
  61076. * This is the main static method (one-liner) of this helper to create different particle systems
  61077. * @param type This string represents the type to the particle system to create
  61078. * @param scene The scene where the particle system should live
  61079. * @param gpu If the system will use gpu
  61080. * @returns the ParticleSystemSet created
  61081. */
  61082. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61083. /**
  61084. * Static function used to export a particle system to a ParticleSystemSet variable.
  61085. * Please note that the emitter shape is not exported
  61086. * @param systems defines the particle systems to export
  61087. * @returns the created particle system set
  61088. */
  61089. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61090. }
  61091. }
  61092. declare module BABYLON {
  61093. interface Engine {
  61094. /**
  61095. * Create an effect to use with particle systems.
  61096. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61097. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61098. * @param uniformsNames defines a list of attribute names
  61099. * @param samplers defines an array of string used to represent textures
  61100. * @param defines defines the string containing the defines to use to compile the shaders
  61101. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61102. * @param onCompiled defines a function to call when the effect creation is successful
  61103. * @param onError defines a function to call when the effect creation has failed
  61104. * @returns the new Effect
  61105. */
  61106. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61107. }
  61108. interface Mesh {
  61109. /**
  61110. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61111. * @returns an array of IParticleSystem
  61112. */
  61113. getEmittedParticleSystems(): IParticleSystem[];
  61114. /**
  61115. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61116. * @returns an array of IParticleSystem
  61117. */
  61118. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61119. }
  61120. /**
  61121. * @hidden
  61122. */
  61123. export var _IDoNeedToBeInTheBuild: number;
  61124. }
  61125. declare module BABYLON {
  61126. /** Defines the 4 color options */
  61127. export enum PointColor {
  61128. /** color value */
  61129. Color = 2,
  61130. /** uv value */
  61131. UV = 1,
  61132. /** random value */
  61133. Random = 0,
  61134. /** stated value */
  61135. Stated = 3
  61136. }
  61137. /**
  61138. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61139. * 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.
  61140. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61141. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61142. *
  61143. * Full documentation here : TO BE ENTERED
  61144. */
  61145. export class PointsCloudSystem implements IDisposable {
  61146. /**
  61147. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61148. * Example : var p = SPS.particles[i];
  61149. */
  61150. particles: CloudPoint[];
  61151. /**
  61152. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61153. */
  61154. nbParticles: number;
  61155. /**
  61156. * This a counter for your own usage. It's not set by any SPS functions.
  61157. */
  61158. counter: number;
  61159. /**
  61160. * The PCS name. This name is also given to the underlying mesh.
  61161. */
  61162. name: string;
  61163. /**
  61164. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61165. */
  61166. mesh: Mesh;
  61167. /**
  61168. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61169. * Please read :
  61170. */
  61171. vars: any;
  61172. /**
  61173. * @hidden
  61174. */
  61175. _size: number;
  61176. private _scene;
  61177. private _promises;
  61178. private _positions;
  61179. private _indices;
  61180. private _normals;
  61181. private _colors;
  61182. private _uvs;
  61183. private _indices32;
  61184. private _positions32;
  61185. private _colors32;
  61186. private _uvs32;
  61187. private _updatable;
  61188. private _isVisibilityBoxLocked;
  61189. private _alwaysVisible;
  61190. private _groups;
  61191. private _groupCounter;
  61192. private _computeParticleColor;
  61193. private _computeParticleTexture;
  61194. private _computeParticleRotation;
  61195. private _computeBoundingBox;
  61196. private _isReady;
  61197. /**
  61198. * Creates a PCS (Points Cloud System) object
  61199. * @param name (String) is the PCS name, this will be the underlying mesh name
  61200. * @param pointSize (number) is the size for each point
  61201. * @param scene (Scene) is the scene in which the PCS is added
  61202. * @param options defines the options of the PCS e.g.
  61203. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61204. */
  61205. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61206. updatable?: boolean;
  61207. });
  61208. /**
  61209. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61210. * If no points were added to the PCS, the returned mesh is just a single point.
  61211. * @returns a promise for the created mesh
  61212. */
  61213. buildMeshAsync(): Promise<Mesh>;
  61214. /**
  61215. * @hidden
  61216. */
  61217. private _buildMesh;
  61218. private _addParticle;
  61219. private _randomUnitVector;
  61220. private _getColorIndicesForCoord;
  61221. private _setPointsColorOrUV;
  61222. private _colorFromTexture;
  61223. private _calculateDensity;
  61224. /**
  61225. * Adds points to the PCS in random positions within a unit sphere
  61226. * @param nb (positive integer) the number of particles to be created from this model
  61227. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61228. * @returns the number of groups in the system
  61229. */
  61230. addPoints(nb: number, pointFunction?: any): number;
  61231. /**
  61232. * Adds points to the PCS from the surface of the model shape
  61233. * @param mesh is any Mesh object that will be used as a surface model for the points
  61234. * @param nb (positive integer) the number of particles to be created from this model
  61235. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61236. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61237. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61238. * @returns the number of groups in the system
  61239. */
  61240. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61241. /**
  61242. * Adds points to the PCS inside the model shape
  61243. * @param mesh is any Mesh object that will be used as a surface model for the points
  61244. * @param nb (positive integer) the number of particles to be created from this model
  61245. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61246. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61247. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61248. * @returns the number of groups in the system
  61249. */
  61250. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61251. /**
  61252. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61253. * This method calls `updateParticle()` for each particle of the SPS.
  61254. * For an animated SPS, it is usually called within the render loop.
  61255. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61256. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61257. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61258. * @returns the PCS.
  61259. */
  61260. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61261. /**
  61262. * Disposes the PCS.
  61263. */
  61264. dispose(): void;
  61265. /**
  61266. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61267. * doc :
  61268. * @returns the PCS.
  61269. */
  61270. refreshVisibleSize(): PointsCloudSystem;
  61271. /**
  61272. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61273. * @param size the size (float) of the visibility box
  61274. * note : this doesn't lock the PCS mesh bounding box.
  61275. * doc :
  61276. */
  61277. setVisibilityBox(size: number): void;
  61278. /**
  61279. * Gets whether the PCS is always visible or not
  61280. * doc :
  61281. */
  61282. get isAlwaysVisible(): boolean;
  61283. /**
  61284. * Sets the PCS as always visible or not
  61285. * doc :
  61286. */
  61287. set isAlwaysVisible(val: boolean);
  61288. /**
  61289. * Tells to `setParticles()` to compute the particle rotations or not
  61290. * Default value : false. The PCS is faster when it's set to false
  61291. * Note : particle rotations are only applied to parent particles
  61292. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61293. */
  61294. set computeParticleRotation(val: boolean);
  61295. /**
  61296. * Tells to `setParticles()` to compute the particle colors or not.
  61297. * Default value : true. The PCS is faster when it's set to false.
  61298. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61299. */
  61300. set computeParticleColor(val: boolean);
  61301. set computeParticleTexture(val: boolean);
  61302. /**
  61303. * Gets if `setParticles()` computes the particle colors or not.
  61304. * Default value : false. The PCS is faster when it's set to false.
  61305. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61306. */
  61307. get computeParticleColor(): boolean;
  61308. /**
  61309. * Gets if `setParticles()` computes the particle textures or not.
  61310. * Default value : false. The PCS is faster when it's set to false.
  61311. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61312. */
  61313. get computeParticleTexture(): boolean;
  61314. /**
  61315. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61316. */
  61317. set computeBoundingBox(val: boolean);
  61318. /**
  61319. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61320. */
  61321. get computeBoundingBox(): boolean;
  61322. /**
  61323. * This function does nothing. It may be overwritten to set all the particle first values.
  61324. * The PCS doesn't call this function, you may have to call it by your own.
  61325. * doc :
  61326. */
  61327. initParticles(): void;
  61328. /**
  61329. * This function does nothing. It may be overwritten to recycle a particle
  61330. * The PCS doesn't call this function, you can to call it
  61331. * doc :
  61332. * @param particle The particle to recycle
  61333. * @returns the recycled particle
  61334. */
  61335. recycleParticle(particle: CloudPoint): CloudPoint;
  61336. /**
  61337. * Updates a particle : this function should be overwritten by the user.
  61338. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61339. * doc :
  61340. * @example : just set a particle position or velocity and recycle conditions
  61341. * @param particle The particle to update
  61342. * @returns the updated particle
  61343. */
  61344. updateParticle(particle: CloudPoint): CloudPoint;
  61345. /**
  61346. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61347. * This does nothing and may be overwritten by the user.
  61348. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61349. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61350. * @param update the boolean update value actually passed to setParticles()
  61351. */
  61352. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61353. /**
  61354. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61355. * This will be passed three parameters.
  61356. * This does nothing and may be overwritten by the user.
  61357. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61358. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61359. * @param update the boolean update value actually passed to setParticles()
  61360. */
  61361. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61362. }
  61363. }
  61364. declare module BABYLON {
  61365. /**
  61366. * Represents one particle of a points cloud system.
  61367. */
  61368. export class CloudPoint {
  61369. /**
  61370. * particle global index
  61371. */
  61372. idx: number;
  61373. /**
  61374. * The color of the particle
  61375. */
  61376. color: Nullable<Color4>;
  61377. /**
  61378. * The world space position of the particle.
  61379. */
  61380. position: Vector3;
  61381. /**
  61382. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61383. */
  61384. rotation: Vector3;
  61385. /**
  61386. * The world space rotation quaternion of the particle.
  61387. */
  61388. rotationQuaternion: Nullable<Quaternion>;
  61389. /**
  61390. * The uv of the particle.
  61391. */
  61392. uv: Nullable<Vector2>;
  61393. /**
  61394. * The current speed of the particle.
  61395. */
  61396. velocity: Vector3;
  61397. /**
  61398. * The pivot point in the particle local space.
  61399. */
  61400. pivot: Vector3;
  61401. /**
  61402. * Must the particle be translated from its pivot point in its local space ?
  61403. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61404. * Default : false
  61405. */
  61406. translateFromPivot: boolean;
  61407. /**
  61408. * Index of this particle in the global "positions" array (Internal use)
  61409. * @hidden
  61410. */
  61411. _pos: number;
  61412. /**
  61413. * @hidden Index of this particle in the global "indices" array (Internal use)
  61414. */
  61415. _ind: number;
  61416. /**
  61417. * Group this particle belongs to
  61418. */
  61419. _group: PointsGroup;
  61420. /**
  61421. * Group id of this particle
  61422. */
  61423. groupId: number;
  61424. /**
  61425. * Index of the particle in its group id (Internal use)
  61426. */
  61427. idxInGroup: number;
  61428. /**
  61429. * @hidden Particle BoundingInfo object (Internal use)
  61430. */
  61431. _boundingInfo: BoundingInfo;
  61432. /**
  61433. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61434. */
  61435. _pcs: PointsCloudSystem;
  61436. /**
  61437. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61438. */
  61439. _stillInvisible: boolean;
  61440. /**
  61441. * @hidden Last computed particle rotation matrix
  61442. */
  61443. _rotationMatrix: number[];
  61444. /**
  61445. * Parent particle Id, if any.
  61446. * Default null.
  61447. */
  61448. parentId: Nullable<number>;
  61449. /**
  61450. * @hidden Internal global position in the PCS.
  61451. */
  61452. _globalPosition: Vector3;
  61453. /**
  61454. * Creates a Point Cloud object.
  61455. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61456. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61457. * @param group (PointsGroup) is the group the particle belongs to
  61458. * @param groupId (integer) is the group identifier in the PCS.
  61459. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61460. * @param pcs defines the PCS it is associated to
  61461. */
  61462. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61463. /**
  61464. * get point size
  61465. */
  61466. get size(): Vector3;
  61467. /**
  61468. * Set point size
  61469. */
  61470. set size(scale: Vector3);
  61471. /**
  61472. * Legacy support, changed quaternion to rotationQuaternion
  61473. */
  61474. get quaternion(): Nullable<Quaternion>;
  61475. /**
  61476. * Legacy support, changed quaternion to rotationQuaternion
  61477. */
  61478. set quaternion(q: Nullable<Quaternion>);
  61479. /**
  61480. * Returns a boolean. True if the particle intersects a mesh, else false
  61481. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61482. * @param target is the object (point or mesh) what the intersection is computed against
  61483. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61484. * @returns true if it intersects
  61485. */
  61486. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61487. /**
  61488. * get the rotation matrix of the particle
  61489. * @hidden
  61490. */
  61491. getRotationMatrix(m: Matrix): void;
  61492. }
  61493. /**
  61494. * Represents a group of points in a points cloud system
  61495. * * PCS internal tool, don't use it manually.
  61496. */
  61497. export class PointsGroup {
  61498. /**
  61499. * The group id
  61500. * @hidden
  61501. */
  61502. groupID: number;
  61503. /**
  61504. * image data for group (internal use)
  61505. * @hidden
  61506. */
  61507. _groupImageData: Nullable<ArrayBufferView>;
  61508. /**
  61509. * Image Width (internal use)
  61510. * @hidden
  61511. */
  61512. _groupImgWidth: number;
  61513. /**
  61514. * Image Height (internal use)
  61515. * @hidden
  61516. */
  61517. _groupImgHeight: number;
  61518. /**
  61519. * Custom position function (internal use)
  61520. * @hidden
  61521. */
  61522. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61523. /**
  61524. * density per facet for surface points
  61525. * @hidden
  61526. */
  61527. _groupDensity: number[];
  61528. /**
  61529. * Only when points are colored by texture carries pointer to texture list array
  61530. * @hidden
  61531. */
  61532. _textureNb: number;
  61533. /**
  61534. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61535. * PCS internal tool, don't use it manually.
  61536. * @hidden
  61537. */
  61538. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61539. }
  61540. }
  61541. declare module BABYLON {
  61542. interface Scene {
  61543. /** @hidden (Backing field) */
  61544. _physicsEngine: Nullable<IPhysicsEngine>;
  61545. /** @hidden */
  61546. _physicsTimeAccumulator: number;
  61547. /**
  61548. * Gets the current physics engine
  61549. * @returns a IPhysicsEngine or null if none attached
  61550. */
  61551. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61552. /**
  61553. * Enables physics to the current scene
  61554. * @param gravity defines the scene's gravity for the physics engine
  61555. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61556. * @return a boolean indicating if the physics engine was initialized
  61557. */
  61558. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61559. /**
  61560. * Disables and disposes the physics engine associated with the scene
  61561. */
  61562. disablePhysicsEngine(): void;
  61563. /**
  61564. * Gets a boolean indicating if there is an active physics engine
  61565. * @returns a boolean indicating if there is an active physics engine
  61566. */
  61567. isPhysicsEnabled(): boolean;
  61568. /**
  61569. * Deletes a physics compound impostor
  61570. * @param compound defines the compound to delete
  61571. */
  61572. deleteCompoundImpostor(compound: any): void;
  61573. /**
  61574. * An event triggered when physic simulation is about to be run
  61575. */
  61576. onBeforePhysicsObservable: Observable<Scene>;
  61577. /**
  61578. * An event triggered when physic simulation has been done
  61579. */
  61580. onAfterPhysicsObservable: Observable<Scene>;
  61581. }
  61582. interface AbstractMesh {
  61583. /** @hidden */
  61584. _physicsImpostor: Nullable<PhysicsImpostor>;
  61585. /**
  61586. * Gets or sets impostor used for physic simulation
  61587. * @see http://doc.babylonjs.com/features/physics_engine
  61588. */
  61589. physicsImpostor: Nullable<PhysicsImpostor>;
  61590. /**
  61591. * Gets the current physics impostor
  61592. * @see http://doc.babylonjs.com/features/physics_engine
  61593. * @returns a physics impostor or null
  61594. */
  61595. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61596. /** Apply a physic impulse to the mesh
  61597. * @param force defines the force to apply
  61598. * @param contactPoint defines where to apply the force
  61599. * @returns the current mesh
  61600. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61601. */
  61602. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61603. /**
  61604. * Creates a physic joint between two meshes
  61605. * @param otherMesh defines the other mesh to use
  61606. * @param pivot1 defines the pivot to use on this mesh
  61607. * @param pivot2 defines the pivot to use on the other mesh
  61608. * @param options defines additional options (can be plugin dependent)
  61609. * @returns the current mesh
  61610. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61611. */
  61612. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61613. /** @hidden */
  61614. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61615. }
  61616. /**
  61617. * Defines the physics engine scene component responsible to manage a physics engine
  61618. */
  61619. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61620. /**
  61621. * The component name helpful to identify the component in the list of scene components.
  61622. */
  61623. readonly name: string;
  61624. /**
  61625. * The scene the component belongs to.
  61626. */
  61627. scene: Scene;
  61628. /**
  61629. * Creates a new instance of the component for the given scene
  61630. * @param scene Defines the scene to register the component in
  61631. */
  61632. constructor(scene: Scene);
  61633. /**
  61634. * Registers the component in a given scene
  61635. */
  61636. register(): void;
  61637. /**
  61638. * Rebuilds the elements related to this component in case of
  61639. * context lost for instance.
  61640. */
  61641. rebuild(): void;
  61642. /**
  61643. * Disposes the component and the associated ressources
  61644. */
  61645. dispose(): void;
  61646. }
  61647. }
  61648. declare module BABYLON {
  61649. /**
  61650. * A helper for physics simulations
  61651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61652. */
  61653. export class PhysicsHelper {
  61654. private _scene;
  61655. private _physicsEngine;
  61656. /**
  61657. * Initializes the Physics helper
  61658. * @param scene Babylon.js scene
  61659. */
  61660. constructor(scene: Scene);
  61661. /**
  61662. * Applies a radial explosion impulse
  61663. * @param origin the origin of the explosion
  61664. * @param radiusOrEventOptions the radius or the options of radial explosion
  61665. * @param strength the explosion strength
  61666. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61667. * @returns A physics radial explosion event, or null
  61668. */
  61669. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61670. /**
  61671. * Applies a radial explosion force
  61672. * @param origin the origin of the explosion
  61673. * @param radiusOrEventOptions the radius or the options of radial explosion
  61674. * @param strength the explosion strength
  61675. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61676. * @returns A physics radial explosion event, or null
  61677. */
  61678. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61679. /**
  61680. * Creates a gravitational field
  61681. * @param origin the origin of the explosion
  61682. * @param radiusOrEventOptions the radius or the options of radial explosion
  61683. * @param strength the explosion strength
  61684. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61685. * @returns A physics gravitational field event, or null
  61686. */
  61687. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61688. /**
  61689. * Creates a physics updraft event
  61690. * @param origin the origin of the updraft
  61691. * @param radiusOrEventOptions the radius or the options of the updraft
  61692. * @param strength the strength of the updraft
  61693. * @param height the height of the updraft
  61694. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61695. * @returns A physics updraft event, or null
  61696. */
  61697. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61698. /**
  61699. * Creates a physics vortex event
  61700. * @param origin the of the vortex
  61701. * @param radiusOrEventOptions the radius or the options of the vortex
  61702. * @param strength the strength of the vortex
  61703. * @param height the height of the vortex
  61704. * @returns a Physics vortex event, or null
  61705. * A physics vortex event or null
  61706. */
  61707. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61708. }
  61709. /**
  61710. * Represents a physics radial explosion event
  61711. */
  61712. class PhysicsRadialExplosionEvent {
  61713. private _scene;
  61714. private _options;
  61715. private _sphere;
  61716. private _dataFetched;
  61717. /**
  61718. * Initializes a radial explosioin event
  61719. * @param _scene BabylonJS scene
  61720. * @param _options The options for the vortex event
  61721. */
  61722. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61723. /**
  61724. * Returns the data related to the radial explosion event (sphere).
  61725. * @returns The radial explosion event data
  61726. */
  61727. getData(): PhysicsRadialExplosionEventData;
  61728. /**
  61729. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61730. * @param impostor A physics imposter
  61731. * @param origin the origin of the explosion
  61732. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61733. */
  61734. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61735. /**
  61736. * Triggers affecterd impostors callbacks
  61737. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61738. */
  61739. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61740. /**
  61741. * Disposes the sphere.
  61742. * @param force Specifies if the sphere should be disposed by force
  61743. */
  61744. dispose(force?: boolean): void;
  61745. /*** Helpers ***/
  61746. private _prepareSphere;
  61747. private _intersectsWithSphere;
  61748. }
  61749. /**
  61750. * Represents a gravitational field event
  61751. */
  61752. class PhysicsGravitationalFieldEvent {
  61753. private _physicsHelper;
  61754. private _scene;
  61755. private _origin;
  61756. private _options;
  61757. private _tickCallback;
  61758. private _sphere;
  61759. private _dataFetched;
  61760. /**
  61761. * Initializes the physics gravitational field event
  61762. * @param _physicsHelper A physics helper
  61763. * @param _scene BabylonJS scene
  61764. * @param _origin The origin position of the gravitational field event
  61765. * @param _options The options for the vortex event
  61766. */
  61767. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61768. /**
  61769. * Returns the data related to the gravitational field event (sphere).
  61770. * @returns A gravitational field event
  61771. */
  61772. getData(): PhysicsGravitationalFieldEventData;
  61773. /**
  61774. * Enables the gravitational field.
  61775. */
  61776. enable(): void;
  61777. /**
  61778. * Disables the gravitational field.
  61779. */
  61780. disable(): void;
  61781. /**
  61782. * Disposes the sphere.
  61783. * @param force The force to dispose from the gravitational field event
  61784. */
  61785. dispose(force?: boolean): void;
  61786. private _tick;
  61787. }
  61788. /**
  61789. * Represents a physics updraft event
  61790. */
  61791. class PhysicsUpdraftEvent {
  61792. private _scene;
  61793. private _origin;
  61794. private _options;
  61795. private _physicsEngine;
  61796. private _originTop;
  61797. private _originDirection;
  61798. private _tickCallback;
  61799. private _cylinder;
  61800. private _cylinderPosition;
  61801. private _dataFetched;
  61802. /**
  61803. * Initializes the physics updraft event
  61804. * @param _scene BabylonJS scene
  61805. * @param _origin The origin position of the updraft
  61806. * @param _options The options for the updraft event
  61807. */
  61808. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61809. /**
  61810. * Returns the data related to the updraft event (cylinder).
  61811. * @returns A physics updraft event
  61812. */
  61813. getData(): PhysicsUpdraftEventData;
  61814. /**
  61815. * Enables the updraft.
  61816. */
  61817. enable(): void;
  61818. /**
  61819. * Disables the updraft.
  61820. */
  61821. disable(): void;
  61822. /**
  61823. * Disposes the cylinder.
  61824. * @param force Specifies if the updraft should be disposed by force
  61825. */
  61826. dispose(force?: boolean): void;
  61827. private getImpostorHitData;
  61828. private _tick;
  61829. /*** Helpers ***/
  61830. private _prepareCylinder;
  61831. private _intersectsWithCylinder;
  61832. }
  61833. /**
  61834. * Represents a physics vortex event
  61835. */
  61836. class PhysicsVortexEvent {
  61837. private _scene;
  61838. private _origin;
  61839. private _options;
  61840. private _physicsEngine;
  61841. private _originTop;
  61842. private _tickCallback;
  61843. private _cylinder;
  61844. private _cylinderPosition;
  61845. private _dataFetched;
  61846. /**
  61847. * Initializes the physics vortex event
  61848. * @param _scene The BabylonJS scene
  61849. * @param _origin The origin position of the vortex
  61850. * @param _options The options for the vortex event
  61851. */
  61852. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61853. /**
  61854. * Returns the data related to the vortex event (cylinder).
  61855. * @returns The physics vortex event data
  61856. */
  61857. getData(): PhysicsVortexEventData;
  61858. /**
  61859. * Enables the vortex.
  61860. */
  61861. enable(): void;
  61862. /**
  61863. * Disables the cortex.
  61864. */
  61865. disable(): void;
  61866. /**
  61867. * Disposes the sphere.
  61868. * @param force
  61869. */
  61870. dispose(force?: boolean): void;
  61871. private getImpostorHitData;
  61872. private _tick;
  61873. /*** Helpers ***/
  61874. private _prepareCylinder;
  61875. private _intersectsWithCylinder;
  61876. }
  61877. /**
  61878. * Options fot the radial explosion event
  61879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61880. */
  61881. export class PhysicsRadialExplosionEventOptions {
  61882. /**
  61883. * The radius of the sphere for the radial explosion.
  61884. */
  61885. radius: number;
  61886. /**
  61887. * The strenth of the explosion.
  61888. */
  61889. strength: number;
  61890. /**
  61891. * The strenght of the force in correspondence to the distance of the affected object
  61892. */
  61893. falloff: PhysicsRadialImpulseFalloff;
  61894. /**
  61895. * Sphere options for the radial explosion.
  61896. */
  61897. sphere: {
  61898. segments: number;
  61899. diameter: number;
  61900. };
  61901. /**
  61902. * Sphere options for the radial explosion.
  61903. */
  61904. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61905. }
  61906. /**
  61907. * Options fot the updraft event
  61908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61909. */
  61910. export class PhysicsUpdraftEventOptions {
  61911. /**
  61912. * The radius of the cylinder for the vortex
  61913. */
  61914. radius: number;
  61915. /**
  61916. * The strenth of the updraft.
  61917. */
  61918. strength: number;
  61919. /**
  61920. * The height of the cylinder for the updraft.
  61921. */
  61922. height: number;
  61923. /**
  61924. * The mode for the the updraft.
  61925. */
  61926. updraftMode: PhysicsUpdraftMode;
  61927. }
  61928. /**
  61929. * Options fot the vortex event
  61930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61931. */
  61932. export class PhysicsVortexEventOptions {
  61933. /**
  61934. * The radius of the cylinder for the vortex
  61935. */
  61936. radius: number;
  61937. /**
  61938. * The strenth of the vortex.
  61939. */
  61940. strength: number;
  61941. /**
  61942. * The height of the cylinder for the vortex.
  61943. */
  61944. height: number;
  61945. /**
  61946. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61947. */
  61948. centripetalForceThreshold: number;
  61949. /**
  61950. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61951. */
  61952. centripetalForceMultiplier: number;
  61953. /**
  61954. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61955. */
  61956. centrifugalForceMultiplier: number;
  61957. /**
  61958. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61959. */
  61960. updraftForceMultiplier: number;
  61961. }
  61962. /**
  61963. * The strenght of the force in correspondence to the distance of the affected object
  61964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61965. */
  61966. export enum PhysicsRadialImpulseFalloff {
  61967. /** Defines that impulse is constant in strength across it's whole radius */
  61968. Constant = 0,
  61969. /** Defines that impulse gets weaker if it's further from the origin */
  61970. Linear = 1
  61971. }
  61972. /**
  61973. * The strength of the force in correspondence to the distance of the affected object
  61974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61975. */
  61976. export enum PhysicsUpdraftMode {
  61977. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61978. Center = 0,
  61979. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61980. Perpendicular = 1
  61981. }
  61982. /**
  61983. * Interface for a physics hit data
  61984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61985. */
  61986. export interface PhysicsHitData {
  61987. /**
  61988. * The force applied at the contact point
  61989. */
  61990. force: Vector3;
  61991. /**
  61992. * The contact point
  61993. */
  61994. contactPoint: Vector3;
  61995. /**
  61996. * The distance from the origin to the contact point
  61997. */
  61998. distanceFromOrigin: number;
  61999. }
  62000. /**
  62001. * Interface for radial explosion event data
  62002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62003. */
  62004. export interface PhysicsRadialExplosionEventData {
  62005. /**
  62006. * A sphere used for the radial explosion event
  62007. */
  62008. sphere: Mesh;
  62009. }
  62010. /**
  62011. * Interface for gravitational field event data
  62012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62013. */
  62014. export interface PhysicsGravitationalFieldEventData {
  62015. /**
  62016. * A sphere mesh used for the gravitational field event
  62017. */
  62018. sphere: Mesh;
  62019. }
  62020. /**
  62021. * Interface for updraft event data
  62022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62023. */
  62024. export interface PhysicsUpdraftEventData {
  62025. /**
  62026. * A cylinder used for the updraft event
  62027. */
  62028. cylinder: Mesh;
  62029. }
  62030. /**
  62031. * Interface for vortex event data
  62032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62033. */
  62034. export interface PhysicsVortexEventData {
  62035. /**
  62036. * A cylinder used for the vortex event
  62037. */
  62038. cylinder: Mesh;
  62039. }
  62040. /**
  62041. * Interface for an affected physics impostor
  62042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62043. */
  62044. export interface PhysicsAffectedImpostorWithData {
  62045. /**
  62046. * The impostor affected by the effect
  62047. */
  62048. impostor: PhysicsImpostor;
  62049. /**
  62050. * The data about the hit/horce from the explosion
  62051. */
  62052. hitData: PhysicsHitData;
  62053. }
  62054. }
  62055. declare module BABYLON {
  62056. /** @hidden */
  62057. export var blackAndWhitePixelShader: {
  62058. name: string;
  62059. shader: string;
  62060. };
  62061. }
  62062. declare module BABYLON {
  62063. /**
  62064. * Post process used to render in black and white
  62065. */
  62066. export class BlackAndWhitePostProcess extends PostProcess {
  62067. /**
  62068. * Linear about to convert he result to black and white (default: 1)
  62069. */
  62070. degree: number;
  62071. /**
  62072. * Creates a black and white post process
  62073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62074. * @param name The name of the effect.
  62075. * @param options The required width/height ratio to downsize to before computing the render pass.
  62076. * @param camera The camera to apply the render pass to.
  62077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62078. * @param engine The engine which the post process will be applied. (default: current engine)
  62079. * @param reusable If the post process can be reused on the same frame. (default: false)
  62080. */
  62081. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62082. }
  62083. }
  62084. declare module BABYLON {
  62085. /**
  62086. * This represents a set of one or more post processes in Babylon.
  62087. * A post process can be used to apply a shader to a texture after it is rendered.
  62088. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62089. */
  62090. export class PostProcessRenderEffect {
  62091. private _postProcesses;
  62092. private _getPostProcesses;
  62093. private _singleInstance;
  62094. private _cameras;
  62095. private _indicesForCamera;
  62096. /**
  62097. * Name of the effect
  62098. * @hidden
  62099. */
  62100. _name: string;
  62101. /**
  62102. * Instantiates a post process render effect.
  62103. * A post process can be used to apply a shader to a texture after it is rendered.
  62104. * @param engine The engine the effect is tied to
  62105. * @param name The name of the effect
  62106. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62107. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62108. */
  62109. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62110. /**
  62111. * Checks if all the post processes in the effect are supported.
  62112. */
  62113. get isSupported(): boolean;
  62114. /**
  62115. * Updates the current state of the effect
  62116. * @hidden
  62117. */
  62118. _update(): void;
  62119. /**
  62120. * Attaches the effect on cameras
  62121. * @param cameras The camera to attach to.
  62122. * @hidden
  62123. */
  62124. _attachCameras(cameras: Camera): void;
  62125. /**
  62126. * Attaches the effect on cameras
  62127. * @param cameras The camera to attach to.
  62128. * @hidden
  62129. */
  62130. _attachCameras(cameras: Camera[]): void;
  62131. /**
  62132. * Detaches the effect on cameras
  62133. * @param cameras The camera to detatch from.
  62134. * @hidden
  62135. */
  62136. _detachCameras(cameras: Camera): void;
  62137. /**
  62138. * Detatches the effect on cameras
  62139. * @param cameras The camera to detatch from.
  62140. * @hidden
  62141. */
  62142. _detachCameras(cameras: Camera[]): void;
  62143. /**
  62144. * Enables the effect on given cameras
  62145. * @param cameras The camera to enable.
  62146. * @hidden
  62147. */
  62148. _enable(cameras: Camera): void;
  62149. /**
  62150. * Enables the effect on given cameras
  62151. * @param cameras The camera to enable.
  62152. * @hidden
  62153. */
  62154. _enable(cameras: Nullable<Camera[]>): void;
  62155. /**
  62156. * Disables the effect on the given cameras
  62157. * @param cameras The camera to disable.
  62158. * @hidden
  62159. */
  62160. _disable(cameras: Camera): void;
  62161. /**
  62162. * Disables the effect on the given cameras
  62163. * @param cameras The camera to disable.
  62164. * @hidden
  62165. */
  62166. _disable(cameras: Nullable<Camera[]>): void;
  62167. /**
  62168. * Gets a list of the post processes contained in the effect.
  62169. * @param camera The camera to get the post processes on.
  62170. * @returns The list of the post processes in the effect.
  62171. */
  62172. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62173. }
  62174. }
  62175. declare module BABYLON {
  62176. /** @hidden */
  62177. export var extractHighlightsPixelShader: {
  62178. name: string;
  62179. shader: string;
  62180. };
  62181. }
  62182. declare module BABYLON {
  62183. /**
  62184. * 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.
  62185. */
  62186. export class ExtractHighlightsPostProcess extends PostProcess {
  62187. /**
  62188. * The luminance threshold, pixels below this value will be set to black.
  62189. */
  62190. threshold: number;
  62191. /** @hidden */
  62192. _exposure: number;
  62193. /**
  62194. * Post process which has the input texture to be used when performing highlight extraction
  62195. * @hidden
  62196. */
  62197. _inputPostProcess: Nullable<PostProcess>;
  62198. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62199. }
  62200. }
  62201. declare module BABYLON {
  62202. /** @hidden */
  62203. export var bloomMergePixelShader: {
  62204. name: string;
  62205. shader: string;
  62206. };
  62207. }
  62208. declare module BABYLON {
  62209. /**
  62210. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62211. */
  62212. export class BloomMergePostProcess extends PostProcess {
  62213. /** Weight of the bloom to be added to the original input. */
  62214. weight: number;
  62215. /**
  62216. * Creates a new instance of @see BloomMergePostProcess
  62217. * @param name The name of the effect.
  62218. * @param originalFromInput Post process which's input will be used for the merge.
  62219. * @param blurred Blurred highlights post process which's output will be used.
  62220. * @param weight Weight of the bloom to be added to the original input.
  62221. * @param options The required width/height ratio to downsize to before computing the render pass.
  62222. * @param camera The camera to apply the render pass to.
  62223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62224. * @param engine The engine which the post process will be applied. (default: current engine)
  62225. * @param reusable If the post process can be reused on the same frame. (default: false)
  62226. * @param textureType Type of textures used when performing the post process. (default: 0)
  62227. * @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)
  62228. */
  62229. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62230. /** Weight of the bloom to be added to the original input. */
  62231. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62232. }
  62233. }
  62234. declare module BABYLON {
  62235. /**
  62236. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62237. */
  62238. export class BloomEffect extends PostProcessRenderEffect {
  62239. private bloomScale;
  62240. /**
  62241. * @hidden Internal
  62242. */
  62243. _effects: Array<PostProcess>;
  62244. /**
  62245. * @hidden Internal
  62246. */
  62247. _downscale: ExtractHighlightsPostProcess;
  62248. private _blurX;
  62249. private _blurY;
  62250. private _merge;
  62251. /**
  62252. * The luminance threshold to find bright areas of the image to bloom.
  62253. */
  62254. get threshold(): number;
  62255. set threshold(value: number);
  62256. /**
  62257. * The strength of the bloom.
  62258. */
  62259. get weight(): number;
  62260. set weight(value: number);
  62261. /**
  62262. * Specifies the size of the bloom blur kernel, relative to the final output size
  62263. */
  62264. get kernel(): number;
  62265. set kernel(value: number);
  62266. /**
  62267. * Creates a new instance of @see BloomEffect
  62268. * @param scene The scene the effect belongs to.
  62269. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62270. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62271. * @param bloomWeight The the strength of bloom.
  62272. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62273. * @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)
  62274. */
  62275. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62276. /**
  62277. * Disposes each of the internal effects for a given camera.
  62278. * @param camera The camera to dispose the effect on.
  62279. */
  62280. disposeEffects(camera: Camera): void;
  62281. /**
  62282. * @hidden Internal
  62283. */
  62284. _updateEffects(): void;
  62285. /**
  62286. * Internal
  62287. * @returns if all the contained post processes are ready.
  62288. * @hidden
  62289. */
  62290. _isReady(): boolean;
  62291. }
  62292. }
  62293. declare module BABYLON {
  62294. /** @hidden */
  62295. export var chromaticAberrationPixelShader: {
  62296. name: string;
  62297. shader: string;
  62298. };
  62299. }
  62300. declare module BABYLON {
  62301. /**
  62302. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62303. */
  62304. export class ChromaticAberrationPostProcess extends PostProcess {
  62305. /**
  62306. * The amount of seperation of rgb channels (default: 30)
  62307. */
  62308. aberrationAmount: number;
  62309. /**
  62310. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62311. */
  62312. radialIntensity: number;
  62313. /**
  62314. * 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))
  62315. */
  62316. direction: Vector2;
  62317. /**
  62318. * 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))
  62319. */
  62320. centerPosition: Vector2;
  62321. /**
  62322. * Creates a new instance ChromaticAberrationPostProcess
  62323. * @param name The name of the effect.
  62324. * @param screenWidth The width of the screen to apply the effect on.
  62325. * @param screenHeight The height of the screen to apply the effect on.
  62326. * @param options The required width/height ratio to downsize to before computing the render pass.
  62327. * @param camera The camera to apply the render pass to.
  62328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62329. * @param engine The engine which the post process will be applied. (default: current engine)
  62330. * @param reusable If the post process can be reused on the same frame. (default: false)
  62331. * @param textureType Type of textures used when performing the post process. (default: 0)
  62332. * @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)
  62333. */
  62334. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62335. }
  62336. }
  62337. declare module BABYLON {
  62338. /** @hidden */
  62339. export var circleOfConfusionPixelShader: {
  62340. name: string;
  62341. shader: string;
  62342. };
  62343. }
  62344. declare module BABYLON {
  62345. /**
  62346. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62347. */
  62348. export class CircleOfConfusionPostProcess extends PostProcess {
  62349. /**
  62350. * 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.
  62351. */
  62352. lensSize: number;
  62353. /**
  62354. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62355. */
  62356. fStop: number;
  62357. /**
  62358. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62359. */
  62360. focusDistance: number;
  62361. /**
  62362. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62363. */
  62364. focalLength: number;
  62365. private _depthTexture;
  62366. /**
  62367. * Creates a new instance CircleOfConfusionPostProcess
  62368. * @param name The name of the effect.
  62369. * @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.
  62370. * @param options The required width/height ratio to downsize to before computing the render pass.
  62371. * @param camera The camera to apply the render pass to.
  62372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62373. * @param engine The engine which the post process will be applied. (default: current engine)
  62374. * @param reusable If the post process can be reused on the same frame. (default: false)
  62375. * @param textureType Type of textures used when performing the post process. (default: 0)
  62376. * @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)
  62377. */
  62378. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62379. /**
  62380. * 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.
  62381. */
  62382. set depthTexture(value: RenderTargetTexture);
  62383. }
  62384. }
  62385. declare module BABYLON {
  62386. /** @hidden */
  62387. export var colorCorrectionPixelShader: {
  62388. name: string;
  62389. shader: string;
  62390. };
  62391. }
  62392. declare module BABYLON {
  62393. /**
  62394. *
  62395. * This post-process allows the modification of rendered colors by using
  62396. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62397. *
  62398. * The object needs to be provided an url to a texture containing the color
  62399. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62400. * Use an image editing software to tweak the LUT to match your needs.
  62401. *
  62402. * For an example of a color LUT, see here:
  62403. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62404. * For explanations on color grading, see here:
  62405. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62406. *
  62407. */
  62408. export class ColorCorrectionPostProcess extends PostProcess {
  62409. private _colorTableTexture;
  62410. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62411. }
  62412. }
  62413. declare module BABYLON {
  62414. /** @hidden */
  62415. export var convolutionPixelShader: {
  62416. name: string;
  62417. shader: string;
  62418. };
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62423. * input texture to perform effects such as edge detection or sharpening
  62424. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62425. */
  62426. export class ConvolutionPostProcess extends PostProcess {
  62427. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62428. kernel: number[];
  62429. /**
  62430. * Creates a new instance ConvolutionPostProcess
  62431. * @param name The name of the effect.
  62432. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62436. * @param engine The engine which the post process will be applied. (default: current engine)
  62437. * @param reusable If the post process can be reused on the same frame. (default: false)
  62438. * @param textureType Type of textures used when performing the post process. (default: 0)
  62439. */
  62440. constructor(name: string,
  62441. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62442. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62443. /**
  62444. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62445. */
  62446. static EdgeDetect0Kernel: number[];
  62447. /**
  62448. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62449. */
  62450. static EdgeDetect1Kernel: number[];
  62451. /**
  62452. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62453. */
  62454. static EdgeDetect2Kernel: number[];
  62455. /**
  62456. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62457. */
  62458. static SharpenKernel: number[];
  62459. /**
  62460. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62461. */
  62462. static EmbossKernel: number[];
  62463. /**
  62464. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62465. */
  62466. static GaussianKernel: number[];
  62467. }
  62468. }
  62469. declare module BABYLON {
  62470. /**
  62471. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62472. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62473. * based on samples that have a large difference in distance than the center pixel.
  62474. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62475. */
  62476. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62477. direction: Vector2;
  62478. /**
  62479. * Creates a new instance CircleOfConfusionPostProcess
  62480. * @param name The name of the effect.
  62481. * @param scene The scene the effect belongs to.
  62482. * @param direction The direction the blur should be applied.
  62483. * @param kernel The size of the kernel used to blur.
  62484. * @param options The required width/height ratio to downsize to before computing the render pass.
  62485. * @param camera The camera to apply the render pass to.
  62486. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62487. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62489. * @param engine The engine which the post process will be applied. (default: current engine)
  62490. * @param reusable If the post process can be reused on the same frame. (default: false)
  62491. * @param textureType Type of textures used when performing the post process. (default: 0)
  62492. * @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)
  62493. */
  62494. 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);
  62495. }
  62496. }
  62497. declare module BABYLON {
  62498. /** @hidden */
  62499. export var depthOfFieldMergePixelShader: {
  62500. name: string;
  62501. shader: string;
  62502. };
  62503. }
  62504. declare module BABYLON {
  62505. /**
  62506. * Options to be set when merging outputs from the default pipeline.
  62507. */
  62508. export class DepthOfFieldMergePostProcessOptions {
  62509. /**
  62510. * The original image to merge on top of
  62511. */
  62512. originalFromInput: PostProcess;
  62513. /**
  62514. * Parameters to perform the merge of the depth of field effect
  62515. */
  62516. depthOfField?: {
  62517. circleOfConfusion: PostProcess;
  62518. blurSteps: Array<PostProcess>;
  62519. };
  62520. /**
  62521. * Parameters to perform the merge of bloom effect
  62522. */
  62523. bloom?: {
  62524. blurred: PostProcess;
  62525. weight: number;
  62526. };
  62527. }
  62528. /**
  62529. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62530. */
  62531. export class DepthOfFieldMergePostProcess extends PostProcess {
  62532. private blurSteps;
  62533. /**
  62534. * Creates a new instance of DepthOfFieldMergePostProcess
  62535. * @param name The name of the effect.
  62536. * @param originalFromInput Post process which's input will be used for the merge.
  62537. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62538. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62539. * @param options The required width/height ratio to downsize to before computing the render pass.
  62540. * @param camera The camera to apply the render pass to.
  62541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62542. * @param engine The engine which the post process will be applied. (default: current engine)
  62543. * @param reusable If the post process can be reused on the same frame. (default: false)
  62544. * @param textureType Type of textures used when performing the post process. (default: 0)
  62545. * @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)
  62546. */
  62547. 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);
  62548. /**
  62549. * Updates the effect with the current post process compile time values and recompiles the shader.
  62550. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62551. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62552. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62553. * @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
  62554. * @param onCompiled Called when the shader has been compiled.
  62555. * @param onError Called if there is an error when compiling a shader.
  62556. */
  62557. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62558. }
  62559. }
  62560. declare module BABYLON {
  62561. /**
  62562. * Specifies the level of max blur that should be applied when using the depth of field effect
  62563. */
  62564. export enum DepthOfFieldEffectBlurLevel {
  62565. /**
  62566. * Subtle blur
  62567. */
  62568. Low = 0,
  62569. /**
  62570. * Medium blur
  62571. */
  62572. Medium = 1,
  62573. /**
  62574. * Large blur
  62575. */
  62576. High = 2
  62577. }
  62578. /**
  62579. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62580. */
  62581. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62582. private _circleOfConfusion;
  62583. /**
  62584. * @hidden Internal, blurs from high to low
  62585. */
  62586. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62587. private _depthOfFieldBlurY;
  62588. private _dofMerge;
  62589. /**
  62590. * @hidden Internal post processes in depth of field effect
  62591. */
  62592. _effects: Array<PostProcess>;
  62593. /**
  62594. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62595. */
  62596. set focalLength(value: number);
  62597. get focalLength(): number;
  62598. /**
  62599. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62600. */
  62601. set fStop(value: number);
  62602. get fStop(): number;
  62603. /**
  62604. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62605. */
  62606. set focusDistance(value: number);
  62607. get focusDistance(): number;
  62608. /**
  62609. * 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.
  62610. */
  62611. set lensSize(value: number);
  62612. get lensSize(): number;
  62613. /**
  62614. * Creates a new instance DepthOfFieldEffect
  62615. * @param scene The scene the effect belongs to.
  62616. * @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.
  62617. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62618. * @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)
  62619. */
  62620. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62621. /**
  62622. * Get the current class name of the current effet
  62623. * @returns "DepthOfFieldEffect"
  62624. */
  62625. getClassName(): string;
  62626. /**
  62627. * 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.
  62628. */
  62629. set depthTexture(value: RenderTargetTexture);
  62630. /**
  62631. * Disposes each of the internal effects for a given camera.
  62632. * @param camera The camera to dispose the effect on.
  62633. */
  62634. disposeEffects(camera: Camera): void;
  62635. /**
  62636. * @hidden Internal
  62637. */
  62638. _updateEffects(): void;
  62639. /**
  62640. * Internal
  62641. * @returns if all the contained post processes are ready.
  62642. * @hidden
  62643. */
  62644. _isReady(): boolean;
  62645. }
  62646. }
  62647. declare module BABYLON {
  62648. /** @hidden */
  62649. export var displayPassPixelShader: {
  62650. name: string;
  62651. shader: string;
  62652. };
  62653. }
  62654. declare module BABYLON {
  62655. /**
  62656. * DisplayPassPostProcess which produces an output the same as it's input
  62657. */
  62658. export class DisplayPassPostProcess extends PostProcess {
  62659. /**
  62660. * Creates the DisplayPassPostProcess
  62661. * @param name The name of the effect.
  62662. * @param options The required width/height ratio to downsize to before computing the render pass.
  62663. * @param camera The camera to apply the render pass to.
  62664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62665. * @param engine The engine which the post process will be applied. (default: current engine)
  62666. * @param reusable If the post process can be reused on the same frame. (default: false)
  62667. */
  62668. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62669. }
  62670. }
  62671. declare module BABYLON {
  62672. /** @hidden */
  62673. export var filterPixelShader: {
  62674. name: string;
  62675. shader: string;
  62676. };
  62677. }
  62678. declare module BABYLON {
  62679. /**
  62680. * Applies a kernel filter to the image
  62681. */
  62682. export class FilterPostProcess extends PostProcess {
  62683. /** The matrix to be applied to the image */
  62684. kernelMatrix: Matrix;
  62685. /**
  62686. *
  62687. * @param name The name of the effect.
  62688. * @param kernelMatrix The matrix to be applied to the image
  62689. * @param options The required width/height ratio to downsize to before computing the render pass.
  62690. * @param camera The camera to apply the render pass to.
  62691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62692. * @param engine The engine which the post process will be applied. (default: current engine)
  62693. * @param reusable If the post process can be reused on the same frame. (default: false)
  62694. */
  62695. constructor(name: string,
  62696. /** The matrix to be applied to the image */
  62697. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62698. }
  62699. }
  62700. declare module BABYLON {
  62701. /** @hidden */
  62702. export var fxaaPixelShader: {
  62703. name: string;
  62704. shader: string;
  62705. };
  62706. }
  62707. declare module BABYLON {
  62708. /** @hidden */
  62709. export var fxaaVertexShader: {
  62710. name: string;
  62711. shader: string;
  62712. };
  62713. }
  62714. declare module BABYLON {
  62715. /**
  62716. * Fxaa post process
  62717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62718. */
  62719. export class FxaaPostProcess extends PostProcess {
  62720. /** @hidden */
  62721. texelWidth: number;
  62722. /** @hidden */
  62723. texelHeight: number;
  62724. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62725. private _getDefines;
  62726. }
  62727. }
  62728. declare module BABYLON {
  62729. /** @hidden */
  62730. export var grainPixelShader: {
  62731. name: string;
  62732. shader: string;
  62733. };
  62734. }
  62735. declare module BABYLON {
  62736. /**
  62737. * The GrainPostProcess adds noise to the image at mid luminance levels
  62738. */
  62739. export class GrainPostProcess extends PostProcess {
  62740. /**
  62741. * The intensity of the grain added (default: 30)
  62742. */
  62743. intensity: number;
  62744. /**
  62745. * If the grain should be randomized on every frame
  62746. */
  62747. animated: boolean;
  62748. /**
  62749. * Creates a new instance of @see GrainPostProcess
  62750. * @param name The name of the effect.
  62751. * @param options The required width/height ratio to downsize to before computing the render pass.
  62752. * @param camera The camera to apply the render pass to.
  62753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62754. * @param engine The engine which the post process will be applied. (default: current engine)
  62755. * @param reusable If the post process can be reused on the same frame. (default: false)
  62756. * @param textureType Type of textures used when performing the post process. (default: 0)
  62757. * @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)
  62758. */
  62759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62760. }
  62761. }
  62762. declare module BABYLON {
  62763. /** @hidden */
  62764. export var highlightsPixelShader: {
  62765. name: string;
  62766. shader: string;
  62767. };
  62768. }
  62769. declare module BABYLON {
  62770. /**
  62771. * Extracts highlights from the image
  62772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62773. */
  62774. export class HighlightsPostProcess extends PostProcess {
  62775. /**
  62776. * Extracts highlights from the image
  62777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62778. * @param name The name of the effect.
  62779. * @param options The required width/height ratio to downsize to before computing the render pass.
  62780. * @param camera The camera to apply the render pass to.
  62781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62782. * @param engine The engine which the post process will be applied. (default: current engine)
  62783. * @param reusable If the post process can be reused on the same frame. (default: false)
  62784. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62785. */
  62786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62787. }
  62788. }
  62789. declare module BABYLON {
  62790. /** @hidden */
  62791. export var mrtFragmentDeclaration: {
  62792. name: string;
  62793. shader: string;
  62794. };
  62795. }
  62796. declare module BABYLON {
  62797. /** @hidden */
  62798. export var geometryPixelShader: {
  62799. name: string;
  62800. shader: string;
  62801. };
  62802. }
  62803. declare module BABYLON {
  62804. /** @hidden */
  62805. export var geometryVertexShader: {
  62806. name: string;
  62807. shader: string;
  62808. };
  62809. }
  62810. declare module BABYLON {
  62811. /** @hidden */
  62812. interface ISavedTransformationMatrix {
  62813. world: Matrix;
  62814. viewProjection: Matrix;
  62815. }
  62816. /**
  62817. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62818. */
  62819. export class GeometryBufferRenderer {
  62820. /**
  62821. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62822. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62823. */
  62824. static readonly POSITION_TEXTURE_TYPE: number;
  62825. /**
  62826. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62827. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62828. */
  62829. static readonly VELOCITY_TEXTURE_TYPE: number;
  62830. /**
  62831. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62832. * in order to compute objects velocities when enableVelocity is set to "true"
  62833. * @hidden
  62834. */
  62835. _previousTransformationMatrices: {
  62836. [index: number]: ISavedTransformationMatrix;
  62837. };
  62838. /**
  62839. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62840. * in order to compute objects velocities when enableVelocity is set to "true"
  62841. * @hidden
  62842. */
  62843. _previousBonesTransformationMatrices: {
  62844. [index: number]: Float32Array;
  62845. };
  62846. /**
  62847. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62848. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62849. */
  62850. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62851. private _scene;
  62852. private _multiRenderTarget;
  62853. private _ratio;
  62854. private _enablePosition;
  62855. private _enableVelocity;
  62856. private _positionIndex;
  62857. private _velocityIndex;
  62858. protected _effect: Effect;
  62859. protected _cachedDefines: string;
  62860. /**
  62861. * Set the render list (meshes to be rendered) used in the G buffer.
  62862. */
  62863. set renderList(meshes: Mesh[]);
  62864. /**
  62865. * Gets wether or not G buffer are supported by the running hardware.
  62866. * This requires draw buffer supports
  62867. */
  62868. get isSupported(): boolean;
  62869. /**
  62870. * Returns the index of the given texture type in the G-Buffer textures array
  62871. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62872. * @returns the index of the given texture type in the G-Buffer textures array
  62873. */
  62874. getTextureIndex(textureType: number): number;
  62875. /**
  62876. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62877. */
  62878. get enablePosition(): boolean;
  62879. /**
  62880. * Sets whether or not objects positions are enabled for the G buffer.
  62881. */
  62882. set enablePosition(enable: boolean);
  62883. /**
  62884. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62885. */
  62886. get enableVelocity(): boolean;
  62887. /**
  62888. * Sets wether or not objects velocities are enabled for the G buffer.
  62889. */
  62890. set enableVelocity(enable: boolean);
  62891. /**
  62892. * Gets the scene associated with the buffer.
  62893. */
  62894. get scene(): Scene;
  62895. /**
  62896. * Gets the ratio used by the buffer during its creation.
  62897. * How big is the buffer related to the main canvas.
  62898. */
  62899. get ratio(): number;
  62900. /** @hidden */
  62901. static _SceneComponentInitialization: (scene: Scene) => void;
  62902. /**
  62903. * Creates a new G Buffer for the scene
  62904. * @param scene The scene the buffer belongs to
  62905. * @param ratio How big is the buffer related to the main canvas.
  62906. */
  62907. constructor(scene: Scene, ratio?: number);
  62908. /**
  62909. * Checks wether everything is ready to render a submesh to the G buffer.
  62910. * @param subMesh the submesh to check readiness for
  62911. * @param useInstances is the mesh drawn using instance or not
  62912. * @returns true if ready otherwise false
  62913. */
  62914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62915. /**
  62916. * Gets the current underlying G Buffer.
  62917. * @returns the buffer
  62918. */
  62919. getGBuffer(): MultiRenderTarget;
  62920. /**
  62921. * Gets the number of samples used to render the buffer (anti aliasing).
  62922. */
  62923. get samples(): number;
  62924. /**
  62925. * Sets the number of samples used to render the buffer (anti aliasing).
  62926. */
  62927. set samples(value: number);
  62928. /**
  62929. * Disposes the renderer and frees up associated resources.
  62930. */
  62931. dispose(): void;
  62932. protected _createRenderTargets(): void;
  62933. private _copyBonesTransformationMatrices;
  62934. }
  62935. }
  62936. declare module BABYLON {
  62937. interface Scene {
  62938. /** @hidden (Backing field) */
  62939. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62940. /**
  62941. * Gets or Sets the current geometry buffer associated to the scene.
  62942. */
  62943. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62944. /**
  62945. * Enables a GeometryBufferRender and associates it with the scene
  62946. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62947. * @returns the GeometryBufferRenderer
  62948. */
  62949. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62950. /**
  62951. * Disables the GeometryBufferRender associated with the scene
  62952. */
  62953. disableGeometryBufferRenderer(): void;
  62954. }
  62955. /**
  62956. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62957. * in several rendering techniques.
  62958. */
  62959. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62960. /**
  62961. * The component name helpful to identify the component in the list of scene components.
  62962. */
  62963. readonly name: string;
  62964. /**
  62965. * The scene the component belongs to.
  62966. */
  62967. scene: Scene;
  62968. /**
  62969. * Creates a new instance of the component for the given scene
  62970. * @param scene Defines the scene to register the component in
  62971. */
  62972. constructor(scene: Scene);
  62973. /**
  62974. * Registers the component in a given scene
  62975. */
  62976. register(): void;
  62977. /**
  62978. * Rebuilds the elements related to this component in case of
  62979. * context lost for instance.
  62980. */
  62981. rebuild(): void;
  62982. /**
  62983. * Disposes the component and the associated ressources
  62984. */
  62985. dispose(): void;
  62986. private _gatherRenderTargets;
  62987. }
  62988. }
  62989. declare module BABYLON {
  62990. /** @hidden */
  62991. export var motionBlurPixelShader: {
  62992. name: string;
  62993. shader: string;
  62994. };
  62995. }
  62996. declare module BABYLON {
  62997. /**
  62998. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62999. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63000. * As an example, all you have to do is to create the post-process:
  63001. * var mb = new BABYLON.MotionBlurPostProcess(
  63002. * 'mb', // The name of the effect.
  63003. * scene, // The scene containing the objects to blur according to their velocity.
  63004. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63005. * camera // The camera to apply the render pass to.
  63006. * );
  63007. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63008. */
  63009. export class MotionBlurPostProcess extends PostProcess {
  63010. /**
  63011. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63012. */
  63013. motionStrength: number;
  63014. /**
  63015. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63016. */
  63017. get motionBlurSamples(): number;
  63018. /**
  63019. * Sets the number of iterations to be used for motion blur quality
  63020. */
  63021. set motionBlurSamples(samples: number);
  63022. private _motionBlurSamples;
  63023. private _geometryBufferRenderer;
  63024. /**
  63025. * Creates a new instance MotionBlurPostProcess
  63026. * @param name The name of the effect.
  63027. * @param scene The scene containing the objects to blur according to their velocity.
  63028. * @param options The required width/height ratio to downsize to before computing the render pass.
  63029. * @param camera The camera to apply the render pass to.
  63030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63031. * @param engine The engine which the post process will be applied. (default: current engine)
  63032. * @param reusable If the post process can be reused on the same frame. (default: false)
  63033. * @param textureType Type of textures used when performing the post process. (default: 0)
  63034. * @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)
  63035. */
  63036. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63037. /**
  63038. * Excludes the given skinned mesh from computing bones velocities.
  63039. * 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.
  63040. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63041. */
  63042. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63043. /**
  63044. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63045. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63046. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63047. */
  63048. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63049. /**
  63050. * Disposes the post process.
  63051. * @param camera The camera to dispose the post process on.
  63052. */
  63053. dispose(camera?: Camera): void;
  63054. }
  63055. }
  63056. declare module BABYLON {
  63057. /** @hidden */
  63058. export var refractionPixelShader: {
  63059. name: string;
  63060. shader: string;
  63061. };
  63062. }
  63063. declare module BABYLON {
  63064. /**
  63065. * Post process which applies a refractin texture
  63066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63067. */
  63068. export class RefractionPostProcess extends PostProcess {
  63069. /** the base color of the refraction (used to taint the rendering) */
  63070. color: Color3;
  63071. /** simulated refraction depth */
  63072. depth: number;
  63073. /** the coefficient of the base color (0 to remove base color tainting) */
  63074. colorLevel: number;
  63075. private _refTexture;
  63076. private _ownRefractionTexture;
  63077. /**
  63078. * Gets or sets the refraction texture
  63079. * Please note that you are responsible for disposing the texture if you set it manually
  63080. */
  63081. get refractionTexture(): Texture;
  63082. set refractionTexture(value: Texture);
  63083. /**
  63084. * Initializes the RefractionPostProcess
  63085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63086. * @param name The name of the effect.
  63087. * @param refractionTextureUrl Url of the refraction texture to use
  63088. * @param color the base color of the refraction (used to taint the rendering)
  63089. * @param depth simulated refraction depth
  63090. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63091. * @param camera The camera to apply the render pass to.
  63092. * @param options The required width/height ratio to downsize to before computing the render pass.
  63093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63094. * @param engine The engine which the post process will be applied. (default: current engine)
  63095. * @param reusable If the post process can be reused on the same frame. (default: false)
  63096. */
  63097. constructor(name: string, refractionTextureUrl: string,
  63098. /** the base color of the refraction (used to taint the rendering) */
  63099. color: Color3,
  63100. /** simulated refraction depth */
  63101. depth: number,
  63102. /** the coefficient of the base color (0 to remove base color tainting) */
  63103. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63104. /**
  63105. * Disposes of the post process
  63106. * @param camera Camera to dispose post process on
  63107. */
  63108. dispose(camera: Camera): void;
  63109. }
  63110. }
  63111. declare module BABYLON {
  63112. /** @hidden */
  63113. export var sharpenPixelShader: {
  63114. name: string;
  63115. shader: string;
  63116. };
  63117. }
  63118. declare module BABYLON {
  63119. /**
  63120. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63121. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63122. */
  63123. export class SharpenPostProcess extends PostProcess {
  63124. /**
  63125. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63126. */
  63127. colorAmount: number;
  63128. /**
  63129. * How much sharpness should be applied (default: 0.3)
  63130. */
  63131. edgeAmount: number;
  63132. /**
  63133. * Creates a new instance ConvolutionPostProcess
  63134. * @param name The name of the effect.
  63135. * @param options The required width/height ratio to downsize to before computing the render pass.
  63136. * @param camera The camera to apply the render pass to.
  63137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63138. * @param engine The engine which the post process will be applied. (default: current engine)
  63139. * @param reusable If the post process can be reused on the same frame. (default: false)
  63140. * @param textureType Type of textures used when performing the post process. (default: 0)
  63141. * @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)
  63142. */
  63143. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63144. }
  63145. }
  63146. declare module BABYLON {
  63147. /**
  63148. * PostProcessRenderPipeline
  63149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63150. */
  63151. export class PostProcessRenderPipeline {
  63152. private engine;
  63153. private _renderEffects;
  63154. private _renderEffectsForIsolatedPass;
  63155. /**
  63156. * List of inspectable custom properties (used by the Inspector)
  63157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63158. */
  63159. inspectableCustomProperties: IInspectable[];
  63160. /**
  63161. * @hidden
  63162. */
  63163. protected _cameras: Camera[];
  63164. /** @hidden */
  63165. _name: string;
  63166. /**
  63167. * Gets pipeline name
  63168. */
  63169. get name(): string;
  63170. /** Gets the list of attached cameras */
  63171. get cameras(): Camera[];
  63172. /**
  63173. * Initializes a PostProcessRenderPipeline
  63174. * @param engine engine to add the pipeline to
  63175. * @param name name of the pipeline
  63176. */
  63177. constructor(engine: Engine, name: string);
  63178. /**
  63179. * Gets the class name
  63180. * @returns "PostProcessRenderPipeline"
  63181. */
  63182. getClassName(): string;
  63183. /**
  63184. * If all the render effects in the pipeline are supported
  63185. */
  63186. get isSupported(): boolean;
  63187. /**
  63188. * Adds an effect to the pipeline
  63189. * @param renderEffect the effect to add
  63190. */
  63191. addEffect(renderEffect: PostProcessRenderEffect): void;
  63192. /** @hidden */
  63193. _rebuild(): void;
  63194. /** @hidden */
  63195. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63196. /** @hidden */
  63197. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63198. /** @hidden */
  63199. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63200. /** @hidden */
  63201. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63202. /** @hidden */
  63203. _attachCameras(cameras: Camera, unique: boolean): void;
  63204. /** @hidden */
  63205. _attachCameras(cameras: Camera[], unique: boolean): void;
  63206. /** @hidden */
  63207. _detachCameras(cameras: Camera): void;
  63208. /** @hidden */
  63209. _detachCameras(cameras: Nullable<Camera[]>): void;
  63210. /** @hidden */
  63211. _update(): void;
  63212. /** @hidden */
  63213. _reset(): void;
  63214. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63215. /**
  63216. * Disposes of the pipeline
  63217. */
  63218. dispose(): void;
  63219. }
  63220. }
  63221. declare module BABYLON {
  63222. /**
  63223. * PostProcessRenderPipelineManager class
  63224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63225. */
  63226. export class PostProcessRenderPipelineManager {
  63227. private _renderPipelines;
  63228. /**
  63229. * Initializes a PostProcessRenderPipelineManager
  63230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63231. */
  63232. constructor();
  63233. /**
  63234. * Gets the list of supported render pipelines
  63235. */
  63236. get supportedPipelines(): PostProcessRenderPipeline[];
  63237. /**
  63238. * Adds a pipeline to the manager
  63239. * @param renderPipeline The pipeline to add
  63240. */
  63241. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63242. /**
  63243. * Attaches a camera to the pipeline
  63244. * @param renderPipelineName The name of the pipeline to attach to
  63245. * @param cameras the camera to attach
  63246. * @param unique if the camera can be attached multiple times to the pipeline
  63247. */
  63248. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63249. /**
  63250. * Detaches a camera from the pipeline
  63251. * @param renderPipelineName The name of the pipeline to detach from
  63252. * @param cameras the camera to detach
  63253. */
  63254. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63255. /**
  63256. * Enables an effect by name on a pipeline
  63257. * @param renderPipelineName the name of the pipeline to enable the effect in
  63258. * @param renderEffectName the name of the effect to enable
  63259. * @param cameras the cameras that the effect should be enabled on
  63260. */
  63261. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63262. /**
  63263. * Disables an effect by name on a pipeline
  63264. * @param renderPipelineName the name of the pipeline to disable the effect in
  63265. * @param renderEffectName the name of the effect to disable
  63266. * @param cameras the cameras that the effect should be disabled on
  63267. */
  63268. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63269. /**
  63270. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63271. */
  63272. update(): void;
  63273. /** @hidden */
  63274. _rebuild(): void;
  63275. /**
  63276. * Disposes of the manager and pipelines
  63277. */
  63278. dispose(): void;
  63279. }
  63280. }
  63281. declare module BABYLON {
  63282. interface Scene {
  63283. /** @hidden (Backing field) */
  63284. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63285. /**
  63286. * Gets the postprocess render pipeline manager
  63287. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63288. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63289. */
  63290. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63291. }
  63292. /**
  63293. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63294. */
  63295. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63296. /**
  63297. * The component name helpfull to identify the component in the list of scene components.
  63298. */
  63299. readonly name: string;
  63300. /**
  63301. * The scene the component belongs to.
  63302. */
  63303. scene: Scene;
  63304. /**
  63305. * Creates a new instance of the component for the given scene
  63306. * @param scene Defines the scene to register the component in
  63307. */
  63308. constructor(scene: Scene);
  63309. /**
  63310. * Registers the component in a given scene
  63311. */
  63312. register(): void;
  63313. /**
  63314. * Rebuilds the elements related to this component in case of
  63315. * context lost for instance.
  63316. */
  63317. rebuild(): void;
  63318. /**
  63319. * Disposes the component and the associated ressources
  63320. */
  63321. dispose(): void;
  63322. private _gatherRenderTargets;
  63323. }
  63324. }
  63325. declare module BABYLON {
  63326. /**
  63327. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63328. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63329. */
  63330. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63331. private _scene;
  63332. private _camerasToBeAttached;
  63333. /**
  63334. * ID of the sharpen post process,
  63335. */
  63336. private readonly SharpenPostProcessId;
  63337. /**
  63338. * @ignore
  63339. * ID of the image processing post process;
  63340. */
  63341. readonly ImageProcessingPostProcessId: string;
  63342. /**
  63343. * @ignore
  63344. * ID of the Fast Approximate Anti-Aliasing post process;
  63345. */
  63346. readonly FxaaPostProcessId: string;
  63347. /**
  63348. * ID of the chromatic aberration post process,
  63349. */
  63350. private readonly ChromaticAberrationPostProcessId;
  63351. /**
  63352. * ID of the grain post process
  63353. */
  63354. private readonly GrainPostProcessId;
  63355. /**
  63356. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63357. */
  63358. sharpen: SharpenPostProcess;
  63359. private _sharpenEffect;
  63360. private bloom;
  63361. /**
  63362. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63363. */
  63364. depthOfField: DepthOfFieldEffect;
  63365. /**
  63366. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63367. */
  63368. fxaa: FxaaPostProcess;
  63369. /**
  63370. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63371. */
  63372. imageProcessing: ImageProcessingPostProcess;
  63373. /**
  63374. * Chromatic aberration post process which will shift rgb colors in the image
  63375. */
  63376. chromaticAberration: ChromaticAberrationPostProcess;
  63377. private _chromaticAberrationEffect;
  63378. /**
  63379. * Grain post process which add noise to the image
  63380. */
  63381. grain: GrainPostProcess;
  63382. private _grainEffect;
  63383. /**
  63384. * Glow post process which adds a glow to emissive areas of the image
  63385. */
  63386. private _glowLayer;
  63387. /**
  63388. * Animations which can be used to tweak settings over a period of time
  63389. */
  63390. animations: Animation[];
  63391. private _imageProcessingConfigurationObserver;
  63392. private _sharpenEnabled;
  63393. private _bloomEnabled;
  63394. private _depthOfFieldEnabled;
  63395. private _depthOfFieldBlurLevel;
  63396. private _fxaaEnabled;
  63397. private _imageProcessingEnabled;
  63398. private _defaultPipelineTextureType;
  63399. private _bloomScale;
  63400. private _chromaticAberrationEnabled;
  63401. private _grainEnabled;
  63402. private _buildAllowed;
  63403. /**
  63404. * Gets active scene
  63405. */
  63406. get scene(): Scene;
  63407. /**
  63408. * Enable or disable the sharpen process from the pipeline
  63409. */
  63410. set sharpenEnabled(enabled: boolean);
  63411. get sharpenEnabled(): boolean;
  63412. private _resizeObserver;
  63413. private _hardwareScaleLevel;
  63414. private _bloomKernel;
  63415. /**
  63416. * Specifies the size of the bloom blur kernel, relative to the final output size
  63417. */
  63418. get bloomKernel(): number;
  63419. set bloomKernel(value: number);
  63420. /**
  63421. * Specifies the weight of the bloom in the final rendering
  63422. */
  63423. private _bloomWeight;
  63424. /**
  63425. * Specifies the luma threshold for the area that will be blurred by the bloom
  63426. */
  63427. private _bloomThreshold;
  63428. private _hdr;
  63429. /**
  63430. * The strength of the bloom.
  63431. */
  63432. set bloomWeight(value: number);
  63433. get bloomWeight(): number;
  63434. /**
  63435. * The strength of the bloom.
  63436. */
  63437. set bloomThreshold(value: number);
  63438. get bloomThreshold(): number;
  63439. /**
  63440. * The scale of the bloom, lower value will provide better performance.
  63441. */
  63442. set bloomScale(value: number);
  63443. get bloomScale(): number;
  63444. /**
  63445. * Enable or disable the bloom from the pipeline
  63446. */
  63447. set bloomEnabled(enabled: boolean);
  63448. get bloomEnabled(): boolean;
  63449. private _rebuildBloom;
  63450. /**
  63451. * If the depth of field is enabled.
  63452. */
  63453. get depthOfFieldEnabled(): boolean;
  63454. set depthOfFieldEnabled(enabled: boolean);
  63455. /**
  63456. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63457. */
  63458. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  63459. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  63460. /**
  63461. * If the anti aliasing is enabled.
  63462. */
  63463. set fxaaEnabled(enabled: boolean);
  63464. get fxaaEnabled(): boolean;
  63465. private _samples;
  63466. /**
  63467. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63468. */
  63469. set samples(sampleCount: number);
  63470. get samples(): number;
  63471. /**
  63472. * If image processing is enabled.
  63473. */
  63474. set imageProcessingEnabled(enabled: boolean);
  63475. get imageProcessingEnabled(): boolean;
  63476. /**
  63477. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63478. */
  63479. set glowLayerEnabled(enabled: boolean);
  63480. get glowLayerEnabled(): boolean;
  63481. /**
  63482. * Gets the glow layer (or null if not defined)
  63483. */
  63484. get glowLayer(): Nullable<GlowLayer>;
  63485. /**
  63486. * Enable or disable the chromaticAberration process from the pipeline
  63487. */
  63488. set chromaticAberrationEnabled(enabled: boolean);
  63489. get chromaticAberrationEnabled(): boolean;
  63490. /**
  63491. * Enable or disable the grain process from the pipeline
  63492. */
  63493. set grainEnabled(enabled: boolean);
  63494. get grainEnabled(): boolean;
  63495. /**
  63496. * @constructor
  63497. * @param name - The rendering pipeline name (default: "")
  63498. * @param hdr - If high dynamic range textures should be used (default: true)
  63499. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63500. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63501. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63502. */
  63503. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63504. /**
  63505. * Get the class name
  63506. * @returns "DefaultRenderingPipeline"
  63507. */
  63508. getClassName(): string;
  63509. /**
  63510. * Force the compilation of the entire pipeline.
  63511. */
  63512. prepare(): void;
  63513. private _hasCleared;
  63514. private _prevPostProcess;
  63515. private _prevPrevPostProcess;
  63516. private _setAutoClearAndTextureSharing;
  63517. private _depthOfFieldSceneObserver;
  63518. private _buildPipeline;
  63519. private _disposePostProcesses;
  63520. /**
  63521. * Adds a camera to the pipeline
  63522. * @param camera the camera to be added
  63523. */
  63524. addCamera(camera: Camera): void;
  63525. /**
  63526. * Removes a camera from the pipeline
  63527. * @param camera the camera to remove
  63528. */
  63529. removeCamera(camera: Camera): void;
  63530. /**
  63531. * Dispose of the pipeline and stop all post processes
  63532. */
  63533. dispose(): void;
  63534. /**
  63535. * Serialize the rendering pipeline (Used when exporting)
  63536. * @returns the serialized object
  63537. */
  63538. serialize(): any;
  63539. /**
  63540. * Parse the serialized pipeline
  63541. * @param source Source pipeline.
  63542. * @param scene The scene to load the pipeline to.
  63543. * @param rootUrl The URL of the serialized pipeline.
  63544. * @returns An instantiated pipeline from the serialized object.
  63545. */
  63546. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63547. }
  63548. }
  63549. declare module BABYLON {
  63550. /** @hidden */
  63551. export var lensHighlightsPixelShader: {
  63552. name: string;
  63553. shader: string;
  63554. };
  63555. }
  63556. declare module BABYLON {
  63557. /** @hidden */
  63558. export var depthOfFieldPixelShader: {
  63559. name: string;
  63560. shader: string;
  63561. };
  63562. }
  63563. declare module BABYLON {
  63564. /**
  63565. * BABYLON.JS Chromatic Aberration GLSL Shader
  63566. * Author: Olivier Guyot
  63567. * Separates very slightly R, G and B colors on the edges of the screen
  63568. * Inspired by Francois Tarlier & Martins Upitis
  63569. */
  63570. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63571. /**
  63572. * @ignore
  63573. * The chromatic aberration PostProcess id in the pipeline
  63574. */
  63575. LensChromaticAberrationEffect: string;
  63576. /**
  63577. * @ignore
  63578. * The highlights enhancing PostProcess id in the pipeline
  63579. */
  63580. HighlightsEnhancingEffect: string;
  63581. /**
  63582. * @ignore
  63583. * The depth-of-field PostProcess id in the pipeline
  63584. */
  63585. LensDepthOfFieldEffect: string;
  63586. private _scene;
  63587. private _depthTexture;
  63588. private _grainTexture;
  63589. private _chromaticAberrationPostProcess;
  63590. private _highlightsPostProcess;
  63591. private _depthOfFieldPostProcess;
  63592. private _edgeBlur;
  63593. private _grainAmount;
  63594. private _chromaticAberration;
  63595. private _distortion;
  63596. private _highlightsGain;
  63597. private _highlightsThreshold;
  63598. private _dofDistance;
  63599. private _dofAperture;
  63600. private _dofDarken;
  63601. private _dofPentagon;
  63602. private _blurNoise;
  63603. /**
  63604. * @constructor
  63605. *
  63606. * Effect parameters are as follow:
  63607. * {
  63608. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63609. * edge_blur: number; // from 0 to x (1 for realism)
  63610. * distortion: number; // from 0 to x (1 for realism)
  63611. * grain_amount: number; // from 0 to 1
  63612. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63613. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63614. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63615. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63616. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63617. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63618. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63619. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63620. * }
  63621. * Note: if an effect parameter is unset, effect is disabled
  63622. *
  63623. * @param name The rendering pipeline name
  63624. * @param parameters - An object containing all parameters (see above)
  63625. * @param scene The scene linked to this pipeline
  63626. * @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)
  63627. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63628. */
  63629. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63630. /**
  63631. * Get the class name
  63632. * @returns "LensRenderingPipeline"
  63633. */
  63634. getClassName(): string;
  63635. /**
  63636. * Gets associated scene
  63637. */
  63638. get scene(): Scene;
  63639. /**
  63640. * Gets or sets the edge blur
  63641. */
  63642. get edgeBlur(): number;
  63643. set edgeBlur(value: number);
  63644. /**
  63645. * Gets or sets the grain amount
  63646. */
  63647. get grainAmount(): number;
  63648. set grainAmount(value: number);
  63649. /**
  63650. * Gets or sets the chromatic aberration amount
  63651. */
  63652. get chromaticAberration(): number;
  63653. set chromaticAberration(value: number);
  63654. /**
  63655. * Gets or sets the depth of field aperture
  63656. */
  63657. get dofAperture(): number;
  63658. set dofAperture(value: number);
  63659. /**
  63660. * Gets or sets the edge distortion
  63661. */
  63662. get edgeDistortion(): number;
  63663. set edgeDistortion(value: number);
  63664. /**
  63665. * Gets or sets the depth of field distortion
  63666. */
  63667. get dofDistortion(): number;
  63668. set dofDistortion(value: number);
  63669. /**
  63670. * Gets or sets the darken out of focus amount
  63671. */
  63672. get darkenOutOfFocus(): number;
  63673. set darkenOutOfFocus(value: number);
  63674. /**
  63675. * Gets or sets a boolean indicating if blur noise is enabled
  63676. */
  63677. get blurNoise(): boolean;
  63678. set blurNoise(value: boolean);
  63679. /**
  63680. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63681. */
  63682. get pentagonBokeh(): boolean;
  63683. set pentagonBokeh(value: boolean);
  63684. /**
  63685. * Gets or sets the highlight grain amount
  63686. */
  63687. get highlightsGain(): number;
  63688. set highlightsGain(value: number);
  63689. /**
  63690. * Gets or sets the highlight threshold
  63691. */
  63692. get highlightsThreshold(): number;
  63693. set highlightsThreshold(value: number);
  63694. /**
  63695. * Sets the amount of blur at the edges
  63696. * @param amount blur amount
  63697. */
  63698. setEdgeBlur(amount: number): void;
  63699. /**
  63700. * Sets edge blur to 0
  63701. */
  63702. disableEdgeBlur(): void;
  63703. /**
  63704. * Sets the amout of grain
  63705. * @param amount Amount of grain
  63706. */
  63707. setGrainAmount(amount: number): void;
  63708. /**
  63709. * Set grain amount to 0
  63710. */
  63711. disableGrain(): void;
  63712. /**
  63713. * Sets the chromatic aberration amount
  63714. * @param amount amount of chromatic aberration
  63715. */
  63716. setChromaticAberration(amount: number): void;
  63717. /**
  63718. * Sets chromatic aberration amount to 0
  63719. */
  63720. disableChromaticAberration(): void;
  63721. /**
  63722. * Sets the EdgeDistortion amount
  63723. * @param amount amount of EdgeDistortion
  63724. */
  63725. setEdgeDistortion(amount: number): void;
  63726. /**
  63727. * Sets edge distortion to 0
  63728. */
  63729. disableEdgeDistortion(): void;
  63730. /**
  63731. * Sets the FocusDistance amount
  63732. * @param amount amount of FocusDistance
  63733. */
  63734. setFocusDistance(amount: number): void;
  63735. /**
  63736. * Disables depth of field
  63737. */
  63738. disableDepthOfField(): void;
  63739. /**
  63740. * Sets the Aperture amount
  63741. * @param amount amount of Aperture
  63742. */
  63743. setAperture(amount: number): void;
  63744. /**
  63745. * Sets the DarkenOutOfFocus amount
  63746. * @param amount amount of DarkenOutOfFocus
  63747. */
  63748. setDarkenOutOfFocus(amount: number): void;
  63749. private _pentagonBokehIsEnabled;
  63750. /**
  63751. * Creates a pentagon bokeh effect
  63752. */
  63753. enablePentagonBokeh(): void;
  63754. /**
  63755. * Disables the pentagon bokeh effect
  63756. */
  63757. disablePentagonBokeh(): void;
  63758. /**
  63759. * Enables noise blur
  63760. */
  63761. enableNoiseBlur(): void;
  63762. /**
  63763. * Disables noise blur
  63764. */
  63765. disableNoiseBlur(): void;
  63766. /**
  63767. * Sets the HighlightsGain amount
  63768. * @param amount amount of HighlightsGain
  63769. */
  63770. setHighlightsGain(amount: number): void;
  63771. /**
  63772. * Sets the HighlightsThreshold amount
  63773. * @param amount amount of HighlightsThreshold
  63774. */
  63775. setHighlightsThreshold(amount: number): void;
  63776. /**
  63777. * Disables highlights
  63778. */
  63779. disableHighlights(): void;
  63780. /**
  63781. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63782. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63783. */
  63784. dispose(disableDepthRender?: boolean): void;
  63785. private _createChromaticAberrationPostProcess;
  63786. private _createHighlightsPostProcess;
  63787. private _createDepthOfFieldPostProcess;
  63788. private _createGrainTexture;
  63789. }
  63790. }
  63791. declare module BABYLON {
  63792. /** @hidden */
  63793. export var ssao2PixelShader: {
  63794. name: string;
  63795. shader: string;
  63796. };
  63797. }
  63798. declare module BABYLON {
  63799. /** @hidden */
  63800. export var ssaoCombinePixelShader: {
  63801. name: string;
  63802. shader: string;
  63803. };
  63804. }
  63805. declare module BABYLON {
  63806. /**
  63807. * Render pipeline to produce ssao effect
  63808. */
  63809. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63810. /**
  63811. * @ignore
  63812. * The PassPostProcess id in the pipeline that contains the original scene color
  63813. */
  63814. SSAOOriginalSceneColorEffect: string;
  63815. /**
  63816. * @ignore
  63817. * The SSAO PostProcess id in the pipeline
  63818. */
  63819. SSAORenderEffect: string;
  63820. /**
  63821. * @ignore
  63822. * The horizontal blur PostProcess id in the pipeline
  63823. */
  63824. SSAOBlurHRenderEffect: string;
  63825. /**
  63826. * @ignore
  63827. * The vertical blur PostProcess id in the pipeline
  63828. */
  63829. SSAOBlurVRenderEffect: string;
  63830. /**
  63831. * @ignore
  63832. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63833. */
  63834. SSAOCombineRenderEffect: string;
  63835. /**
  63836. * The output strength of the SSAO post-process. Default value is 1.0.
  63837. */
  63838. totalStrength: number;
  63839. /**
  63840. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63841. */
  63842. maxZ: number;
  63843. /**
  63844. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63845. */
  63846. minZAspect: number;
  63847. private _samples;
  63848. /**
  63849. * Number of samples used for the SSAO calculations. Default value is 8
  63850. */
  63851. set samples(n: number);
  63852. get samples(): number;
  63853. private _textureSamples;
  63854. /**
  63855. * Number of samples to use for antialiasing
  63856. */
  63857. set textureSamples(n: number);
  63858. get textureSamples(): number;
  63859. /**
  63860. * Ratio object used for SSAO ratio and blur ratio
  63861. */
  63862. private _ratio;
  63863. /**
  63864. * Dynamically generated sphere sampler.
  63865. */
  63866. private _sampleSphere;
  63867. /**
  63868. * Blur filter offsets
  63869. */
  63870. private _samplerOffsets;
  63871. private _expensiveBlur;
  63872. /**
  63873. * If bilateral blur should be used
  63874. */
  63875. set expensiveBlur(b: boolean);
  63876. get expensiveBlur(): boolean;
  63877. /**
  63878. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63879. */
  63880. radius: number;
  63881. /**
  63882. * The base color of the SSAO post-process
  63883. * The final result is "base + ssao" between [0, 1]
  63884. */
  63885. base: number;
  63886. /**
  63887. * Support test.
  63888. */
  63889. static get IsSupported(): boolean;
  63890. private _scene;
  63891. private _depthTexture;
  63892. private _normalTexture;
  63893. private _randomTexture;
  63894. private _originalColorPostProcess;
  63895. private _ssaoPostProcess;
  63896. private _blurHPostProcess;
  63897. private _blurVPostProcess;
  63898. private _ssaoCombinePostProcess;
  63899. /**
  63900. * Gets active scene
  63901. */
  63902. get scene(): Scene;
  63903. /**
  63904. * @constructor
  63905. * @param name The rendering pipeline name
  63906. * @param scene The scene linked to this pipeline
  63907. * @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 }
  63908. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63909. */
  63910. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63911. /**
  63912. * Get the class name
  63913. * @returns "SSAO2RenderingPipeline"
  63914. */
  63915. getClassName(): string;
  63916. /**
  63917. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63918. */
  63919. dispose(disableGeometryBufferRenderer?: boolean): void;
  63920. private _createBlurPostProcess;
  63921. /** @hidden */
  63922. _rebuild(): void;
  63923. private _bits;
  63924. private _radicalInverse_VdC;
  63925. private _hammersley;
  63926. private _hemisphereSample_uniform;
  63927. private _generateHemisphere;
  63928. private _createSSAOPostProcess;
  63929. private _createSSAOCombinePostProcess;
  63930. private _createRandomTexture;
  63931. /**
  63932. * Serialize the rendering pipeline (Used when exporting)
  63933. * @returns the serialized object
  63934. */
  63935. serialize(): any;
  63936. /**
  63937. * Parse the serialized pipeline
  63938. * @param source Source pipeline.
  63939. * @param scene The scene to load the pipeline to.
  63940. * @param rootUrl The URL of the serialized pipeline.
  63941. * @returns An instantiated pipeline from the serialized object.
  63942. */
  63943. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63944. }
  63945. }
  63946. declare module BABYLON {
  63947. /** @hidden */
  63948. export var ssaoPixelShader: {
  63949. name: string;
  63950. shader: string;
  63951. };
  63952. }
  63953. declare module BABYLON {
  63954. /**
  63955. * Render pipeline to produce ssao effect
  63956. */
  63957. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63958. /**
  63959. * @ignore
  63960. * The PassPostProcess id in the pipeline that contains the original scene color
  63961. */
  63962. SSAOOriginalSceneColorEffect: string;
  63963. /**
  63964. * @ignore
  63965. * The SSAO PostProcess id in the pipeline
  63966. */
  63967. SSAORenderEffect: string;
  63968. /**
  63969. * @ignore
  63970. * The horizontal blur PostProcess id in the pipeline
  63971. */
  63972. SSAOBlurHRenderEffect: string;
  63973. /**
  63974. * @ignore
  63975. * The vertical blur PostProcess id in the pipeline
  63976. */
  63977. SSAOBlurVRenderEffect: string;
  63978. /**
  63979. * @ignore
  63980. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63981. */
  63982. SSAOCombineRenderEffect: string;
  63983. /**
  63984. * The output strength of the SSAO post-process. Default value is 1.0.
  63985. */
  63986. totalStrength: number;
  63987. /**
  63988. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63989. */
  63990. radius: number;
  63991. /**
  63992. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63993. * Must not be equal to fallOff and superior to fallOff.
  63994. * Default value is 0.0075
  63995. */
  63996. area: number;
  63997. /**
  63998. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63999. * Must not be equal to area and inferior to area.
  64000. * Default value is 0.000001
  64001. */
  64002. fallOff: number;
  64003. /**
  64004. * The base color of the SSAO post-process
  64005. * The final result is "base + ssao" between [0, 1]
  64006. */
  64007. base: number;
  64008. private _scene;
  64009. private _depthTexture;
  64010. private _randomTexture;
  64011. private _originalColorPostProcess;
  64012. private _ssaoPostProcess;
  64013. private _blurHPostProcess;
  64014. private _blurVPostProcess;
  64015. private _ssaoCombinePostProcess;
  64016. private _firstUpdate;
  64017. /**
  64018. * Gets active scene
  64019. */
  64020. get scene(): Scene;
  64021. /**
  64022. * @constructor
  64023. * @param name - The rendering pipeline name
  64024. * @param scene - The scene linked to this pipeline
  64025. * @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 }
  64026. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64027. */
  64028. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64029. /**
  64030. * Get the class name
  64031. * @returns "SSAORenderingPipeline"
  64032. */
  64033. getClassName(): string;
  64034. /**
  64035. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64036. */
  64037. dispose(disableDepthRender?: boolean): void;
  64038. private _createBlurPostProcess;
  64039. /** @hidden */
  64040. _rebuild(): void;
  64041. private _createSSAOPostProcess;
  64042. private _createSSAOCombinePostProcess;
  64043. private _createRandomTexture;
  64044. }
  64045. }
  64046. declare module BABYLON {
  64047. /** @hidden */
  64048. export var standardPixelShader: {
  64049. name: string;
  64050. shader: string;
  64051. };
  64052. }
  64053. declare module BABYLON {
  64054. /**
  64055. * Standard rendering pipeline
  64056. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64057. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64058. */
  64059. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64060. /**
  64061. * Public members
  64062. */
  64063. /**
  64064. * Post-process which contains the original scene color before the pipeline applies all the effects
  64065. */
  64066. originalPostProcess: Nullable<PostProcess>;
  64067. /**
  64068. * Post-process used to down scale an image x4
  64069. */
  64070. downSampleX4PostProcess: Nullable<PostProcess>;
  64071. /**
  64072. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64073. */
  64074. brightPassPostProcess: Nullable<PostProcess>;
  64075. /**
  64076. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64077. */
  64078. blurHPostProcesses: PostProcess[];
  64079. /**
  64080. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64081. */
  64082. blurVPostProcesses: PostProcess[];
  64083. /**
  64084. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64085. */
  64086. textureAdderPostProcess: Nullable<PostProcess>;
  64087. /**
  64088. * Post-process used to create volumetric lighting effect
  64089. */
  64090. volumetricLightPostProcess: Nullable<PostProcess>;
  64091. /**
  64092. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64093. */
  64094. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64095. /**
  64096. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64097. */
  64098. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64099. /**
  64100. * Post-process used to merge the volumetric light effect and the real scene color
  64101. */
  64102. volumetricLightMergePostProces: Nullable<PostProcess>;
  64103. /**
  64104. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64105. */
  64106. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64107. /**
  64108. * Base post-process used to calculate the average luminance of the final image for HDR
  64109. */
  64110. luminancePostProcess: Nullable<PostProcess>;
  64111. /**
  64112. * Post-processes used to create down sample post-processes in order to get
  64113. * the average luminance of the final image for HDR
  64114. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64115. */
  64116. luminanceDownSamplePostProcesses: PostProcess[];
  64117. /**
  64118. * Post-process used to create a HDR effect (light adaptation)
  64119. */
  64120. hdrPostProcess: Nullable<PostProcess>;
  64121. /**
  64122. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64123. */
  64124. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64125. /**
  64126. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64127. */
  64128. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64129. /**
  64130. * Post-process used to merge the final HDR post-process and the real scene color
  64131. */
  64132. hdrFinalPostProcess: Nullable<PostProcess>;
  64133. /**
  64134. * Post-process used to create a lens flare effect
  64135. */
  64136. lensFlarePostProcess: Nullable<PostProcess>;
  64137. /**
  64138. * Post-process that merges the result of the lens flare post-process and the real scene color
  64139. */
  64140. lensFlareComposePostProcess: Nullable<PostProcess>;
  64141. /**
  64142. * Post-process used to create a motion blur effect
  64143. */
  64144. motionBlurPostProcess: Nullable<PostProcess>;
  64145. /**
  64146. * Post-process used to create a depth of field effect
  64147. */
  64148. depthOfFieldPostProcess: Nullable<PostProcess>;
  64149. /**
  64150. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64151. */
  64152. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64153. /**
  64154. * Represents the brightness threshold in order to configure the illuminated surfaces
  64155. */
  64156. brightThreshold: number;
  64157. /**
  64158. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64159. */
  64160. blurWidth: number;
  64161. /**
  64162. * Sets if the blur for highlighted surfaces must be only horizontal
  64163. */
  64164. horizontalBlur: boolean;
  64165. /**
  64166. * Gets the overall exposure used by the pipeline
  64167. */
  64168. get exposure(): number;
  64169. /**
  64170. * Sets the overall exposure used by the pipeline
  64171. */
  64172. set exposure(value: number);
  64173. /**
  64174. * Texture used typically to simulate "dirty" on camera lens
  64175. */
  64176. lensTexture: Nullable<Texture>;
  64177. /**
  64178. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64179. */
  64180. volumetricLightCoefficient: number;
  64181. /**
  64182. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64183. */
  64184. volumetricLightPower: number;
  64185. /**
  64186. * Used the set the blur intensity to smooth the volumetric lights
  64187. */
  64188. volumetricLightBlurScale: number;
  64189. /**
  64190. * Light (spot or directional) used to generate the volumetric lights rays
  64191. * The source light must have a shadow generate so the pipeline can get its
  64192. * depth map
  64193. */
  64194. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64195. /**
  64196. * For eye adaptation, represents the minimum luminance the eye can see
  64197. */
  64198. hdrMinimumLuminance: number;
  64199. /**
  64200. * For eye adaptation, represents the decrease luminance speed
  64201. */
  64202. hdrDecreaseRate: number;
  64203. /**
  64204. * For eye adaptation, represents the increase luminance speed
  64205. */
  64206. hdrIncreaseRate: number;
  64207. /**
  64208. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64209. */
  64210. get hdrAutoExposure(): boolean;
  64211. /**
  64212. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64213. */
  64214. set hdrAutoExposure(value: boolean);
  64215. /**
  64216. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64217. */
  64218. lensColorTexture: Nullable<Texture>;
  64219. /**
  64220. * The overall strengh for the lens flare effect
  64221. */
  64222. lensFlareStrength: number;
  64223. /**
  64224. * Dispersion coefficient for lens flare ghosts
  64225. */
  64226. lensFlareGhostDispersal: number;
  64227. /**
  64228. * Main lens flare halo width
  64229. */
  64230. lensFlareHaloWidth: number;
  64231. /**
  64232. * Based on the lens distortion effect, defines how much the lens flare result
  64233. * is distorted
  64234. */
  64235. lensFlareDistortionStrength: number;
  64236. /**
  64237. * Configures the blur intensity used for for lens flare (halo)
  64238. */
  64239. lensFlareBlurWidth: number;
  64240. /**
  64241. * Lens star texture must be used to simulate rays on the flares and is available
  64242. * in the documentation
  64243. */
  64244. lensStarTexture: Nullable<Texture>;
  64245. /**
  64246. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64247. * flare effect by taking account of the dirt texture
  64248. */
  64249. lensFlareDirtTexture: Nullable<Texture>;
  64250. /**
  64251. * Represents the focal length for the depth of field effect
  64252. */
  64253. depthOfFieldDistance: number;
  64254. /**
  64255. * Represents the blur intensity for the blurred part of the depth of field effect
  64256. */
  64257. depthOfFieldBlurWidth: number;
  64258. /**
  64259. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64260. */
  64261. get motionStrength(): number;
  64262. /**
  64263. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64264. */
  64265. set motionStrength(strength: number);
  64266. /**
  64267. * Gets wether or not the motion blur post-process is object based or screen based.
  64268. */
  64269. get objectBasedMotionBlur(): boolean;
  64270. /**
  64271. * Sets wether or not the motion blur post-process should be object based or screen based
  64272. */
  64273. set objectBasedMotionBlur(value: boolean);
  64274. /**
  64275. * List of animations for the pipeline (IAnimatable implementation)
  64276. */
  64277. animations: Animation[];
  64278. /**
  64279. * Private members
  64280. */
  64281. private _scene;
  64282. private _currentDepthOfFieldSource;
  64283. private _basePostProcess;
  64284. private _fixedExposure;
  64285. private _currentExposure;
  64286. private _hdrAutoExposure;
  64287. private _hdrCurrentLuminance;
  64288. private _motionStrength;
  64289. private _isObjectBasedMotionBlur;
  64290. private _floatTextureType;
  64291. private _camerasToBeAttached;
  64292. private _ratio;
  64293. private _bloomEnabled;
  64294. private _depthOfFieldEnabled;
  64295. private _vlsEnabled;
  64296. private _lensFlareEnabled;
  64297. private _hdrEnabled;
  64298. private _motionBlurEnabled;
  64299. private _fxaaEnabled;
  64300. private _motionBlurSamples;
  64301. private _volumetricLightStepsCount;
  64302. private _samples;
  64303. /**
  64304. * @ignore
  64305. * Specifies if the bloom pipeline is enabled
  64306. */
  64307. get BloomEnabled(): boolean;
  64308. set BloomEnabled(enabled: boolean);
  64309. /**
  64310. * @ignore
  64311. * Specifies if the depth of field pipeline is enabed
  64312. */
  64313. get DepthOfFieldEnabled(): boolean;
  64314. set DepthOfFieldEnabled(enabled: boolean);
  64315. /**
  64316. * @ignore
  64317. * Specifies if the lens flare pipeline is enabed
  64318. */
  64319. get LensFlareEnabled(): boolean;
  64320. set LensFlareEnabled(enabled: boolean);
  64321. /**
  64322. * @ignore
  64323. * Specifies if the HDR pipeline is enabled
  64324. */
  64325. get HDREnabled(): boolean;
  64326. set HDREnabled(enabled: boolean);
  64327. /**
  64328. * @ignore
  64329. * Specifies if the volumetric lights scattering effect is enabled
  64330. */
  64331. get VLSEnabled(): boolean;
  64332. set VLSEnabled(enabled: boolean);
  64333. /**
  64334. * @ignore
  64335. * Specifies if the motion blur effect is enabled
  64336. */
  64337. get MotionBlurEnabled(): boolean;
  64338. set MotionBlurEnabled(enabled: boolean);
  64339. /**
  64340. * Specifies if anti-aliasing is enabled
  64341. */
  64342. get fxaaEnabled(): boolean;
  64343. set fxaaEnabled(enabled: boolean);
  64344. /**
  64345. * Specifies the number of steps used to calculate the volumetric lights
  64346. * Typically in interval [50, 200]
  64347. */
  64348. get volumetricLightStepsCount(): number;
  64349. set volumetricLightStepsCount(count: number);
  64350. /**
  64351. * Specifies the number of samples used for the motion blur effect
  64352. * Typically in interval [16, 64]
  64353. */
  64354. get motionBlurSamples(): number;
  64355. set motionBlurSamples(samples: number);
  64356. /**
  64357. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64358. */
  64359. get samples(): number;
  64360. set samples(sampleCount: number);
  64361. /**
  64362. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64363. * @constructor
  64364. * @param name The rendering pipeline name
  64365. * @param scene The scene linked to this pipeline
  64366. * @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)
  64367. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64368. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64369. */
  64370. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64371. private _buildPipeline;
  64372. private _createDownSampleX4PostProcess;
  64373. private _createBrightPassPostProcess;
  64374. private _createBlurPostProcesses;
  64375. private _createTextureAdderPostProcess;
  64376. private _createVolumetricLightPostProcess;
  64377. private _createLuminancePostProcesses;
  64378. private _createHdrPostProcess;
  64379. private _createLensFlarePostProcess;
  64380. private _createDepthOfFieldPostProcess;
  64381. private _createMotionBlurPostProcess;
  64382. private _getDepthTexture;
  64383. private _disposePostProcesses;
  64384. /**
  64385. * Dispose of the pipeline and stop all post processes
  64386. */
  64387. dispose(): void;
  64388. /**
  64389. * Serialize the rendering pipeline (Used when exporting)
  64390. * @returns the serialized object
  64391. */
  64392. serialize(): any;
  64393. /**
  64394. * Parse the serialized pipeline
  64395. * @param source Source pipeline.
  64396. * @param scene The scene to load the pipeline to.
  64397. * @param rootUrl The URL of the serialized pipeline.
  64398. * @returns An instantiated pipeline from the serialized object.
  64399. */
  64400. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64401. /**
  64402. * Luminance steps
  64403. */
  64404. static LuminanceSteps: number;
  64405. }
  64406. }
  64407. declare module BABYLON {
  64408. /** @hidden */
  64409. export var tonemapPixelShader: {
  64410. name: string;
  64411. shader: string;
  64412. };
  64413. }
  64414. declare module BABYLON {
  64415. /** Defines operator used for tonemapping */
  64416. export enum TonemappingOperator {
  64417. /** Hable */
  64418. Hable = 0,
  64419. /** Reinhard */
  64420. Reinhard = 1,
  64421. /** HejiDawson */
  64422. HejiDawson = 2,
  64423. /** Photographic */
  64424. Photographic = 3
  64425. }
  64426. /**
  64427. * Defines a post process to apply tone mapping
  64428. */
  64429. export class TonemapPostProcess extends PostProcess {
  64430. private _operator;
  64431. /** Defines the required exposure adjustement */
  64432. exposureAdjustment: number;
  64433. /**
  64434. * Creates a new TonemapPostProcess
  64435. * @param name defines the name of the postprocess
  64436. * @param _operator defines the operator to use
  64437. * @param exposureAdjustment defines the required exposure adjustement
  64438. * @param camera defines the camera to use (can be null)
  64439. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64440. * @param engine defines the hosting engine (can be ignore if camera is set)
  64441. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64442. */
  64443. constructor(name: string, _operator: TonemappingOperator,
  64444. /** Defines the required exposure adjustement */
  64445. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64446. }
  64447. }
  64448. declare module BABYLON {
  64449. /** @hidden */
  64450. export var depthVertexShader: {
  64451. name: string;
  64452. shader: string;
  64453. };
  64454. }
  64455. declare module BABYLON {
  64456. /** @hidden */
  64457. export var volumetricLightScatteringPixelShader: {
  64458. name: string;
  64459. shader: string;
  64460. };
  64461. }
  64462. declare module BABYLON {
  64463. /** @hidden */
  64464. export var volumetricLightScatteringPassVertexShader: {
  64465. name: string;
  64466. shader: string;
  64467. };
  64468. }
  64469. declare module BABYLON {
  64470. /** @hidden */
  64471. export var volumetricLightScatteringPassPixelShader: {
  64472. name: string;
  64473. shader: string;
  64474. };
  64475. }
  64476. declare module BABYLON {
  64477. /**
  64478. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64479. */
  64480. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64481. private _volumetricLightScatteringPass;
  64482. private _volumetricLightScatteringRTT;
  64483. private _viewPort;
  64484. private _screenCoordinates;
  64485. private _cachedDefines;
  64486. /**
  64487. * If not undefined, the mesh position is computed from the attached node position
  64488. */
  64489. attachedNode: {
  64490. position: Vector3;
  64491. };
  64492. /**
  64493. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64494. */
  64495. customMeshPosition: Vector3;
  64496. /**
  64497. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64498. */
  64499. useCustomMeshPosition: boolean;
  64500. /**
  64501. * If the post-process should inverse the light scattering direction
  64502. */
  64503. invert: boolean;
  64504. /**
  64505. * The internal mesh used by the post-process
  64506. */
  64507. mesh: Mesh;
  64508. /**
  64509. * @hidden
  64510. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64511. */
  64512. get useDiffuseColor(): boolean;
  64513. set useDiffuseColor(useDiffuseColor: boolean);
  64514. /**
  64515. * Array containing the excluded meshes not rendered in the internal pass
  64516. */
  64517. excludedMeshes: AbstractMesh[];
  64518. /**
  64519. * Controls the overall intensity of the post-process
  64520. */
  64521. exposure: number;
  64522. /**
  64523. * Dissipates each sample's contribution in range [0, 1]
  64524. */
  64525. decay: number;
  64526. /**
  64527. * Controls the overall intensity of each sample
  64528. */
  64529. weight: number;
  64530. /**
  64531. * Controls the density of each sample
  64532. */
  64533. density: number;
  64534. /**
  64535. * @constructor
  64536. * @param name The post-process name
  64537. * @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)
  64538. * @param camera The camera that the post-process will be attached to
  64539. * @param mesh The mesh used to create the light scattering
  64540. * @param samples The post-process quality, default 100
  64541. * @param samplingModeThe post-process filtering mode
  64542. * @param engine The babylon engine
  64543. * @param reusable If the post-process is reusable
  64544. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64545. */
  64546. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64547. /**
  64548. * Returns the string "VolumetricLightScatteringPostProcess"
  64549. * @returns "VolumetricLightScatteringPostProcess"
  64550. */
  64551. getClassName(): string;
  64552. private _isReady;
  64553. /**
  64554. * Sets the new light position for light scattering effect
  64555. * @param position The new custom light position
  64556. */
  64557. setCustomMeshPosition(position: Vector3): void;
  64558. /**
  64559. * Returns the light position for light scattering effect
  64560. * @return Vector3 The custom light position
  64561. */
  64562. getCustomMeshPosition(): Vector3;
  64563. /**
  64564. * Disposes the internal assets and detaches the post-process from the camera
  64565. */
  64566. dispose(camera: Camera): void;
  64567. /**
  64568. * Returns the render target texture used by the post-process
  64569. * @return the render target texture used by the post-process
  64570. */
  64571. getPass(): RenderTargetTexture;
  64572. private _meshExcluded;
  64573. private _createPass;
  64574. private _updateMeshScreenCoordinates;
  64575. /**
  64576. * Creates a default mesh for the Volumeric Light Scattering post-process
  64577. * @param name The mesh name
  64578. * @param scene The scene where to create the mesh
  64579. * @return the default mesh
  64580. */
  64581. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64582. }
  64583. }
  64584. declare module BABYLON {
  64585. interface Scene {
  64586. /** @hidden (Backing field) */
  64587. _boundingBoxRenderer: BoundingBoxRenderer;
  64588. /** @hidden (Backing field) */
  64589. _forceShowBoundingBoxes: boolean;
  64590. /**
  64591. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64592. */
  64593. forceShowBoundingBoxes: boolean;
  64594. /**
  64595. * Gets the bounding box renderer associated with the scene
  64596. * @returns a BoundingBoxRenderer
  64597. */
  64598. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64599. }
  64600. interface AbstractMesh {
  64601. /** @hidden (Backing field) */
  64602. _showBoundingBox: boolean;
  64603. /**
  64604. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64605. */
  64606. showBoundingBox: boolean;
  64607. }
  64608. /**
  64609. * Component responsible of rendering the bounding box of the meshes in a scene.
  64610. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64611. */
  64612. export class BoundingBoxRenderer implements ISceneComponent {
  64613. /**
  64614. * The component name helpfull to identify the component in the list of scene components.
  64615. */
  64616. readonly name: string;
  64617. /**
  64618. * The scene the component belongs to.
  64619. */
  64620. scene: Scene;
  64621. /**
  64622. * Color of the bounding box lines placed in front of an object
  64623. */
  64624. frontColor: Color3;
  64625. /**
  64626. * Color of the bounding box lines placed behind an object
  64627. */
  64628. backColor: Color3;
  64629. /**
  64630. * Defines if the renderer should show the back lines or not
  64631. */
  64632. showBackLines: boolean;
  64633. /**
  64634. * @hidden
  64635. */
  64636. renderList: SmartArray<BoundingBox>;
  64637. private _colorShader;
  64638. private _vertexBuffers;
  64639. private _indexBuffer;
  64640. private _fillIndexBuffer;
  64641. private _fillIndexData;
  64642. /**
  64643. * Instantiates a new bounding box renderer in a scene.
  64644. * @param scene the scene the renderer renders in
  64645. */
  64646. constructor(scene: Scene);
  64647. /**
  64648. * Registers the component in a given scene
  64649. */
  64650. register(): void;
  64651. private _evaluateSubMesh;
  64652. private _activeMesh;
  64653. private _prepareRessources;
  64654. private _createIndexBuffer;
  64655. /**
  64656. * Rebuilds the elements related to this component in case of
  64657. * context lost for instance.
  64658. */
  64659. rebuild(): void;
  64660. /**
  64661. * @hidden
  64662. */
  64663. reset(): void;
  64664. /**
  64665. * Render the bounding boxes of a specific rendering group
  64666. * @param renderingGroupId defines the rendering group to render
  64667. */
  64668. render(renderingGroupId: number): void;
  64669. /**
  64670. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64671. * @param mesh Define the mesh to render the occlusion bounding box for
  64672. */
  64673. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64674. /**
  64675. * Dispose and release the resources attached to this renderer.
  64676. */
  64677. dispose(): void;
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /** @hidden */
  64682. export var depthPixelShader: {
  64683. name: string;
  64684. shader: string;
  64685. };
  64686. }
  64687. declare module BABYLON {
  64688. /**
  64689. * This represents a depth renderer in Babylon.
  64690. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64691. */
  64692. export class DepthRenderer {
  64693. private _scene;
  64694. private _depthMap;
  64695. private _effect;
  64696. private readonly _storeNonLinearDepth;
  64697. private readonly _clearColor;
  64698. /** Get if the depth renderer is using packed depth or not */
  64699. readonly isPacked: boolean;
  64700. private _cachedDefines;
  64701. private _camera;
  64702. /**
  64703. * Specifiess that the depth renderer will only be used within
  64704. * the camera it is created for.
  64705. * This can help forcing its rendering during the camera processing.
  64706. */
  64707. useOnlyInActiveCamera: boolean;
  64708. /** @hidden */
  64709. static _SceneComponentInitialization: (scene: Scene) => void;
  64710. /**
  64711. * Instantiates a depth renderer
  64712. * @param scene The scene the renderer belongs to
  64713. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64714. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64715. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64716. */
  64717. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64718. /**
  64719. * Creates the depth rendering effect and checks if the effect is ready.
  64720. * @param subMesh The submesh to be used to render the depth map of
  64721. * @param useInstances If multiple world instances should be used
  64722. * @returns if the depth renderer is ready to render the depth map
  64723. */
  64724. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64725. /**
  64726. * Gets the texture which the depth map will be written to.
  64727. * @returns The depth map texture
  64728. */
  64729. getDepthMap(): RenderTargetTexture;
  64730. /**
  64731. * Disposes of the depth renderer.
  64732. */
  64733. dispose(): void;
  64734. }
  64735. }
  64736. declare module BABYLON {
  64737. interface Scene {
  64738. /** @hidden (Backing field) */
  64739. _depthRenderer: {
  64740. [id: string]: DepthRenderer;
  64741. };
  64742. /**
  64743. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64744. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64745. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64746. * @returns the created depth renderer
  64747. */
  64748. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64749. /**
  64750. * Disables a depth renderer for a given camera
  64751. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64752. */
  64753. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64754. }
  64755. /**
  64756. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64757. * in several rendering techniques.
  64758. */
  64759. export class DepthRendererSceneComponent implements ISceneComponent {
  64760. /**
  64761. * The component name helpfull to identify the component in the list of scene components.
  64762. */
  64763. readonly name: string;
  64764. /**
  64765. * The scene the component belongs to.
  64766. */
  64767. scene: Scene;
  64768. /**
  64769. * Creates a new instance of the component for the given scene
  64770. * @param scene Defines the scene to register the component in
  64771. */
  64772. constructor(scene: Scene);
  64773. /**
  64774. * Registers the component in a given scene
  64775. */
  64776. register(): void;
  64777. /**
  64778. * Rebuilds the elements related to this component in case of
  64779. * context lost for instance.
  64780. */
  64781. rebuild(): void;
  64782. /**
  64783. * Disposes the component and the associated ressources
  64784. */
  64785. dispose(): void;
  64786. private _gatherRenderTargets;
  64787. private _gatherActiveCameraRenderTargets;
  64788. }
  64789. }
  64790. declare module BABYLON {
  64791. /** @hidden */
  64792. export var outlinePixelShader: {
  64793. name: string;
  64794. shader: string;
  64795. };
  64796. }
  64797. declare module BABYLON {
  64798. /** @hidden */
  64799. export var outlineVertexShader: {
  64800. name: string;
  64801. shader: string;
  64802. };
  64803. }
  64804. declare module BABYLON {
  64805. interface Scene {
  64806. /** @hidden */
  64807. _outlineRenderer: OutlineRenderer;
  64808. /**
  64809. * Gets the outline renderer associated with the scene
  64810. * @returns a OutlineRenderer
  64811. */
  64812. getOutlineRenderer(): OutlineRenderer;
  64813. }
  64814. interface AbstractMesh {
  64815. /** @hidden (Backing field) */
  64816. _renderOutline: boolean;
  64817. /**
  64818. * Gets or sets a boolean indicating if the outline must be rendered as well
  64819. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64820. */
  64821. renderOutline: boolean;
  64822. /** @hidden (Backing field) */
  64823. _renderOverlay: boolean;
  64824. /**
  64825. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64826. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64827. */
  64828. renderOverlay: boolean;
  64829. }
  64830. /**
  64831. * This class is responsible to draw bothe outline/overlay of meshes.
  64832. * It should not be used directly but through the available method on mesh.
  64833. */
  64834. export class OutlineRenderer implements ISceneComponent {
  64835. /**
  64836. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64837. */
  64838. private static _StencilReference;
  64839. /**
  64840. * The name of the component. Each component must have a unique name.
  64841. */
  64842. name: string;
  64843. /**
  64844. * The scene the component belongs to.
  64845. */
  64846. scene: Scene;
  64847. /**
  64848. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64849. */
  64850. zOffset: number;
  64851. private _engine;
  64852. private _effect;
  64853. private _cachedDefines;
  64854. private _savedDepthWrite;
  64855. /**
  64856. * Instantiates a new outline renderer. (There could be only one per scene).
  64857. * @param scene Defines the scene it belongs to
  64858. */
  64859. constructor(scene: Scene);
  64860. /**
  64861. * Register the component to one instance of a scene.
  64862. */
  64863. register(): void;
  64864. /**
  64865. * Rebuilds the elements related to this component in case of
  64866. * context lost for instance.
  64867. */
  64868. rebuild(): void;
  64869. /**
  64870. * Disposes the component and the associated ressources.
  64871. */
  64872. dispose(): void;
  64873. /**
  64874. * Renders the outline in the canvas.
  64875. * @param subMesh Defines the sumesh to render
  64876. * @param batch Defines the batch of meshes in case of instances
  64877. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64878. */
  64879. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64880. /**
  64881. * Returns whether or not the outline renderer is ready for a given submesh.
  64882. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64883. * @param subMesh Defines the submesh to check readyness for
  64884. * @param useInstances Defines wheter wee are trying to render instances or not
  64885. * @returns true if ready otherwise false
  64886. */
  64887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64888. private _beforeRenderingMesh;
  64889. private _afterRenderingMesh;
  64890. }
  64891. }
  64892. declare module BABYLON {
  64893. /**
  64894. * Defines the basic options interface of a Sprite Frame Source Size.
  64895. */
  64896. export interface ISpriteJSONSpriteSourceSize {
  64897. /**
  64898. * number of the original width of the Frame
  64899. */
  64900. w: number;
  64901. /**
  64902. * number of the original height of the Frame
  64903. */
  64904. h: number;
  64905. }
  64906. /**
  64907. * Defines the basic options interface of a Sprite Frame Data.
  64908. */
  64909. export interface ISpriteJSONSpriteFrameData {
  64910. /**
  64911. * number of the x offset of the Frame
  64912. */
  64913. x: number;
  64914. /**
  64915. * number of the y offset of the Frame
  64916. */
  64917. y: number;
  64918. /**
  64919. * number of the width of the Frame
  64920. */
  64921. w: number;
  64922. /**
  64923. * number of the height of the Frame
  64924. */
  64925. h: number;
  64926. }
  64927. /**
  64928. * Defines the basic options interface of a JSON Sprite.
  64929. */
  64930. export interface ISpriteJSONSprite {
  64931. /**
  64932. * string name of the Frame
  64933. */
  64934. filename: string;
  64935. /**
  64936. * ISpriteJSONSpriteFrame basic object of the frame data
  64937. */
  64938. frame: ISpriteJSONSpriteFrameData;
  64939. /**
  64940. * boolean to flag is the frame was rotated.
  64941. */
  64942. rotated: boolean;
  64943. /**
  64944. * boolean to flag is the frame was trimmed.
  64945. */
  64946. trimmed: boolean;
  64947. /**
  64948. * ISpriteJSONSpriteFrame basic object of the source data
  64949. */
  64950. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64951. /**
  64952. * ISpriteJSONSpriteFrame basic object of the source data
  64953. */
  64954. sourceSize: ISpriteJSONSpriteSourceSize;
  64955. }
  64956. /**
  64957. * Defines the basic options interface of a JSON atlas.
  64958. */
  64959. export interface ISpriteJSONAtlas {
  64960. /**
  64961. * Array of objects that contain the frame data.
  64962. */
  64963. frames: Array<ISpriteJSONSprite>;
  64964. /**
  64965. * object basic object containing the sprite meta data.
  64966. */
  64967. meta?: object;
  64968. }
  64969. }
  64970. declare module BABYLON {
  64971. /** @hidden */
  64972. export var spriteMapPixelShader: {
  64973. name: string;
  64974. shader: string;
  64975. };
  64976. }
  64977. declare module BABYLON {
  64978. /** @hidden */
  64979. export var spriteMapVertexShader: {
  64980. name: string;
  64981. shader: string;
  64982. };
  64983. }
  64984. declare module BABYLON {
  64985. /**
  64986. * Defines the basic options interface of a SpriteMap
  64987. */
  64988. export interface ISpriteMapOptions {
  64989. /**
  64990. * Vector2 of the number of cells in the grid.
  64991. */
  64992. stageSize?: Vector2;
  64993. /**
  64994. * Vector2 of the size of the output plane in World Units.
  64995. */
  64996. outputSize?: Vector2;
  64997. /**
  64998. * Vector3 of the position of the output plane in World Units.
  64999. */
  65000. outputPosition?: Vector3;
  65001. /**
  65002. * Vector3 of the rotation of the output plane.
  65003. */
  65004. outputRotation?: Vector3;
  65005. /**
  65006. * number of layers that the system will reserve in resources.
  65007. */
  65008. layerCount?: number;
  65009. /**
  65010. * number of max animation frames a single cell will reserve in resources.
  65011. */
  65012. maxAnimationFrames?: number;
  65013. /**
  65014. * number cell index of the base tile when the system compiles.
  65015. */
  65016. baseTile?: number;
  65017. /**
  65018. * boolean flip the sprite after its been repositioned by the framing data.
  65019. */
  65020. flipU?: boolean;
  65021. /**
  65022. * Vector3 scalar of the global RGB values of the SpriteMap.
  65023. */
  65024. colorMultiply?: Vector3;
  65025. }
  65026. /**
  65027. * Defines the IDisposable interface in order to be cleanable from resources.
  65028. */
  65029. export interface ISpriteMap extends IDisposable {
  65030. /**
  65031. * String name of the SpriteMap.
  65032. */
  65033. name: string;
  65034. /**
  65035. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  65036. */
  65037. atlasJSON: ISpriteJSONAtlas;
  65038. /**
  65039. * Texture of the SpriteMap.
  65040. */
  65041. spriteSheet: Texture;
  65042. /**
  65043. * The parameters to initialize the SpriteMap with.
  65044. */
  65045. options: ISpriteMapOptions;
  65046. }
  65047. /**
  65048. * Class used to manage a grid restricted sprite deployment on an Output plane.
  65049. */
  65050. export class SpriteMap implements ISpriteMap {
  65051. /** The Name of the spriteMap */
  65052. name: string;
  65053. /** The JSON file with the frame and meta data */
  65054. atlasJSON: ISpriteJSONAtlas;
  65055. /** The systems Sprite Sheet Texture */
  65056. spriteSheet: Texture;
  65057. /** Arguments passed with the Constructor */
  65058. options: ISpriteMapOptions;
  65059. /** Public Sprite Storage array, parsed from atlasJSON */
  65060. sprites: Array<ISpriteJSONSprite>;
  65061. /** Returns the Number of Sprites in the System */
  65062. get spriteCount(): number;
  65063. /** Returns the Position of Output Plane*/
  65064. get position(): Vector3;
  65065. /** Returns the Position of Output Plane*/
  65066. set position(v: Vector3);
  65067. /** Returns the Rotation of Output Plane*/
  65068. get rotation(): Vector3;
  65069. /** Returns the Rotation of Output Plane*/
  65070. set rotation(v: Vector3);
  65071. /** Sets the AnimationMap*/
  65072. get animationMap(): RawTexture;
  65073. /** Sets the AnimationMap*/
  65074. set animationMap(v: RawTexture);
  65075. /** Scene that the SpriteMap was created in */
  65076. private _scene;
  65077. /** Texture Buffer of Float32 that holds tile frame data*/
  65078. private _frameMap;
  65079. /** Texture Buffers of Float32 that holds tileMap data*/
  65080. private _tileMaps;
  65081. /** Texture Buffer of Float32 that holds Animation Data*/
  65082. private _animationMap;
  65083. /** Custom ShaderMaterial Central to the System*/
  65084. private _material;
  65085. /** Custom ShaderMaterial Central to the System*/
  65086. private _output;
  65087. /** Systems Time Ticker*/
  65088. private _time;
  65089. /**
  65090. * Creates a new SpriteMap
  65091. * @param name defines the SpriteMaps Name
  65092. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65093. * @param spriteSheet is the Texture that the Sprites are on.
  65094. * @param options a basic deployment configuration
  65095. * @param scene The Scene that the map is deployed on
  65096. */
  65097. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65098. /**
  65099. * Returns tileID location
  65100. * @returns Vector2 the cell position ID
  65101. */
  65102. getTileID(): Vector2;
  65103. /**
  65104. * Gets the UV location of the mouse over the SpriteMap.
  65105. * @returns Vector2 the UV position of the mouse interaction
  65106. */
  65107. getMousePosition(): Vector2;
  65108. /**
  65109. * Creates the "frame" texture Buffer
  65110. * -------------------------------------
  65111. * Structure of frames
  65112. * "filename": "Falling-Water-2.png",
  65113. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65114. * "rotated": true,
  65115. * "trimmed": true,
  65116. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65117. * "sourceSize": {"w":32,"h":32}
  65118. * @returns RawTexture of the frameMap
  65119. */
  65120. private _createFrameBuffer;
  65121. /**
  65122. * Creates the tileMap texture Buffer
  65123. * @param buffer normally and array of numbers, or a false to generate from scratch
  65124. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65125. * @returns RawTexture of the tileMap
  65126. */
  65127. private _createTileBuffer;
  65128. /**
  65129. * Modifies the data of the tileMaps
  65130. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65131. * @param pos is the iVector2 Coordinates of the Tile
  65132. * @param tile The SpriteIndex of the new Tile
  65133. */
  65134. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65135. /**
  65136. * Creates the animationMap texture Buffer
  65137. * @param buffer normally and array of numbers, or a false to generate from scratch
  65138. * @returns RawTexture of the animationMap
  65139. */
  65140. private _createTileAnimationBuffer;
  65141. /**
  65142. * Modifies the data of the animationMap
  65143. * @param cellID is the Index of the Sprite
  65144. * @param _frame is the target Animation frame
  65145. * @param toCell is the Target Index of the next frame of the animation
  65146. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65147. * @param speed is a global scalar of the time variable on the map.
  65148. */
  65149. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65150. /**
  65151. * Exports the .tilemaps file
  65152. */
  65153. saveTileMaps(): void;
  65154. /**
  65155. * Imports the .tilemaps file
  65156. * @param url of the .tilemaps file
  65157. */
  65158. loadTileMaps(url: string): void;
  65159. /**
  65160. * Release associated resources
  65161. */
  65162. dispose(): void;
  65163. }
  65164. }
  65165. declare module BABYLON {
  65166. /**
  65167. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65168. * @see http://doc.babylonjs.com/babylon101/sprites
  65169. */
  65170. export class SpritePackedManager extends SpriteManager {
  65171. /** defines the packed manager's name */
  65172. name: string;
  65173. /**
  65174. * Creates a new sprite manager from a packed sprite sheet
  65175. * @param name defines the manager's name
  65176. * @param imgUrl defines the sprite sheet url
  65177. * @param capacity defines the maximum allowed number of sprites
  65178. * @param scene defines the hosting scene
  65179. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65180. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65181. * @param samplingMode defines the smapling mode to use with spritesheet
  65182. * @param fromPacked set to true; do not alter
  65183. */
  65184. constructor(
  65185. /** defines the packed manager's name */
  65186. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65187. }
  65188. }
  65189. declare module BABYLON {
  65190. /**
  65191. * Defines the list of states available for a task inside a AssetsManager
  65192. */
  65193. export enum AssetTaskState {
  65194. /**
  65195. * Initialization
  65196. */
  65197. INIT = 0,
  65198. /**
  65199. * Running
  65200. */
  65201. RUNNING = 1,
  65202. /**
  65203. * Done
  65204. */
  65205. DONE = 2,
  65206. /**
  65207. * Error
  65208. */
  65209. ERROR = 3
  65210. }
  65211. /**
  65212. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65213. */
  65214. export abstract class AbstractAssetTask {
  65215. /**
  65216. * Task name
  65217. */ name: string;
  65218. /**
  65219. * Callback called when the task is successful
  65220. */
  65221. onSuccess: (task: any) => void;
  65222. /**
  65223. * Callback called when the task is not successful
  65224. */
  65225. onError: (task: any, message?: string, exception?: any) => void;
  65226. /**
  65227. * Creates a new AssetsManager
  65228. * @param name defines the name of the task
  65229. */
  65230. constructor(
  65231. /**
  65232. * Task name
  65233. */ name: string);
  65234. private _isCompleted;
  65235. private _taskState;
  65236. private _errorObject;
  65237. /**
  65238. * Get if the task is completed
  65239. */
  65240. get isCompleted(): boolean;
  65241. /**
  65242. * Gets the current state of the task
  65243. */
  65244. get taskState(): AssetTaskState;
  65245. /**
  65246. * Gets the current error object (if task is in error)
  65247. */
  65248. get errorObject(): {
  65249. message?: string;
  65250. exception?: any;
  65251. };
  65252. /**
  65253. * Internal only
  65254. * @hidden
  65255. */
  65256. _setErrorObject(message?: string, exception?: any): void;
  65257. /**
  65258. * Execute the current task
  65259. * @param scene defines the scene where you want your assets to be loaded
  65260. * @param onSuccess is a callback called when the task is successfully executed
  65261. * @param onError is a callback called if an error occurs
  65262. */
  65263. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65264. /**
  65265. * Execute the current task
  65266. * @param scene defines the scene where you want your assets to be loaded
  65267. * @param onSuccess is a callback called when the task is successfully executed
  65268. * @param onError is a callback called if an error occurs
  65269. */
  65270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65271. /**
  65272. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65273. * This can be used with failed tasks that have the reason for failure fixed.
  65274. */
  65275. reset(): void;
  65276. private onErrorCallback;
  65277. private onDoneCallback;
  65278. }
  65279. /**
  65280. * Define the interface used by progress events raised during assets loading
  65281. */
  65282. export interface IAssetsProgressEvent {
  65283. /**
  65284. * Defines the number of remaining tasks to process
  65285. */
  65286. remainingCount: number;
  65287. /**
  65288. * Defines the total number of tasks
  65289. */
  65290. totalCount: number;
  65291. /**
  65292. * Defines the task that was just processed
  65293. */
  65294. task: AbstractAssetTask;
  65295. }
  65296. /**
  65297. * Class used to share progress information about assets loading
  65298. */
  65299. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65300. /**
  65301. * Defines the number of remaining tasks to process
  65302. */
  65303. remainingCount: number;
  65304. /**
  65305. * Defines the total number of tasks
  65306. */
  65307. totalCount: number;
  65308. /**
  65309. * Defines the task that was just processed
  65310. */
  65311. task: AbstractAssetTask;
  65312. /**
  65313. * Creates a AssetsProgressEvent
  65314. * @param remainingCount defines the number of remaining tasks to process
  65315. * @param totalCount defines the total number of tasks
  65316. * @param task defines the task that was just processed
  65317. */
  65318. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65319. }
  65320. /**
  65321. * Define a task used by AssetsManager to load meshes
  65322. */
  65323. export class MeshAssetTask extends AbstractAssetTask {
  65324. /**
  65325. * Defines the name of the task
  65326. */
  65327. name: string;
  65328. /**
  65329. * Defines the list of mesh's names you want to load
  65330. */
  65331. meshesNames: any;
  65332. /**
  65333. * Defines the root url to use as a base to load your meshes and associated resources
  65334. */
  65335. rootUrl: string;
  65336. /**
  65337. * Defines the filename of the scene to load from
  65338. */
  65339. sceneFilename: string;
  65340. /**
  65341. * Gets the list of loaded meshes
  65342. */
  65343. loadedMeshes: Array<AbstractMesh>;
  65344. /**
  65345. * Gets the list of loaded particle systems
  65346. */
  65347. loadedParticleSystems: Array<IParticleSystem>;
  65348. /**
  65349. * Gets the list of loaded skeletons
  65350. */
  65351. loadedSkeletons: Array<Skeleton>;
  65352. /**
  65353. * Gets the list of loaded animation groups
  65354. */
  65355. loadedAnimationGroups: Array<AnimationGroup>;
  65356. /**
  65357. * Callback called when the task is successful
  65358. */
  65359. onSuccess: (task: MeshAssetTask) => void;
  65360. /**
  65361. * Callback called when the task is successful
  65362. */
  65363. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65364. /**
  65365. * Creates a new MeshAssetTask
  65366. * @param name defines the name of the task
  65367. * @param meshesNames defines the list of mesh's names you want to load
  65368. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65369. * @param sceneFilename defines the filename of the scene to load from
  65370. */
  65371. constructor(
  65372. /**
  65373. * Defines the name of the task
  65374. */
  65375. name: string,
  65376. /**
  65377. * Defines the list of mesh's names you want to load
  65378. */
  65379. meshesNames: any,
  65380. /**
  65381. * Defines the root url to use as a base to load your meshes and associated resources
  65382. */
  65383. rootUrl: string,
  65384. /**
  65385. * Defines the filename of the scene to load from
  65386. */
  65387. sceneFilename: string);
  65388. /**
  65389. * Execute the current task
  65390. * @param scene defines the scene where you want your assets to be loaded
  65391. * @param onSuccess is a callback called when the task is successfully executed
  65392. * @param onError is a callback called if an error occurs
  65393. */
  65394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65395. }
  65396. /**
  65397. * Define a task used by AssetsManager to load text content
  65398. */
  65399. export class TextFileAssetTask extends AbstractAssetTask {
  65400. /**
  65401. * Defines the name of the task
  65402. */
  65403. name: string;
  65404. /**
  65405. * Defines the location of the file to load
  65406. */
  65407. url: string;
  65408. /**
  65409. * Gets the loaded text string
  65410. */
  65411. text: string;
  65412. /**
  65413. * Callback called when the task is successful
  65414. */
  65415. onSuccess: (task: TextFileAssetTask) => void;
  65416. /**
  65417. * Callback called when the task is successful
  65418. */
  65419. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65420. /**
  65421. * Creates a new TextFileAssetTask object
  65422. * @param name defines the name of the task
  65423. * @param url defines the location of the file to load
  65424. */
  65425. constructor(
  65426. /**
  65427. * Defines the name of the task
  65428. */
  65429. name: string,
  65430. /**
  65431. * Defines the location of the file to load
  65432. */
  65433. url: string);
  65434. /**
  65435. * Execute the current task
  65436. * @param scene defines the scene where you want your assets to be loaded
  65437. * @param onSuccess is a callback called when the task is successfully executed
  65438. * @param onError is a callback called if an error occurs
  65439. */
  65440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65441. }
  65442. /**
  65443. * Define a task used by AssetsManager to load binary data
  65444. */
  65445. export class BinaryFileAssetTask extends AbstractAssetTask {
  65446. /**
  65447. * Defines the name of the task
  65448. */
  65449. name: string;
  65450. /**
  65451. * Defines the location of the file to load
  65452. */
  65453. url: string;
  65454. /**
  65455. * Gets the lodaded data (as an array buffer)
  65456. */
  65457. data: ArrayBuffer;
  65458. /**
  65459. * Callback called when the task is successful
  65460. */
  65461. onSuccess: (task: BinaryFileAssetTask) => void;
  65462. /**
  65463. * Callback called when the task is successful
  65464. */
  65465. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65466. /**
  65467. * Creates a new BinaryFileAssetTask object
  65468. * @param name defines the name of the new task
  65469. * @param url defines the location of the file to load
  65470. */
  65471. constructor(
  65472. /**
  65473. * Defines the name of the task
  65474. */
  65475. name: string,
  65476. /**
  65477. * Defines the location of the file to load
  65478. */
  65479. url: string);
  65480. /**
  65481. * Execute the current task
  65482. * @param scene defines the scene where you want your assets to be loaded
  65483. * @param onSuccess is a callback called when the task is successfully executed
  65484. * @param onError is a callback called if an error occurs
  65485. */
  65486. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65487. }
  65488. /**
  65489. * Define a task used by AssetsManager to load images
  65490. */
  65491. export class ImageAssetTask extends AbstractAssetTask {
  65492. /**
  65493. * Defines the name of the task
  65494. */
  65495. name: string;
  65496. /**
  65497. * Defines the location of the image to load
  65498. */
  65499. url: string;
  65500. /**
  65501. * Gets the loaded images
  65502. */
  65503. image: HTMLImageElement;
  65504. /**
  65505. * Callback called when the task is successful
  65506. */
  65507. onSuccess: (task: ImageAssetTask) => void;
  65508. /**
  65509. * Callback called when the task is successful
  65510. */
  65511. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65512. /**
  65513. * Creates a new ImageAssetTask
  65514. * @param name defines the name of the task
  65515. * @param url defines the location of the image to load
  65516. */
  65517. constructor(
  65518. /**
  65519. * Defines the name of the task
  65520. */
  65521. name: string,
  65522. /**
  65523. * Defines the location of the image to load
  65524. */
  65525. url: string);
  65526. /**
  65527. * Execute the current task
  65528. * @param scene defines the scene where you want your assets to be loaded
  65529. * @param onSuccess is a callback called when the task is successfully executed
  65530. * @param onError is a callback called if an error occurs
  65531. */
  65532. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65533. }
  65534. /**
  65535. * Defines the interface used by texture loading tasks
  65536. */
  65537. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65538. /**
  65539. * Gets the loaded texture
  65540. */
  65541. texture: TEX;
  65542. }
  65543. /**
  65544. * Define a task used by AssetsManager to load 2D textures
  65545. */
  65546. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65547. /**
  65548. * Defines the name of the task
  65549. */
  65550. name: string;
  65551. /**
  65552. * Defines the location of the file to load
  65553. */
  65554. url: string;
  65555. /**
  65556. * Defines if mipmap should not be generated (default is false)
  65557. */
  65558. noMipmap?: boolean | undefined;
  65559. /**
  65560. * Defines if texture must be inverted on Y axis (default is false)
  65561. */
  65562. invertY?: boolean | undefined;
  65563. /**
  65564. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65565. */
  65566. samplingMode: number;
  65567. /**
  65568. * Gets the loaded texture
  65569. */
  65570. texture: Texture;
  65571. /**
  65572. * Callback called when the task is successful
  65573. */
  65574. onSuccess: (task: TextureAssetTask) => void;
  65575. /**
  65576. * Callback called when the task is successful
  65577. */
  65578. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65579. /**
  65580. * Creates a new TextureAssetTask object
  65581. * @param name defines the name of the task
  65582. * @param url defines the location of the file to load
  65583. * @param noMipmap defines if mipmap should not be generated (default is false)
  65584. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65585. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65586. */
  65587. constructor(
  65588. /**
  65589. * Defines the name of the task
  65590. */
  65591. name: string,
  65592. /**
  65593. * Defines the location of the file to load
  65594. */
  65595. url: string,
  65596. /**
  65597. * Defines if mipmap should not be generated (default is false)
  65598. */
  65599. noMipmap?: boolean | undefined,
  65600. /**
  65601. * Defines if texture must be inverted on Y axis (default is false)
  65602. */
  65603. invertY?: boolean | undefined,
  65604. /**
  65605. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65606. */
  65607. samplingMode?: number);
  65608. /**
  65609. * Execute the current task
  65610. * @param scene defines the scene where you want your assets to be loaded
  65611. * @param onSuccess is a callback called when the task is successfully executed
  65612. * @param onError is a callback called if an error occurs
  65613. */
  65614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65615. }
  65616. /**
  65617. * Define a task used by AssetsManager to load cube textures
  65618. */
  65619. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65620. /**
  65621. * Defines the name of the task
  65622. */
  65623. name: string;
  65624. /**
  65625. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65626. */
  65627. url: string;
  65628. /**
  65629. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65630. */
  65631. extensions?: string[] | undefined;
  65632. /**
  65633. * Defines if mipmaps should not be generated (default is false)
  65634. */
  65635. noMipmap?: boolean | undefined;
  65636. /**
  65637. * Defines the explicit list of files (undefined by default)
  65638. */
  65639. files?: string[] | undefined;
  65640. /**
  65641. * Gets the loaded texture
  65642. */
  65643. texture: CubeTexture;
  65644. /**
  65645. * Callback called when the task is successful
  65646. */
  65647. onSuccess: (task: CubeTextureAssetTask) => void;
  65648. /**
  65649. * Callback called when the task is successful
  65650. */
  65651. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65652. /**
  65653. * Creates a new CubeTextureAssetTask
  65654. * @param name defines the name of the task
  65655. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65656. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65657. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65658. * @param files defines the explicit list of files (undefined by default)
  65659. */
  65660. constructor(
  65661. /**
  65662. * Defines the name of the task
  65663. */
  65664. name: string,
  65665. /**
  65666. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65667. */
  65668. url: string,
  65669. /**
  65670. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65671. */
  65672. extensions?: string[] | undefined,
  65673. /**
  65674. * Defines if mipmaps should not be generated (default is false)
  65675. */
  65676. noMipmap?: boolean | undefined,
  65677. /**
  65678. * Defines the explicit list of files (undefined by default)
  65679. */
  65680. files?: string[] | undefined);
  65681. /**
  65682. * Execute the current task
  65683. * @param scene defines the scene where you want your assets to be loaded
  65684. * @param onSuccess is a callback called when the task is successfully executed
  65685. * @param onError is a callback called if an error occurs
  65686. */
  65687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65688. }
  65689. /**
  65690. * Define a task used by AssetsManager to load HDR cube textures
  65691. */
  65692. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  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. * Gets the loaded texture
  65723. */
  65724. texture: HDRCubeTexture;
  65725. /**
  65726. * Callback called when the task is successful
  65727. */
  65728. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65729. /**
  65730. * Callback called when the task is successful
  65731. */
  65732. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65733. /**
  65734. * Creates a new HDRCubeTextureAssetTask object
  65735. * @param name defines the name of the task
  65736. * @param url defines the location of the file to load
  65737. * @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.
  65738. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65739. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65740. * @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)
  65741. * @param reserved Internal use only
  65742. */
  65743. constructor(
  65744. /**
  65745. * Defines the name of the task
  65746. */
  65747. name: string,
  65748. /**
  65749. * Defines the location of the file to load
  65750. */
  65751. url: string,
  65752. /**
  65753. * Defines the desired size (the more it increases the longer the generation will be)
  65754. */
  65755. size: number,
  65756. /**
  65757. * Defines if mipmaps should not be generated (default is false)
  65758. */
  65759. noMipmap?: boolean,
  65760. /**
  65761. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65762. */
  65763. generateHarmonics?: boolean,
  65764. /**
  65765. * 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)
  65766. */
  65767. gammaSpace?: boolean,
  65768. /**
  65769. * Internal Use Only
  65770. */
  65771. reserved?: boolean);
  65772. /**
  65773. * Execute the current task
  65774. * @param scene defines the scene where you want your assets to be loaded
  65775. * @param onSuccess is a callback called when the task is successfully executed
  65776. * @param onError is a callback called if an error occurs
  65777. */
  65778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65779. }
  65780. /**
  65781. * Define a task used by AssetsManager to load Equirectangular cube textures
  65782. */
  65783. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65784. /**
  65785. * Defines the name of the task
  65786. */
  65787. name: string;
  65788. /**
  65789. * Defines the location of the file to load
  65790. */
  65791. url: string;
  65792. /**
  65793. * Defines the desired size (the more it increases the longer the generation will be)
  65794. */
  65795. size: number;
  65796. /**
  65797. * Defines if mipmaps should not be generated (default is false)
  65798. */
  65799. noMipmap: boolean;
  65800. /**
  65801. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65802. * but the standard material would require them in Gamma space) (default is true)
  65803. */
  65804. gammaSpace: boolean;
  65805. /**
  65806. * Gets the loaded texture
  65807. */
  65808. texture: EquiRectangularCubeTexture;
  65809. /**
  65810. * Callback called when the task is successful
  65811. */
  65812. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65813. /**
  65814. * Callback called when the task is successful
  65815. */
  65816. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65817. /**
  65818. * Creates a new EquiRectangularCubeTextureAssetTask object
  65819. * @param name defines the name of the task
  65820. * @param url defines the location of the file to load
  65821. * @param size defines the desired size (the more it increases the longer the generation will be)
  65822. * If the size is omitted this implies you are using a preprocessed cubemap.
  65823. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65824. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65825. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65826. * (default is true)
  65827. */
  65828. constructor(
  65829. /**
  65830. * Defines the name of the task
  65831. */
  65832. name: string,
  65833. /**
  65834. * Defines the location of the file to load
  65835. */
  65836. url: string,
  65837. /**
  65838. * Defines the desired size (the more it increases the longer the generation will be)
  65839. */
  65840. size: number,
  65841. /**
  65842. * Defines if mipmaps should not be generated (default is false)
  65843. */
  65844. noMipmap?: boolean,
  65845. /**
  65846. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65847. * but the standard material would require them in Gamma space) (default is true)
  65848. */
  65849. gammaSpace?: boolean);
  65850. /**
  65851. * Execute the current task
  65852. * @param scene defines the scene where you want your assets to be loaded
  65853. * @param onSuccess is a callback called when the task is successfully executed
  65854. * @param onError is a callback called if an error occurs
  65855. */
  65856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65857. }
  65858. /**
  65859. * This class can be used to easily import assets into a scene
  65860. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65861. */
  65862. export class AssetsManager {
  65863. private _scene;
  65864. private _isLoading;
  65865. protected _tasks: AbstractAssetTask[];
  65866. protected _waitingTasksCount: number;
  65867. protected _totalTasksCount: number;
  65868. /**
  65869. * Callback called when all tasks are processed
  65870. */
  65871. onFinish: (tasks: AbstractAssetTask[]) => void;
  65872. /**
  65873. * Callback called when a task is successful
  65874. */
  65875. onTaskSuccess: (task: AbstractAssetTask) => void;
  65876. /**
  65877. * Callback called when a task had an error
  65878. */
  65879. onTaskError: (task: AbstractAssetTask) => void;
  65880. /**
  65881. * Callback called when a task is done (whatever the result is)
  65882. */
  65883. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65884. /**
  65885. * Observable called when all tasks are processed
  65886. */
  65887. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65888. /**
  65889. * Observable called when a task had an error
  65890. */
  65891. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65892. /**
  65893. * Observable called when all tasks were executed
  65894. */
  65895. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65896. /**
  65897. * Observable called when a task is done (whatever the result is)
  65898. */
  65899. onProgressObservable: Observable<IAssetsProgressEvent>;
  65900. /**
  65901. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65903. */
  65904. useDefaultLoadingScreen: boolean;
  65905. /**
  65906. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65907. * when all assets have been downloaded.
  65908. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65909. */
  65910. autoHideLoadingUI: boolean;
  65911. /**
  65912. * Creates a new AssetsManager
  65913. * @param scene defines the scene to work on
  65914. */
  65915. constructor(scene: Scene);
  65916. /**
  65917. * Add a MeshAssetTask to the list of active tasks
  65918. * @param taskName defines the name of the new task
  65919. * @param meshesNames defines the name of meshes to load
  65920. * @param rootUrl defines the root url to use to locate files
  65921. * @param sceneFilename defines the filename of the scene file
  65922. * @returns a new MeshAssetTask object
  65923. */
  65924. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65925. /**
  65926. * Add a TextFileAssetTask to the list of active tasks
  65927. * @param taskName defines the name of the new task
  65928. * @param url defines the url of the file to load
  65929. * @returns a new TextFileAssetTask object
  65930. */
  65931. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65932. /**
  65933. * Add a BinaryFileAssetTask to the list of active tasks
  65934. * @param taskName defines the name of the new task
  65935. * @param url defines the url of the file to load
  65936. * @returns a new BinaryFileAssetTask object
  65937. */
  65938. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65939. /**
  65940. * Add a ImageAssetTask to the list of active tasks
  65941. * @param taskName defines the name of the new task
  65942. * @param url defines the url of the file to load
  65943. * @returns a new ImageAssetTask object
  65944. */
  65945. addImageTask(taskName: string, url: string): ImageAssetTask;
  65946. /**
  65947. * Add a TextureAssetTask to the list of active tasks
  65948. * @param taskName defines the name of the new task
  65949. * @param url defines the url of the file to load
  65950. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65951. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65952. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65953. * @returns a new TextureAssetTask object
  65954. */
  65955. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65956. /**
  65957. * Add a CubeTextureAssetTask to the list of active tasks
  65958. * @param taskName defines the name of the new task
  65959. * @param url defines the url of the file to load
  65960. * @param extensions defines the extension to use to load the cube map (can be null)
  65961. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65962. * @param files defines the list of files to load (can be null)
  65963. * @returns a new CubeTextureAssetTask object
  65964. */
  65965. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65966. /**
  65967. *
  65968. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65969. * @param taskName defines the name of the new task
  65970. * @param url defines the url of the file to load
  65971. * @param size defines the size you want for the cubemap (can be null)
  65972. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65973. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65974. * @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)
  65975. * @param reserved Internal use only
  65976. * @returns a new HDRCubeTextureAssetTask object
  65977. */
  65978. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65979. /**
  65980. *
  65981. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65982. * @param taskName defines the name of the new task
  65983. * @param url defines the url of the file to load
  65984. * @param size defines the size you want for the cubemap (can be null)
  65985. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65986. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65987. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65988. * @returns a new EquiRectangularCubeTextureAssetTask object
  65989. */
  65990. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65991. /**
  65992. * Remove a task from the assets manager.
  65993. * @param task the task to remove
  65994. */
  65995. removeTask(task: AbstractAssetTask): void;
  65996. private _decreaseWaitingTasksCount;
  65997. private _runTask;
  65998. /**
  65999. * Reset the AssetsManager and remove all tasks
  66000. * @return the current instance of the AssetsManager
  66001. */
  66002. reset(): AssetsManager;
  66003. /**
  66004. * Start the loading process
  66005. * @return the current instance of the AssetsManager
  66006. */
  66007. load(): AssetsManager;
  66008. /**
  66009. * Start the loading process as an async operation
  66010. * @return a promise returning the list of failed tasks
  66011. */
  66012. loadAsync(): Promise<void>;
  66013. }
  66014. }
  66015. declare module BABYLON {
  66016. /**
  66017. * Wrapper class for promise with external resolve and reject.
  66018. */
  66019. export class Deferred<T> {
  66020. /**
  66021. * The promise associated with this deferred object.
  66022. */
  66023. readonly promise: Promise<T>;
  66024. private _resolve;
  66025. private _reject;
  66026. /**
  66027. * The resolve method of the promise associated with this deferred object.
  66028. */
  66029. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  66030. /**
  66031. * The reject method of the promise associated with this deferred object.
  66032. */
  66033. get reject(): (reason?: any) => void;
  66034. /**
  66035. * Constructor for this deferred object.
  66036. */
  66037. constructor();
  66038. }
  66039. }
  66040. declare module BABYLON {
  66041. /**
  66042. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66043. */
  66044. export class MeshExploder {
  66045. private _centerMesh;
  66046. private _meshes;
  66047. private _meshesOrigins;
  66048. private _toCenterVectors;
  66049. private _scaledDirection;
  66050. private _newPosition;
  66051. private _centerPosition;
  66052. /**
  66053. * Explodes meshes from a center mesh.
  66054. * @param meshes The meshes to explode.
  66055. * @param centerMesh The mesh to be center of explosion.
  66056. */
  66057. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66058. private _setCenterMesh;
  66059. /**
  66060. * Get class name
  66061. * @returns "MeshExploder"
  66062. */
  66063. getClassName(): string;
  66064. /**
  66065. * "Exploded meshes"
  66066. * @returns Array of meshes with the centerMesh at index 0.
  66067. */
  66068. getMeshes(): Array<Mesh>;
  66069. /**
  66070. * Explodes meshes giving a specific direction
  66071. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66072. */
  66073. explode(direction?: number): void;
  66074. }
  66075. }
  66076. declare module BABYLON {
  66077. /**
  66078. * Class used to help managing file picking and drag'n'drop
  66079. */
  66080. export class FilesInput {
  66081. /**
  66082. * List of files ready to be loaded
  66083. */
  66084. static get FilesToLoad(): {
  66085. [key: string]: File;
  66086. };
  66087. /**
  66088. * Callback called when a file is processed
  66089. */
  66090. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66091. private _engine;
  66092. private _currentScene;
  66093. private _sceneLoadedCallback;
  66094. private _progressCallback;
  66095. private _additionalRenderLoopLogicCallback;
  66096. private _textureLoadingCallback;
  66097. private _startingProcessingFilesCallback;
  66098. private _onReloadCallback;
  66099. private _errorCallback;
  66100. private _elementToMonitor;
  66101. private _sceneFileToLoad;
  66102. private _filesToLoad;
  66103. /**
  66104. * Creates a new FilesInput
  66105. * @param engine defines the rendering engine
  66106. * @param scene defines the hosting scene
  66107. * @param sceneLoadedCallback callback called when scene is loaded
  66108. * @param progressCallback callback called to track progress
  66109. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66110. * @param textureLoadingCallback callback called when a texture is loading
  66111. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66112. * @param onReloadCallback callback called when a reload is requested
  66113. * @param errorCallback callback call if an error occurs
  66114. */
  66115. 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);
  66116. private _dragEnterHandler;
  66117. private _dragOverHandler;
  66118. private _dropHandler;
  66119. /**
  66120. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66121. * @param elementToMonitor defines the DOM element to track
  66122. */
  66123. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66124. /**
  66125. * Release all associated resources
  66126. */
  66127. dispose(): void;
  66128. private renderFunction;
  66129. private drag;
  66130. private drop;
  66131. private _traverseFolder;
  66132. private _processFiles;
  66133. /**
  66134. * Load files from a drop event
  66135. * @param event defines the drop event to use as source
  66136. */
  66137. loadFiles(event: any): void;
  66138. private _processReload;
  66139. /**
  66140. * Reload the current scene from the loaded files
  66141. */
  66142. reload(): void;
  66143. }
  66144. }
  66145. declare module BABYLON {
  66146. /**
  66147. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66149. */
  66150. export class SceneOptimization {
  66151. /**
  66152. * Defines the priority of this optimization (0 by default which means first in the list)
  66153. */
  66154. priority: number;
  66155. /**
  66156. * Gets a string describing the action executed by the current optimization
  66157. * @returns description string
  66158. */
  66159. getDescription(): string;
  66160. /**
  66161. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66162. * @param scene defines the current scene where to apply this optimization
  66163. * @param optimizer defines the current optimizer
  66164. * @returns true if everything that can be done was applied
  66165. */
  66166. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66167. /**
  66168. * Creates the SceneOptimization object
  66169. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66170. * @param desc defines the description associated with the optimization
  66171. */
  66172. constructor(
  66173. /**
  66174. * Defines the priority of this optimization (0 by default which means first in the list)
  66175. */
  66176. priority?: number);
  66177. }
  66178. /**
  66179. * Defines an optimization used to reduce the size of render target textures
  66180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66181. */
  66182. export class TextureOptimization extends SceneOptimization {
  66183. /**
  66184. * Defines the priority of this optimization (0 by default which means first in the list)
  66185. */
  66186. priority: number;
  66187. /**
  66188. * 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
  66189. */
  66190. maximumSize: number;
  66191. /**
  66192. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66193. */
  66194. step: number;
  66195. /**
  66196. * Gets a string describing the action executed by the current optimization
  66197. * @returns description string
  66198. */
  66199. getDescription(): string;
  66200. /**
  66201. * Creates the TextureOptimization object
  66202. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66203. * @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
  66204. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  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 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
  66213. */
  66214. maximumSize?: number,
  66215. /**
  66216. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  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 increase or decrease the rendering resolution
  66229. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66230. */
  66231. export class HardwareScalingOptimization extends SceneOptimization {
  66232. /**
  66233. * Defines the priority of this optimization (0 by default which means first in the list)
  66234. */
  66235. priority: number;
  66236. /**
  66237. * Defines the maximum scale to use (2 by default)
  66238. */
  66239. maximumScale: number;
  66240. /**
  66241. * Defines the step to use between two passes (0.5 by default)
  66242. */
  66243. step: number;
  66244. private _currentScale;
  66245. private _directionOffset;
  66246. /**
  66247. * Gets a string describing the action executed by the current optimization
  66248. * @return description string
  66249. */
  66250. getDescription(): string;
  66251. /**
  66252. * Creates the HardwareScalingOptimization object
  66253. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66254. * @param maximumScale defines the maximum scale to use (2 by default)
  66255. * @param step defines the step to use between two passes (0.5 by default)
  66256. */
  66257. constructor(
  66258. /**
  66259. * Defines the priority of this optimization (0 by default which means first in the list)
  66260. */
  66261. priority?: number,
  66262. /**
  66263. * Defines the maximum scale to use (2 by default)
  66264. */
  66265. maximumScale?: number,
  66266. /**
  66267. * Defines the step to use between two passes (0.5 by default)
  66268. */
  66269. step?: number);
  66270. /**
  66271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66272. * @param scene defines the current scene where to apply this optimization
  66273. * @param optimizer defines the current optimizer
  66274. * @returns true if everything that can be done was applied
  66275. */
  66276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66277. }
  66278. /**
  66279. * Defines an optimization used to remove shadows
  66280. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66281. */
  66282. export class ShadowsOptimization extends SceneOptimization {
  66283. /**
  66284. * Gets a string describing the action executed by the current optimization
  66285. * @return description string
  66286. */
  66287. getDescription(): string;
  66288. /**
  66289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66290. * @param scene defines the current scene where to apply this optimization
  66291. * @param optimizer defines the current optimizer
  66292. * @returns true if everything that can be done was applied
  66293. */
  66294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66295. }
  66296. /**
  66297. * Defines an optimization used to turn post-processes off
  66298. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66299. */
  66300. export class PostProcessesOptimization extends SceneOptimization {
  66301. /**
  66302. * Gets a string describing the action executed by the current optimization
  66303. * @return description string
  66304. */
  66305. getDescription(): string;
  66306. /**
  66307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66308. * @param scene defines the current scene where to apply this optimization
  66309. * @param optimizer defines the current optimizer
  66310. * @returns true if everything that can be done was applied
  66311. */
  66312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66313. }
  66314. /**
  66315. * Defines an optimization used to turn lens flares off
  66316. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66317. */
  66318. export class LensFlaresOptimization extends SceneOptimization {
  66319. /**
  66320. * Gets a string describing the action executed by the current optimization
  66321. * @return description string
  66322. */
  66323. getDescription(): string;
  66324. /**
  66325. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66326. * @param scene defines the current scene where to apply this optimization
  66327. * @param optimizer defines the current optimizer
  66328. * @returns true if everything that can be done was applied
  66329. */
  66330. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66331. }
  66332. /**
  66333. * Defines an optimization based on user defined callback.
  66334. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66335. */
  66336. export class CustomOptimization extends SceneOptimization {
  66337. /**
  66338. * Callback called to apply the custom optimization.
  66339. */
  66340. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66341. /**
  66342. * Callback called to get custom description
  66343. */
  66344. onGetDescription: () => string;
  66345. /**
  66346. * Gets a string describing the action executed by the current optimization
  66347. * @returns description string
  66348. */
  66349. getDescription(): string;
  66350. /**
  66351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66352. * @param scene defines the current scene where to apply this optimization
  66353. * @param optimizer defines the current optimizer
  66354. * @returns true if everything that can be done was applied
  66355. */
  66356. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66357. }
  66358. /**
  66359. * Defines an optimization used to turn particles off
  66360. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66361. */
  66362. export class ParticlesOptimization extends SceneOptimization {
  66363. /**
  66364. * Gets a string describing the action executed by the current optimization
  66365. * @return description string
  66366. */
  66367. getDescription(): string;
  66368. /**
  66369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66370. * @param scene defines the current scene where to apply this optimization
  66371. * @param optimizer defines the current optimizer
  66372. * @returns true if everything that can be done was applied
  66373. */
  66374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66375. }
  66376. /**
  66377. * Defines an optimization used to turn render targets off
  66378. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66379. */
  66380. export class RenderTargetsOptimization extends SceneOptimization {
  66381. /**
  66382. * Gets a string describing the action executed by the current optimization
  66383. * @return description string
  66384. */
  66385. getDescription(): string;
  66386. /**
  66387. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66388. * @param scene defines the current scene where to apply this optimization
  66389. * @param optimizer defines the current optimizer
  66390. * @returns true if everything that can be done was applied
  66391. */
  66392. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66393. }
  66394. /**
  66395. * Defines an optimization used to merge meshes with compatible materials
  66396. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66397. */
  66398. export class MergeMeshesOptimization extends SceneOptimization {
  66399. private static _UpdateSelectionTree;
  66400. /**
  66401. * Gets or sets a boolean which defines if optimization octree has to be updated
  66402. */
  66403. static get UpdateSelectionTree(): boolean;
  66404. /**
  66405. * Gets or sets a boolean which defines if optimization octree has to be updated
  66406. */
  66407. static set UpdateSelectionTree(value: boolean);
  66408. /**
  66409. * Gets a string describing the action executed by the current optimization
  66410. * @return description string
  66411. */
  66412. getDescription(): string;
  66413. private _canBeMerged;
  66414. /**
  66415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66416. * @param scene defines the current scene where to apply this optimization
  66417. * @param optimizer defines the current optimizer
  66418. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66419. * @returns true if everything that can be done was applied
  66420. */
  66421. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66422. }
  66423. /**
  66424. * Defines a list of options used by SceneOptimizer
  66425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66426. */
  66427. export class SceneOptimizerOptions {
  66428. /**
  66429. * Defines the target frame rate to reach (60 by default)
  66430. */
  66431. targetFrameRate: number;
  66432. /**
  66433. * Defines the interval between two checkes (2000ms by default)
  66434. */
  66435. trackerDuration: number;
  66436. /**
  66437. * Gets the list of optimizations to apply
  66438. */
  66439. optimizations: SceneOptimization[];
  66440. /**
  66441. * Creates a new list of options used by SceneOptimizer
  66442. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66443. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66444. */
  66445. constructor(
  66446. /**
  66447. * Defines the target frame rate to reach (60 by default)
  66448. */
  66449. targetFrameRate?: number,
  66450. /**
  66451. * Defines the interval between two checkes (2000ms by default)
  66452. */
  66453. trackerDuration?: number);
  66454. /**
  66455. * Add a new optimization
  66456. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66457. * @returns the current SceneOptimizerOptions
  66458. */
  66459. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66460. /**
  66461. * Add a new custom optimization
  66462. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66463. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66465. * @returns the current SceneOptimizerOptions
  66466. */
  66467. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66468. /**
  66469. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66470. * @param targetFrameRate defines the target frame rate (60 by default)
  66471. * @returns a SceneOptimizerOptions object
  66472. */
  66473. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66474. /**
  66475. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66476. * @param targetFrameRate defines the target frame rate (60 by default)
  66477. * @returns a SceneOptimizerOptions object
  66478. */
  66479. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66480. /**
  66481. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66482. * @param targetFrameRate defines the target frame rate (60 by default)
  66483. * @returns a SceneOptimizerOptions object
  66484. */
  66485. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66486. }
  66487. /**
  66488. * Class used to run optimizations in order to reach a target frame rate
  66489. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66490. */
  66491. export class SceneOptimizer implements IDisposable {
  66492. private _isRunning;
  66493. private _options;
  66494. private _scene;
  66495. private _currentPriorityLevel;
  66496. private _targetFrameRate;
  66497. private _trackerDuration;
  66498. private _currentFrameRate;
  66499. private _sceneDisposeObserver;
  66500. private _improvementMode;
  66501. /**
  66502. * Defines an observable called when the optimizer reaches the target frame rate
  66503. */
  66504. onSuccessObservable: Observable<SceneOptimizer>;
  66505. /**
  66506. * Defines an observable called when the optimizer enables an optimization
  66507. */
  66508. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66509. /**
  66510. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66511. */
  66512. onFailureObservable: Observable<SceneOptimizer>;
  66513. /**
  66514. * Gets a boolean indicating if the optimizer is in improvement mode
  66515. */
  66516. get isInImprovementMode(): boolean;
  66517. /**
  66518. * Gets the current priority level (0 at start)
  66519. */
  66520. get currentPriorityLevel(): number;
  66521. /**
  66522. * Gets the current frame rate checked by the SceneOptimizer
  66523. */
  66524. get currentFrameRate(): number;
  66525. /**
  66526. * Gets or sets the current target frame rate (60 by default)
  66527. */
  66528. get targetFrameRate(): number;
  66529. /**
  66530. * Gets or sets the current target frame rate (60 by default)
  66531. */
  66532. set targetFrameRate(value: number);
  66533. /**
  66534. * Gets or sets the current interval between two checks (every 2000ms by default)
  66535. */
  66536. get trackerDuration(): number;
  66537. /**
  66538. * Gets or sets the current interval between two checks (every 2000ms by default)
  66539. */
  66540. set trackerDuration(value: number);
  66541. /**
  66542. * Gets the list of active optimizations
  66543. */
  66544. get optimizations(): SceneOptimization[];
  66545. /**
  66546. * Creates a new SceneOptimizer
  66547. * @param scene defines the scene to work on
  66548. * @param options defines the options to use with the SceneOptimizer
  66549. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66550. * @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)
  66551. */
  66552. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66553. /**
  66554. * Stops the current optimizer
  66555. */
  66556. stop(): void;
  66557. /**
  66558. * Reset the optimizer to initial step (current priority level = 0)
  66559. */
  66560. reset(): void;
  66561. /**
  66562. * Start the optimizer. By default it will try to reach a specific framerate
  66563. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66564. */
  66565. start(): void;
  66566. private _checkCurrentState;
  66567. /**
  66568. * Release all resources
  66569. */
  66570. dispose(): void;
  66571. /**
  66572. * Helper function to create a SceneOptimizer with one single line of code
  66573. * @param scene defines the scene to work on
  66574. * @param options defines the options to use with the SceneOptimizer
  66575. * @param onSuccess defines a callback to call on success
  66576. * @param onFailure defines a callback to call on failure
  66577. * @returns the new SceneOptimizer object
  66578. */
  66579. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66580. }
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * Class used to serialize a scene into a string
  66585. */
  66586. export class SceneSerializer {
  66587. /**
  66588. * Clear cache used by a previous serialization
  66589. */
  66590. static ClearCache(): void;
  66591. /**
  66592. * Serialize a scene into a JSON compatible object
  66593. * @param scene defines the scene to serialize
  66594. * @returns a JSON compatible object
  66595. */
  66596. static Serialize(scene: Scene): any;
  66597. /**
  66598. * Serialize a mesh into a JSON compatible object
  66599. * @param toSerialize defines the mesh to serialize
  66600. * @param withParents defines if parents must be serialized as well
  66601. * @param withChildren defines if children must be serialized as well
  66602. * @returns a JSON compatible object
  66603. */
  66604. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66605. }
  66606. }
  66607. declare module BABYLON {
  66608. /**
  66609. * Class used to host texture specific utilities
  66610. */
  66611. export class TextureTools {
  66612. /**
  66613. * Uses the GPU to create a copy texture rescaled at a given size
  66614. * @param texture Texture to copy from
  66615. * @param width defines the desired width
  66616. * @param height defines the desired height
  66617. * @param useBilinearMode defines if bilinear mode has to be used
  66618. * @return the generated texture
  66619. */
  66620. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66621. }
  66622. }
  66623. declare module BABYLON {
  66624. /**
  66625. * This represents the different options available for the video capture.
  66626. */
  66627. export interface VideoRecorderOptions {
  66628. /** Defines the mime type of the video. */
  66629. mimeType: string;
  66630. /** Defines the FPS the video should be recorded at. */
  66631. fps: number;
  66632. /** Defines the chunk size for the recording data. */
  66633. recordChunckSize: number;
  66634. /** The audio tracks to attach to the recording. */
  66635. audioTracks?: MediaStreamTrack[];
  66636. }
  66637. /**
  66638. * This can help with recording videos from BabylonJS.
  66639. * This is based on the available WebRTC functionalities of the browser.
  66640. *
  66641. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66642. */
  66643. export class VideoRecorder {
  66644. private static readonly _defaultOptions;
  66645. /**
  66646. * Returns whether or not the VideoRecorder is available in your browser.
  66647. * @param engine Defines the Babylon Engine.
  66648. * @returns true if supported otherwise false.
  66649. */
  66650. static IsSupported(engine: Engine): boolean;
  66651. private readonly _options;
  66652. private _canvas;
  66653. private _mediaRecorder;
  66654. private _recordedChunks;
  66655. private _fileName;
  66656. private _resolve;
  66657. private _reject;
  66658. /**
  66659. * True when a recording is already in progress.
  66660. */
  66661. get isRecording(): boolean;
  66662. /**
  66663. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66664. * @param engine Defines the BabylonJS Engine you wish to record.
  66665. * @param options Defines options that can be used to customize the capture.
  66666. */
  66667. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66668. /**
  66669. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66670. */
  66671. stopRecording(): void;
  66672. /**
  66673. * Starts recording the canvas for a max duration specified in parameters.
  66674. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66675. * If null no automatic download will start and you can rely on the promise to get the data back.
  66676. * @param maxDuration Defines the maximum recording time in seconds.
  66677. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66678. * @return A promise callback at the end of the recording with the video data in Blob.
  66679. */
  66680. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66681. /**
  66682. * Releases internal resources used during the recording.
  66683. */
  66684. dispose(): void;
  66685. private _handleDataAvailable;
  66686. private _handleError;
  66687. private _handleStop;
  66688. }
  66689. }
  66690. declare module BABYLON {
  66691. /**
  66692. * Class containing a set of static utilities functions for screenshots
  66693. */
  66694. export class ScreenshotTools {
  66695. /**
  66696. * Captures a screenshot of the current rendering
  66697. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66698. * @param engine defines the rendering engine
  66699. * @param camera defines the source camera
  66700. * @param size This parameter can be set to a single number or to an object with the
  66701. * following (optional) properties: precision, width, height. If a single number is passed,
  66702. * it will be used for both width and height. If an object is passed, the screenshot size
  66703. * will be derived from the parameters. The precision property is a multiplier allowing
  66704. * rendering at a higher or lower resolution
  66705. * @param successCallback defines the callback receives a single parameter which contains the
  66706. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66707. * src parameter of an <img> to display it
  66708. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66709. * Check your browser for supported MIME types
  66710. */
  66711. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66712. /**
  66713. * Captures a screenshot of the current rendering
  66714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66715. * @param engine defines the rendering engine
  66716. * @param camera defines the source camera
  66717. * @param size This parameter can be set to a single number or to an object with the
  66718. * following (optional) properties: precision, width, height. If a single number is passed,
  66719. * it will be used for both width and height. If an object is passed, the screenshot size
  66720. * will be derived from the parameters. The precision property is a multiplier allowing
  66721. * rendering at a higher or lower resolution
  66722. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66723. * Check your browser for supported MIME types
  66724. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66725. * to the src parameter of an <img> to display it
  66726. */
  66727. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66728. /**
  66729. * Generates an image screenshot from the specified camera.
  66730. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66731. * @param engine The engine to use for rendering
  66732. * @param camera The camera to use for rendering
  66733. * @param size This parameter can be set to a single number or to an object with the
  66734. * following (optional) properties: precision, width, height. If a single number is passed,
  66735. * it will be used for both width and height. If an object is passed, the screenshot size
  66736. * will be derived from the parameters. The precision property is a multiplier allowing
  66737. * rendering at a higher or lower resolution
  66738. * @param successCallback The callback receives a single parameter which contains the
  66739. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66740. * src parameter of an <img> to display it
  66741. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66742. * Check your browser for supported MIME types
  66743. * @param samples Texture samples (default: 1)
  66744. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66745. * @param fileName A name for for the downloaded file.
  66746. */
  66747. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66748. /**
  66749. * Generates an image screenshot from the specified camera.
  66750. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66751. * @param engine The engine to use for rendering
  66752. * @param camera The camera to use for rendering
  66753. * @param size This parameter can be set to a single number or to an object with the
  66754. * following (optional) properties: precision, width, height. If a single number is passed,
  66755. * it will be used for both width and height. If an object is passed, the screenshot size
  66756. * will be derived from the parameters. The precision property is a multiplier allowing
  66757. * rendering at a higher or lower resolution
  66758. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66759. * Check your browser for supported MIME types
  66760. * @param samples Texture samples (default: 1)
  66761. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66762. * @param fileName A name for for the downloaded file.
  66763. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66764. * to the src parameter of an <img> to display it
  66765. */
  66766. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66767. /**
  66768. * Gets height and width for screenshot size
  66769. * @private
  66770. */
  66771. private static _getScreenshotSize;
  66772. }
  66773. }
  66774. declare module BABYLON {
  66775. /**
  66776. * Interface for a data buffer
  66777. */
  66778. export interface IDataBuffer {
  66779. /**
  66780. * Reads bytes from the data buffer.
  66781. * @param byteOffset The byte offset to read
  66782. * @param byteLength The byte length to read
  66783. * @returns A promise that resolves when the bytes are read
  66784. */
  66785. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66786. /**
  66787. * The byte length of the buffer.
  66788. */
  66789. readonly byteLength: number;
  66790. }
  66791. /**
  66792. * Utility class for reading from a data buffer
  66793. */
  66794. export class DataReader {
  66795. /**
  66796. * The data buffer associated with this data reader.
  66797. */
  66798. readonly buffer: IDataBuffer;
  66799. /**
  66800. * The current byte offset from the beginning of the data buffer.
  66801. */
  66802. byteOffset: number;
  66803. private _dataView;
  66804. private _dataByteOffset;
  66805. /**
  66806. * Constructor
  66807. * @param buffer The buffer to read
  66808. */
  66809. constructor(buffer: IDataBuffer);
  66810. /**
  66811. * Loads the given byte length.
  66812. * @param byteLength The byte length to load
  66813. * @returns A promise that resolves when the load is complete
  66814. */
  66815. loadAsync(byteLength: number): Promise<void>;
  66816. /**
  66817. * Read a unsigned 32-bit integer from the currently loaded data range.
  66818. * @returns The 32-bit integer read
  66819. */
  66820. readUint32(): number;
  66821. /**
  66822. * Read a byte array from the currently loaded data range.
  66823. * @param byteLength The byte length to read
  66824. * @returns The byte array read
  66825. */
  66826. readUint8Array(byteLength: number): Uint8Array;
  66827. /**
  66828. * Read a string from the currently loaded data range.
  66829. * @param byteLength The byte length to read
  66830. * @returns The string read
  66831. */
  66832. readString(byteLength: number): string;
  66833. /**
  66834. * Skips the given byte length the currently loaded data range.
  66835. * @param byteLength The byte length to skip
  66836. */
  66837. skipBytes(byteLength: number): void;
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * A cursor which tracks a point on a path
  66843. */
  66844. export class PathCursor {
  66845. private path;
  66846. /**
  66847. * Stores path cursor callbacks for when an onchange event is triggered
  66848. */
  66849. private _onchange;
  66850. /**
  66851. * The value of the path cursor
  66852. */
  66853. value: number;
  66854. /**
  66855. * The animation array of the path cursor
  66856. */
  66857. animations: Animation[];
  66858. /**
  66859. * Initializes the path cursor
  66860. * @param path The path to track
  66861. */
  66862. constructor(path: Path2);
  66863. /**
  66864. * Gets the cursor point on the path
  66865. * @returns A point on the path cursor at the cursor location
  66866. */
  66867. getPoint(): Vector3;
  66868. /**
  66869. * Moves the cursor ahead by the step amount
  66870. * @param step The amount to move the cursor forward
  66871. * @returns This path cursor
  66872. */
  66873. moveAhead(step?: number): PathCursor;
  66874. /**
  66875. * Moves the cursor behind by the step amount
  66876. * @param step The amount to move the cursor back
  66877. * @returns This path cursor
  66878. */
  66879. moveBack(step?: number): PathCursor;
  66880. /**
  66881. * Moves the cursor by the step amount
  66882. * If the step amount is greater than one, an exception is thrown
  66883. * @param step The amount to move the cursor
  66884. * @returns This path cursor
  66885. */
  66886. move(step: number): PathCursor;
  66887. /**
  66888. * Ensures that the value is limited between zero and one
  66889. * @returns This path cursor
  66890. */
  66891. private ensureLimits;
  66892. /**
  66893. * Runs onchange callbacks on change (used by the animation engine)
  66894. * @returns This path cursor
  66895. */
  66896. private raiseOnChange;
  66897. /**
  66898. * Executes a function on change
  66899. * @param f A path cursor onchange callback
  66900. * @returns This path cursor
  66901. */
  66902. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66903. }
  66904. }
  66905. declare module BABYLON {
  66906. /** @hidden */
  66907. export var blurPixelShader: {
  66908. name: string;
  66909. shader: string;
  66910. };
  66911. }
  66912. declare module BABYLON {
  66913. /** @hidden */
  66914. export var pointCloudVertexDeclaration: {
  66915. name: string;
  66916. shader: string;
  66917. };
  66918. }
  66919. // Mixins
  66920. interface Window {
  66921. mozIndexedDB: IDBFactory;
  66922. webkitIndexedDB: IDBFactory;
  66923. msIndexedDB: IDBFactory;
  66924. webkitURL: typeof URL;
  66925. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66926. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66927. WebGLRenderingContext: WebGLRenderingContext;
  66928. MSGesture: MSGesture;
  66929. CANNON: any;
  66930. AudioContext: AudioContext;
  66931. webkitAudioContext: AudioContext;
  66932. PointerEvent: any;
  66933. Math: Math;
  66934. Uint8Array: Uint8ArrayConstructor;
  66935. Float32Array: Float32ArrayConstructor;
  66936. mozURL: typeof URL;
  66937. msURL: typeof URL;
  66938. VRFrameData: any; // WebVR, from specs 1.1
  66939. DracoDecoderModule: any;
  66940. setImmediate(handler: (...args: any[]) => void): number;
  66941. }
  66942. interface HTMLCanvasElement {
  66943. requestPointerLock(): void;
  66944. msRequestPointerLock?(): void;
  66945. mozRequestPointerLock?(): void;
  66946. webkitRequestPointerLock?(): void;
  66947. /** Track wether a record is in progress */
  66948. isRecording: boolean;
  66949. /** Capture Stream method defined by some browsers */
  66950. captureStream(fps?: number): MediaStream;
  66951. }
  66952. interface CanvasRenderingContext2D {
  66953. msImageSmoothingEnabled: boolean;
  66954. }
  66955. interface MouseEvent {
  66956. mozMovementX: number;
  66957. mozMovementY: number;
  66958. webkitMovementX: number;
  66959. webkitMovementY: number;
  66960. msMovementX: number;
  66961. msMovementY: number;
  66962. }
  66963. interface Navigator {
  66964. mozGetVRDevices: (any: any) => any;
  66965. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66966. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66967. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66968. webkitGetGamepads(): Gamepad[];
  66969. msGetGamepads(): Gamepad[];
  66970. webkitGamepads(): Gamepad[];
  66971. }
  66972. interface HTMLVideoElement {
  66973. mozSrcObject: any;
  66974. }
  66975. interface Math {
  66976. fround(x: number): number;
  66977. imul(a: number, b: number): number;
  66978. }
  66979. interface WebGLRenderingContext {
  66980. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66981. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66982. vertexAttribDivisor(index: number, divisor: number): void;
  66983. createVertexArray(): any;
  66984. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66985. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66986. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66987. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66988. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66989. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66990. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66991. // Queries
  66992. createQuery(): WebGLQuery;
  66993. deleteQuery(query: WebGLQuery): void;
  66994. beginQuery(target: number, query: WebGLQuery): void;
  66995. endQuery(target: number): void;
  66996. getQueryParameter(query: WebGLQuery, pname: number): any;
  66997. getQuery(target: number, pname: number): any;
  66998. MAX_SAMPLES: number;
  66999. RGBA8: number;
  67000. READ_FRAMEBUFFER: number;
  67001. DRAW_FRAMEBUFFER: number;
  67002. UNIFORM_BUFFER: number;
  67003. HALF_FLOAT_OES: number;
  67004. RGBA16F: number;
  67005. RGBA32F: number;
  67006. R32F: number;
  67007. RG32F: number;
  67008. RGB32F: number;
  67009. R16F: number;
  67010. RG16F: number;
  67011. RGB16F: number;
  67012. RED: number;
  67013. RG: number;
  67014. R8: number;
  67015. RG8: number;
  67016. UNSIGNED_INT_24_8: number;
  67017. DEPTH24_STENCIL8: number;
  67018. MIN: number;
  67019. MAX: number;
  67020. /* Multiple Render Targets */
  67021. drawBuffers(buffers: number[]): void;
  67022. readBuffer(src: number): void;
  67023. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  67024. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  67025. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  67026. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  67027. // Occlusion Query
  67028. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  67029. ANY_SAMPLES_PASSED: number;
  67030. QUERY_RESULT_AVAILABLE: number;
  67031. QUERY_RESULT: number;
  67032. }
  67033. interface WebGLProgram {
  67034. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  67035. }
  67036. interface EXT_disjoint_timer_query {
  67037. QUERY_COUNTER_BITS_EXT: number;
  67038. TIME_ELAPSED_EXT: number;
  67039. TIMESTAMP_EXT: number;
  67040. GPU_DISJOINT_EXT: number;
  67041. QUERY_RESULT_EXT: number;
  67042. QUERY_RESULT_AVAILABLE_EXT: number;
  67043. queryCounterEXT(query: WebGLQuery, target: number): void;
  67044. createQueryEXT(): WebGLQuery;
  67045. beginQueryEXT(target: number, query: WebGLQuery): void;
  67046. endQueryEXT(target: number): void;
  67047. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  67048. deleteQueryEXT(query: WebGLQuery): void;
  67049. }
  67050. interface WebGLUniformLocation {
  67051. _currentState: any;
  67052. }
  67053. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  67054. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  67055. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  67056. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67057. interface WebGLRenderingContext {
  67058. readonly RASTERIZER_DISCARD: number;
  67059. readonly DEPTH_COMPONENT24: number;
  67060. readonly TEXTURE_3D: number;
  67061. readonly TEXTURE_2D_ARRAY: number;
  67062. readonly TEXTURE_COMPARE_FUNC: number;
  67063. readonly TEXTURE_COMPARE_MODE: number;
  67064. readonly COMPARE_REF_TO_TEXTURE: number;
  67065. readonly TEXTURE_WRAP_R: number;
  67066. readonly HALF_FLOAT: number;
  67067. readonly RGB8: number;
  67068. readonly RED_INTEGER: number;
  67069. readonly RG_INTEGER: number;
  67070. readonly RGB_INTEGER: number;
  67071. readonly RGBA_INTEGER: number;
  67072. readonly R8_SNORM: number;
  67073. readonly RG8_SNORM: number;
  67074. readonly RGB8_SNORM: number;
  67075. readonly RGBA8_SNORM: number;
  67076. readonly R8I: number;
  67077. readonly RG8I: number;
  67078. readonly RGB8I: number;
  67079. readonly RGBA8I: number;
  67080. readonly R8UI: number;
  67081. readonly RG8UI: number;
  67082. readonly RGB8UI: number;
  67083. readonly RGBA8UI: number;
  67084. readonly R16I: number;
  67085. readonly RG16I: number;
  67086. readonly RGB16I: number;
  67087. readonly RGBA16I: number;
  67088. readonly R16UI: number;
  67089. readonly RG16UI: number;
  67090. readonly RGB16UI: number;
  67091. readonly RGBA16UI: number;
  67092. readonly R32I: number;
  67093. readonly RG32I: number;
  67094. readonly RGB32I: number;
  67095. readonly RGBA32I: number;
  67096. readonly R32UI: number;
  67097. readonly RG32UI: number;
  67098. readonly RGB32UI: number;
  67099. readonly RGBA32UI: number;
  67100. readonly RGB10_A2UI: number;
  67101. readonly R11F_G11F_B10F: number;
  67102. readonly RGB9_E5: number;
  67103. readonly RGB10_A2: number;
  67104. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67105. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67106. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67107. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67108. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67109. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67110. 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;
  67111. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67112. readonly TRANSFORM_FEEDBACK: number;
  67113. readonly INTERLEAVED_ATTRIBS: number;
  67114. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67115. createTransformFeedback(): WebGLTransformFeedback;
  67116. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67117. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67118. beginTransformFeedback(primitiveMode: number): void;
  67119. endTransformFeedback(): void;
  67120. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67121. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67122. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67123. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67124. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67125. }
  67126. interface ImageBitmap {
  67127. readonly width: number;
  67128. readonly height: number;
  67129. close(): void;
  67130. }
  67131. interface WebGLQuery extends WebGLObject {
  67132. }
  67133. declare var WebGLQuery: {
  67134. prototype: WebGLQuery;
  67135. new(): WebGLQuery;
  67136. };
  67137. interface WebGLSampler extends WebGLObject {
  67138. }
  67139. declare var WebGLSampler: {
  67140. prototype: WebGLSampler;
  67141. new(): WebGLSampler;
  67142. };
  67143. interface WebGLSync extends WebGLObject {
  67144. }
  67145. declare var WebGLSync: {
  67146. prototype: WebGLSync;
  67147. new(): WebGLSync;
  67148. };
  67149. interface WebGLTransformFeedback extends WebGLObject {
  67150. }
  67151. declare var WebGLTransformFeedback: {
  67152. prototype: WebGLTransformFeedback;
  67153. new(): WebGLTransformFeedback;
  67154. };
  67155. interface WebGLVertexArrayObject extends WebGLObject {
  67156. }
  67157. declare var WebGLVertexArrayObject: {
  67158. prototype: WebGLVertexArrayObject;
  67159. new(): WebGLVertexArrayObject;
  67160. };
  67161. // Type definitions for WebVR API
  67162. // Project: https://w3c.github.io/webvr/
  67163. // Definitions by: six a <https://github.com/lostfictions>
  67164. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67165. interface VRDisplay extends EventTarget {
  67166. /**
  67167. * Dictionary of capabilities describing the VRDisplay.
  67168. */
  67169. readonly capabilities: VRDisplayCapabilities;
  67170. /**
  67171. * z-depth defining the far plane of the eye view frustum
  67172. * enables mapping of values in the render target depth
  67173. * attachment to scene coordinates. Initially set to 10000.0.
  67174. */
  67175. depthFar: number;
  67176. /**
  67177. * z-depth defining the near plane of the eye view frustum
  67178. * enables mapping of values in the render target depth
  67179. * attachment to scene coordinates. Initially set to 0.01.
  67180. */
  67181. depthNear: number;
  67182. /**
  67183. * An identifier for this distinct VRDisplay. Used as an
  67184. * association point in the Gamepad API.
  67185. */
  67186. readonly displayId: number;
  67187. /**
  67188. * A display name, a user-readable name identifying it.
  67189. */
  67190. readonly displayName: string;
  67191. readonly isConnected: boolean;
  67192. readonly isPresenting: boolean;
  67193. /**
  67194. * If this VRDisplay supports room-scale experiences, the optional
  67195. * stage attribute contains details on the room-scale parameters.
  67196. */
  67197. readonly stageParameters: VRStageParameters | null;
  67198. /**
  67199. * Passing the value returned by `requestAnimationFrame` to
  67200. * `cancelAnimationFrame` will unregister the callback.
  67201. * @param handle Define the hanle of the request to cancel
  67202. */
  67203. cancelAnimationFrame(handle: number): void;
  67204. /**
  67205. * Stops presenting to the VRDisplay.
  67206. * @returns a promise to know when it stopped
  67207. */
  67208. exitPresent(): Promise<void>;
  67209. /**
  67210. * Return the current VREyeParameters for the given eye.
  67211. * @param whichEye Define the eye we want the parameter for
  67212. * @returns the eye parameters
  67213. */
  67214. getEyeParameters(whichEye: string): VREyeParameters;
  67215. /**
  67216. * Populates the passed VRFrameData with the information required to render
  67217. * the current frame.
  67218. * @param frameData Define the data structure to populate
  67219. * @returns true if ok otherwise false
  67220. */
  67221. getFrameData(frameData: VRFrameData): boolean;
  67222. /**
  67223. * Get the layers currently being presented.
  67224. * @returns the list of VR layers
  67225. */
  67226. getLayers(): VRLayer[];
  67227. /**
  67228. * Return a VRPose containing the future predicted pose of the VRDisplay
  67229. * when the current frame will be presented. The value returned will not
  67230. * change until JavaScript has returned control to the browser.
  67231. *
  67232. * The VRPose will contain the position, orientation, velocity,
  67233. * and acceleration of each of these properties.
  67234. * @returns the pose object
  67235. */
  67236. getPose(): VRPose;
  67237. /**
  67238. * Return the current instantaneous pose of the VRDisplay, with no
  67239. * prediction applied.
  67240. * @returns the current instantaneous pose
  67241. */
  67242. getImmediatePose(): VRPose;
  67243. /**
  67244. * The callback passed to `requestAnimationFrame` will be called
  67245. * any time a new frame should be rendered. When the VRDisplay is
  67246. * presenting the callback will be called at the native refresh
  67247. * rate of the HMD. When not presenting this function acts
  67248. * identically to how window.requestAnimationFrame acts. Content should
  67249. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67250. * asynchronously from other displays and at differing refresh rates.
  67251. * @param callback Define the eaction to run next frame
  67252. * @returns the request handle it
  67253. */
  67254. requestAnimationFrame(callback: FrameRequestCallback): number;
  67255. /**
  67256. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67257. * Repeat calls while already presenting will update the VRLayers being displayed.
  67258. * @param layers Define the list of layer to present
  67259. * @returns a promise to know when the request has been fulfilled
  67260. */
  67261. requestPresent(layers: VRLayer[]): Promise<void>;
  67262. /**
  67263. * Reset the pose for this display, treating its current position and
  67264. * orientation as the "origin/zero" values. VRPose.position,
  67265. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67266. * updated when calling resetPose(). This should be called in only
  67267. * sitting-space experiences.
  67268. */
  67269. resetPose(): void;
  67270. /**
  67271. * The VRLayer provided to the VRDisplay will be captured and presented
  67272. * in the HMD. Calling this function has the same effect on the source
  67273. * canvas as any other operation that uses its source image, and canvases
  67274. * created without preserveDrawingBuffer set to true will be cleared.
  67275. * @param pose Define the pose to submit
  67276. */
  67277. submitFrame(pose?: VRPose): void;
  67278. }
  67279. declare var VRDisplay: {
  67280. prototype: VRDisplay;
  67281. new(): VRDisplay;
  67282. };
  67283. interface VRLayer {
  67284. leftBounds?: number[] | Float32Array | null;
  67285. rightBounds?: number[] | Float32Array | null;
  67286. source?: HTMLCanvasElement | null;
  67287. }
  67288. interface VRDisplayCapabilities {
  67289. readonly canPresent: boolean;
  67290. readonly hasExternalDisplay: boolean;
  67291. readonly hasOrientation: boolean;
  67292. readonly hasPosition: boolean;
  67293. readonly maxLayers: number;
  67294. }
  67295. interface VREyeParameters {
  67296. /** @deprecated */
  67297. readonly fieldOfView: VRFieldOfView;
  67298. readonly offset: Float32Array;
  67299. readonly renderHeight: number;
  67300. readonly renderWidth: number;
  67301. }
  67302. interface VRFieldOfView {
  67303. readonly downDegrees: number;
  67304. readonly leftDegrees: number;
  67305. readonly rightDegrees: number;
  67306. readonly upDegrees: number;
  67307. }
  67308. interface VRFrameData {
  67309. readonly leftProjectionMatrix: Float32Array;
  67310. readonly leftViewMatrix: Float32Array;
  67311. readonly pose: VRPose;
  67312. readonly rightProjectionMatrix: Float32Array;
  67313. readonly rightViewMatrix: Float32Array;
  67314. readonly timestamp: number;
  67315. }
  67316. interface VRPose {
  67317. readonly angularAcceleration: Float32Array | null;
  67318. readonly angularVelocity: Float32Array | null;
  67319. readonly linearAcceleration: Float32Array | null;
  67320. readonly linearVelocity: Float32Array | null;
  67321. readonly orientation: Float32Array | null;
  67322. readonly position: Float32Array | null;
  67323. readonly timestamp: number;
  67324. }
  67325. interface VRStageParameters {
  67326. sittingToStandingTransform?: Float32Array;
  67327. sizeX?: number;
  67328. sizeY?: number;
  67329. }
  67330. interface Navigator {
  67331. getVRDisplays(): Promise<VRDisplay[]>;
  67332. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  67333. }
  67334. interface Window {
  67335. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  67336. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  67337. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  67338. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67339. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67340. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  67341. }
  67342. interface Gamepad {
  67343. readonly displayId: number;
  67344. }
  67345. type XRSessionMode =
  67346. | "inline"
  67347. | "immersive-vr"
  67348. | "immersive-ar";
  67349. type XRReferenceSpaceType =
  67350. | "viewer"
  67351. | "local"
  67352. | "local-floor"
  67353. | "bounded-floor"
  67354. | "unbounded";
  67355. type XREnvironmentBlendMode =
  67356. | "opaque"
  67357. | "additive"
  67358. | "alpha-blend";
  67359. type XRVisibilityState =
  67360. | "visible"
  67361. | "visible-blurred"
  67362. | "hidden";
  67363. type XRHandedness =
  67364. | "none"
  67365. | "left"
  67366. | "right";
  67367. type XRTargetRayMode =
  67368. | "gaze"
  67369. | "tracked-pointer"
  67370. | "screen";
  67371. type XREye =
  67372. | "none"
  67373. | "left"
  67374. | "right";
  67375. interface XRSpace extends EventTarget {
  67376. }
  67377. interface XRRenderState {
  67378. depthNear?: number;
  67379. depthFar?: number;
  67380. inlineVerticalFieldOfView?: number;
  67381. baseLayer?: XRWebGLLayer;
  67382. }
  67383. interface XRInputSource {
  67384. handedness: XRHandedness;
  67385. targetRayMode: XRTargetRayMode;
  67386. targetRaySpace: XRSpace;
  67387. gripSpace: XRSpace | undefined;
  67388. gamepad: Gamepad | undefined;
  67389. profiles: Array<string>;
  67390. }
  67391. interface XRSession extends XRAnchorCreator {
  67392. addEventListener: Function;
  67393. removeEventListener: Function;
  67394. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  67395. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  67396. requestAnimationFrame: Function;
  67397. end(): Promise<void>;
  67398. renderState: XRRenderState;
  67399. inputSources: Array<XRInputSource>;
  67400. // AR hit test
  67401. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  67402. updateWorldTrackingState(options: {
  67403. planeDetectionState?: { enabled: boolean; }
  67404. }): void;
  67405. }
  67406. interface XRReferenceSpace extends XRSpace {
  67407. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  67408. onreset: any;
  67409. }
  67410. type XRPlaneSet = Set<XRPlane>;
  67411. type XRAnchorSet = Set<XRAnchor>;
  67412. interface XRFrame {
  67413. session: XRSession;
  67414. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  67415. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  67416. // Anchors
  67417. trackedAnchors?: XRAnchorSet;
  67418. // Planes
  67419. worldInformation: {
  67420. detectedPlanes?: XRPlaneSet;
  67421. };
  67422. }
  67423. interface XRViewerPose extends XRPose {
  67424. views: Array<XRView>;
  67425. }
  67426. interface XRPose {
  67427. transform: XRRigidTransform;
  67428. emulatedPosition: boolean;
  67429. }
  67430. interface XRWebGLLayerOptions {
  67431. antialias?: boolean;
  67432. depth?: boolean;
  67433. stencil?: boolean;
  67434. alpha?: boolean;
  67435. multiview?: boolean;
  67436. framebufferScaleFactor?: number;
  67437. }
  67438. declare var XRWebGLLayer: {
  67439. prototype: XRWebGLLayer;
  67440. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  67441. };
  67442. interface XRWebGLLayer {
  67443. framebuffer: WebGLFramebuffer;
  67444. framebufferWidth: number;
  67445. framebufferHeight: number;
  67446. getViewport: Function;
  67447. }
  67448. declare class XRRigidTransform {
  67449. constructor(matrix: Float32Array);
  67450. position: DOMPointReadOnly;
  67451. orientation: DOMPointReadOnly;
  67452. matrix: Float32Array;
  67453. inverse: XRRigidTransform;
  67454. }
  67455. interface XRView {
  67456. eye: XREye;
  67457. projectionMatrix: Float32Array;
  67458. transform: XRRigidTransform;
  67459. }
  67460. interface XRInputSourceChangeEvent {
  67461. session: XRSession;
  67462. removed: Array<XRInputSource>;
  67463. added: Array<XRInputSource>;
  67464. }
  67465. interface XRInputSourceEvent extends Event {
  67466. readonly frame: XRFrame;
  67467. readonly inputSource: XRInputSource;
  67468. }
  67469. // Experimental(er) features
  67470. declare class XRRay {
  67471. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  67472. origin: DOMPointReadOnly;
  67473. direction: DOMPointReadOnly;
  67474. matrix: Float32Array;
  67475. }
  67476. interface XRHitResult {
  67477. hitMatrix: Float32Array;
  67478. }
  67479. interface XRAnchor {
  67480. // remove?
  67481. id?: string;
  67482. anchorSpace: XRSpace;
  67483. lastChangedTime: number;
  67484. detach(): void;
  67485. }
  67486. interface XRPlane extends XRAnchorCreator {
  67487. orientation: "Horizontal" | "Vertical";
  67488. planeSpace: XRSpace;
  67489. polygon: Array<DOMPointReadOnly>;
  67490. lastChangedTime: number;
  67491. }
  67492. interface XRAnchorCreator {
  67493. // AR Anchors
  67494. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  67495. }
  67496. /**
  67497. * @ignore
  67498. */
  67499. declare module BABYLON.GLTF2.Exporter {
  67500. }
  67501. /**
  67502. * @ignore
  67503. */
  67504. declare module BABYLON.GLTF1 {
  67505. }
  67506. declare module BABYLON.GUI {
  67507. /**
  67508. * Class used to specific a value and its associated unit
  67509. */
  67510. export class ValueAndUnit {
  67511. /** defines the unit to store */
  67512. unit: number;
  67513. /** defines a boolean indicating if the value can be negative */
  67514. negativeValueAllowed: boolean;
  67515. private _value;
  67516. private _originalUnit;
  67517. /**
  67518. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  67519. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67520. */
  67521. ignoreAdaptiveScaling: boolean;
  67522. /**
  67523. * Creates a new ValueAndUnit
  67524. * @param value defines the value to store
  67525. * @param unit defines the unit to store
  67526. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  67527. */
  67528. constructor(value: number,
  67529. /** defines the unit to store */
  67530. unit?: number,
  67531. /** defines a boolean indicating if the value can be negative */
  67532. negativeValueAllowed?: boolean);
  67533. /** Gets a boolean indicating if the value is a percentage */
  67534. get isPercentage(): boolean;
  67535. /** Gets a boolean indicating if the value is store as pixel */
  67536. get isPixel(): boolean;
  67537. /** Gets direct internal value */
  67538. get internalValue(): number;
  67539. /**
  67540. * Gets value as pixel
  67541. * @param host defines the root host
  67542. * @param refValue defines the reference value for percentages
  67543. * @returns the value as pixel
  67544. */
  67545. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  67546. /**
  67547. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  67548. * @param value defines the value to store
  67549. * @param unit defines the unit to store
  67550. * @returns the current ValueAndUnit
  67551. */
  67552. updateInPlace(value: number, unit?: number): ValueAndUnit;
  67553. /**
  67554. * Gets the value accordingly to its unit
  67555. * @param host defines the root host
  67556. * @returns the value
  67557. */
  67558. getValue(host: AdvancedDynamicTexture): number;
  67559. /**
  67560. * Gets a string representation of the value
  67561. * @param host defines the root host
  67562. * @param decimals defines an optional number of decimals to display
  67563. * @returns a string
  67564. */
  67565. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  67566. /**
  67567. * Store a value parsed from a string
  67568. * @param source defines the source string
  67569. * @returns true if the value was successfully parsed
  67570. */
  67571. fromString(source: string | number): boolean;
  67572. private static _Regex;
  67573. private static _UNITMODE_PERCENTAGE;
  67574. private static _UNITMODE_PIXEL;
  67575. /** UNITMODE_PERCENTAGE */
  67576. static get UNITMODE_PERCENTAGE(): number;
  67577. /** UNITMODE_PIXEL */
  67578. static get UNITMODE_PIXEL(): number;
  67579. }
  67580. }
  67581. declare module BABYLON.GUI {
  67582. /**
  67583. * Define a style used by control to automatically setup properties based on a template.
  67584. * Only support font related properties so far
  67585. */
  67586. export class Style implements BABYLON.IDisposable {
  67587. private _fontFamily;
  67588. private _fontStyle;
  67589. private _fontWeight;
  67590. /** @hidden */
  67591. _host: AdvancedDynamicTexture;
  67592. /** @hidden */
  67593. _fontSize: ValueAndUnit;
  67594. /**
  67595. * BABYLON.Observable raised when the style values are changed
  67596. */
  67597. onChangedObservable: BABYLON.Observable<Style>;
  67598. /**
  67599. * Creates a new style object
  67600. * @param host defines the AdvancedDynamicTexture which hosts this style
  67601. */
  67602. constructor(host: AdvancedDynamicTexture);
  67603. /**
  67604. * Gets or sets the font size
  67605. */
  67606. get fontSize(): string | number;
  67607. set fontSize(value: string | number);
  67608. /**
  67609. * Gets or sets the font family
  67610. */
  67611. get fontFamily(): string;
  67612. set fontFamily(value: string);
  67613. /**
  67614. * Gets or sets the font style
  67615. */
  67616. get fontStyle(): string;
  67617. set fontStyle(value: string);
  67618. /** Gets or sets font weight */
  67619. get fontWeight(): string;
  67620. set fontWeight(value: string);
  67621. /** Dispose all associated resources */
  67622. dispose(): void;
  67623. }
  67624. }
  67625. declare module BABYLON.GUI {
  67626. /**
  67627. * Class used to transport BABYLON.Vector2 information for pointer events
  67628. */
  67629. export class Vector2WithInfo extends BABYLON.Vector2 {
  67630. /** defines the current mouse button index */
  67631. buttonIndex: number;
  67632. /**
  67633. * Creates a new Vector2WithInfo
  67634. * @param source defines the vector2 data to transport
  67635. * @param buttonIndex defines the current mouse button index
  67636. */
  67637. constructor(source: BABYLON.Vector2,
  67638. /** defines the current mouse button index */
  67639. buttonIndex?: number);
  67640. }
  67641. /** Class used to provide 2D matrix features */
  67642. export class Matrix2D {
  67643. /** Gets the internal array of 6 floats used to store matrix data */
  67644. m: Float32Array;
  67645. /**
  67646. * Creates a new matrix
  67647. * @param m00 defines value for (0, 0)
  67648. * @param m01 defines value for (0, 1)
  67649. * @param m10 defines value for (1, 0)
  67650. * @param m11 defines value for (1, 1)
  67651. * @param m20 defines value for (2, 0)
  67652. * @param m21 defines value for (2, 1)
  67653. */
  67654. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  67655. /**
  67656. * Fills the matrix from direct values
  67657. * @param m00 defines value for (0, 0)
  67658. * @param m01 defines value for (0, 1)
  67659. * @param m10 defines value for (1, 0)
  67660. * @param m11 defines value for (1, 1)
  67661. * @param m20 defines value for (2, 0)
  67662. * @param m21 defines value for (2, 1)
  67663. * @returns the current modified matrix
  67664. */
  67665. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  67666. /**
  67667. * Gets matrix determinant
  67668. * @returns the determinant
  67669. */
  67670. determinant(): number;
  67671. /**
  67672. * Inverses the matrix and stores it in a target matrix
  67673. * @param result defines the target matrix
  67674. * @returns the current matrix
  67675. */
  67676. invertToRef(result: Matrix2D): Matrix2D;
  67677. /**
  67678. * Multiplies the current matrix with another one
  67679. * @param other defines the second operand
  67680. * @param result defines the target matrix
  67681. * @returns the current matrix
  67682. */
  67683. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67684. /**
  67685. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67686. * @param x defines the x coordinate to transform
  67687. * @param y defines the x coordinate to transform
  67688. * @param result defines the target vector2
  67689. * @returns the current matrix
  67690. */
  67691. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67692. /**
  67693. * Creates an identity matrix
  67694. * @returns a new matrix
  67695. */
  67696. static Identity(): Matrix2D;
  67697. /**
  67698. * Creates a translation matrix and stores it in a target matrix
  67699. * @param x defines the x coordinate of the translation
  67700. * @param y defines the y coordinate of the translation
  67701. * @param result defines the target matrix
  67702. */
  67703. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67704. /**
  67705. * Creates a scaling matrix and stores it in a target matrix
  67706. * @param x defines the x coordinate of the scaling
  67707. * @param y defines the y coordinate of the scaling
  67708. * @param result defines the target matrix
  67709. */
  67710. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67711. /**
  67712. * Creates a rotation matrix and stores it in a target matrix
  67713. * @param angle defines the rotation angle
  67714. * @param result defines the target matrix
  67715. */
  67716. static RotationToRef(angle: number, result: Matrix2D): void;
  67717. private static _TempPreTranslationMatrix;
  67718. private static _TempPostTranslationMatrix;
  67719. private static _TempRotationMatrix;
  67720. private static _TempScalingMatrix;
  67721. private static _TempCompose0;
  67722. private static _TempCompose1;
  67723. private static _TempCompose2;
  67724. /**
  67725. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67726. * @param tx defines the x coordinate of the translation
  67727. * @param ty defines the y coordinate of the translation
  67728. * @param angle defines the rotation angle
  67729. * @param scaleX defines the x coordinate of the scaling
  67730. * @param scaleY defines the y coordinate of the scaling
  67731. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67732. * @param result defines the target matrix
  67733. */
  67734. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67735. }
  67736. }
  67737. declare module BABYLON.GUI {
  67738. /**
  67739. * Class used to store 2D control sizes
  67740. */
  67741. export class Measure {
  67742. /** defines left coordinate */
  67743. left: number;
  67744. /** defines top coordinate */
  67745. top: number;
  67746. /** defines width dimension */
  67747. width: number;
  67748. /** defines height dimension */
  67749. height: number;
  67750. /**
  67751. * Creates a new measure
  67752. * @param left defines left coordinate
  67753. * @param top defines top coordinate
  67754. * @param width defines width dimension
  67755. * @param height defines height dimension
  67756. */
  67757. constructor(
  67758. /** defines left coordinate */
  67759. left: number,
  67760. /** defines top coordinate */
  67761. top: number,
  67762. /** defines width dimension */
  67763. width: number,
  67764. /** defines height dimension */
  67765. height: number);
  67766. /**
  67767. * Copy from another measure
  67768. * @param other defines the other measure to copy from
  67769. */
  67770. copyFrom(other: Measure): void;
  67771. /**
  67772. * Copy from a group of 4 floats
  67773. * @param left defines left coordinate
  67774. * @param top defines top coordinate
  67775. * @param width defines width dimension
  67776. * @param height defines height dimension
  67777. */
  67778. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67779. /**
  67780. * Computes the axis aligned bounding box measure for two given measures
  67781. * @param a Input measure
  67782. * @param b Input measure
  67783. * @param result the resulting bounding measure
  67784. */
  67785. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67786. /**
  67787. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67788. * @param transform the matrix to transform the measure before computing the AABB
  67789. * @param result the resulting AABB
  67790. */
  67791. transformToRef(transform: Matrix2D, result: Measure): void;
  67792. /**
  67793. * Check equality between this measure and another one
  67794. * @param other defines the other measures
  67795. * @returns true if both measures are equals
  67796. */
  67797. isEqualsTo(other: Measure): boolean;
  67798. /**
  67799. * Creates an empty measure
  67800. * @returns a new measure
  67801. */
  67802. static Empty(): Measure;
  67803. }
  67804. }
  67805. declare module BABYLON.GUI {
  67806. /**
  67807. * Interface used to define a control that can receive focus
  67808. */
  67809. export interface IFocusableControl {
  67810. /**
  67811. * Function called when the control receives the focus
  67812. */
  67813. onFocus(): void;
  67814. /**
  67815. * Function called when the control loses the focus
  67816. */
  67817. onBlur(): void;
  67818. /**
  67819. * Function called to let the control handle keyboard events
  67820. * @param evt defines the current keyboard event
  67821. */
  67822. processKeyboard(evt: KeyboardEvent): void;
  67823. /**
  67824. * Function called to get the list of controls that should not steal the focus from this control
  67825. * @returns an array of controls
  67826. */
  67827. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67828. }
  67829. /**
  67830. * Class used to create texture to support 2D GUI elements
  67831. * @see http://doc.babylonjs.com/how_to/gui
  67832. */
  67833. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67834. private _isDirty;
  67835. private _renderObserver;
  67836. private _resizeObserver;
  67837. private _preKeyboardObserver;
  67838. private _pointerMoveObserver;
  67839. private _pointerObserver;
  67840. private _canvasPointerOutObserver;
  67841. private _background;
  67842. /** @hidden */
  67843. _rootContainer: Container;
  67844. /** @hidden */
  67845. _lastPickedControl: Control;
  67846. /** @hidden */
  67847. _lastControlOver: {
  67848. [pointerId: number]: Control;
  67849. };
  67850. /** @hidden */
  67851. _lastControlDown: {
  67852. [pointerId: number]: Control;
  67853. };
  67854. /** @hidden */
  67855. _capturingControl: {
  67856. [pointerId: number]: Control;
  67857. };
  67858. /** @hidden */
  67859. _shouldBlockPointer: boolean;
  67860. /** @hidden */
  67861. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67862. /** @hidden */
  67863. _linkedControls: Control[];
  67864. private _isFullscreen;
  67865. private _fullscreenViewport;
  67866. private _idealWidth;
  67867. private _idealHeight;
  67868. private _useSmallestIdeal;
  67869. private _renderAtIdealSize;
  67870. private _focusedControl;
  67871. private _blockNextFocusCheck;
  67872. private _renderScale;
  67873. private _rootElement;
  67874. private _cursorChanged;
  67875. /**
  67876. * Define type to string to ensure compatibility across browsers
  67877. * Safari doesn't support DataTransfer constructor
  67878. */
  67879. private _clipboardData;
  67880. /**
  67881. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67882. */
  67883. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67884. /**
  67885. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67886. */
  67887. onControlPickedObservable: BABYLON.Observable<Control>;
  67888. /**
  67889. * BABYLON.Observable event triggered before layout is evaluated
  67890. */
  67891. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67892. /**
  67893. * BABYLON.Observable event triggered after the layout was evaluated
  67894. */
  67895. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67896. /**
  67897. * BABYLON.Observable event triggered before the texture is rendered
  67898. */
  67899. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67900. /**
  67901. * BABYLON.Observable event triggered after the texture was rendered
  67902. */
  67903. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67904. /**
  67905. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67906. */
  67907. premulAlpha: boolean;
  67908. /**
  67909. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67910. * Useful when you want more antialiasing
  67911. */
  67912. get renderScale(): number;
  67913. set renderScale(value: number);
  67914. /** Gets or sets the background color */
  67915. get background(): string;
  67916. set background(value: string);
  67917. /**
  67918. * Gets or sets the ideal width used to design controls.
  67919. * The GUI will then rescale everything accordingly
  67920. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67921. */
  67922. get idealWidth(): number;
  67923. set idealWidth(value: number);
  67924. /**
  67925. * Gets or sets the ideal height used to design controls.
  67926. * The GUI will then rescale everything accordingly
  67927. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67928. */
  67929. get idealHeight(): number;
  67930. set idealHeight(value: number);
  67931. /**
  67932. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67933. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67934. */
  67935. get useSmallestIdeal(): boolean;
  67936. set useSmallestIdeal(value: boolean);
  67937. /**
  67938. * Gets or sets a boolean indicating if adaptive scaling must be used
  67939. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67940. */
  67941. get renderAtIdealSize(): boolean;
  67942. set renderAtIdealSize(value: boolean);
  67943. /**
  67944. * Gets the underlying layer used to render the texture when in fullscreen mode
  67945. */
  67946. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  67947. /**
  67948. * Gets the root container control
  67949. */
  67950. get rootContainer(): Container;
  67951. /**
  67952. * Returns an array containing the root container.
  67953. * This is mostly used to let the Inspector introspects the ADT
  67954. * @returns an array containing the rootContainer
  67955. */
  67956. getChildren(): Array<Container>;
  67957. /**
  67958. * Will return all controls that are inside this texture
  67959. * @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
  67960. * @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
  67961. * @return all child controls
  67962. */
  67963. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67964. /**
  67965. * Gets or sets the current focused control
  67966. */
  67967. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  67968. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  67969. /**
  67970. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  67971. */
  67972. get isForeground(): boolean;
  67973. set isForeground(value: boolean);
  67974. /**
  67975. * Gets or set information about clipboardData
  67976. */
  67977. get clipboardData(): string;
  67978. set clipboardData(value: string);
  67979. /**
  67980. * Creates a new AdvancedDynamicTexture
  67981. * @param name defines the name of the texture
  67982. * @param width defines the width of the texture
  67983. * @param height defines the height of the texture
  67984. * @param scene defines the hosting scene
  67985. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  67986. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  67987. */
  67988. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  67989. /**
  67990. * Get the current class name of the texture useful for serialization or dynamic coding.
  67991. * @returns "AdvancedDynamicTexture"
  67992. */
  67993. getClassName(): string;
  67994. /**
  67995. * Function used to execute a function on all controls
  67996. * @param func defines the function to execute
  67997. * @param container defines the container where controls belong. If null the root container will be used
  67998. */
  67999. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  68000. private _useInvalidateRectOptimization;
  68001. /**
  68002. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  68003. */
  68004. get useInvalidateRectOptimization(): boolean;
  68005. set useInvalidateRectOptimization(value: boolean);
  68006. private _invalidatedRectangle;
  68007. /**
  68008. * Invalidates a rectangle area on the gui texture
  68009. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  68010. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  68011. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  68012. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  68013. */
  68014. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  68015. /**
  68016. * Marks the texture as dirty forcing a complete update
  68017. */
  68018. markAsDirty(): void;
  68019. /**
  68020. * Helper function used to create a new style
  68021. * @returns a new style
  68022. * @see http://doc.babylonjs.com/how_to/gui#styles
  68023. */
  68024. createStyle(): Style;
  68025. /**
  68026. * Adds a new control to the root container
  68027. * @param control defines the control to add
  68028. * @returns the current texture
  68029. */
  68030. addControl(control: Control): AdvancedDynamicTexture;
  68031. /**
  68032. * Removes a control from the root container
  68033. * @param control defines the control to remove
  68034. * @returns the current texture
  68035. */
  68036. removeControl(control: Control): AdvancedDynamicTexture;
  68037. /**
  68038. * Release all resources
  68039. */
  68040. dispose(): void;
  68041. private _onResize;
  68042. /** @hidden */
  68043. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  68044. /**
  68045. * Get screen coordinates for a vector3
  68046. * @param position defines the position to project
  68047. * @param worldMatrix defines the world matrix to use
  68048. * @returns the projected position
  68049. */
  68050. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  68051. private _checkUpdate;
  68052. private _clearMeasure;
  68053. private _render;
  68054. /** @hidden */
  68055. _changeCursor(cursor: string): void;
  68056. /** @hidden */
  68057. _registerLastControlDown(control: Control, pointerId: number): void;
  68058. private _doPicking;
  68059. /** @hidden */
  68060. _cleanControlAfterRemovalFromList(list: {
  68061. [pointerId: number]: Control;
  68062. }, control: Control): void;
  68063. /** @hidden */
  68064. _cleanControlAfterRemoval(control: Control): void;
  68065. /** Attach to all scene events required to support pointer events */
  68066. attach(): void;
  68067. /** @hidden */
  68068. private onClipboardCopy;
  68069. /** @hidden */
  68070. private onClipboardCut;
  68071. /** @hidden */
  68072. private onClipboardPaste;
  68073. /**
  68074. * Register the clipboard Events onto the canvas
  68075. */
  68076. registerClipboardEvents(): void;
  68077. /**
  68078. * Unregister the clipboard Events from the canvas
  68079. */
  68080. unRegisterClipboardEvents(): void;
  68081. /**
  68082. * Connect the texture to a hosting mesh to enable interactions
  68083. * @param mesh defines the mesh to attach to
  68084. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  68085. */
  68086. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  68087. /**
  68088. * Move the focus to a specific control
  68089. * @param control defines the control which will receive the focus
  68090. */
  68091. moveFocusToControl(control: IFocusableControl): void;
  68092. private _manageFocus;
  68093. private _attachToOnPointerOut;
  68094. /**
  68095. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  68096. * @param mesh defines the mesh which will receive the texture
  68097. * @param width defines the texture width (1024 by default)
  68098. * @param height defines the texture height (1024 by default)
  68099. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  68100. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  68101. * @returns a new AdvancedDynamicTexture
  68102. */
  68103. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  68104. /**
  68105. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  68106. * In this mode the texture will rely on a layer for its rendering.
  68107. * This allows it to be treated like any other layer.
  68108. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  68109. * LayerMask is set through advancedTexture.layer.layerMask
  68110. * @param name defines name for the texture
  68111. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  68112. * @param scene defines the hsoting scene
  68113. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  68114. * @returns a new AdvancedDynamicTexture
  68115. */
  68116. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  68117. }
  68118. }
  68119. declare module BABYLON.GUI {
  68120. /**
  68121. * Root class used for all 2D controls
  68122. * @see http://doc.babylonjs.com/how_to/gui#controls
  68123. */
  68124. export class Control {
  68125. /** defines the name of the control */
  68126. name?: string | undefined;
  68127. /**
  68128. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  68129. */
  68130. static AllowAlphaInheritance: boolean;
  68131. private _alpha;
  68132. private _alphaSet;
  68133. private _zIndex;
  68134. /** @hidden */
  68135. _host: AdvancedDynamicTexture;
  68136. /** Gets or sets the control parent */
  68137. parent: BABYLON.Nullable<Container>;
  68138. /** @hidden */
  68139. _currentMeasure: Measure;
  68140. private _fontFamily;
  68141. private _fontStyle;
  68142. private _fontWeight;
  68143. private _fontSize;
  68144. private _font;
  68145. /** @hidden */
  68146. _width: ValueAndUnit;
  68147. /** @hidden */
  68148. _height: ValueAndUnit;
  68149. /** @hidden */
  68150. protected _fontOffset: {
  68151. ascent: number;
  68152. height: number;
  68153. descent: number;
  68154. };
  68155. private _color;
  68156. private _style;
  68157. private _styleObserver;
  68158. /** @hidden */
  68159. protected _horizontalAlignment: number;
  68160. /** @hidden */
  68161. protected _verticalAlignment: number;
  68162. /** @hidden */
  68163. protected _isDirty: boolean;
  68164. /** @hidden */
  68165. protected _wasDirty: boolean;
  68166. /** @hidden */
  68167. _tempParentMeasure: Measure;
  68168. /** @hidden */
  68169. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  68170. /** @hidden */
  68171. protected _cachedParentMeasure: Measure;
  68172. private _paddingLeft;
  68173. private _paddingRight;
  68174. private _paddingTop;
  68175. private _paddingBottom;
  68176. /** @hidden */
  68177. _left: ValueAndUnit;
  68178. /** @hidden */
  68179. _top: ValueAndUnit;
  68180. private _scaleX;
  68181. private _scaleY;
  68182. private _rotation;
  68183. private _transformCenterX;
  68184. private _transformCenterY;
  68185. /** @hidden */
  68186. _transformMatrix: Matrix2D;
  68187. /** @hidden */
  68188. protected _invertTransformMatrix: Matrix2D;
  68189. /** @hidden */
  68190. protected _transformedPosition: BABYLON.Vector2;
  68191. private _isMatrixDirty;
  68192. private _cachedOffsetX;
  68193. private _cachedOffsetY;
  68194. private _isVisible;
  68195. private _isHighlighted;
  68196. /** @hidden */
  68197. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68198. private _fontSet;
  68199. private _dummyVector2;
  68200. private _downCount;
  68201. private _enterCount;
  68202. private _doNotRender;
  68203. private _downPointerIds;
  68204. protected _isEnabled: boolean;
  68205. protected _disabledColor: string;
  68206. /** @hidden */
  68207. protected _rebuildLayout: boolean;
  68208. /** @hidden */
  68209. _isClipped: boolean;
  68210. /** @hidden */
  68211. _automaticSize: boolean;
  68212. /** @hidden */
  68213. _tag: any;
  68214. /**
  68215. * 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
  68216. */
  68217. uniqueId: number;
  68218. /**
  68219. * Gets or sets an object used to store user defined information for the node
  68220. */
  68221. metadata: any;
  68222. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  68223. isHitTestVisible: boolean;
  68224. /** Gets or sets a boolean indicating if the control can block pointer events */
  68225. isPointerBlocker: boolean;
  68226. /** Gets or sets a boolean indicating if the control can be focusable */
  68227. isFocusInvisible: boolean;
  68228. /**
  68229. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  68230. * 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
  68231. */
  68232. clipChildren: boolean;
  68233. /**
  68234. * Gets or sets a boolean indicating that control content must be clipped
  68235. * 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
  68236. */
  68237. clipContent: boolean;
  68238. /**
  68239. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  68240. */
  68241. useBitmapCache: boolean;
  68242. private _cacheData;
  68243. private _shadowOffsetX;
  68244. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  68245. get shadowOffsetX(): number;
  68246. set shadowOffsetX(value: number);
  68247. private _shadowOffsetY;
  68248. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  68249. get shadowOffsetY(): number;
  68250. set shadowOffsetY(value: number);
  68251. private _shadowBlur;
  68252. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  68253. get shadowBlur(): number;
  68254. set shadowBlur(value: number);
  68255. private _shadowColor;
  68256. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  68257. get shadowColor(): string;
  68258. set shadowColor(value: string);
  68259. /** Gets or sets the cursor to use when the control is hovered */
  68260. hoverCursor: string;
  68261. /** @hidden */
  68262. protected _linkOffsetX: ValueAndUnit;
  68263. /** @hidden */
  68264. protected _linkOffsetY: ValueAndUnit;
  68265. /** Gets the control type name */
  68266. get typeName(): string;
  68267. /**
  68268. * Get the current class name of the control.
  68269. * @returns current class name
  68270. */
  68271. getClassName(): string;
  68272. /**
  68273. * An event triggered when the pointer move over the control.
  68274. */
  68275. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  68276. /**
  68277. * An event triggered when the pointer move out of the control.
  68278. */
  68279. onPointerOutObservable: BABYLON.Observable<Control>;
  68280. /**
  68281. * An event triggered when the pointer taps the control
  68282. */
  68283. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  68284. /**
  68285. * An event triggered when pointer up
  68286. */
  68287. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  68288. /**
  68289. * An event triggered when a control is clicked on
  68290. */
  68291. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  68292. /**
  68293. * An event triggered when pointer enters the control
  68294. */
  68295. onPointerEnterObservable: BABYLON.Observable<Control>;
  68296. /**
  68297. * An event triggered when the control is marked as dirty
  68298. */
  68299. onDirtyObservable: BABYLON.Observable<Control>;
  68300. /**
  68301. * An event triggered before drawing the control
  68302. */
  68303. onBeforeDrawObservable: BABYLON.Observable<Control>;
  68304. /**
  68305. * An event triggered after the control was drawn
  68306. */
  68307. onAfterDrawObservable: BABYLON.Observable<Control>;
  68308. /**
  68309. * Get the hosting AdvancedDynamicTexture
  68310. */
  68311. get host(): AdvancedDynamicTexture;
  68312. /** Gets or set information about font offsets (used to render and align text) */
  68313. get fontOffset(): {
  68314. ascent: number;
  68315. height: number;
  68316. descent: number;
  68317. };
  68318. set fontOffset(offset: {
  68319. ascent: number;
  68320. height: number;
  68321. descent: number;
  68322. });
  68323. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  68324. get alpha(): number;
  68325. set alpha(value: number);
  68326. /**
  68327. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  68328. */
  68329. get isHighlighted(): boolean;
  68330. set isHighlighted(value: boolean);
  68331. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  68332. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68333. */
  68334. get scaleX(): number;
  68335. set scaleX(value: number);
  68336. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  68337. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68338. */
  68339. get scaleY(): number;
  68340. set scaleY(value: number);
  68341. /** Gets or sets the rotation angle (0 by default)
  68342. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68343. */
  68344. get rotation(): number;
  68345. set rotation(value: number);
  68346. /** Gets or sets the transformation center on Y axis (0 by default)
  68347. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68348. */
  68349. get transformCenterY(): number;
  68350. set transformCenterY(value: number);
  68351. /** Gets or sets the transformation center on X axis (0 by default)
  68352. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  68353. */
  68354. get transformCenterX(): number;
  68355. set transformCenterX(value: number);
  68356. /**
  68357. * Gets or sets the horizontal alignment
  68358. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68359. */
  68360. get horizontalAlignment(): number;
  68361. set horizontalAlignment(value: number);
  68362. /**
  68363. * Gets or sets the vertical alignment
  68364. * @see http://doc.babylonjs.com/how_to/gui#alignments
  68365. */
  68366. get verticalAlignment(): number;
  68367. set verticalAlignment(value: number);
  68368. /**
  68369. * Gets or sets control width
  68370. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68371. */
  68372. get width(): string | number;
  68373. set width(value: string | number);
  68374. /**
  68375. * Gets or sets the control width in pixel
  68376. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68377. */
  68378. get widthInPixels(): number;
  68379. set widthInPixels(value: number);
  68380. /**
  68381. * Gets or sets control height
  68382. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68383. */
  68384. get height(): string | number;
  68385. set height(value: string | number);
  68386. /**
  68387. * Gets or sets control height in pixel
  68388. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68389. */
  68390. get heightInPixels(): number;
  68391. set heightInPixels(value: number);
  68392. /** Gets or set font family */
  68393. get fontFamily(): string;
  68394. set fontFamily(value: string);
  68395. /** Gets or sets font style */
  68396. get fontStyle(): string;
  68397. set fontStyle(value: string);
  68398. /** Gets or sets font weight */
  68399. get fontWeight(): string;
  68400. set fontWeight(value: string);
  68401. /**
  68402. * Gets or sets style
  68403. * @see http://doc.babylonjs.com/how_to/gui#styles
  68404. */
  68405. get style(): BABYLON.Nullable<Style>;
  68406. set style(value: BABYLON.Nullable<Style>);
  68407. /** @hidden */
  68408. get _isFontSizeInPercentage(): boolean;
  68409. /** Gets or sets font size in pixels */
  68410. get fontSizeInPixels(): number;
  68411. set fontSizeInPixels(value: number);
  68412. /** Gets or sets font size */
  68413. get fontSize(): string | number;
  68414. set fontSize(value: string | number);
  68415. /** Gets or sets foreground color */
  68416. get color(): string;
  68417. set color(value: string);
  68418. /** Gets or sets z index which is used to reorder controls on the z axis */
  68419. get zIndex(): number;
  68420. set zIndex(value: number);
  68421. /** Gets or sets a boolean indicating if the control can be rendered */
  68422. get notRenderable(): boolean;
  68423. set notRenderable(value: boolean);
  68424. /** Gets or sets a boolean indicating if the control is visible */
  68425. get isVisible(): boolean;
  68426. set isVisible(value: boolean);
  68427. /** Gets a boolean indicating that the control needs to update its rendering */
  68428. get isDirty(): boolean;
  68429. /**
  68430. * Gets the current linked mesh (or null if none)
  68431. */
  68432. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  68433. /**
  68434. * Gets or sets a value indicating the padding to use on the left of the control
  68435. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68436. */
  68437. get paddingLeft(): string | number;
  68438. set paddingLeft(value: string | number);
  68439. /**
  68440. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  68441. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68442. */
  68443. get paddingLeftInPixels(): number;
  68444. set paddingLeftInPixels(value: number);
  68445. /**
  68446. * Gets or sets a value indicating the padding to use on the right of the control
  68447. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68448. */
  68449. get paddingRight(): string | number;
  68450. set paddingRight(value: string | number);
  68451. /**
  68452. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  68453. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68454. */
  68455. get paddingRightInPixels(): number;
  68456. set paddingRightInPixels(value: number);
  68457. /**
  68458. * Gets or sets a value indicating the padding to use on the top of the control
  68459. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68460. */
  68461. get paddingTop(): string | number;
  68462. set paddingTop(value: string | number);
  68463. /**
  68464. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  68465. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68466. */
  68467. get paddingTopInPixels(): number;
  68468. set paddingTopInPixels(value: number);
  68469. /**
  68470. * Gets or sets a value indicating the padding to use on the bottom of the control
  68471. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68472. */
  68473. get paddingBottom(): string | number;
  68474. set paddingBottom(value: string | number);
  68475. /**
  68476. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  68477. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68478. */
  68479. get paddingBottomInPixels(): number;
  68480. set paddingBottomInPixels(value: number);
  68481. /**
  68482. * Gets or sets a value indicating the left coordinate of the control
  68483. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68484. */
  68485. get left(): string | number;
  68486. set left(value: string | number);
  68487. /**
  68488. * Gets or sets a value indicating the left coordinate in pixels of the control
  68489. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68490. */
  68491. get leftInPixels(): number;
  68492. set leftInPixels(value: number);
  68493. /**
  68494. * Gets or sets a value indicating the top coordinate of the control
  68495. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68496. */
  68497. get top(): string | number;
  68498. set top(value: string | number);
  68499. /**
  68500. * Gets or sets a value indicating the top coordinate in pixels of the control
  68501. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68502. */
  68503. get topInPixels(): number;
  68504. set topInPixels(value: number);
  68505. /**
  68506. * Gets or sets a value indicating the offset on X axis to the linked mesh
  68507. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68508. */
  68509. get linkOffsetX(): string | number;
  68510. set linkOffsetX(value: string | number);
  68511. /**
  68512. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  68513. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68514. */
  68515. get linkOffsetXInPixels(): number;
  68516. set linkOffsetXInPixels(value: number);
  68517. /**
  68518. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  68519. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68520. */
  68521. get linkOffsetY(): string | number;
  68522. set linkOffsetY(value: string | number);
  68523. /**
  68524. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  68525. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68526. */
  68527. get linkOffsetYInPixels(): number;
  68528. set linkOffsetYInPixels(value: number);
  68529. /** Gets the center coordinate on X axis */
  68530. get centerX(): number;
  68531. /** Gets the center coordinate on Y axis */
  68532. get centerY(): number;
  68533. /** Gets or sets if control is Enabled*/
  68534. get isEnabled(): boolean;
  68535. set isEnabled(value: boolean);
  68536. /** Gets or sets background color of control if it's disabled*/
  68537. get disabledColor(): string;
  68538. set disabledColor(value: string);
  68539. /**
  68540. * Creates a new control
  68541. * @param name defines the name of the control
  68542. */
  68543. constructor(
  68544. /** defines the name of the control */
  68545. name?: string | undefined);
  68546. /** @hidden */
  68547. protected _getTypeName(): string;
  68548. /**
  68549. * Gets the first ascendant in the hierarchy of the given type
  68550. * @param className defines the required type
  68551. * @returns the ascendant or null if not found
  68552. */
  68553. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  68554. /** @hidden */
  68555. _resetFontCache(): void;
  68556. /**
  68557. * Determines if a container is an ascendant of the current control
  68558. * @param container defines the container to look for
  68559. * @returns true if the container is one of the ascendant of the control
  68560. */
  68561. isAscendant(container: Control): boolean;
  68562. /**
  68563. * Gets coordinates in local control space
  68564. * @param globalCoordinates defines the coordinates to transform
  68565. * @returns the new coordinates in local space
  68566. */
  68567. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68568. /**
  68569. * Gets coordinates in local control space
  68570. * @param globalCoordinates defines the coordinates to transform
  68571. * @param result defines the target vector2 where to store the result
  68572. * @returns the current control
  68573. */
  68574. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  68575. /**
  68576. * Gets coordinates in parent local control space
  68577. * @param globalCoordinates defines the coordinates to transform
  68578. * @returns the new coordinates in parent local space
  68579. */
  68580. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  68581. /**
  68582. * Move the current control to a vector3 position projected onto the screen.
  68583. * @param position defines the target position
  68584. * @param scene defines the hosting scene
  68585. */
  68586. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  68587. /**
  68588. * Will store all controls that have this control as ascendant in a given array
  68589. * @param results defines the array where to store the descendants
  68590. * @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
  68591. * @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
  68592. */
  68593. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68594. /**
  68595. * Will return all controls that have this control as ascendant
  68596. * @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
  68597. * @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
  68598. * @return all child controls
  68599. */
  68600. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68601. /**
  68602. * Link current control with a target mesh
  68603. * @param mesh defines the mesh to link with
  68604. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  68605. */
  68606. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  68607. /** @hidden */
  68608. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  68609. /** @hidden */
  68610. _offsetLeft(offset: number): void;
  68611. /** @hidden */
  68612. _offsetTop(offset: number): void;
  68613. /** @hidden */
  68614. _markMatrixAsDirty(): void;
  68615. /** @hidden */
  68616. _flagDescendantsAsMatrixDirty(): void;
  68617. /** @hidden */
  68618. _intersectsRect(rect: Measure): boolean;
  68619. /** @hidden */
  68620. protected invalidateRect(): void;
  68621. /** @hidden */
  68622. _markAsDirty(force?: boolean): void;
  68623. /** @hidden */
  68624. _markAllAsDirty(): void;
  68625. /** @hidden */
  68626. _link(host: AdvancedDynamicTexture): void;
  68627. /** @hidden */
  68628. protected _transform(context?: CanvasRenderingContext2D): void;
  68629. /** @hidden */
  68630. _renderHighlight(context: CanvasRenderingContext2D): void;
  68631. /** @hidden */
  68632. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68633. /** @hidden */
  68634. protected _applyStates(context: CanvasRenderingContext2D): void;
  68635. /** @hidden */
  68636. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68637. /** @hidden */
  68638. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68639. protected _evaluateClippingState(parentMeasure: Measure): void;
  68640. /** @hidden */
  68641. _measure(): void;
  68642. /** @hidden */
  68643. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68644. /** @hidden */
  68645. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68646. /** @hidden */
  68647. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68648. /** @hidden */
  68649. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68650. private static _ClipMeasure;
  68651. private _tmpMeasureA;
  68652. private _clip;
  68653. /** @hidden */
  68654. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  68655. /** @hidden */
  68656. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68657. /**
  68658. * Tests if a given coordinates belong to the current control
  68659. * @param x defines x coordinate to test
  68660. * @param y defines y coordinate to test
  68661. * @returns true if the coordinates are inside the control
  68662. */
  68663. contains(x: number, y: number): boolean;
  68664. /** @hidden */
  68665. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68666. /** @hidden */
  68667. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68668. /** @hidden */
  68669. _onPointerEnter(target: Control): boolean;
  68670. /** @hidden */
  68671. _onPointerOut(target: Control, force?: boolean): void;
  68672. /** @hidden */
  68673. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68674. /** @hidden */
  68675. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68676. /** @hidden */
  68677. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68678. /** @hidden */
  68679. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  68680. private _prepareFont;
  68681. /** Releases associated resources */
  68682. dispose(): void;
  68683. private static _HORIZONTAL_ALIGNMENT_LEFT;
  68684. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  68685. private static _HORIZONTAL_ALIGNMENT_CENTER;
  68686. private static _VERTICAL_ALIGNMENT_TOP;
  68687. private static _VERTICAL_ALIGNMENT_BOTTOM;
  68688. private static _VERTICAL_ALIGNMENT_CENTER;
  68689. /** HORIZONTAL_ALIGNMENT_LEFT */
  68690. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  68691. /** HORIZONTAL_ALIGNMENT_RIGHT */
  68692. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  68693. /** HORIZONTAL_ALIGNMENT_CENTER */
  68694. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  68695. /** VERTICAL_ALIGNMENT_TOP */
  68696. static get VERTICAL_ALIGNMENT_TOP(): number;
  68697. /** VERTICAL_ALIGNMENT_BOTTOM */
  68698. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  68699. /** VERTICAL_ALIGNMENT_CENTER */
  68700. static get VERTICAL_ALIGNMENT_CENTER(): number;
  68701. private static _FontHeightSizes;
  68702. /** @hidden */
  68703. static _GetFontOffset(font: string): {
  68704. ascent: number;
  68705. height: number;
  68706. descent: number;
  68707. };
  68708. /**
  68709. * Creates a stack panel that can be used to render headers
  68710. * @param control defines the control to associate with the header
  68711. * @param text defines the text of the header
  68712. * @param size defines the size of the header
  68713. * @param options defines options used to configure the header
  68714. * @returns a new StackPanel
  68715. * @ignore
  68716. * @hidden
  68717. */
  68718. static AddHeader: (control: Control, text: string, size: string | number, options: {
  68719. isHorizontal: boolean;
  68720. controlFirst: boolean;
  68721. }) => any;
  68722. /** @hidden */
  68723. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  68724. }
  68725. }
  68726. declare module BABYLON.GUI {
  68727. /**
  68728. * Root class for 2D containers
  68729. * @see http://doc.babylonjs.com/how_to/gui#containers
  68730. */
  68731. export class Container extends Control {
  68732. name?: string | undefined;
  68733. /** @hidden */
  68734. protected _children: Control[];
  68735. /** @hidden */
  68736. protected _measureForChildren: Measure;
  68737. /** @hidden */
  68738. protected _background: string;
  68739. /** @hidden */
  68740. protected _adaptWidthToChildren: boolean;
  68741. /** @hidden */
  68742. protected _adaptHeightToChildren: boolean;
  68743. /**
  68744. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68745. */
  68746. logLayoutCycleErrors: boolean;
  68747. /**
  68748. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68749. */
  68750. maxLayoutCycle: number;
  68751. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68752. get adaptHeightToChildren(): boolean;
  68753. set adaptHeightToChildren(value: boolean);
  68754. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68755. get adaptWidthToChildren(): boolean;
  68756. set adaptWidthToChildren(value: boolean);
  68757. /** Gets or sets background color */
  68758. get background(): string;
  68759. set background(value: string);
  68760. /** Gets the list of children */
  68761. get children(): Control[];
  68762. /**
  68763. * Creates a new Container
  68764. * @param name defines the name of the container
  68765. */
  68766. constructor(name?: string | undefined);
  68767. protected _getTypeName(): string;
  68768. _flagDescendantsAsMatrixDirty(): void;
  68769. /**
  68770. * Gets a child using its name
  68771. * @param name defines the child name to look for
  68772. * @returns the child control if found
  68773. */
  68774. getChildByName(name: string): BABYLON.Nullable<Control>;
  68775. /**
  68776. * Gets a child using its type and its name
  68777. * @param name defines the child name to look for
  68778. * @param type defines the child type to look for
  68779. * @returns the child control if found
  68780. */
  68781. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68782. /**
  68783. * Search for a specific control in children
  68784. * @param control defines the control to look for
  68785. * @returns true if the control is in child list
  68786. */
  68787. containsControl(control: Control): boolean;
  68788. /**
  68789. * Adds a new control to the current container
  68790. * @param control defines the control to add
  68791. * @returns the current container
  68792. */
  68793. addControl(control: BABYLON.Nullable<Control>): Container;
  68794. /**
  68795. * Removes all controls from the current container
  68796. * @returns the current container
  68797. */
  68798. clearControls(): Container;
  68799. /**
  68800. * Removes a control from the current container
  68801. * @param control defines the control to remove
  68802. * @returns the current container
  68803. */
  68804. removeControl(control: Control): Container;
  68805. /** @hidden */
  68806. _reOrderControl(control: Control): void;
  68807. /** @hidden */
  68808. _offsetLeft(offset: number): void;
  68809. /** @hidden */
  68810. _offsetTop(offset: number): void;
  68811. /** @hidden */
  68812. _markAllAsDirty(): void;
  68813. /** @hidden */
  68814. protected _localDraw(context: CanvasRenderingContext2D): void;
  68815. /** @hidden */
  68816. _link(host: AdvancedDynamicTexture): void;
  68817. /** @hidden */
  68818. protected _beforeLayout(): void;
  68819. /** @hidden */
  68820. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68821. /** @hidden */
  68822. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68823. protected _postMeasure(): void;
  68824. /** @hidden */
  68825. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68826. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68827. /** @hidden */
  68828. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68829. /** @hidden */
  68830. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68831. /** Releases associated resources */
  68832. dispose(): void;
  68833. }
  68834. }
  68835. declare module BABYLON.GUI {
  68836. /** Class used to create rectangle container */
  68837. export class Rectangle extends Container {
  68838. name?: string | undefined;
  68839. private _thickness;
  68840. private _cornerRadius;
  68841. /** Gets or sets border thickness */
  68842. get thickness(): number;
  68843. set thickness(value: number);
  68844. /** Gets or sets the corner radius angle */
  68845. get cornerRadius(): number;
  68846. set cornerRadius(value: number);
  68847. /**
  68848. * Creates a new Rectangle
  68849. * @param name defines the control name
  68850. */
  68851. constructor(name?: string | undefined);
  68852. protected _getTypeName(): string;
  68853. protected _localDraw(context: CanvasRenderingContext2D): void;
  68854. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68855. private _drawRoundedRect;
  68856. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68857. }
  68858. }
  68859. declare module BABYLON.GUI {
  68860. /**
  68861. * Enum that determines the text-wrapping mode to use.
  68862. */
  68863. export enum TextWrapping {
  68864. /**
  68865. * Clip the text when it's larger than Control.width; this is the default mode.
  68866. */
  68867. Clip = 0,
  68868. /**
  68869. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68870. */
  68871. WordWrap = 1,
  68872. /**
  68873. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68874. */
  68875. Ellipsis = 2
  68876. }
  68877. /**
  68878. * Class used to create text block control
  68879. */
  68880. export class TextBlock extends Control {
  68881. /**
  68882. * Defines the name of the control
  68883. */
  68884. name?: string | undefined;
  68885. private _text;
  68886. private _textWrapping;
  68887. private _textHorizontalAlignment;
  68888. private _textVerticalAlignment;
  68889. private _lines;
  68890. private _resizeToFit;
  68891. private _lineSpacing;
  68892. private _outlineWidth;
  68893. private _outlineColor;
  68894. /**
  68895. * An event triggered after the text is changed
  68896. */
  68897. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68898. /**
  68899. * An event triggered after the text was broken up into lines
  68900. */
  68901. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68902. /**
  68903. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68904. */
  68905. get lines(): any[];
  68906. /**
  68907. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68908. */
  68909. get resizeToFit(): boolean;
  68910. /**
  68911. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68912. */
  68913. set resizeToFit(value: boolean);
  68914. /**
  68915. * Gets or sets a boolean indicating if text must be wrapped
  68916. */
  68917. get textWrapping(): TextWrapping | boolean;
  68918. /**
  68919. * Gets or sets a boolean indicating if text must be wrapped
  68920. */
  68921. set textWrapping(value: TextWrapping | boolean);
  68922. /**
  68923. * Gets or sets text to display
  68924. */
  68925. get text(): string;
  68926. /**
  68927. * Gets or sets text to display
  68928. */
  68929. set text(value: string);
  68930. /**
  68931. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68932. */
  68933. get textHorizontalAlignment(): number;
  68934. /**
  68935. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68936. */
  68937. set textHorizontalAlignment(value: number);
  68938. /**
  68939. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68940. */
  68941. get textVerticalAlignment(): number;
  68942. /**
  68943. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68944. */
  68945. set textVerticalAlignment(value: number);
  68946. /**
  68947. * Gets or sets line spacing value
  68948. */
  68949. set lineSpacing(value: string | number);
  68950. /**
  68951. * Gets or sets line spacing value
  68952. */
  68953. get lineSpacing(): string | number;
  68954. /**
  68955. * Gets or sets outlineWidth of the text to display
  68956. */
  68957. get outlineWidth(): number;
  68958. /**
  68959. * Gets or sets outlineWidth of the text to display
  68960. */
  68961. set outlineWidth(value: number);
  68962. /**
  68963. * Gets or sets outlineColor of the text to display
  68964. */
  68965. get outlineColor(): string;
  68966. /**
  68967. * Gets or sets outlineColor of the text to display
  68968. */
  68969. set outlineColor(value: string);
  68970. /**
  68971. * Creates a new TextBlock object
  68972. * @param name defines the name of the control
  68973. * @param text defines the text to display (emptry string by default)
  68974. */
  68975. constructor(
  68976. /**
  68977. * Defines the name of the control
  68978. */
  68979. name?: string | undefined, text?: string);
  68980. protected _getTypeName(): string;
  68981. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68982. private _drawText;
  68983. /** @hidden */
  68984. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68985. protected _applyStates(context: CanvasRenderingContext2D): void;
  68986. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  68987. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  68988. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  68989. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  68990. protected _renderLines(context: CanvasRenderingContext2D): void;
  68991. /**
  68992. * Given a width constraint applied on the text block, find the expected height
  68993. * @returns expected height
  68994. */
  68995. computeExpectedHeight(): number;
  68996. dispose(): void;
  68997. }
  68998. }
  68999. declare module BABYLON.GUI {
  69000. /**
  69001. * Class used to create 2D images
  69002. */
  69003. export class Image extends Control {
  69004. name?: string | undefined;
  69005. private _workingCanvas;
  69006. private _domImage;
  69007. private _imageWidth;
  69008. private _imageHeight;
  69009. private _loaded;
  69010. private _stretch;
  69011. private _source;
  69012. private _autoScale;
  69013. private _sourceLeft;
  69014. private _sourceTop;
  69015. private _sourceWidth;
  69016. private _sourceHeight;
  69017. private _cellWidth;
  69018. private _cellHeight;
  69019. private _cellId;
  69020. private _populateNinePatchSlicesFromImage;
  69021. private _sliceLeft;
  69022. private _sliceRight;
  69023. private _sliceTop;
  69024. private _sliceBottom;
  69025. private _detectPointerOnOpaqueOnly;
  69026. /**
  69027. * BABYLON.Observable notified when the content is loaded
  69028. */
  69029. onImageLoadedObservable: BABYLON.Observable<Image>;
  69030. /**
  69031. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  69032. */
  69033. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  69034. /**
  69035. * Gets a boolean indicating that the content is loaded
  69036. */
  69037. get isLoaded(): boolean;
  69038. /**
  69039. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  69040. */
  69041. get populateNinePatchSlicesFromImage(): boolean;
  69042. set populateNinePatchSlicesFromImage(value: boolean);
  69043. /**
  69044. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  69045. * Beware using this as this will comsume more memory as the image has to be stored twice
  69046. */
  69047. get detectPointerOnOpaqueOnly(): boolean;
  69048. set detectPointerOnOpaqueOnly(value: boolean);
  69049. /**
  69050. * Gets or sets the left value for slicing (9-patch)
  69051. */
  69052. get sliceLeft(): number;
  69053. set sliceLeft(value: number);
  69054. /**
  69055. * Gets or sets the right value for slicing (9-patch)
  69056. */
  69057. get sliceRight(): number;
  69058. set sliceRight(value: number);
  69059. /**
  69060. * Gets or sets the top value for slicing (9-patch)
  69061. */
  69062. get sliceTop(): number;
  69063. set sliceTop(value: number);
  69064. /**
  69065. * Gets or sets the bottom value for slicing (9-patch)
  69066. */
  69067. get sliceBottom(): number;
  69068. set sliceBottom(value: number);
  69069. /**
  69070. * Gets or sets the left coordinate in the source image
  69071. */
  69072. get sourceLeft(): number;
  69073. set sourceLeft(value: number);
  69074. /**
  69075. * Gets or sets the top coordinate in the source image
  69076. */
  69077. get sourceTop(): number;
  69078. set sourceTop(value: number);
  69079. /**
  69080. * Gets or sets the width to capture in the source image
  69081. */
  69082. get sourceWidth(): number;
  69083. set sourceWidth(value: number);
  69084. /**
  69085. * Gets or sets the height to capture in the source image
  69086. */
  69087. get sourceHeight(): number;
  69088. set sourceHeight(value: number);
  69089. /**
  69090. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  69091. * @see http://doc.babylonjs.com/how_to/gui#image
  69092. */
  69093. get autoScale(): boolean;
  69094. set autoScale(value: boolean);
  69095. /** Gets or sets the streching mode used by the image */
  69096. get stretch(): number;
  69097. set stretch(value: number);
  69098. /** @hidden */
  69099. _rotate90(n: number): Image;
  69100. /**
  69101. * Gets or sets the internal DOM image used to render the control
  69102. */
  69103. set domImage(value: HTMLImageElement);
  69104. get domImage(): HTMLImageElement;
  69105. private _onImageLoaded;
  69106. private _extractNinePatchSliceDataFromImage;
  69107. /**
  69108. * Gets or sets image source url
  69109. */
  69110. set source(value: BABYLON.Nullable<string>);
  69111. /**
  69112. * Checks for svg document with icon id present
  69113. */
  69114. private _svgCheck;
  69115. /**
  69116. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  69117. * given external svg file and icon id
  69118. */
  69119. private _getSVGAttribs;
  69120. /**
  69121. * Gets or sets the cell width to use when animation sheet is enabled
  69122. * @see http://doc.babylonjs.com/how_to/gui#image
  69123. */
  69124. get cellWidth(): number;
  69125. set cellWidth(value: number);
  69126. /**
  69127. * Gets or sets the cell height to use when animation sheet is enabled
  69128. * @see http://doc.babylonjs.com/how_to/gui#image
  69129. */
  69130. get cellHeight(): number;
  69131. set cellHeight(value: number);
  69132. /**
  69133. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  69134. * @see http://doc.babylonjs.com/how_to/gui#image
  69135. */
  69136. get cellId(): number;
  69137. set cellId(value: number);
  69138. /**
  69139. * Creates a new Image
  69140. * @param name defines the control name
  69141. * @param url defines the image url
  69142. */
  69143. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  69144. /**
  69145. * Tests if a given coordinates belong to the current control
  69146. * @param x defines x coordinate to test
  69147. * @param y defines y coordinate to test
  69148. * @returns true if the coordinates are inside the control
  69149. */
  69150. contains(x: number, y: number): boolean;
  69151. protected _getTypeName(): string;
  69152. /** Force the control to synchronize with its content */
  69153. synchronizeSizeWithContent(): void;
  69154. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69155. private _prepareWorkingCanvasForOpaqueDetection;
  69156. private _drawImage;
  69157. _draw(context: CanvasRenderingContext2D): void;
  69158. private _renderCornerPatch;
  69159. private _renderNinePatch;
  69160. dispose(): void;
  69161. /** STRETCH_NONE */
  69162. static readonly STRETCH_NONE: number;
  69163. /** STRETCH_FILL */
  69164. static readonly STRETCH_FILL: number;
  69165. /** STRETCH_UNIFORM */
  69166. static readonly STRETCH_UNIFORM: number;
  69167. /** STRETCH_EXTEND */
  69168. static readonly STRETCH_EXTEND: number;
  69169. /** NINE_PATCH */
  69170. static readonly STRETCH_NINE_PATCH: number;
  69171. }
  69172. }
  69173. declare module BABYLON.GUI {
  69174. /**
  69175. * Class used to create 2D buttons
  69176. */
  69177. export class Button extends Rectangle {
  69178. name?: string | undefined;
  69179. /**
  69180. * Function called to generate a pointer enter animation
  69181. */
  69182. pointerEnterAnimation: () => void;
  69183. /**
  69184. * Function called to generate a pointer out animation
  69185. */
  69186. pointerOutAnimation: () => void;
  69187. /**
  69188. * Function called to generate a pointer down animation
  69189. */
  69190. pointerDownAnimation: () => void;
  69191. /**
  69192. * Function called to generate a pointer up animation
  69193. */
  69194. pointerUpAnimation: () => void;
  69195. /**
  69196. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  69197. */
  69198. delegatePickingToChildren: boolean;
  69199. private _image;
  69200. /**
  69201. * Returns the image part of the button (if any)
  69202. */
  69203. get image(): BABYLON.Nullable<Image>;
  69204. private _textBlock;
  69205. /**
  69206. * Returns the image part of the button (if any)
  69207. */
  69208. get textBlock(): BABYLON.Nullable<TextBlock>;
  69209. /**
  69210. * Creates a new Button
  69211. * @param name defines the name of the button
  69212. */
  69213. constructor(name?: string | undefined);
  69214. protected _getTypeName(): string;
  69215. /** @hidden */
  69216. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69217. /** @hidden */
  69218. _onPointerEnter(target: Control): boolean;
  69219. /** @hidden */
  69220. _onPointerOut(target: Control, force?: boolean): void;
  69221. /** @hidden */
  69222. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69223. /** @hidden */
  69224. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69225. /**
  69226. * Creates a new button made with an image and a text
  69227. * @param name defines the name of the button
  69228. * @param text defines the text of the button
  69229. * @param imageUrl defines the url of the image
  69230. * @returns a new Button
  69231. */
  69232. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  69233. /**
  69234. * Creates a new button made with an image
  69235. * @param name defines the name of the button
  69236. * @param imageUrl defines the url of the image
  69237. * @returns a new Button
  69238. */
  69239. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  69240. /**
  69241. * Creates a new button made with a text
  69242. * @param name defines the name of the button
  69243. * @param text defines the text of the button
  69244. * @returns a new Button
  69245. */
  69246. static CreateSimpleButton(name: string, text: string): Button;
  69247. /**
  69248. * Creates a new button made with an image and a centered text
  69249. * @param name defines the name of the button
  69250. * @param text defines the text of the button
  69251. * @param imageUrl defines the url of the image
  69252. * @returns a new Button
  69253. */
  69254. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  69255. }
  69256. }
  69257. declare module BABYLON.GUI {
  69258. /**
  69259. * Class used to create a 2D stack panel container
  69260. */
  69261. export class StackPanel extends Container {
  69262. name?: string | undefined;
  69263. private _isVertical;
  69264. private _manualWidth;
  69265. private _manualHeight;
  69266. private _doNotTrackManualChanges;
  69267. /**
  69268. * Gets or sets a boolean indicating that layou warnings should be ignored
  69269. */
  69270. ignoreLayoutWarnings: boolean;
  69271. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  69272. get isVertical(): boolean;
  69273. set isVertical(value: boolean);
  69274. /**
  69275. * Gets or sets panel width.
  69276. * This value should not be set when in horizontal mode as it will be computed automatically
  69277. */
  69278. set width(value: string | number);
  69279. get width(): string | number;
  69280. /**
  69281. * Gets or sets panel height.
  69282. * This value should not be set when in vertical mode as it will be computed automatically
  69283. */
  69284. set height(value: string | number);
  69285. get height(): string | number;
  69286. /**
  69287. * Creates a new StackPanel
  69288. * @param name defines control name
  69289. */
  69290. constructor(name?: string | undefined);
  69291. protected _getTypeName(): string;
  69292. /** @hidden */
  69293. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69294. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69295. protected _postMeasure(): void;
  69296. }
  69297. }
  69298. declare module BABYLON.GUI {
  69299. /**
  69300. * Class used to represent a 2D checkbox
  69301. */
  69302. export class Checkbox extends Control {
  69303. name?: string | undefined;
  69304. private _isChecked;
  69305. private _background;
  69306. private _checkSizeRatio;
  69307. private _thickness;
  69308. /** Gets or sets border thickness */
  69309. get thickness(): number;
  69310. set thickness(value: number);
  69311. /**
  69312. * BABYLON.Observable raised when isChecked property changes
  69313. */
  69314. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69315. /** Gets or sets a value indicating the ratio between overall size and check size */
  69316. get checkSizeRatio(): number;
  69317. set checkSizeRatio(value: number);
  69318. /** Gets or sets background color */
  69319. get background(): string;
  69320. set background(value: string);
  69321. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69322. get isChecked(): boolean;
  69323. set isChecked(value: boolean);
  69324. /**
  69325. * Creates a new CheckBox
  69326. * @param name defines the control name
  69327. */
  69328. constructor(name?: string | undefined);
  69329. protected _getTypeName(): string;
  69330. /** @hidden */
  69331. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69332. /** @hidden */
  69333. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69334. /**
  69335. * Utility function to easily create a checkbox with a header
  69336. * @param title defines the label to use for the header
  69337. * @param onValueChanged defines the callback to call when value changes
  69338. * @returns a StackPanel containing the checkbox and a textBlock
  69339. */
  69340. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  69341. }
  69342. }
  69343. declare module BABYLON.GUI {
  69344. /**
  69345. * Class used to store key control properties
  69346. */
  69347. export class KeyPropertySet {
  69348. /** Width */
  69349. width?: string;
  69350. /** Height */
  69351. height?: string;
  69352. /** Left padding */
  69353. paddingLeft?: string;
  69354. /** Right padding */
  69355. paddingRight?: string;
  69356. /** Top padding */
  69357. paddingTop?: string;
  69358. /** Bottom padding */
  69359. paddingBottom?: string;
  69360. /** Foreground color */
  69361. color?: string;
  69362. /** Background color */
  69363. background?: string;
  69364. }
  69365. /**
  69366. * Class used to create virtual keyboard
  69367. */
  69368. export class VirtualKeyboard extends StackPanel {
  69369. /** BABYLON.Observable raised when a key is pressed */
  69370. onKeyPressObservable: BABYLON.Observable<string>;
  69371. /** Gets or sets default key button width */
  69372. defaultButtonWidth: string;
  69373. /** Gets or sets default key button height */
  69374. defaultButtonHeight: string;
  69375. /** Gets or sets default key button left padding */
  69376. defaultButtonPaddingLeft: string;
  69377. /** Gets or sets default key button right padding */
  69378. defaultButtonPaddingRight: string;
  69379. /** Gets or sets default key button top padding */
  69380. defaultButtonPaddingTop: string;
  69381. /** Gets or sets default key button bottom padding */
  69382. defaultButtonPaddingBottom: string;
  69383. /** Gets or sets default key button foreground color */
  69384. defaultButtonColor: string;
  69385. /** Gets or sets default key button background color */
  69386. defaultButtonBackground: string;
  69387. /** Gets or sets shift button foreground color */
  69388. shiftButtonColor: string;
  69389. /** Gets or sets shift button thickness*/
  69390. selectedShiftThickness: number;
  69391. /** Gets shift key state */
  69392. shiftState: number;
  69393. protected _getTypeName(): string;
  69394. private _createKey;
  69395. /**
  69396. * Adds a new row of keys
  69397. * @param keys defines the list of keys to add
  69398. * @param propertySets defines the associated property sets
  69399. */
  69400. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  69401. /**
  69402. * Set the shift key to a specific state
  69403. * @param shiftState defines the new shift state
  69404. */
  69405. applyShiftState(shiftState: number): void;
  69406. private _currentlyConnectedInputText;
  69407. private _connectedInputTexts;
  69408. private _onKeyPressObserver;
  69409. /** Gets the input text control currently attached to the keyboard */
  69410. get connectedInputText(): BABYLON.Nullable<InputText>;
  69411. /**
  69412. * Connects the keyboard with an input text control
  69413. *
  69414. * @param input defines the target control
  69415. */
  69416. connect(input: InputText): void;
  69417. /**
  69418. * Disconnects the keyboard from connected InputText controls
  69419. *
  69420. * @param input optionally defines a target control, otherwise all are disconnected
  69421. */
  69422. disconnect(input?: InputText): void;
  69423. private _removeConnectedInputObservables;
  69424. /**
  69425. * Release all resources
  69426. */
  69427. dispose(): void;
  69428. /**
  69429. * Creates a new keyboard using a default layout
  69430. *
  69431. * @param name defines control name
  69432. * @returns a new VirtualKeyboard
  69433. */
  69434. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  69435. }
  69436. }
  69437. declare module BABYLON.GUI {
  69438. /**
  69439. * Class used to create input text control
  69440. */
  69441. export class InputText extends Control implements IFocusableControl {
  69442. name?: string | undefined;
  69443. private _text;
  69444. private _placeholderText;
  69445. private _background;
  69446. private _focusedBackground;
  69447. private _focusedColor;
  69448. private _placeholderColor;
  69449. private _thickness;
  69450. private _margin;
  69451. private _autoStretchWidth;
  69452. private _maxWidth;
  69453. private _isFocused;
  69454. private _blinkTimeout;
  69455. private _blinkIsEven;
  69456. private _cursorOffset;
  69457. private _scrollLeft;
  69458. private _textWidth;
  69459. private _clickedCoordinate;
  69460. private _deadKey;
  69461. private _addKey;
  69462. private _currentKey;
  69463. private _isTextHighlightOn;
  69464. private _textHighlightColor;
  69465. private _highligherOpacity;
  69466. private _highlightedText;
  69467. private _startHighlightIndex;
  69468. private _endHighlightIndex;
  69469. private _cursorIndex;
  69470. private _onFocusSelectAll;
  69471. private _isPointerDown;
  69472. private _onClipboardObserver;
  69473. private _onPointerDblTapObserver;
  69474. /** @hidden */
  69475. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  69476. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  69477. promptMessage: string;
  69478. /** Force disable prompt on mobile device */
  69479. disableMobilePrompt: boolean;
  69480. /** BABYLON.Observable raised when the text changes */
  69481. onTextChangedObservable: BABYLON.Observable<InputText>;
  69482. /** BABYLON.Observable raised just before an entered character is to be added */
  69483. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  69484. /** BABYLON.Observable raised when the control gets the focus */
  69485. onFocusObservable: BABYLON.Observable<InputText>;
  69486. /** BABYLON.Observable raised when the control loses the focus */
  69487. onBlurObservable: BABYLON.Observable<InputText>;
  69488. /**Observable raised when the text is highlighted */
  69489. onTextHighlightObservable: BABYLON.Observable<InputText>;
  69490. /**Observable raised when copy event is triggered */
  69491. onTextCopyObservable: BABYLON.Observable<InputText>;
  69492. /** BABYLON.Observable raised when cut event is triggered */
  69493. onTextCutObservable: BABYLON.Observable<InputText>;
  69494. /** BABYLON.Observable raised when paste event is triggered */
  69495. onTextPasteObservable: BABYLON.Observable<InputText>;
  69496. /** BABYLON.Observable raised when a key event was processed */
  69497. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  69498. /** Gets or sets the maximum width allowed by the control */
  69499. get maxWidth(): string | number;
  69500. /** Gets the maximum width allowed by the control in pixels */
  69501. get maxWidthInPixels(): number;
  69502. set maxWidth(value: string | number);
  69503. /** Gets or sets the text highlighter transparency; default: 0.4 */
  69504. get highligherOpacity(): number;
  69505. set highligherOpacity(value: number);
  69506. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  69507. get onFocusSelectAll(): boolean;
  69508. set onFocusSelectAll(value: boolean);
  69509. /** Gets or sets the text hightlight color */
  69510. get textHighlightColor(): string;
  69511. set textHighlightColor(value: string);
  69512. /** Gets or sets control margin */
  69513. get margin(): string;
  69514. /** Gets control margin in pixels */
  69515. get marginInPixels(): number;
  69516. set margin(value: string);
  69517. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  69518. get autoStretchWidth(): boolean;
  69519. set autoStretchWidth(value: boolean);
  69520. /** Gets or sets border thickness */
  69521. get thickness(): number;
  69522. set thickness(value: number);
  69523. /** Gets or sets the background color when focused */
  69524. get focusedBackground(): string;
  69525. set focusedBackground(value: string);
  69526. /** Gets or sets the background color when focused */
  69527. get focusedColor(): string;
  69528. set focusedColor(value: string);
  69529. /** Gets or sets the background color */
  69530. get background(): string;
  69531. set background(value: string);
  69532. /** Gets or sets the placeholder color */
  69533. get placeholderColor(): string;
  69534. set placeholderColor(value: string);
  69535. /** Gets or sets the text displayed when the control is empty */
  69536. get placeholderText(): string;
  69537. set placeholderText(value: string);
  69538. /** Gets or sets the dead key flag */
  69539. get deadKey(): boolean;
  69540. set deadKey(flag: boolean);
  69541. /** Gets or sets the highlight text */
  69542. get highlightedText(): string;
  69543. set highlightedText(text: string);
  69544. /** Gets or sets if the current key should be added */
  69545. get addKey(): boolean;
  69546. set addKey(flag: boolean);
  69547. /** Gets or sets the value of the current key being entered */
  69548. get currentKey(): string;
  69549. set currentKey(key: string);
  69550. /** Gets or sets the text displayed in the control */
  69551. get text(): string;
  69552. set text(value: string);
  69553. /** Gets or sets control width */
  69554. get width(): string | number;
  69555. set width(value: string | number);
  69556. /**
  69557. * Creates a new InputText
  69558. * @param name defines the control name
  69559. * @param text defines the text of the control
  69560. */
  69561. constructor(name?: string | undefined, text?: string);
  69562. /** @hidden */
  69563. onBlur(): void;
  69564. /** @hidden */
  69565. onFocus(): void;
  69566. protected _getTypeName(): string;
  69567. /**
  69568. * Function called to get the list of controls that should not steal the focus from this control
  69569. * @returns an array of controls
  69570. */
  69571. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69572. /** @hidden */
  69573. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  69574. /** @hidden */
  69575. private _updateValueFromCursorIndex;
  69576. /** @hidden */
  69577. private _processDblClick;
  69578. /** @hidden */
  69579. private _selectAllText;
  69580. /**
  69581. * Handles the keyboard event
  69582. * @param evt Defines the KeyboardEvent
  69583. */
  69584. processKeyboard(evt: KeyboardEvent): void;
  69585. /** @hidden */
  69586. private _onCopyText;
  69587. /** @hidden */
  69588. private _onCutText;
  69589. /** @hidden */
  69590. private _onPasteText;
  69591. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69592. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69593. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69594. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69595. protected _beforeRenderText(text: string): string;
  69596. dispose(): void;
  69597. }
  69598. }
  69599. declare module BABYLON.GUI {
  69600. /**
  69601. * Class used to create a 2D grid container
  69602. */
  69603. export class Grid extends Container {
  69604. name?: string | undefined;
  69605. private _rowDefinitions;
  69606. private _columnDefinitions;
  69607. private _cells;
  69608. private _childControls;
  69609. /**
  69610. * Gets the number of columns
  69611. */
  69612. get columnCount(): number;
  69613. /**
  69614. * Gets the number of rows
  69615. */
  69616. get rowCount(): number;
  69617. /** Gets the list of children */
  69618. get children(): Control[];
  69619. /** Gets the list of cells (e.g. the containers) */
  69620. get cells(): {
  69621. [key: string]: Container;
  69622. };
  69623. /**
  69624. * Gets the definition of a specific row
  69625. * @param index defines the index of the row
  69626. * @returns the row definition
  69627. */
  69628. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69629. /**
  69630. * Gets the definition of a specific column
  69631. * @param index defines the index of the column
  69632. * @returns the column definition
  69633. */
  69634. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  69635. /**
  69636. * Adds a new row to the grid
  69637. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69638. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  69639. * @returns the current grid
  69640. */
  69641. addRowDefinition(height: number, isPixel?: boolean): Grid;
  69642. /**
  69643. * Adds a new column to the grid
  69644. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69645. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69646. * @returns the current grid
  69647. */
  69648. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  69649. /**
  69650. * Update a row definition
  69651. * @param index defines the index of the row to update
  69652. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  69653. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  69654. * @returns the current grid
  69655. */
  69656. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  69657. /**
  69658. * Update a column definition
  69659. * @param index defines the index of the column to update
  69660. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  69661. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  69662. * @returns the current grid
  69663. */
  69664. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  69665. /**
  69666. * Gets the list of children stored in a specific cell
  69667. * @param row defines the row to check
  69668. * @param column defines the column to check
  69669. * @returns the list of controls
  69670. */
  69671. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  69672. /**
  69673. * Gets a string representing the child cell info (row x column)
  69674. * @param child defines the control to get info from
  69675. * @returns a string containing the child cell info (row x column)
  69676. */
  69677. getChildCellInfo(child: Control): string;
  69678. private _removeCell;
  69679. private _offsetCell;
  69680. /**
  69681. * Remove a column definition at specified index
  69682. * @param index defines the index of the column to remove
  69683. * @returns the current grid
  69684. */
  69685. removeColumnDefinition(index: number): Grid;
  69686. /**
  69687. * Remove a row definition at specified index
  69688. * @param index defines the index of the row to remove
  69689. * @returns the current grid
  69690. */
  69691. removeRowDefinition(index: number): Grid;
  69692. /**
  69693. * Adds a new control to the current grid
  69694. * @param control defines the control to add
  69695. * @param row defines the row where to add the control (0 by default)
  69696. * @param column defines the column where to add the control (0 by default)
  69697. * @returns the current grid
  69698. */
  69699. addControl(control: Control, row?: number, column?: number): Grid;
  69700. /**
  69701. * Removes a control from the current container
  69702. * @param control defines the control to remove
  69703. * @returns the current container
  69704. */
  69705. removeControl(control: Control): Container;
  69706. /**
  69707. * Creates a new Grid
  69708. * @param name defines control name
  69709. */
  69710. constructor(name?: string | undefined);
  69711. protected _getTypeName(): string;
  69712. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  69713. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69714. _flagDescendantsAsMatrixDirty(): void;
  69715. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69716. /** Releases associated resources */
  69717. dispose(): void;
  69718. }
  69719. }
  69720. declare module BABYLON.GUI {
  69721. /** Class used to create color pickers */
  69722. export class ColorPicker extends Control {
  69723. name?: string | undefined;
  69724. private static _Epsilon;
  69725. private _colorWheelCanvas;
  69726. private _value;
  69727. private _tmpColor;
  69728. private _pointerStartedOnSquare;
  69729. private _pointerStartedOnWheel;
  69730. private _squareLeft;
  69731. private _squareTop;
  69732. private _squareSize;
  69733. private _h;
  69734. private _s;
  69735. private _v;
  69736. private _lastPointerDownID;
  69737. /**
  69738. * BABYLON.Observable raised when the value changes
  69739. */
  69740. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  69741. /** Gets or sets the color of the color picker */
  69742. get value(): BABYLON.Color3;
  69743. set value(value: BABYLON.Color3);
  69744. /**
  69745. * Gets or sets control width
  69746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69747. */
  69748. get width(): string | number;
  69749. set width(value: string | number);
  69750. /**
  69751. * Gets or sets control height
  69752. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69753. */
  69754. get height(): string | number;
  69755. /** Gets or sets control height */
  69756. set height(value: string | number);
  69757. /** Gets or sets control size */
  69758. get size(): string | number;
  69759. set size(value: string | number);
  69760. /**
  69761. * Creates a new ColorPicker
  69762. * @param name defines the control name
  69763. */
  69764. constructor(name?: string | undefined);
  69765. protected _getTypeName(): string;
  69766. /** @hidden */
  69767. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69768. private _updateSquareProps;
  69769. private _drawGradientSquare;
  69770. private _drawCircle;
  69771. private _createColorWheelCanvas;
  69772. /** @hidden */
  69773. _draw(context: CanvasRenderingContext2D): void;
  69774. private _pointerIsDown;
  69775. private _updateValueFromPointer;
  69776. private _isPointOnSquare;
  69777. private _isPointOnWheel;
  69778. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69779. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69780. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69781. /**
  69782. * This function expands the color picker by creating a color picker dialog with manual
  69783. * color value input and the ability to save colors into an array to be used later in
  69784. * subsequent launches of the dialogue.
  69785. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69786. * @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.
  69787. * @returns picked color as a hex string and the saved colors array as hex strings.
  69788. */
  69789. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69790. pickerWidth?: string;
  69791. pickerHeight?: string;
  69792. headerHeight?: string;
  69793. lastColor?: string;
  69794. swatchLimit?: number;
  69795. numSwatchesPerLine?: number;
  69796. savedColors?: Array<string>;
  69797. }): Promise<{
  69798. savedColors?: string[];
  69799. pickedColor: string;
  69800. }>;
  69801. }
  69802. }
  69803. declare module BABYLON.GUI {
  69804. /** Class used to create 2D ellipse containers */
  69805. export class Ellipse extends Container {
  69806. name?: string | undefined;
  69807. private _thickness;
  69808. /** Gets or sets border thickness */
  69809. get thickness(): number;
  69810. set thickness(value: number);
  69811. /**
  69812. * Creates a new Ellipse
  69813. * @param name defines the control name
  69814. */
  69815. constructor(name?: string | undefined);
  69816. protected _getTypeName(): string;
  69817. protected _localDraw(context: CanvasRenderingContext2D): void;
  69818. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69819. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69820. }
  69821. }
  69822. declare module BABYLON.GUI {
  69823. /**
  69824. * Class used to create a password control
  69825. */
  69826. export class InputPassword extends InputText {
  69827. protected _beforeRenderText(text: string): string;
  69828. }
  69829. }
  69830. declare module BABYLON.GUI {
  69831. /** Class used to render 2D lines */
  69832. export class Line extends Control {
  69833. name?: string | undefined;
  69834. private _lineWidth;
  69835. private _x1;
  69836. private _y1;
  69837. private _x2;
  69838. private _y2;
  69839. private _dash;
  69840. private _connectedControl;
  69841. private _connectedControlDirtyObserver;
  69842. /** Gets or sets the dash pattern */
  69843. get dash(): Array<number>;
  69844. set dash(value: Array<number>);
  69845. /** Gets or sets the control connected with the line end */
  69846. get connectedControl(): Control;
  69847. set connectedControl(value: Control);
  69848. /** Gets or sets start coordinates on X axis */
  69849. get x1(): string | number;
  69850. set x1(value: string | number);
  69851. /** Gets or sets start coordinates on Y axis */
  69852. get y1(): string | number;
  69853. set y1(value: string | number);
  69854. /** Gets or sets end coordinates on X axis */
  69855. get x2(): string | number;
  69856. set x2(value: string | number);
  69857. /** Gets or sets end coordinates on Y axis */
  69858. get y2(): string | number;
  69859. set y2(value: string | number);
  69860. /** Gets or sets line width */
  69861. get lineWidth(): number;
  69862. set lineWidth(value: number);
  69863. /** Gets or sets horizontal alignment */
  69864. set horizontalAlignment(value: number);
  69865. /** Gets or sets vertical alignment */
  69866. set verticalAlignment(value: number);
  69867. private get _effectiveX2();
  69868. private get _effectiveY2();
  69869. /**
  69870. * Creates a new Line
  69871. * @param name defines the control name
  69872. */
  69873. constructor(name?: string | undefined);
  69874. protected _getTypeName(): string;
  69875. _draw(context: CanvasRenderingContext2D): void;
  69876. _measure(): void;
  69877. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69878. /**
  69879. * Move one end of the line given 3D cartesian coordinates.
  69880. * @param position Targeted world position
  69881. * @param scene BABYLON.Scene
  69882. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69883. */
  69884. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69885. /**
  69886. * Move one end of the line to a position in screen absolute space.
  69887. * @param projectedPosition Position in screen absolute space (X, Y)
  69888. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69889. */
  69890. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69891. }
  69892. }
  69893. declare module BABYLON.GUI {
  69894. /**
  69895. * Class used to store a point for a MultiLine object.
  69896. * The point can be pure 2D coordinates, a mesh or a control
  69897. */
  69898. export class MultiLinePoint {
  69899. private _multiLine;
  69900. private _x;
  69901. private _y;
  69902. private _control;
  69903. private _mesh;
  69904. private _controlObserver;
  69905. private _meshObserver;
  69906. /** @hidden */
  69907. _point: BABYLON.Vector2;
  69908. /**
  69909. * Creates a new MultiLinePoint
  69910. * @param multiLine defines the source MultiLine object
  69911. */
  69912. constructor(multiLine: MultiLine);
  69913. /** Gets or sets x coordinate */
  69914. get x(): string | number;
  69915. set x(value: string | number);
  69916. /** Gets or sets y coordinate */
  69917. get y(): string | number;
  69918. set y(value: string | number);
  69919. /** Gets or sets the control associated with this point */
  69920. get control(): BABYLON.Nullable<Control>;
  69921. set control(value: BABYLON.Nullable<Control>);
  69922. /** Gets or sets the mesh associated with this point */
  69923. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  69924. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  69925. /** Resets links */
  69926. resetLinks(): void;
  69927. /**
  69928. * Gets a translation vector
  69929. * @returns the translation vector
  69930. */
  69931. translate(): BABYLON.Vector2;
  69932. private _translatePoint;
  69933. /** Release associated resources */
  69934. dispose(): void;
  69935. }
  69936. }
  69937. declare module BABYLON.GUI {
  69938. /**
  69939. * Class used to create multi line control
  69940. */
  69941. export class MultiLine extends Control {
  69942. name?: string | undefined;
  69943. private _lineWidth;
  69944. private _dash;
  69945. private _points;
  69946. private _minX;
  69947. private _minY;
  69948. private _maxX;
  69949. private _maxY;
  69950. /**
  69951. * Creates a new MultiLine
  69952. * @param name defines the control name
  69953. */
  69954. constructor(name?: string | undefined);
  69955. /** Gets or sets dash pattern */
  69956. get dash(): Array<number>;
  69957. set dash(value: Array<number>);
  69958. /**
  69959. * Gets point stored at specified index
  69960. * @param index defines the index to look for
  69961. * @returns the requested point if found
  69962. */
  69963. getAt(index: number): MultiLinePoint;
  69964. /** Function called when a point is updated */
  69965. onPointUpdate: () => void;
  69966. /**
  69967. * Adds new points to the point collection
  69968. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  69969. * @returns the list of created MultiLinePoint
  69970. */
  69971. add(...items: (AbstractMesh | Control | {
  69972. x: string | number;
  69973. y: string | number;
  69974. })[]): MultiLinePoint[];
  69975. /**
  69976. * Adds a new point to the point collection
  69977. * @param item defines the item (mesh, control or 2d coordiantes) to add
  69978. * @returns the created MultiLinePoint
  69979. */
  69980. push(item?: (AbstractMesh | Control | {
  69981. x: string | number;
  69982. y: string | number;
  69983. })): MultiLinePoint;
  69984. /**
  69985. * Remove a specific value or point from the active point collection
  69986. * @param value defines the value or point to remove
  69987. */
  69988. remove(value: number | MultiLinePoint): void;
  69989. /**
  69990. * Resets this object to initial state (no point)
  69991. */
  69992. reset(): void;
  69993. /**
  69994. * Resets all links
  69995. */
  69996. resetLinks(): void;
  69997. /** Gets or sets line width */
  69998. get lineWidth(): number;
  69999. set lineWidth(value: number);
  70000. set horizontalAlignment(value: number);
  70001. set verticalAlignment(value: number);
  70002. protected _getTypeName(): string;
  70003. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70005. _measure(): void;
  70006. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70007. dispose(): void;
  70008. }
  70009. }
  70010. declare module BABYLON.GUI {
  70011. /**
  70012. * Class used to create radio button controls
  70013. */
  70014. export class RadioButton extends Control {
  70015. name?: string | undefined;
  70016. private _isChecked;
  70017. private _background;
  70018. private _checkSizeRatio;
  70019. private _thickness;
  70020. /** Gets or sets border thickness */
  70021. get thickness(): number;
  70022. set thickness(value: number);
  70023. /** Gets or sets group name */
  70024. group: string;
  70025. /** BABYLON.Observable raised when isChecked is changed */
  70026. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  70027. /** Gets or sets a value indicating the ratio between overall size and check size */
  70028. get checkSizeRatio(): number;
  70029. set checkSizeRatio(value: number);
  70030. /** Gets or sets background color */
  70031. get background(): string;
  70032. set background(value: string);
  70033. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  70034. get isChecked(): boolean;
  70035. set isChecked(value: boolean);
  70036. /**
  70037. * Creates a new RadioButton
  70038. * @param name defines the control name
  70039. */
  70040. constructor(name?: string | undefined);
  70041. protected _getTypeName(): string;
  70042. _draw(context: CanvasRenderingContext2D): void;
  70043. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70044. /**
  70045. * Utility function to easily create a radio button with a header
  70046. * @param title defines the label to use for the header
  70047. * @param group defines the group to use for the radio button
  70048. * @param isChecked defines the initial state of the radio button
  70049. * @param onValueChanged defines the callback to call when value changes
  70050. * @returns a StackPanel containing the radio button and a textBlock
  70051. */
  70052. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  70053. }
  70054. }
  70055. declare module BABYLON.GUI {
  70056. /**
  70057. * Class used to create slider controls
  70058. */
  70059. export class BaseSlider extends Control {
  70060. name?: string | undefined;
  70061. protected _thumbWidth: ValueAndUnit;
  70062. private _minimum;
  70063. private _maximum;
  70064. private _value;
  70065. private _isVertical;
  70066. protected _barOffset: ValueAndUnit;
  70067. private _isThumbClamped;
  70068. protected _displayThumb: boolean;
  70069. private _step;
  70070. private _lastPointerDownID;
  70071. protected _effectiveBarOffset: number;
  70072. protected _renderLeft: number;
  70073. protected _renderTop: number;
  70074. protected _renderWidth: number;
  70075. protected _renderHeight: number;
  70076. protected _backgroundBoxLength: number;
  70077. protected _backgroundBoxThickness: number;
  70078. protected _effectiveThumbThickness: number;
  70079. /** BABYLON.Observable raised when the sldier value changes */
  70080. onValueChangedObservable: BABYLON.Observable<number>;
  70081. /** Gets or sets a boolean indicating if the thumb must be rendered */
  70082. get displayThumb(): boolean;
  70083. set displayThumb(value: boolean);
  70084. /** Gets or sets a step to apply to values (0 by default) */
  70085. get step(): number;
  70086. set step(value: number);
  70087. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  70088. get barOffset(): string | number;
  70089. /** Gets main bar offset in pixels*/
  70090. get barOffsetInPixels(): number;
  70091. set barOffset(value: string | number);
  70092. /** Gets or sets thumb width */
  70093. get thumbWidth(): string | number;
  70094. /** Gets thumb width in pixels */
  70095. get thumbWidthInPixels(): number;
  70096. set thumbWidth(value: string | number);
  70097. /** Gets or sets minimum value */
  70098. get minimum(): number;
  70099. set minimum(value: number);
  70100. /** Gets or sets maximum value */
  70101. get maximum(): number;
  70102. set maximum(value: number);
  70103. /** Gets or sets current value */
  70104. get value(): number;
  70105. set value(value: number);
  70106. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  70107. get isVertical(): boolean;
  70108. set isVertical(value: boolean);
  70109. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  70110. get isThumbClamped(): boolean;
  70111. set isThumbClamped(value: boolean);
  70112. /**
  70113. * Creates a new BaseSlider
  70114. * @param name defines the control name
  70115. */
  70116. constructor(name?: string | undefined);
  70117. protected _getTypeName(): string;
  70118. protected _getThumbPosition(): number;
  70119. protected _getThumbThickness(type: string): number;
  70120. protected _prepareRenderingData(type: string): void;
  70121. private _pointerIsDown;
  70122. /** @hidden */
  70123. protected _updateValueFromPointer(x: number, y: number): void;
  70124. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70125. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70126. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70127. }
  70128. }
  70129. declare module BABYLON.GUI {
  70130. /**
  70131. * Class used to create slider controls
  70132. */
  70133. export class Slider extends BaseSlider {
  70134. name?: string | undefined;
  70135. private _background;
  70136. private _borderColor;
  70137. private _isThumbCircle;
  70138. protected _displayValueBar: boolean;
  70139. /** Gets or sets a boolean indicating if the value bar must be rendered */
  70140. get displayValueBar(): boolean;
  70141. set displayValueBar(value: boolean);
  70142. /** Gets or sets border color */
  70143. get borderColor(): string;
  70144. set borderColor(value: string);
  70145. /** Gets or sets background color */
  70146. get background(): string;
  70147. set background(value: string);
  70148. /** Gets or sets a boolean indicating if the thumb should be round or square */
  70149. get isThumbCircle(): boolean;
  70150. set isThumbCircle(value: boolean);
  70151. /**
  70152. * Creates a new Slider
  70153. * @param name defines the control name
  70154. */
  70155. constructor(name?: string | undefined);
  70156. protected _getTypeName(): string;
  70157. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70158. }
  70159. }
  70160. declare module BABYLON.GUI {
  70161. /** Class used to create a RadioGroup
  70162. * which contains groups of radio buttons
  70163. */
  70164. export class SelectorGroup {
  70165. /** name of SelectorGroup */
  70166. name: string;
  70167. private _groupPanel;
  70168. private _selectors;
  70169. private _groupHeader;
  70170. /**
  70171. * Creates a new SelectorGroup
  70172. * @param name of group, used as a group heading
  70173. */
  70174. constructor(
  70175. /** name of SelectorGroup */
  70176. name: string);
  70177. /** Gets the groupPanel of the SelectorGroup */
  70178. get groupPanel(): StackPanel;
  70179. /** Gets the selectors array */
  70180. get selectors(): StackPanel[];
  70181. /** Gets and sets the group header */
  70182. get header(): string;
  70183. set header(label: string);
  70184. /** @hidden */
  70185. private _addGroupHeader;
  70186. /** @hidden*/
  70187. _getSelector(selectorNb: number): StackPanel | undefined;
  70188. /** Removes the selector at the given position
  70189. * @param selectorNb the position of the selector within the group
  70190. */
  70191. removeSelector(selectorNb: number): void;
  70192. }
  70193. /** Class used to create a CheckboxGroup
  70194. * which contains groups of checkbox buttons
  70195. */
  70196. export class CheckboxGroup extends SelectorGroup {
  70197. /** Adds a checkbox as a control
  70198. * @param text is the label for the selector
  70199. * @param func is the function called when the Selector is checked
  70200. * @param checked is true when Selector is checked
  70201. */
  70202. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  70203. /** @hidden */
  70204. _setSelectorLabel(selectorNb: number, label: string): void;
  70205. /** @hidden */
  70206. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70207. /** @hidden */
  70208. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70209. /** @hidden */
  70210. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70211. }
  70212. /** Class used to create a RadioGroup
  70213. * which contains groups of radio buttons
  70214. */
  70215. export class RadioGroup extends SelectorGroup {
  70216. private _selectNb;
  70217. /** Adds a radio button as a control
  70218. * @param label is the label for the selector
  70219. * @param func is the function called when the Selector is checked
  70220. * @param checked is true when Selector is checked
  70221. */
  70222. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  70223. /** @hidden */
  70224. _setSelectorLabel(selectorNb: number, label: string): void;
  70225. /** @hidden */
  70226. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70227. /** @hidden */
  70228. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70229. /** @hidden */
  70230. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70231. }
  70232. /** Class used to create a SliderGroup
  70233. * which contains groups of slider buttons
  70234. */
  70235. export class SliderGroup extends SelectorGroup {
  70236. /**
  70237. * Adds a slider to the SelectorGroup
  70238. * @param label is the label for the SliderBar
  70239. * @param func is the function called when the Slider moves
  70240. * @param unit is a string describing the units used, eg degrees or metres
  70241. * @param min is the minimum value for the Slider
  70242. * @param max is the maximum value for the Slider
  70243. * @param value is the start value for the Slider between min and max
  70244. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  70245. */
  70246. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  70247. /** @hidden */
  70248. _setSelectorLabel(selectorNb: number, label: string): void;
  70249. /** @hidden */
  70250. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70251. /** @hidden */
  70252. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70253. /** @hidden */
  70254. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70255. }
  70256. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  70257. * @see http://doc.babylonjs.com/how_to/selector
  70258. */
  70259. export class SelectionPanel extends Rectangle {
  70260. /** name of SelectionPanel */
  70261. name: string;
  70262. /** an array of SelectionGroups */
  70263. groups: SelectorGroup[];
  70264. private _panel;
  70265. private _buttonColor;
  70266. private _buttonBackground;
  70267. private _headerColor;
  70268. private _barColor;
  70269. private _barHeight;
  70270. private _spacerHeight;
  70271. private _labelColor;
  70272. private _groups;
  70273. private _bars;
  70274. /**
  70275. * Creates a new SelectionPanel
  70276. * @param name of SelectionPanel
  70277. * @param groups is an array of SelectionGroups
  70278. */
  70279. constructor(
  70280. /** name of SelectionPanel */
  70281. name: string,
  70282. /** an array of SelectionGroups */
  70283. groups?: SelectorGroup[]);
  70284. protected _getTypeName(): string;
  70285. /** Gets or sets the headerColor */
  70286. get headerColor(): string;
  70287. set headerColor(color: string);
  70288. private _setHeaderColor;
  70289. /** Gets or sets the button color */
  70290. get buttonColor(): string;
  70291. set buttonColor(color: string);
  70292. private _setbuttonColor;
  70293. /** Gets or sets the label color */
  70294. get labelColor(): string;
  70295. set labelColor(color: string);
  70296. private _setLabelColor;
  70297. /** Gets or sets the button background */
  70298. get buttonBackground(): string;
  70299. set buttonBackground(color: string);
  70300. private _setButtonBackground;
  70301. /** Gets or sets the color of separator bar */
  70302. get barColor(): string;
  70303. set barColor(color: string);
  70304. private _setBarColor;
  70305. /** Gets or sets the height of separator bar */
  70306. get barHeight(): string;
  70307. set barHeight(value: string);
  70308. private _setBarHeight;
  70309. /** Gets or sets the height of spacers*/
  70310. get spacerHeight(): string;
  70311. set spacerHeight(value: string);
  70312. private _setSpacerHeight;
  70313. /** Adds a bar between groups */
  70314. private _addSpacer;
  70315. /** Add a group to the selection panel
  70316. * @param group is the selector group to add
  70317. */
  70318. addGroup(group: SelectorGroup): void;
  70319. /** Remove the group from the given position
  70320. * @param groupNb is the position of the group in the list
  70321. */
  70322. removeGroup(groupNb: number): void;
  70323. /** Change a group header label
  70324. * @param label is the new group header label
  70325. * @param groupNb is the number of the group to relabel
  70326. * */
  70327. setHeaderName(label: string, groupNb: number): void;
  70328. /** Change selector label to the one given
  70329. * @param label is the new selector label
  70330. * @param groupNb is the number of the groupcontaining the selector
  70331. * @param selectorNb is the number of the selector within a group to relabel
  70332. * */
  70333. relabel(label: string, groupNb: number, selectorNb: number): void;
  70334. /** For a given group position remove the selector at the given position
  70335. * @param groupNb is the number of the group to remove the selector from
  70336. * @param selectorNb is the number of the selector within the group
  70337. */
  70338. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  70339. /** For a given group position of correct type add a checkbox button
  70340. * @param groupNb is the number of the group to remove the selector from
  70341. * @param label is the label for the selector
  70342. * @param func is the function called when the Selector is checked
  70343. * @param checked is true when Selector is checked
  70344. */
  70345. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70346. /** For a given group position of correct type add a radio button
  70347. * @param groupNb is the number of the group to remove the selector from
  70348. * @param label is the label for the selector
  70349. * @param func is the function called when the Selector is checked
  70350. * @param checked is true when Selector is checked
  70351. */
  70352. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  70353. /**
  70354. * For a given slider group add a slider
  70355. * @param groupNb is the number of the group to add the slider to
  70356. * @param label is the label for the Slider
  70357. * @param func is the function called when the Slider moves
  70358. * @param unit is a string describing the units used, eg degrees or metres
  70359. * @param min is the minimum value for the Slider
  70360. * @param max is the maximum value for the Slider
  70361. * @param value is the start value for the Slider between min and max
  70362. * @param onVal is the function used to format the value displayed, eg radians to degrees
  70363. */
  70364. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  70365. }
  70366. }
  70367. declare module BABYLON.GUI {
  70368. /**
  70369. * Class used to hold a the container for ScrollViewer
  70370. * @hidden
  70371. */
  70372. export class _ScrollViewerWindow extends Container {
  70373. parentClientWidth: number;
  70374. parentClientHeight: number;
  70375. /**
  70376. * Creates a new ScrollViewerWindow
  70377. * @param name of ScrollViewerWindow
  70378. */
  70379. constructor(name?: string);
  70380. protected _getTypeName(): string;
  70381. /** @hidden */
  70382. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70383. protected _postMeasure(): void;
  70384. }
  70385. }
  70386. declare module BABYLON.GUI {
  70387. /**
  70388. * Class used to create slider controls
  70389. */
  70390. export class ScrollBar extends BaseSlider {
  70391. name?: string | undefined;
  70392. private _background;
  70393. private _borderColor;
  70394. private _tempMeasure;
  70395. /** Gets or sets border color */
  70396. get borderColor(): string;
  70397. set borderColor(value: string);
  70398. /** Gets or sets background color */
  70399. get background(): string;
  70400. set background(value: string);
  70401. /**
  70402. * Creates a new Slider
  70403. * @param name defines the control name
  70404. */
  70405. constructor(name?: string | undefined);
  70406. protected _getTypeName(): string;
  70407. protected _getThumbThickness(): number;
  70408. _draw(context: CanvasRenderingContext2D): void;
  70409. private _first;
  70410. private _originX;
  70411. private _originY;
  70412. /** @hidden */
  70413. protected _updateValueFromPointer(x: number, y: number): void;
  70414. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70415. }
  70416. }
  70417. declare module BABYLON.GUI {
  70418. /**
  70419. * Class used to create slider controls
  70420. */
  70421. export class ImageScrollBar extends BaseSlider {
  70422. name?: string | undefined;
  70423. private _backgroundBaseImage;
  70424. private _backgroundImage;
  70425. private _thumbImage;
  70426. private _thumbBaseImage;
  70427. private _thumbLength;
  70428. private _thumbHeight;
  70429. private _barImageHeight;
  70430. private _tempMeasure;
  70431. /**
  70432. * Gets or sets the image used to render the background for horizontal bar
  70433. */
  70434. get backgroundImage(): Image;
  70435. set backgroundImage(value: Image);
  70436. /**
  70437. * Gets or sets the image used to render the thumb
  70438. */
  70439. get thumbImage(): Image;
  70440. set thumbImage(value: Image);
  70441. /**
  70442. * Gets or sets the length of the thumb
  70443. */
  70444. get thumbLength(): number;
  70445. set thumbLength(value: number);
  70446. /**
  70447. * Gets or sets the height of the thumb
  70448. */
  70449. get thumbHeight(): number;
  70450. set thumbHeight(value: number);
  70451. /**
  70452. * Gets or sets the height of the bar image
  70453. */
  70454. get barImageHeight(): number;
  70455. set barImageHeight(value: number);
  70456. /**
  70457. * Creates a new ImageScrollBar
  70458. * @param name defines the control name
  70459. */
  70460. constructor(name?: string | undefined);
  70461. protected _getTypeName(): string;
  70462. protected _getThumbThickness(): number;
  70463. _draw(context: CanvasRenderingContext2D): void;
  70464. private _first;
  70465. private _originX;
  70466. private _originY;
  70467. /** @hidden */
  70468. protected _updateValueFromPointer(x: number, y: number): void;
  70469. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70470. }
  70471. }
  70472. declare module BABYLON.GUI {
  70473. /**
  70474. * Class used to hold a viewer window and sliders in a grid
  70475. */
  70476. export class ScrollViewer extends Rectangle {
  70477. private _grid;
  70478. private _horizontalBarSpace;
  70479. private _verticalBarSpace;
  70480. private _dragSpace;
  70481. private _horizontalBar;
  70482. private _verticalBar;
  70483. private _barColor;
  70484. private _barBackground;
  70485. private _barImage;
  70486. private _barBackgroundImage;
  70487. private _barSize;
  70488. private _endLeft;
  70489. private _endTop;
  70490. private _window;
  70491. private _pointerIsOver;
  70492. private _wheelPrecision;
  70493. private _onPointerObserver;
  70494. private _clientWidth;
  70495. private _clientHeight;
  70496. private _useImageBar;
  70497. private _thumbLength;
  70498. private _thumbHeight;
  70499. private _barImageHeight;
  70500. /**
  70501. * Gets the horizontal scrollbar
  70502. */
  70503. get horizontalBar(): ScrollBar | ImageScrollBar;
  70504. /**
  70505. * Gets the vertical scrollbar
  70506. */
  70507. get verticalBar(): ScrollBar | ImageScrollBar;
  70508. /**
  70509. * Adds a new control to the current container
  70510. * @param control defines the control to add
  70511. * @returns the current container
  70512. */
  70513. addControl(control: BABYLON.Nullable<Control>): Container;
  70514. /**
  70515. * Removes a control from the current container
  70516. * @param control defines the control to remove
  70517. * @returns the current container
  70518. */
  70519. removeControl(control: Control): Container;
  70520. /** Gets the list of children */
  70521. get children(): Control[];
  70522. _flagDescendantsAsMatrixDirty(): void;
  70523. /**
  70524. * Creates a new ScrollViewer
  70525. * @param name of ScrollViewer
  70526. */
  70527. constructor(name?: string, isImageBased?: boolean);
  70528. /** Reset the scroll viewer window to initial size */
  70529. resetWindow(): void;
  70530. protected _getTypeName(): string;
  70531. private _buildClientSizes;
  70532. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70533. protected _postMeasure(): void;
  70534. /**
  70535. * Gets or sets the mouse wheel precision
  70536. * from 0 to 1 with a default value of 0.05
  70537. * */
  70538. get wheelPrecision(): number;
  70539. set wheelPrecision(value: number);
  70540. /** Gets or sets the scroll bar container background color */
  70541. get scrollBackground(): string;
  70542. set scrollBackground(color: string);
  70543. /** Gets or sets the bar color */
  70544. get barColor(): string;
  70545. set barColor(color: string);
  70546. /** Gets or sets the bar image */
  70547. get thumbImage(): Image;
  70548. set thumbImage(value: Image);
  70549. /** Gets or sets the size of the bar */
  70550. get barSize(): number;
  70551. set barSize(value: number);
  70552. /** Gets or sets the length of the thumb */
  70553. get thumbLength(): number;
  70554. set thumbLength(value: number);
  70555. /** Gets or sets the height of the thumb */
  70556. get thumbHeight(): number;
  70557. set thumbHeight(value: number);
  70558. /** Gets or sets the height of the bar image */
  70559. get barImageHeight(): number;
  70560. set barImageHeight(value: number);
  70561. /** Gets or sets the bar background */
  70562. get barBackground(): string;
  70563. set barBackground(color: string);
  70564. /** Gets or sets the bar background image */
  70565. get barImage(): Image;
  70566. set barImage(value: Image);
  70567. /** @hidden */
  70568. private _updateScroller;
  70569. _link(host: AdvancedDynamicTexture): void;
  70570. /** @hidden */
  70571. private _addBar;
  70572. /** @hidden */
  70573. private _attachWheel;
  70574. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70575. /** Releases associated resources */
  70576. dispose(): void;
  70577. }
  70578. }
  70579. declare module BABYLON.GUI {
  70580. /** Class used to render a grid */
  70581. export class DisplayGrid extends Control {
  70582. name?: string | undefined;
  70583. private _cellWidth;
  70584. private _cellHeight;
  70585. private _minorLineTickness;
  70586. private _minorLineColor;
  70587. private _majorLineTickness;
  70588. private _majorLineColor;
  70589. private _majorLineFrequency;
  70590. private _background;
  70591. private _displayMajorLines;
  70592. private _displayMinorLines;
  70593. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  70594. get displayMinorLines(): boolean;
  70595. set displayMinorLines(value: boolean);
  70596. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  70597. get displayMajorLines(): boolean;
  70598. set displayMajorLines(value: boolean);
  70599. /** Gets or sets background color (Black by default) */
  70600. get background(): string;
  70601. set background(value: string);
  70602. /** Gets or sets the width of each cell (20 by default) */
  70603. get cellWidth(): number;
  70604. set cellWidth(value: number);
  70605. /** Gets or sets the height of each cell (20 by default) */
  70606. get cellHeight(): number;
  70607. set cellHeight(value: number);
  70608. /** Gets or sets the tickness of minor lines (1 by default) */
  70609. get minorLineTickness(): number;
  70610. set minorLineTickness(value: number);
  70611. /** Gets or sets the color of minor lines (DarkGray by default) */
  70612. get minorLineColor(): string;
  70613. set minorLineColor(value: string);
  70614. /** Gets or sets the tickness of major lines (2 by default) */
  70615. get majorLineTickness(): number;
  70616. set majorLineTickness(value: number);
  70617. /** Gets or sets the color of major lines (White by default) */
  70618. get majorLineColor(): string;
  70619. set majorLineColor(value: string);
  70620. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  70621. get majorLineFrequency(): number;
  70622. set majorLineFrequency(value: number);
  70623. /**
  70624. * Creates a new GridDisplayRectangle
  70625. * @param name defines the control name
  70626. */
  70627. constructor(name?: string | undefined);
  70628. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70629. protected _getTypeName(): string;
  70630. }
  70631. }
  70632. declare module BABYLON.GUI {
  70633. /**
  70634. * Class used to create slider controls based on images
  70635. */
  70636. export class ImageBasedSlider extends BaseSlider {
  70637. name?: string | undefined;
  70638. private _backgroundImage;
  70639. private _thumbImage;
  70640. private _valueBarImage;
  70641. private _tempMeasure;
  70642. get displayThumb(): boolean;
  70643. set displayThumb(value: boolean);
  70644. /**
  70645. * Gets or sets the image used to render the background
  70646. */
  70647. get backgroundImage(): Image;
  70648. set backgroundImage(value: Image);
  70649. /**
  70650. * Gets or sets the image used to render the value bar
  70651. */
  70652. get valueBarImage(): Image;
  70653. set valueBarImage(value: Image);
  70654. /**
  70655. * Gets or sets the image used to render the thumb
  70656. */
  70657. get thumbImage(): Image;
  70658. set thumbImage(value: Image);
  70659. /**
  70660. * Creates a new ImageBasedSlider
  70661. * @param name defines the control name
  70662. */
  70663. constructor(name?: string | undefined);
  70664. protected _getTypeName(): string;
  70665. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70666. }
  70667. }
  70668. declare module BABYLON.GUI {
  70669. /**
  70670. * Forcing an export so that this code will execute
  70671. * @hidden
  70672. */
  70673. const name = "Statics";
  70674. }
  70675. declare module BABYLON.GUI {
  70676. /**
  70677. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  70678. */
  70679. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  70680. /**
  70681. * Define the instrumented AdvancedDynamicTexture.
  70682. */
  70683. texture: AdvancedDynamicTexture;
  70684. private _captureRenderTime;
  70685. private _renderTime;
  70686. private _captureLayoutTime;
  70687. private _layoutTime;
  70688. private _onBeginRenderObserver;
  70689. private _onEndRenderObserver;
  70690. private _onBeginLayoutObserver;
  70691. private _onEndLayoutObserver;
  70692. /**
  70693. * Gets the perf counter used to capture render time
  70694. */
  70695. get renderTimeCounter(): BABYLON.PerfCounter;
  70696. /**
  70697. * Gets the perf counter used to capture layout time
  70698. */
  70699. get layoutTimeCounter(): BABYLON.PerfCounter;
  70700. /**
  70701. * Enable or disable the render time capture
  70702. */
  70703. get captureRenderTime(): boolean;
  70704. set captureRenderTime(value: boolean);
  70705. /**
  70706. * Enable or disable the layout time capture
  70707. */
  70708. get captureLayoutTime(): boolean;
  70709. set captureLayoutTime(value: boolean);
  70710. /**
  70711. * Instantiates a new advanced dynamic texture instrumentation.
  70712. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  70713. * @param texture Defines the AdvancedDynamicTexture to instrument
  70714. */
  70715. constructor(
  70716. /**
  70717. * Define the instrumented AdvancedDynamicTexture.
  70718. */
  70719. texture: AdvancedDynamicTexture);
  70720. /**
  70721. * Dispose and release associated resources.
  70722. */
  70723. dispose(): void;
  70724. }
  70725. }
  70726. declare module BABYLON.GUI {
  70727. /**
  70728. * Class used to load GUI via XML.
  70729. */
  70730. export class XmlLoader {
  70731. private _nodes;
  70732. private _nodeTypes;
  70733. private _isLoaded;
  70734. private _objectAttributes;
  70735. private _parentClass;
  70736. /**
  70737. * Create a new xml loader
  70738. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  70739. */
  70740. constructor(parentClass?: null);
  70741. private _getChainElement;
  70742. private _getClassAttribute;
  70743. private _createGuiElement;
  70744. private _parseGrid;
  70745. private _parseElement;
  70746. private _prepareSourceElement;
  70747. private _parseElementsFromSource;
  70748. private _parseXml;
  70749. /**
  70750. * Gets if the loading has finished.
  70751. * @returns whether the loading has finished or not
  70752. */
  70753. isLoaded(): boolean;
  70754. /**
  70755. * Gets a loaded node / control by id.
  70756. * @param id the Controls id set in the xml
  70757. * @returns element of type Control
  70758. */
  70759. getNodeById(id: string): any;
  70760. /**
  70761. * Gets all loaded nodes / controls
  70762. * @returns Array of controls
  70763. */
  70764. getNodes(): any;
  70765. /**
  70766. * Initiates the xml layout loading
  70767. * @param xmlFile defines the xml layout to load
  70768. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  70769. * @param callback defines the callback called on layout load.
  70770. */
  70771. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  70772. }
  70773. }
  70774. declare module BABYLON.GUI {
  70775. /**
  70776. * Class used to create containers for controls
  70777. */
  70778. export class Container3D extends Control3D {
  70779. private _blockLayout;
  70780. /**
  70781. * Gets the list of child controls
  70782. */
  70783. protected _children: Control3D[];
  70784. /**
  70785. * Gets the list of child controls
  70786. */
  70787. get children(): Array<Control3D>;
  70788. /**
  70789. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  70790. * This is helpful to optimize layout operation when adding multiple children in a row
  70791. */
  70792. get blockLayout(): boolean;
  70793. set blockLayout(value: boolean);
  70794. /**
  70795. * Creates a new container
  70796. * @param name defines the container name
  70797. */
  70798. constructor(name?: string);
  70799. /**
  70800. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  70801. * @returns the current container
  70802. */
  70803. updateLayout(): Container3D;
  70804. /**
  70805. * Gets a boolean indicating if the given control is in the children of this control
  70806. * @param control defines the control to check
  70807. * @returns true if the control is in the child list
  70808. */
  70809. containsControl(control: Control3D): boolean;
  70810. /**
  70811. * Adds a control to the children of this control
  70812. * @param control defines the control to add
  70813. * @returns the current container
  70814. */
  70815. addControl(control: Control3D): Container3D;
  70816. /**
  70817. * This function will be called everytime a new control is added
  70818. */
  70819. protected _arrangeChildren(): void;
  70820. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70821. /**
  70822. * Removes a control from the children of this control
  70823. * @param control defines the control to remove
  70824. * @returns the current container
  70825. */
  70826. removeControl(control: Control3D): Container3D;
  70827. protected _getTypeName(): string;
  70828. /**
  70829. * Releases all associated resources
  70830. */
  70831. dispose(): void;
  70832. /** Control rotation will remain unchanged */
  70833. static readonly UNSET_ORIENTATION: number;
  70834. /** Control will rotate to make it look at sphere central axis */
  70835. static readonly FACEORIGIN_ORIENTATION: number;
  70836. /** Control will rotate to make it look back at sphere central axis */
  70837. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  70838. /** Control will rotate to look at z axis (0, 0, 1) */
  70839. static readonly FACEFORWARD_ORIENTATION: number;
  70840. /** Control will rotate to look at negative z axis (0, 0, -1) */
  70841. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  70842. }
  70843. }
  70844. declare module BABYLON.GUI {
  70845. /**
  70846. * Class used to manage 3D user interface
  70847. * @see http://doc.babylonjs.com/how_to/gui3d
  70848. */
  70849. export class GUI3DManager implements BABYLON.IDisposable {
  70850. private _scene;
  70851. private _sceneDisposeObserver;
  70852. private _utilityLayer;
  70853. private _rootContainer;
  70854. private _pointerObserver;
  70855. private _pointerOutObserver;
  70856. /** @hidden */
  70857. _lastPickedControl: Control3D;
  70858. /** @hidden */
  70859. _lastControlOver: {
  70860. [pointerId: number]: Control3D;
  70861. };
  70862. /** @hidden */
  70863. _lastControlDown: {
  70864. [pointerId: number]: Control3D;
  70865. };
  70866. /**
  70867. * BABYLON.Observable raised when the point picked by the pointer events changed
  70868. */
  70869. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70870. /** @hidden */
  70871. _sharedMaterials: {
  70872. [key: string]: BABYLON.Material;
  70873. };
  70874. /** Gets the hosting scene */
  70875. get scene(): BABYLON.Scene;
  70876. /** Gets associated utility layer */
  70877. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70878. /**
  70879. * Creates a new GUI3DManager
  70880. * @param scene
  70881. */
  70882. constructor(scene?: BABYLON.Scene);
  70883. private _handlePointerOut;
  70884. private _doPicking;
  70885. /**
  70886. * Gets the root container
  70887. */
  70888. get rootContainer(): Container3D;
  70889. /**
  70890. * Gets a boolean indicating if the given control is in the root child list
  70891. * @param control defines the control to check
  70892. * @returns true if the control is in the root child list
  70893. */
  70894. containsControl(control: Control3D): boolean;
  70895. /**
  70896. * Adds a control to the root child list
  70897. * @param control defines the control to add
  70898. * @returns the current manager
  70899. */
  70900. addControl(control: Control3D): GUI3DManager;
  70901. /**
  70902. * Removes a control from the root child list
  70903. * @param control defines the control to remove
  70904. * @returns the current container
  70905. */
  70906. removeControl(control: Control3D): GUI3DManager;
  70907. /**
  70908. * Releases all associated resources
  70909. */
  70910. dispose(): void;
  70911. }
  70912. }
  70913. declare module BABYLON.GUI {
  70914. /**
  70915. * Class used to transport BABYLON.Vector3 information for pointer events
  70916. */
  70917. export class Vector3WithInfo extends BABYLON.Vector3 {
  70918. /** defines the current mouse button index */
  70919. buttonIndex: number;
  70920. /**
  70921. * Creates a new Vector3WithInfo
  70922. * @param source defines the vector3 data to transport
  70923. * @param buttonIndex defines the current mouse button index
  70924. */
  70925. constructor(source: BABYLON.Vector3,
  70926. /** defines the current mouse button index */
  70927. buttonIndex?: number);
  70928. }
  70929. }
  70930. declare module BABYLON.GUI {
  70931. /**
  70932. * Class used as base class for controls
  70933. */
  70934. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70935. /** Defines the control name */
  70936. name?: string | undefined;
  70937. /** @hidden */
  70938. _host: GUI3DManager;
  70939. private _node;
  70940. private _downCount;
  70941. private _enterCount;
  70942. private _downPointerIds;
  70943. private _isVisible;
  70944. /** Gets or sets the control position in world space */
  70945. get position(): BABYLON.Vector3;
  70946. set position(value: BABYLON.Vector3);
  70947. /** Gets or sets the control scaling in world space */
  70948. get scaling(): BABYLON.Vector3;
  70949. set scaling(value: BABYLON.Vector3);
  70950. /** Callback used to start pointer enter animation */
  70951. pointerEnterAnimation: () => void;
  70952. /** Callback used to start pointer out animation */
  70953. pointerOutAnimation: () => void;
  70954. /** Callback used to start pointer down animation */
  70955. pointerDownAnimation: () => void;
  70956. /** Callback used to start pointer up animation */
  70957. pointerUpAnimation: () => void;
  70958. /**
  70959. * An event triggered when the pointer move over the control
  70960. */
  70961. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70962. /**
  70963. * An event triggered when the pointer move out of the control
  70964. */
  70965. onPointerOutObservable: BABYLON.Observable<Control3D>;
  70966. /**
  70967. * An event triggered when the pointer taps the control
  70968. */
  70969. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  70970. /**
  70971. * An event triggered when pointer is up
  70972. */
  70973. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  70974. /**
  70975. * An event triggered when a control is clicked on (with a mouse)
  70976. */
  70977. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  70978. /**
  70979. * An event triggered when pointer enters the control
  70980. */
  70981. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  70982. /**
  70983. * Gets or sets the parent container
  70984. */
  70985. parent: BABYLON.Nullable<Container3D>;
  70986. private _behaviors;
  70987. /**
  70988. * Gets the list of attached behaviors
  70989. * @see http://doc.babylonjs.com/features/behaviour
  70990. */
  70991. get behaviors(): BABYLON.Behavior<Control3D>[];
  70992. /**
  70993. * Attach a behavior to the control
  70994. * @see http://doc.babylonjs.com/features/behaviour
  70995. * @param behavior defines the behavior to attach
  70996. * @returns the current control
  70997. */
  70998. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70999. /**
  71000. * Remove an attached behavior
  71001. * @see http://doc.babylonjs.com/features/behaviour
  71002. * @param behavior defines the behavior to attach
  71003. * @returns the current control
  71004. */
  71005. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71006. /**
  71007. * Gets an attached behavior by name
  71008. * @param name defines the name of the behavior to look for
  71009. * @see http://doc.babylonjs.com/features/behaviour
  71010. * @returns null if behavior was not found else the requested behavior
  71011. */
  71012. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  71013. /** Gets or sets a boolean indicating if the control is visible */
  71014. get isVisible(): boolean;
  71015. set isVisible(value: boolean);
  71016. /**
  71017. * Creates a new control
  71018. * @param name defines the control name
  71019. */
  71020. constructor(
  71021. /** Defines the control name */
  71022. name?: string | undefined);
  71023. /**
  71024. * Gets a string representing the class name
  71025. */
  71026. get typeName(): string;
  71027. /**
  71028. * Get the current class name of the control.
  71029. * @returns current class name
  71030. */
  71031. getClassName(): string;
  71032. protected _getTypeName(): string;
  71033. /**
  71034. * Gets the transform node used by this control
  71035. */
  71036. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  71037. /**
  71038. * Gets the mesh used to render this control
  71039. */
  71040. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71041. /**
  71042. * Link the control as child of the given node
  71043. * @param node defines the node to link to. Use null to unlink the control
  71044. * @returns the current control
  71045. */
  71046. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  71047. /** @hidden **/
  71048. _prepareNode(scene: BABYLON.Scene): void;
  71049. /**
  71050. * Node creation.
  71051. * Can be overriden by children
  71052. * @param scene defines the scene where the node must be attached
  71053. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  71054. */
  71055. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  71056. /**
  71057. * Affect a material to the given mesh
  71058. * @param mesh defines the mesh which will represent the control
  71059. */
  71060. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71061. /** @hidden */
  71062. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  71063. /** @hidden */
  71064. _onPointerEnter(target: Control3D): boolean;
  71065. /** @hidden */
  71066. _onPointerOut(target: Control3D): void;
  71067. /** @hidden */
  71068. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71069. /** @hidden */
  71070. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71071. /** @hidden */
  71072. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71073. /** @hidden */
  71074. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71075. /** @hidden */
  71076. _disposeNode(): void;
  71077. /**
  71078. * Releases all associated resources
  71079. */
  71080. dispose(): void;
  71081. }
  71082. }
  71083. declare module BABYLON.GUI {
  71084. /**
  71085. * Class used as a root to all buttons
  71086. */
  71087. export class AbstractButton3D extends Control3D {
  71088. /**
  71089. * Creates a new button
  71090. * @param name defines the control name
  71091. */
  71092. constructor(name?: string);
  71093. protected _getTypeName(): string;
  71094. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71095. }
  71096. }
  71097. declare module BABYLON.GUI {
  71098. /**
  71099. * Class used to create a button in 3D
  71100. */
  71101. export class Button3D extends AbstractButton3D {
  71102. /** @hidden */
  71103. protected _currentMaterial: BABYLON.Material;
  71104. private _facadeTexture;
  71105. private _content;
  71106. private _contentResolution;
  71107. private _contentScaleRatio;
  71108. /**
  71109. * Gets or sets the texture resolution used to render content (512 by default)
  71110. */
  71111. get contentResolution(): BABYLON.int;
  71112. set contentResolution(value: BABYLON.int);
  71113. /**
  71114. * Gets or sets the texture scale ratio used to render content (2 by default)
  71115. */
  71116. get contentScaleRatio(): number;
  71117. set contentScaleRatio(value: number);
  71118. protected _disposeFacadeTexture(): void;
  71119. protected _resetContent(): void;
  71120. /**
  71121. * Creates a new button
  71122. * @param name defines the control name
  71123. */
  71124. constructor(name?: string);
  71125. /**
  71126. * Gets or sets the GUI 2D content used to display the button's facade
  71127. */
  71128. get content(): Control;
  71129. set content(value: Control);
  71130. /**
  71131. * Apply the facade texture (created from the content property).
  71132. * This function can be overloaded by child classes
  71133. * @param facadeTexture defines the AdvancedDynamicTexture to use
  71134. */
  71135. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71136. protected _getTypeName(): string;
  71137. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71138. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71139. /**
  71140. * Releases all associated resources
  71141. */
  71142. dispose(): void;
  71143. }
  71144. }
  71145. declare module BABYLON.GUI {
  71146. /**
  71147. * Abstract class used to create a container panel deployed on the surface of a volume
  71148. */
  71149. export abstract class VolumeBasedPanel extends Container3D {
  71150. private _columns;
  71151. private _rows;
  71152. private _rowThenColum;
  71153. private _orientation;
  71154. protected _cellWidth: number;
  71155. protected _cellHeight: number;
  71156. /**
  71157. * Gets or sets the distance between elements
  71158. */
  71159. margin: number;
  71160. /**
  71161. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  71162. * | Value | Type | Description |
  71163. * | ----- | ----------------------------------- | ----------- |
  71164. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  71165. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  71166. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  71167. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  71168. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  71169. */
  71170. get orientation(): number;
  71171. set orientation(value: number);
  71172. /**
  71173. * Gets or sets the number of columns requested (10 by default).
  71174. * The panel will automatically compute the number of rows based on number of child controls.
  71175. */
  71176. get columns(): BABYLON.int;
  71177. set columns(value: BABYLON.int);
  71178. /**
  71179. * Gets or sets a the number of rows requested.
  71180. * The panel will automatically compute the number of columns based on number of child controls.
  71181. */
  71182. get rows(): BABYLON.int;
  71183. set rows(value: BABYLON.int);
  71184. /**
  71185. * Creates new VolumeBasedPanel
  71186. */
  71187. constructor();
  71188. protected _arrangeChildren(): void;
  71189. /** Child classes must implement this function to provide correct control positioning */
  71190. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71191. /** Child classes can implement this function to provide additional processing */
  71192. protected _finalProcessing(): void;
  71193. }
  71194. }
  71195. declare module BABYLON.GUI {
  71196. /**
  71197. * Class used to create a container panel deployed on the surface of a cylinder
  71198. */
  71199. export class CylinderPanel extends VolumeBasedPanel {
  71200. private _radius;
  71201. /**
  71202. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  71203. */
  71204. get radius(): BABYLON.float;
  71205. set radius(value: BABYLON.float);
  71206. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71207. private _cylindricalMapping;
  71208. }
  71209. }
  71210. declare module BABYLON.GUI {
  71211. /** @hidden */
  71212. export var fluentVertexShader: {
  71213. name: string;
  71214. shader: string;
  71215. };
  71216. }
  71217. declare module BABYLON.GUI {
  71218. /** @hidden */
  71219. export var fluentPixelShader: {
  71220. name: string;
  71221. shader: string;
  71222. };
  71223. }
  71224. declare module BABYLON.GUI {
  71225. /** @hidden */
  71226. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  71227. INNERGLOW: boolean;
  71228. BORDER: boolean;
  71229. HOVERLIGHT: boolean;
  71230. TEXTURE: boolean;
  71231. constructor();
  71232. }
  71233. /**
  71234. * Class used to render controls with fluent desgin
  71235. */
  71236. export class FluentMaterial extends BABYLON.PushMaterial {
  71237. /**
  71238. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  71239. */
  71240. innerGlowColorIntensity: number;
  71241. /**
  71242. * Gets or sets the inner glow color (white by default)
  71243. */
  71244. innerGlowColor: BABYLON.Color3;
  71245. /**
  71246. * Gets or sets alpha value (default is 1.0)
  71247. */
  71248. alpha: number;
  71249. /**
  71250. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  71251. */
  71252. albedoColor: BABYLON.Color3;
  71253. /**
  71254. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  71255. */
  71256. renderBorders: boolean;
  71257. /**
  71258. * Gets or sets border width (default is 0.5)
  71259. */
  71260. borderWidth: number;
  71261. /**
  71262. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  71263. */
  71264. edgeSmoothingValue: number;
  71265. /**
  71266. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  71267. */
  71268. borderMinValue: number;
  71269. /**
  71270. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  71271. */
  71272. renderHoverLight: boolean;
  71273. /**
  71274. * Gets or sets the radius used to render the hover light (default is 1.0)
  71275. */
  71276. hoverRadius: number;
  71277. /**
  71278. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  71279. */
  71280. hoverColor: BABYLON.Color4;
  71281. /**
  71282. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  71283. */
  71284. hoverPosition: BABYLON.Vector3;
  71285. private _albedoTexture;
  71286. /** Gets or sets the texture to use for albedo color */
  71287. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71288. /**
  71289. * Creates a new Fluent material
  71290. * @param name defines the name of the material
  71291. * @param scene defines the hosting scene
  71292. */
  71293. constructor(name: string, scene: BABYLON.Scene);
  71294. needAlphaBlending(): boolean;
  71295. needAlphaTesting(): boolean;
  71296. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71297. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71298. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71299. getActiveTextures(): BABYLON.BaseTexture[];
  71300. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71301. dispose(forceDisposeEffect?: boolean): void;
  71302. clone(name: string): FluentMaterial;
  71303. serialize(): any;
  71304. getClassName(): string;
  71305. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  71306. }
  71307. }
  71308. declare module BABYLON.GUI {
  71309. /**
  71310. * Class used to create a holographic button in 3D
  71311. */
  71312. export class HolographicButton extends Button3D {
  71313. private _backPlate;
  71314. private _textPlate;
  71315. private _frontPlate;
  71316. private _text;
  71317. private _imageUrl;
  71318. private _shareMaterials;
  71319. private _frontMaterial;
  71320. private _backMaterial;
  71321. private _plateMaterial;
  71322. private _pickedPointObserver;
  71323. private _tooltipFade;
  71324. private _tooltipTextBlock;
  71325. private _tooltipTexture;
  71326. private _tooltipMesh;
  71327. private _tooltipHoverObserver;
  71328. private _tooltipOutObserver;
  71329. private _disposeTooltip;
  71330. /**
  71331. * Rendering ground id of all the mesh in the button
  71332. */
  71333. set renderingGroupId(id: number);
  71334. get renderingGroupId(): number;
  71335. /**
  71336. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  71337. */
  71338. set tooltipText(text: BABYLON.Nullable<string>);
  71339. get tooltipText(): BABYLON.Nullable<string>;
  71340. /**
  71341. * Gets or sets text for the button
  71342. */
  71343. get text(): string;
  71344. set text(value: string);
  71345. /**
  71346. * Gets or sets the image url for the button
  71347. */
  71348. get imageUrl(): string;
  71349. set imageUrl(value: string);
  71350. /**
  71351. * Gets the back material used by this button
  71352. */
  71353. get backMaterial(): FluentMaterial;
  71354. /**
  71355. * Gets the front material used by this button
  71356. */
  71357. get frontMaterial(): FluentMaterial;
  71358. /**
  71359. * Gets the plate material used by this button
  71360. */
  71361. get plateMaterial(): BABYLON.StandardMaterial;
  71362. /**
  71363. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  71364. */
  71365. get shareMaterials(): boolean;
  71366. /**
  71367. * Creates a new button
  71368. * @param name defines the control name
  71369. */
  71370. constructor(name?: string, shareMaterials?: boolean);
  71371. protected _getTypeName(): string;
  71372. private _rebuildContent;
  71373. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71374. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71375. private _createBackMaterial;
  71376. private _createFrontMaterial;
  71377. private _createPlateMaterial;
  71378. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  71379. /**
  71380. * Releases all associated resources
  71381. */
  71382. dispose(): void;
  71383. }
  71384. }
  71385. declare module BABYLON.GUI {
  71386. /**
  71387. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  71388. */
  71389. export class MeshButton3D extends Button3D {
  71390. /** @hidden */
  71391. protected _currentMesh: BABYLON.Mesh;
  71392. /**
  71393. * Creates a new 3D button based on a mesh
  71394. * @param mesh mesh to become a 3D button
  71395. * @param name defines the control name
  71396. */
  71397. constructor(mesh: BABYLON.Mesh, name?: string);
  71398. protected _getTypeName(): string;
  71399. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71400. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71401. }
  71402. }
  71403. declare module BABYLON.GUI {
  71404. /**
  71405. * Class used to create a container panel deployed on the surface of a plane
  71406. */
  71407. export class PlanePanel extends VolumeBasedPanel {
  71408. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71409. }
  71410. }
  71411. declare module BABYLON.GUI {
  71412. /**
  71413. * Class used to create a container panel where items get randomized planar mapping
  71414. */
  71415. export class ScatterPanel extends VolumeBasedPanel {
  71416. private _iteration;
  71417. /**
  71418. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  71419. */
  71420. get iteration(): BABYLON.float;
  71421. set iteration(value: BABYLON.float);
  71422. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71423. private _scatterMapping;
  71424. protected _finalProcessing(): void;
  71425. }
  71426. }
  71427. declare module BABYLON.GUI {
  71428. /**
  71429. * Class used to create a container panel deployed on the surface of a sphere
  71430. */
  71431. export class SpherePanel extends VolumeBasedPanel {
  71432. private _radius;
  71433. /**
  71434. * Gets or sets the radius of the sphere where to project controls (5 by default)
  71435. */
  71436. get radius(): BABYLON.float;
  71437. set radius(value: BABYLON.float);
  71438. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71439. private _sphericalMapping;
  71440. }
  71441. }
  71442. declare module BABYLON.GUI {
  71443. /**
  71444. * Class used to create a stack panel in 3D on XY plane
  71445. */
  71446. export class StackPanel3D extends Container3D {
  71447. private _isVertical;
  71448. /**
  71449. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  71450. */
  71451. get isVertical(): boolean;
  71452. set isVertical(value: boolean);
  71453. /**
  71454. * Gets or sets the distance between elements
  71455. */
  71456. margin: number;
  71457. /**
  71458. * Creates new StackPanel
  71459. * @param isVertical
  71460. */
  71461. constructor(isVertical?: boolean);
  71462. protected _arrangeChildren(): void;
  71463. }
  71464. }
  71465. declare module BABYLON {
  71466. /**
  71467. * Configuration for glTF validation
  71468. */
  71469. export interface IGLTFValidationConfiguration {
  71470. /**
  71471. * The url of the glTF validator.
  71472. */
  71473. url: string;
  71474. }
  71475. /**
  71476. * glTF validation
  71477. */
  71478. export class GLTFValidation {
  71479. /**
  71480. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  71481. */
  71482. static Configuration: IGLTFValidationConfiguration;
  71483. private static _LoadScriptPromise;
  71484. /**
  71485. * Validate a glTF asset using the glTF-Validator.
  71486. * @param data The JSON of a glTF or the array buffer of a binary glTF
  71487. * @param rootUrl The root url for the glTF
  71488. * @param fileName The file name for the glTF
  71489. * @param getExternalResource The callback to get external resources for the glTF validator
  71490. * @returns A promise that resolves with the glTF validation results once complete
  71491. */
  71492. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  71493. }
  71494. }
  71495. declare module BABYLON {
  71496. /**
  71497. * Mode that determines the coordinate system to use.
  71498. */
  71499. export enum GLTFLoaderCoordinateSystemMode {
  71500. /**
  71501. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  71502. */
  71503. AUTO = 0,
  71504. /**
  71505. * Sets the useRightHandedSystem flag on the scene.
  71506. */
  71507. FORCE_RIGHT_HANDED = 1
  71508. }
  71509. /**
  71510. * Mode that determines what animations will start.
  71511. */
  71512. export enum GLTFLoaderAnimationStartMode {
  71513. /**
  71514. * No animation will start.
  71515. */
  71516. NONE = 0,
  71517. /**
  71518. * The first animation will start.
  71519. */
  71520. FIRST = 1,
  71521. /**
  71522. * All animations will start.
  71523. */
  71524. ALL = 2
  71525. }
  71526. /**
  71527. * Interface that contains the data for the glTF asset.
  71528. */
  71529. export interface IGLTFLoaderData {
  71530. /**
  71531. * The object that represents the glTF JSON.
  71532. */
  71533. json: Object;
  71534. /**
  71535. * The BIN chunk of a binary glTF.
  71536. */
  71537. bin: Nullable<IDataBuffer>;
  71538. }
  71539. /**
  71540. * Interface for extending the loader.
  71541. */
  71542. export interface IGLTFLoaderExtension {
  71543. /**
  71544. * The name of this extension.
  71545. */
  71546. readonly name: string;
  71547. /**
  71548. * Defines whether this extension is enabled.
  71549. */
  71550. enabled: boolean;
  71551. /**
  71552. * Defines the order of this extension.
  71553. * The loader sorts the extensions using these values when loading.
  71554. */
  71555. order?: number;
  71556. }
  71557. /**
  71558. * Loader state.
  71559. */
  71560. export enum GLTFLoaderState {
  71561. /**
  71562. * The asset is loading.
  71563. */
  71564. LOADING = 0,
  71565. /**
  71566. * The asset is ready for rendering.
  71567. */
  71568. READY = 1,
  71569. /**
  71570. * The asset is completely loaded.
  71571. */
  71572. COMPLETE = 2
  71573. }
  71574. /** @hidden */
  71575. export interface IGLTFLoader extends IDisposable {
  71576. readonly state: Nullable<GLTFLoaderState>;
  71577. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  71578. meshes: AbstractMesh[];
  71579. particleSystems: IParticleSystem[];
  71580. skeletons: Skeleton[];
  71581. animationGroups: AnimationGroup[];
  71582. }>;
  71583. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  71584. }
  71585. /**
  71586. * File loader for loading glTF files into a scene.
  71587. */
  71588. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  71589. /** @hidden */
  71590. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71591. /** @hidden */
  71592. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  71593. /**
  71594. * Raised when the asset has been parsed
  71595. */
  71596. onParsedObservable: Observable<IGLTFLoaderData>;
  71597. private _onParsedObserver;
  71598. /**
  71599. * Raised when the asset has been parsed
  71600. */
  71601. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  71602. /**
  71603. * 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.
  71604. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  71605. * Defaults to true.
  71606. * @hidden
  71607. */
  71608. static IncrementalLoading: boolean;
  71609. /**
  71610. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  71611. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  71612. * @hidden
  71613. */
  71614. static HomogeneousCoordinates: boolean;
  71615. /**
  71616. * The coordinate system mode. Defaults to AUTO.
  71617. */
  71618. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  71619. /**
  71620. * The animation start mode. Defaults to FIRST.
  71621. */
  71622. animationStartMode: GLTFLoaderAnimationStartMode;
  71623. /**
  71624. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  71625. */
  71626. compileMaterials: boolean;
  71627. /**
  71628. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  71629. */
  71630. useClipPlane: boolean;
  71631. /**
  71632. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  71633. */
  71634. compileShadowGenerators: boolean;
  71635. /**
  71636. * Defines if the Alpha blended materials are only applied as coverage.
  71637. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  71638. * If true, no extra effects are applied to transparent pixels.
  71639. */
  71640. transparencyAsCoverage: boolean;
  71641. /**
  71642. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  71643. * Enabling will disable offline support and glTF validator.
  71644. * Defaults to false.
  71645. */
  71646. useRangeRequests: boolean;
  71647. /**
  71648. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  71649. */
  71650. createInstances: boolean;
  71651. /**
  71652. * Function called before loading a url referenced by the asset.
  71653. */
  71654. preprocessUrlAsync: (url: string) => Promise<string>;
  71655. /**
  71656. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71657. */
  71658. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  71659. private _onMeshLoadedObserver;
  71660. /**
  71661. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  71662. */
  71663. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  71664. /**
  71665. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  71666. */
  71667. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  71668. private _onTextureLoadedObserver;
  71669. /**
  71670. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  71671. */
  71672. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  71673. /**
  71674. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  71675. */
  71676. readonly onMaterialLoadedObservable: Observable<Material>;
  71677. private _onMaterialLoadedObserver;
  71678. /**
  71679. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  71680. */
  71681. set onMaterialLoaded(callback: (material: Material) => void);
  71682. /**
  71683. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  71684. */
  71685. readonly onCameraLoadedObservable: Observable<Camera>;
  71686. private _onCameraLoadedObserver;
  71687. /**
  71688. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  71689. */
  71690. set onCameraLoaded(callback: (camera: Camera) => void);
  71691. /**
  71692. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  71693. * For assets with LODs, raised when all of the LODs are complete.
  71694. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71695. */
  71696. readonly onCompleteObservable: Observable<void>;
  71697. private _onCompleteObserver;
  71698. /**
  71699. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  71700. * For assets with LODs, raised when all of the LODs are complete.
  71701. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  71702. */
  71703. set onComplete(callback: () => void);
  71704. /**
  71705. * Observable raised when an error occurs.
  71706. */
  71707. readonly onErrorObservable: Observable<any>;
  71708. private _onErrorObserver;
  71709. /**
  71710. * Callback raised when an error occurs.
  71711. */
  71712. set onError(callback: (reason: any) => void);
  71713. /**
  71714. * Observable raised after the loader is disposed.
  71715. */
  71716. readonly onDisposeObservable: Observable<void>;
  71717. private _onDisposeObserver;
  71718. /**
  71719. * Callback raised after the loader is disposed.
  71720. */
  71721. set onDispose(callback: () => void);
  71722. /**
  71723. * Observable raised after a loader extension is created.
  71724. * Set additional options for a loader extension in this event.
  71725. */
  71726. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  71727. private _onExtensionLoadedObserver;
  71728. /**
  71729. * Callback raised after a loader extension is created.
  71730. */
  71731. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  71732. /**
  71733. * Defines if the loader logging is enabled.
  71734. */
  71735. get loggingEnabled(): boolean;
  71736. set loggingEnabled(value: boolean);
  71737. /**
  71738. * Defines if the loader should capture performance counters.
  71739. */
  71740. get capturePerformanceCounters(): boolean;
  71741. set capturePerformanceCounters(value: boolean);
  71742. /**
  71743. * Defines if the loader should validate the asset.
  71744. */
  71745. validate: boolean;
  71746. /**
  71747. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  71748. */
  71749. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  71750. private _onValidatedObserver;
  71751. /**
  71752. * Callback raised after a loader extension is created.
  71753. */
  71754. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  71755. private _loader;
  71756. /**
  71757. * Name of the loader ("gltf")
  71758. */
  71759. name: string;
  71760. /** @hidden */
  71761. extensions: ISceneLoaderPluginExtensions;
  71762. /**
  71763. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  71764. */
  71765. dispose(): void;
  71766. /** @hidden */
  71767. _clear(): void;
  71768. /** @hidden */
  71769. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71770. /** @hidden */
  71771. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  71772. /** @hidden */
  71773. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71774. meshes: AbstractMesh[];
  71775. particleSystems: IParticleSystem[];
  71776. skeletons: Skeleton[];
  71777. animationGroups: AnimationGroup[];
  71778. }>;
  71779. /** @hidden */
  71780. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71781. /** @hidden */
  71782. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  71783. /** @hidden */
  71784. canDirectLoad(data: string): boolean;
  71785. /** @hidden */
  71786. directLoad(scene: Scene, data: string): any;
  71787. /**
  71788. * The callback that allows custom handling of the root url based on the response url.
  71789. * @param rootUrl the original root url
  71790. * @param responseURL the response url if available
  71791. * @returns the new root url
  71792. */
  71793. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  71794. /** @hidden */
  71795. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  71796. /**
  71797. * The loader state or null if the loader is not active.
  71798. */
  71799. get loaderState(): Nullable<GLTFLoaderState>;
  71800. /**
  71801. * Returns a promise that resolves when the asset is completely loaded.
  71802. * @returns a promise that resolves when the asset is completely loaded.
  71803. */
  71804. whenCompleteAsync(): Promise<void>;
  71805. private _validate;
  71806. private _getLoader;
  71807. private _parseJson;
  71808. private _unpackBinaryAsync;
  71809. private _unpackBinaryV1Async;
  71810. private _unpackBinaryV2Async;
  71811. private static _parseVersion;
  71812. private static _compareVersion;
  71813. private static readonly _logSpaces;
  71814. private _logIndentLevel;
  71815. private _loggingEnabled;
  71816. /** @hidden */
  71817. _log: (message: string) => void;
  71818. /** @hidden */
  71819. _logOpen(message: string): void;
  71820. /** @hidden */
  71821. _logClose(): void;
  71822. private _logEnabled;
  71823. private _logDisabled;
  71824. private _capturePerformanceCounters;
  71825. /** @hidden */
  71826. _startPerformanceCounter: (counterName: string) => void;
  71827. /** @hidden */
  71828. _endPerformanceCounter: (counterName: string) => void;
  71829. private _startPerformanceCounterEnabled;
  71830. private _startPerformanceCounterDisabled;
  71831. private _endPerformanceCounterEnabled;
  71832. private _endPerformanceCounterDisabled;
  71833. }
  71834. }
  71835. declare module BABYLON.GLTF1 {
  71836. /**
  71837. * Enums
  71838. * @hidden
  71839. */
  71840. export enum EComponentType {
  71841. BYTE = 5120,
  71842. UNSIGNED_BYTE = 5121,
  71843. SHORT = 5122,
  71844. UNSIGNED_SHORT = 5123,
  71845. FLOAT = 5126
  71846. }
  71847. /** @hidden */
  71848. export enum EShaderType {
  71849. FRAGMENT = 35632,
  71850. VERTEX = 35633
  71851. }
  71852. /** @hidden */
  71853. export enum EParameterType {
  71854. BYTE = 5120,
  71855. UNSIGNED_BYTE = 5121,
  71856. SHORT = 5122,
  71857. UNSIGNED_SHORT = 5123,
  71858. INT = 5124,
  71859. UNSIGNED_INT = 5125,
  71860. FLOAT = 5126,
  71861. FLOAT_VEC2 = 35664,
  71862. FLOAT_VEC3 = 35665,
  71863. FLOAT_VEC4 = 35666,
  71864. INT_VEC2 = 35667,
  71865. INT_VEC3 = 35668,
  71866. INT_VEC4 = 35669,
  71867. BOOL = 35670,
  71868. BOOL_VEC2 = 35671,
  71869. BOOL_VEC3 = 35672,
  71870. BOOL_VEC4 = 35673,
  71871. FLOAT_MAT2 = 35674,
  71872. FLOAT_MAT3 = 35675,
  71873. FLOAT_MAT4 = 35676,
  71874. SAMPLER_2D = 35678
  71875. }
  71876. /** @hidden */
  71877. export enum ETextureWrapMode {
  71878. CLAMP_TO_EDGE = 33071,
  71879. MIRRORED_REPEAT = 33648,
  71880. REPEAT = 10497
  71881. }
  71882. /** @hidden */
  71883. export enum ETextureFilterType {
  71884. NEAREST = 9728,
  71885. LINEAR = 9728,
  71886. NEAREST_MIPMAP_NEAREST = 9984,
  71887. LINEAR_MIPMAP_NEAREST = 9985,
  71888. NEAREST_MIPMAP_LINEAR = 9986,
  71889. LINEAR_MIPMAP_LINEAR = 9987
  71890. }
  71891. /** @hidden */
  71892. export enum ETextureFormat {
  71893. ALPHA = 6406,
  71894. RGB = 6407,
  71895. RGBA = 6408,
  71896. LUMINANCE = 6409,
  71897. LUMINANCE_ALPHA = 6410
  71898. }
  71899. /** @hidden */
  71900. export enum ECullingType {
  71901. FRONT = 1028,
  71902. BACK = 1029,
  71903. FRONT_AND_BACK = 1032
  71904. }
  71905. /** @hidden */
  71906. export enum EBlendingFunction {
  71907. ZERO = 0,
  71908. ONE = 1,
  71909. SRC_COLOR = 768,
  71910. ONE_MINUS_SRC_COLOR = 769,
  71911. DST_COLOR = 774,
  71912. ONE_MINUS_DST_COLOR = 775,
  71913. SRC_ALPHA = 770,
  71914. ONE_MINUS_SRC_ALPHA = 771,
  71915. DST_ALPHA = 772,
  71916. ONE_MINUS_DST_ALPHA = 773,
  71917. CONSTANT_COLOR = 32769,
  71918. ONE_MINUS_CONSTANT_COLOR = 32770,
  71919. CONSTANT_ALPHA = 32771,
  71920. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71921. SRC_ALPHA_SATURATE = 776
  71922. }
  71923. /** @hidden */
  71924. export interface IGLTFProperty {
  71925. extensions?: {
  71926. [key: string]: any;
  71927. };
  71928. extras?: Object;
  71929. }
  71930. /** @hidden */
  71931. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71932. name?: string;
  71933. }
  71934. /** @hidden */
  71935. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71936. bufferView: string;
  71937. byteOffset: number;
  71938. byteStride: number;
  71939. count: number;
  71940. type: string;
  71941. componentType: EComponentType;
  71942. max?: number[];
  71943. min?: number[];
  71944. name?: string;
  71945. }
  71946. /** @hidden */
  71947. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71948. buffer: string;
  71949. byteOffset: number;
  71950. byteLength: number;
  71951. byteStride: number;
  71952. target?: number;
  71953. }
  71954. /** @hidden */
  71955. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71956. uri: string;
  71957. byteLength?: number;
  71958. type?: string;
  71959. }
  71960. /** @hidden */
  71961. export interface IGLTFShader extends IGLTFChildRootProperty {
  71962. uri: string;
  71963. type: EShaderType;
  71964. }
  71965. /** @hidden */
  71966. export interface IGLTFProgram extends IGLTFChildRootProperty {
  71967. attributes: string[];
  71968. fragmentShader: string;
  71969. vertexShader: string;
  71970. }
  71971. /** @hidden */
  71972. export interface IGLTFTechniqueParameter {
  71973. type: number;
  71974. count?: number;
  71975. semantic?: string;
  71976. node?: string;
  71977. value?: number | boolean | string | Array<any>;
  71978. source?: string;
  71979. babylonValue?: any;
  71980. }
  71981. /** @hidden */
  71982. export interface IGLTFTechniqueCommonProfile {
  71983. lightingModel: string;
  71984. texcoordBindings: Object;
  71985. parameters?: Array<any>;
  71986. }
  71987. /** @hidden */
  71988. export interface IGLTFTechniqueStatesFunctions {
  71989. blendColor?: number[];
  71990. blendEquationSeparate?: number[];
  71991. blendFuncSeparate?: number[];
  71992. colorMask: boolean[];
  71993. cullFace: number[];
  71994. }
  71995. /** @hidden */
  71996. export interface IGLTFTechniqueStates {
  71997. enable: number[];
  71998. functions: IGLTFTechniqueStatesFunctions;
  71999. }
  72000. /** @hidden */
  72001. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  72002. parameters: {
  72003. [key: string]: IGLTFTechniqueParameter;
  72004. };
  72005. program: string;
  72006. attributes: {
  72007. [key: string]: string;
  72008. };
  72009. uniforms: {
  72010. [key: string]: string;
  72011. };
  72012. states: IGLTFTechniqueStates;
  72013. }
  72014. /** @hidden */
  72015. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  72016. technique?: string;
  72017. values: string[];
  72018. }
  72019. /** @hidden */
  72020. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  72021. attributes: {
  72022. [key: string]: string;
  72023. };
  72024. indices: string;
  72025. material: string;
  72026. mode?: number;
  72027. }
  72028. /** @hidden */
  72029. export interface IGLTFMesh extends IGLTFChildRootProperty {
  72030. primitives: IGLTFMeshPrimitive[];
  72031. }
  72032. /** @hidden */
  72033. export interface IGLTFImage extends IGLTFChildRootProperty {
  72034. uri: string;
  72035. }
  72036. /** @hidden */
  72037. export interface IGLTFSampler extends IGLTFChildRootProperty {
  72038. magFilter?: number;
  72039. minFilter?: number;
  72040. wrapS?: number;
  72041. wrapT?: number;
  72042. }
  72043. /** @hidden */
  72044. export interface IGLTFTexture extends IGLTFChildRootProperty {
  72045. sampler: string;
  72046. source: string;
  72047. format?: ETextureFormat;
  72048. internalFormat?: ETextureFormat;
  72049. target?: number;
  72050. type?: number;
  72051. babylonTexture?: Texture;
  72052. }
  72053. /** @hidden */
  72054. export interface IGLTFAmbienLight {
  72055. color?: number[];
  72056. }
  72057. /** @hidden */
  72058. export interface IGLTFDirectionalLight {
  72059. color?: number[];
  72060. }
  72061. /** @hidden */
  72062. export interface IGLTFPointLight {
  72063. color?: number[];
  72064. constantAttenuation?: number;
  72065. linearAttenuation?: number;
  72066. quadraticAttenuation?: number;
  72067. }
  72068. /** @hidden */
  72069. export interface IGLTFSpotLight {
  72070. color?: number[];
  72071. constantAttenuation?: number;
  72072. fallOfAngle?: number;
  72073. fallOffExponent?: number;
  72074. linearAttenuation?: number;
  72075. quadraticAttenuation?: number;
  72076. }
  72077. /** @hidden */
  72078. export interface IGLTFLight extends IGLTFChildRootProperty {
  72079. type: string;
  72080. }
  72081. /** @hidden */
  72082. export interface IGLTFCameraOrthographic {
  72083. xmag: number;
  72084. ymag: number;
  72085. zfar: number;
  72086. znear: number;
  72087. }
  72088. /** @hidden */
  72089. export interface IGLTFCameraPerspective {
  72090. aspectRatio: number;
  72091. yfov: number;
  72092. zfar: number;
  72093. znear: number;
  72094. }
  72095. /** @hidden */
  72096. export interface IGLTFCamera extends IGLTFChildRootProperty {
  72097. type: string;
  72098. }
  72099. /** @hidden */
  72100. export interface IGLTFAnimationChannelTarget {
  72101. id: string;
  72102. path: string;
  72103. }
  72104. /** @hidden */
  72105. export interface IGLTFAnimationChannel {
  72106. sampler: string;
  72107. target: IGLTFAnimationChannelTarget;
  72108. }
  72109. /** @hidden */
  72110. export interface IGLTFAnimationSampler {
  72111. input: string;
  72112. output: string;
  72113. interpolation?: string;
  72114. }
  72115. /** @hidden */
  72116. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  72117. channels?: IGLTFAnimationChannel[];
  72118. parameters?: {
  72119. [key: string]: string;
  72120. };
  72121. samplers?: {
  72122. [key: string]: IGLTFAnimationSampler;
  72123. };
  72124. }
  72125. /** @hidden */
  72126. export interface IGLTFNodeInstanceSkin {
  72127. skeletons: string[];
  72128. skin: string;
  72129. meshes: string[];
  72130. }
  72131. /** @hidden */
  72132. export interface IGLTFSkins extends IGLTFChildRootProperty {
  72133. bindShapeMatrix: number[];
  72134. inverseBindMatrices: string;
  72135. jointNames: string[];
  72136. babylonSkeleton?: Skeleton;
  72137. }
  72138. /** @hidden */
  72139. export interface IGLTFNode extends IGLTFChildRootProperty {
  72140. camera?: string;
  72141. children: string[];
  72142. skin?: string;
  72143. jointName?: string;
  72144. light?: string;
  72145. matrix: number[];
  72146. mesh?: string;
  72147. meshes?: string[];
  72148. rotation?: number[];
  72149. scale?: number[];
  72150. translation?: number[];
  72151. babylonNode?: Node;
  72152. }
  72153. /** @hidden */
  72154. export interface IGLTFScene extends IGLTFChildRootProperty {
  72155. nodes: string[];
  72156. }
  72157. /** @hidden */
  72158. export interface IGLTFRuntime {
  72159. extensions: {
  72160. [key: string]: any;
  72161. };
  72162. accessors: {
  72163. [key: string]: IGLTFAccessor;
  72164. };
  72165. buffers: {
  72166. [key: string]: IGLTFBuffer;
  72167. };
  72168. bufferViews: {
  72169. [key: string]: IGLTFBufferView;
  72170. };
  72171. meshes: {
  72172. [key: string]: IGLTFMesh;
  72173. };
  72174. lights: {
  72175. [key: string]: IGLTFLight;
  72176. };
  72177. cameras: {
  72178. [key: string]: IGLTFCamera;
  72179. };
  72180. nodes: {
  72181. [key: string]: IGLTFNode;
  72182. };
  72183. images: {
  72184. [key: string]: IGLTFImage;
  72185. };
  72186. textures: {
  72187. [key: string]: IGLTFTexture;
  72188. };
  72189. shaders: {
  72190. [key: string]: IGLTFShader;
  72191. };
  72192. programs: {
  72193. [key: string]: IGLTFProgram;
  72194. };
  72195. samplers: {
  72196. [key: string]: IGLTFSampler;
  72197. };
  72198. techniques: {
  72199. [key: string]: IGLTFTechnique;
  72200. };
  72201. materials: {
  72202. [key: string]: IGLTFMaterial;
  72203. };
  72204. animations: {
  72205. [key: string]: IGLTFAnimation;
  72206. };
  72207. skins: {
  72208. [key: string]: IGLTFSkins;
  72209. };
  72210. currentScene?: Object;
  72211. scenes: {
  72212. [key: string]: IGLTFScene;
  72213. };
  72214. extensionsUsed: string[];
  72215. extensionsRequired?: string[];
  72216. buffersCount: number;
  72217. shaderscount: number;
  72218. scene: Scene;
  72219. rootUrl: string;
  72220. loadedBufferCount: number;
  72221. loadedBufferViews: {
  72222. [name: string]: ArrayBufferView;
  72223. };
  72224. loadedShaderCount: number;
  72225. importOnlyMeshes: boolean;
  72226. importMeshesNames?: string[];
  72227. dummyNodes: Node[];
  72228. }
  72229. /** @hidden */
  72230. export interface INodeToRoot {
  72231. bone: Bone;
  72232. node: IGLTFNode;
  72233. id: string;
  72234. }
  72235. /** @hidden */
  72236. export interface IJointNode {
  72237. node: IGLTFNode;
  72238. id: string;
  72239. }
  72240. }
  72241. declare module BABYLON.GLTF1 {
  72242. /**
  72243. * Utils functions for GLTF
  72244. * @hidden
  72245. */
  72246. export class GLTFUtils {
  72247. /**
  72248. * Sets the given "parameter" matrix
  72249. * @param scene: the Scene object
  72250. * @param source: the source node where to pick the matrix
  72251. * @param parameter: the GLTF technique parameter
  72252. * @param uniformName: the name of the shader's uniform
  72253. * @param shaderMaterial: the shader material
  72254. */
  72255. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  72256. /**
  72257. * Sets the given "parameter" matrix
  72258. * @param shaderMaterial: the shader material
  72259. * @param uniform: the name of the shader's uniform
  72260. * @param value: the value of the uniform
  72261. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  72262. */
  72263. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  72264. /**
  72265. * Returns the wrap mode of the texture
  72266. * @param mode: the mode value
  72267. */
  72268. static GetWrapMode(mode: number): number;
  72269. /**
  72270. * Returns the byte stride giving an accessor
  72271. * @param accessor: the GLTF accessor objet
  72272. */
  72273. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  72274. /**
  72275. * Returns the texture filter mode giving a mode value
  72276. * @param mode: the filter mode value
  72277. */
  72278. static GetTextureFilterMode(mode: number): ETextureFilterType;
  72279. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  72280. /**
  72281. * Returns a buffer from its accessor
  72282. * @param gltfRuntime: the GLTF runtime
  72283. * @param accessor: the GLTF accessor
  72284. */
  72285. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  72286. /**
  72287. * Decodes a buffer view into a string
  72288. * @param view: the buffer view
  72289. */
  72290. static DecodeBufferToText(view: ArrayBufferView): string;
  72291. /**
  72292. * Returns the default material of gltf. Related to
  72293. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  72294. * @param scene: the Babylon.js scene
  72295. */
  72296. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  72297. private static _DefaultMaterial;
  72298. }
  72299. }
  72300. declare module BABYLON.GLTF1 {
  72301. /**
  72302. * Implementation of the base glTF spec
  72303. * @hidden
  72304. */
  72305. export class GLTFLoaderBase {
  72306. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  72307. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72308. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  72309. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72310. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  72311. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72312. }
  72313. /**
  72314. * glTF V1 Loader
  72315. * @hidden
  72316. */
  72317. export class GLTFLoader implements IGLTFLoader {
  72318. static Extensions: {
  72319. [name: string]: GLTFLoaderExtension;
  72320. };
  72321. static RegisterExtension(extension: GLTFLoaderExtension): void;
  72322. state: Nullable<GLTFLoaderState>;
  72323. dispose(): void;
  72324. private _importMeshAsync;
  72325. /**
  72326. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  72327. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72328. * @param scene the scene the meshes should be added to
  72329. * @param data gltf data containing information of the meshes in a loaded file
  72330. * @param rootUrl root url to load from
  72331. * @param onProgress event that fires when loading progress has occured
  72332. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72333. */
  72334. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  72335. meshes: AbstractMesh[];
  72336. particleSystems: IParticleSystem[];
  72337. skeletons: Skeleton[];
  72338. animationGroups: AnimationGroup[];
  72339. }>;
  72340. private _loadAsync;
  72341. /**
  72342. * Imports all objects from a loaded gltf file and adds them to the scene
  72343. * @param scene the scene the objects should be added to
  72344. * @param data gltf data containing information of the meshes in a loaded file
  72345. * @param rootUrl root url to load from
  72346. * @param onProgress event that fires when loading progress has occured
  72347. * @returns a promise which completes when objects have been loaded to the scene
  72348. */
  72349. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  72350. private _loadShadersAsync;
  72351. private _loadBuffersAsync;
  72352. private _createNodes;
  72353. }
  72354. /** @hidden */
  72355. export abstract class GLTFLoaderExtension {
  72356. private _name;
  72357. constructor(name: string);
  72358. get name(): string;
  72359. /**
  72360. * Defines an override for loading the runtime
  72361. * Return true to stop further extensions from loading the runtime
  72362. */
  72363. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  72364. /**
  72365. * Defines an onverride for creating gltf runtime
  72366. * Return true to stop further extensions from creating the runtime
  72367. */
  72368. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  72369. /**
  72370. * Defines an override for loading buffers
  72371. * Return true to stop further extensions from loading this buffer
  72372. */
  72373. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  72374. /**
  72375. * Defines an override for loading texture buffers
  72376. * Return true to stop further extensions from loading this texture data
  72377. */
  72378. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72379. /**
  72380. * Defines an override for creating textures
  72381. * Return true to stop further extensions from loading this texture
  72382. */
  72383. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  72384. /**
  72385. * Defines an override for loading shader strings
  72386. * Return true to stop further extensions from loading this shader data
  72387. */
  72388. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72389. /**
  72390. * Defines an override for loading materials
  72391. * Return true to stop further extensions from loading this material
  72392. */
  72393. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72394. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  72395. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  72396. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  72397. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  72398. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  72399. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  72400. private static LoadTextureBufferAsync;
  72401. private static CreateTextureAsync;
  72402. private static ApplyExtensions;
  72403. }
  72404. }
  72405. declare module BABYLON.GLTF1 {
  72406. /** @hidden */
  72407. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  72408. private _bin;
  72409. constructor();
  72410. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  72411. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72412. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  72413. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  72414. }
  72415. }
  72416. declare module BABYLON.GLTF1 {
  72417. /** @hidden */
  72418. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  72419. constructor();
  72420. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  72421. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  72422. private _loadTexture;
  72423. }
  72424. }
  72425. declare module BABYLON.GLTF2.Loader {
  72426. /**
  72427. * Loader interface with an index field.
  72428. */
  72429. export interface IArrayItem {
  72430. /**
  72431. * The index of this item in the array.
  72432. */
  72433. index: number;
  72434. }
  72435. /**
  72436. * Loader interface with additional members.
  72437. */
  72438. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  72439. /** @hidden */
  72440. _data?: Promise<ArrayBufferView>;
  72441. /** @hidden */
  72442. _babylonVertexBuffer?: Promise<VertexBuffer>;
  72443. }
  72444. /**
  72445. * Loader interface with additional members.
  72446. */
  72447. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  72448. }
  72449. /** @hidden */
  72450. export interface _IAnimationSamplerData {
  72451. input: Float32Array;
  72452. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  72453. output: Float32Array;
  72454. }
  72455. /**
  72456. * Loader interface with additional members.
  72457. */
  72458. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  72459. /** @hidden */
  72460. _data?: Promise<_IAnimationSamplerData>;
  72461. }
  72462. /**
  72463. * Loader interface with additional members.
  72464. */
  72465. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  72466. channels: IAnimationChannel[];
  72467. samplers: IAnimationSampler[];
  72468. /** @hidden */
  72469. _babylonAnimationGroup?: AnimationGroup;
  72470. }
  72471. /**
  72472. * Loader interface with additional members.
  72473. */
  72474. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  72475. /** @hidden */
  72476. _data?: Promise<ArrayBufferView>;
  72477. }
  72478. /**
  72479. * Loader interface with additional members.
  72480. */
  72481. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  72482. /** @hidden */
  72483. _data?: Promise<ArrayBufferView>;
  72484. /** @hidden */
  72485. _babylonBuffer?: Promise<Buffer>;
  72486. }
  72487. /**
  72488. * Loader interface with additional members.
  72489. */
  72490. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  72491. }
  72492. /**
  72493. * Loader interface with additional members.
  72494. */
  72495. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  72496. /** @hidden */
  72497. _data?: Promise<ArrayBufferView>;
  72498. }
  72499. /**
  72500. * Loader interface with additional members.
  72501. */
  72502. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  72503. }
  72504. /**
  72505. * Loader interface with additional members.
  72506. */
  72507. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  72508. }
  72509. /**
  72510. * Loader interface with additional members.
  72511. */
  72512. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  72513. baseColorTexture?: ITextureInfo;
  72514. metallicRoughnessTexture?: ITextureInfo;
  72515. }
  72516. /**
  72517. * Loader interface with additional members.
  72518. */
  72519. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  72520. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72521. normalTexture?: IMaterialNormalTextureInfo;
  72522. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72523. emissiveTexture?: ITextureInfo;
  72524. /** @hidden */
  72525. _data?: {
  72526. [babylonDrawMode: number]: {
  72527. babylonMaterial: Material;
  72528. babylonMeshes: AbstractMesh[];
  72529. promise: Promise<void>;
  72530. };
  72531. };
  72532. }
  72533. /**
  72534. * Loader interface with additional members.
  72535. */
  72536. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  72537. primitives: IMeshPrimitive[];
  72538. }
  72539. /**
  72540. * Loader interface with additional members.
  72541. */
  72542. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  72543. /** @hidden */
  72544. _instanceData?: {
  72545. babylonSourceMesh: Mesh;
  72546. promise: Promise<any>;
  72547. };
  72548. }
  72549. /**
  72550. * Loader interface with additional members.
  72551. */
  72552. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  72553. /**
  72554. * The parent glTF node.
  72555. */
  72556. parent?: INode;
  72557. /** @hidden */
  72558. _babylonTransformNode?: TransformNode;
  72559. /** @hidden */
  72560. _primitiveBabylonMeshes?: AbstractMesh[];
  72561. /** @hidden */
  72562. _babylonBones?: Bone[];
  72563. /** @hidden */
  72564. _numMorphTargets?: number;
  72565. }
  72566. /** @hidden */
  72567. export interface _ISamplerData {
  72568. noMipMaps: boolean;
  72569. samplingMode: number;
  72570. wrapU: number;
  72571. wrapV: number;
  72572. }
  72573. /**
  72574. * Loader interface with additional members.
  72575. */
  72576. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  72577. /** @hidden */
  72578. _data?: _ISamplerData;
  72579. }
  72580. /**
  72581. * Loader interface with additional members.
  72582. */
  72583. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  72584. }
  72585. /**
  72586. * Loader interface with additional members.
  72587. */
  72588. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  72589. /** @hidden */
  72590. _data?: {
  72591. babylonSkeleton: Skeleton;
  72592. promise: Promise<void>;
  72593. };
  72594. }
  72595. /**
  72596. * Loader interface with additional members.
  72597. */
  72598. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  72599. }
  72600. /**
  72601. * Loader interface with additional members.
  72602. */
  72603. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  72604. }
  72605. /**
  72606. * Loader interface with additional members.
  72607. */
  72608. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  72609. accessors?: IAccessor[];
  72610. animations?: IAnimation[];
  72611. buffers?: IBuffer[];
  72612. bufferViews?: IBufferView[];
  72613. cameras?: ICamera[];
  72614. images?: IImage[];
  72615. materials?: IMaterial[];
  72616. meshes?: IMesh[];
  72617. nodes?: INode[];
  72618. samplers?: ISampler[];
  72619. scenes?: IScene[];
  72620. skins?: ISkin[];
  72621. textures?: ITexture[];
  72622. }
  72623. }
  72624. declare module BABYLON.GLTF2 {
  72625. /**
  72626. * Interface for a glTF loader extension.
  72627. */
  72628. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  72629. /**
  72630. * Called after the loader state changes to LOADING.
  72631. */
  72632. onLoading?(): void;
  72633. /**
  72634. * Called after the loader state changes to READY.
  72635. */
  72636. onReady?(): void;
  72637. /**
  72638. * Define this method to modify the default behavior when loading scenes.
  72639. * @param context The context when loading the asset
  72640. * @param scene The glTF scene property
  72641. * @returns A promise that resolves when the load is complete or null if not handled
  72642. */
  72643. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  72644. /**
  72645. * Define this method to modify the default behavior when loading nodes.
  72646. * @param context The context when loading the asset
  72647. * @param node The glTF node property
  72648. * @param assign A function called synchronously after parsing the glTF properties
  72649. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  72650. */
  72651. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72652. /**
  72653. * Define this method to modify the default behavior when loading cameras.
  72654. * @param context The context when loading the asset
  72655. * @param camera The glTF camera property
  72656. * @param assign A function called synchronously after parsing the glTF properties
  72657. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  72658. */
  72659. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72660. /**
  72661. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  72662. * @param context The context when loading the asset
  72663. * @param primitive The glTF mesh primitive property
  72664. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  72665. */
  72666. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72667. /**
  72668. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72669. * @param context The context when loading the asset
  72670. * @param name The mesh name when loading the asset
  72671. * @param node The glTF node when loading the asset
  72672. * @param mesh The glTF mesh when loading the asset
  72673. * @param primitive The glTF mesh primitive property
  72674. * @param assign A function called synchronously after parsing the glTF properties
  72675. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72676. */
  72677. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72678. /**
  72679. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  72680. * @param context The context when loading the asset
  72681. * @param material The glTF material property
  72682. * @param assign A function called synchronously after parsing the glTF properties
  72683. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  72684. */
  72685. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72686. /**
  72687. * Define this method to modify the default behavior when creating materials.
  72688. * @param context The context when loading the asset
  72689. * @param material The glTF material property
  72690. * @param babylonDrawMode The draw mode for the Babylon material
  72691. * @returns The Babylon material or null if not handled
  72692. */
  72693. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72694. /**
  72695. * Define this method to modify the default behavior when loading material properties.
  72696. * @param context The context when loading the asset
  72697. * @param material The glTF material property
  72698. * @param babylonMaterial The Babylon material
  72699. * @returns A promise that resolves when the load is complete or null if not handled
  72700. */
  72701. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72702. /**
  72703. * Define this method to modify the default behavior when loading texture infos.
  72704. * @param context The context when loading the asset
  72705. * @param textureInfo The glTF texture info property
  72706. * @param assign A function called synchronously after parsing the glTF properties
  72707. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  72708. */
  72709. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72710. /**
  72711. * Define this method to modify the default behavior when loading animations.
  72712. * @param context The context when loading the asset
  72713. * @param animation The glTF animation property
  72714. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  72715. */
  72716. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72717. /**
  72718. * @hidden Define this method to modify the default behavior when loading skins.
  72719. * @param context The context when loading the asset
  72720. * @param node The glTF node property
  72721. * @param skin The glTF skin property
  72722. * @returns A promise that resolves when the load is complete or null if not handled
  72723. */
  72724. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  72725. /**
  72726. * @hidden Define this method to modify the default behavior when loading uris.
  72727. * @param context The context when loading the asset
  72728. * @param property The glTF property associated with the uri
  72729. * @param uri The uri to load
  72730. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72731. */
  72732. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72733. /**
  72734. * Define this method to modify the default behavior when loading buffer views.
  72735. * @param context The context when loading the asset
  72736. * @param bufferView The glTF buffer view property
  72737. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72738. */
  72739. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  72740. /**
  72741. * Define this method to modify the default behavior when loading buffers.
  72742. * @param context The context when loading the asset
  72743. * @param buffer The glTF buffer property
  72744. * @param byteOffset The byte offset to load
  72745. * @param byteLength The byte length to load
  72746. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  72747. */
  72748. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72749. }
  72750. }
  72751. declare module BABYLON.GLTF2 {
  72752. /**
  72753. * Helper class for working with arrays when loading the glTF asset
  72754. */
  72755. export class ArrayItem {
  72756. /**
  72757. * Gets an item from the given array.
  72758. * @param context The context when loading the asset
  72759. * @param array The array to get the item from
  72760. * @param index The index to the array
  72761. * @returns The array item
  72762. */
  72763. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  72764. /**
  72765. * Assign an `index` field to each item of the given array.
  72766. * @param array The array of items
  72767. */
  72768. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  72769. }
  72770. /**
  72771. * The glTF 2.0 loader
  72772. */
  72773. export class GLTFLoader implements IGLTFLoader {
  72774. /** @hidden */
  72775. _completePromises: Promise<any>[];
  72776. private _disposed;
  72777. private _parent;
  72778. private _state;
  72779. private _extensions;
  72780. private _rootUrl;
  72781. private _fileName;
  72782. private _uniqueRootUrl;
  72783. private _gltf;
  72784. private _bin;
  72785. private _babylonScene;
  72786. private _rootBabylonMesh;
  72787. private _defaultBabylonMaterialData;
  72788. private _progressCallback?;
  72789. private _requests;
  72790. private static readonly _DefaultSampler;
  72791. private static _RegisteredExtensions;
  72792. /**
  72793. * Registers a loader extension.
  72794. * @param name The name of the loader extension.
  72795. * @param factory The factory function that creates the loader extension.
  72796. */
  72797. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  72798. /**
  72799. * Unregisters a loader extension.
  72800. * @param name The name of the loader extension.
  72801. * @returns A boolean indicating whether the extension has been unregistered
  72802. */
  72803. static UnregisterExtension(name: string): boolean;
  72804. /**
  72805. * Gets the loader state.
  72806. */
  72807. get state(): Nullable<GLTFLoaderState>;
  72808. /**
  72809. * The object that represents the glTF JSON.
  72810. */
  72811. get gltf(): IGLTF;
  72812. /**
  72813. * The BIN chunk of a binary glTF.
  72814. */
  72815. get bin(): Nullable<IDataBuffer>;
  72816. /**
  72817. * The parent file loader.
  72818. */
  72819. get parent(): GLTFFileLoader;
  72820. /**
  72821. * The Babylon scene when loading the asset.
  72822. */
  72823. get babylonScene(): Scene;
  72824. /**
  72825. * The root Babylon mesh when loading the asset.
  72826. */
  72827. get rootBabylonMesh(): Mesh;
  72828. /** @hidden */
  72829. constructor(parent: GLTFFileLoader);
  72830. /** @hidden */
  72831. dispose(): void;
  72832. /** @hidden */
  72833. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72834. meshes: AbstractMesh[];
  72835. particleSystems: IParticleSystem[];
  72836. skeletons: Skeleton[];
  72837. animationGroups: AnimationGroup[];
  72838. }>;
  72839. /** @hidden */
  72840. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72841. private _loadAsync;
  72842. private _loadData;
  72843. private _setupData;
  72844. private _loadExtensions;
  72845. private _checkExtensions;
  72846. private _setState;
  72847. private _createRootNode;
  72848. /**
  72849. * Loads a glTF scene.
  72850. * @param context The context when loading the asset
  72851. * @param scene The glTF scene property
  72852. * @returns A promise that resolves when the load is complete
  72853. */
  72854. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  72855. private _forEachPrimitive;
  72856. private _getMeshes;
  72857. private _getSkeletons;
  72858. private _getAnimationGroups;
  72859. private _startAnimations;
  72860. /**
  72861. * Loads a glTF node.
  72862. * @param context The context when loading the asset
  72863. * @param node The glTF node property
  72864. * @param assign A function called synchronously after parsing the glTF properties
  72865. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  72866. */
  72867. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  72868. private _loadMeshAsync;
  72869. /**
  72870. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  72871. * @param context The context when loading the asset
  72872. * @param name The mesh name when loading the asset
  72873. * @param node The glTF node when loading the asset
  72874. * @param mesh The glTF mesh when loading the asset
  72875. * @param primitive The glTF mesh primitive property
  72876. * @param assign A function called synchronously after parsing the glTF properties
  72877. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  72878. */
  72879. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  72880. private _loadVertexDataAsync;
  72881. private _createMorphTargets;
  72882. private _loadMorphTargetsAsync;
  72883. private _loadMorphTargetVertexDataAsync;
  72884. private static _LoadTransform;
  72885. private _loadSkinAsync;
  72886. private _loadBones;
  72887. private _loadBone;
  72888. private _loadSkinInverseBindMatricesDataAsync;
  72889. private _updateBoneMatrices;
  72890. private _getNodeMatrix;
  72891. /**
  72892. * Loads a glTF camera.
  72893. * @param context The context when loading the asset
  72894. * @param camera The glTF camera property
  72895. * @param assign A function called synchronously after parsing the glTF properties
  72896. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  72897. */
  72898. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  72899. private _loadAnimationsAsync;
  72900. /**
  72901. * Loads a glTF animation.
  72902. * @param context The context when loading the asset
  72903. * @param animation The glTF animation property
  72904. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  72905. */
  72906. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  72907. /**
  72908. * @hidden Loads a glTF animation channel.
  72909. * @param context The context when loading the asset
  72910. * @param animationContext The context of the animation when loading the asset
  72911. * @param animation The glTF animation property
  72912. * @param channel The glTF animation channel property
  72913. * @param babylonAnimationGroup The babylon animation group property
  72914. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72915. * @returns A void promise when the channel load is complete
  72916. */
  72917. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72918. private _loadAnimationSamplerAsync;
  72919. private _loadBufferAsync;
  72920. /**
  72921. * Loads a glTF buffer view.
  72922. * @param context The context when loading the asset
  72923. * @param bufferView The glTF buffer view property
  72924. * @returns A promise that resolves with the loaded data when the load is complete
  72925. */
  72926. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72927. private _loadAccessorAsync;
  72928. private _loadFloatAccessorAsync;
  72929. private _loadIndicesAccessorAsync;
  72930. private _loadVertexBufferViewAsync;
  72931. private _loadVertexAccessorAsync;
  72932. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72933. /** @hidden */
  72934. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72935. private _createDefaultMaterial;
  72936. /**
  72937. * Creates a Babylon material from a glTF material.
  72938. * @param context The context when loading the asset
  72939. * @param material The glTF material property
  72940. * @param babylonDrawMode The draw mode for the Babylon material
  72941. * @returns The Babylon material
  72942. */
  72943. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72944. /**
  72945. * Loads properties from a glTF material into a Babylon material.
  72946. * @param context The context when loading the asset
  72947. * @param material The glTF material property
  72948. * @param babylonMaterial The Babylon material
  72949. * @returns A promise that resolves when the load is complete
  72950. */
  72951. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72952. /**
  72953. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72954. * @param context The context when loading the asset
  72955. * @param material The glTF material property
  72956. * @param babylonMaterial The Babylon material
  72957. * @returns A promise that resolves when the load is complete
  72958. */
  72959. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72960. /**
  72961. * Loads the alpha properties from a glTF material into a Babylon material.
  72962. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72963. * @param context The context when loading the asset
  72964. * @param material The glTF material property
  72965. * @param babylonMaterial The Babylon material
  72966. */
  72967. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  72968. /**
  72969. * Loads a glTF texture info.
  72970. * @param context The context when loading the asset
  72971. * @param textureInfo The glTF texture info property
  72972. * @param assign A function called synchronously after parsing the glTF properties
  72973. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  72974. */
  72975. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  72976. private _loadTextureAsync;
  72977. private _loadSampler;
  72978. /**
  72979. * Loads a glTF image.
  72980. * @param context The context when loading the asset
  72981. * @param image The glTF image property
  72982. * @returns A promise that resolves with the loaded data when the load is complete
  72983. */
  72984. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  72985. /**
  72986. * Loads a glTF uri.
  72987. * @param context The context when loading the asset
  72988. * @param property The glTF property associated with the uri
  72989. * @param uri The base64 or relative uri
  72990. * @returns A promise that resolves with the loaded data when the load is complete
  72991. */
  72992. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  72993. private _onProgress;
  72994. /**
  72995. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  72996. * @param babylonObject the Babylon object with metadata
  72997. * @param pointer the JSON pointer
  72998. */
  72999. static AddPointerMetadata(babylonObject: {
  73000. metadata: any;
  73001. }, pointer: string): void;
  73002. private static _GetTextureWrapMode;
  73003. private static _GetTextureSamplingMode;
  73004. private static _GetTypedArrayConstructor;
  73005. private static _GetTypedArray;
  73006. private static _GetNumComponents;
  73007. private static _ValidateUri;
  73008. private static _GetDrawMode;
  73009. private _compileMaterialsAsync;
  73010. private _compileShadowGeneratorsAsync;
  73011. private _forEachExtensions;
  73012. private _applyExtensions;
  73013. private _extensionsOnLoading;
  73014. private _extensionsOnReady;
  73015. private _extensionsLoadSceneAsync;
  73016. private _extensionsLoadNodeAsync;
  73017. private _extensionsLoadCameraAsync;
  73018. private _extensionsLoadVertexDataAsync;
  73019. private _extensionsLoadMeshPrimitiveAsync;
  73020. private _extensionsLoadMaterialAsync;
  73021. private _extensionsCreateMaterial;
  73022. private _extensionsLoadMaterialPropertiesAsync;
  73023. private _extensionsLoadTextureInfoAsync;
  73024. private _extensionsLoadAnimationAsync;
  73025. private _extensionsLoadSkinAsync;
  73026. private _extensionsLoadUriAsync;
  73027. private _extensionsLoadBufferViewAsync;
  73028. private _extensionsLoadBufferAsync;
  73029. /**
  73030. * Helper method called by a loader extension to load an glTF extension.
  73031. * @param context The context when loading the asset
  73032. * @param property The glTF property to load the extension from
  73033. * @param extensionName The name of the extension to load
  73034. * @param actionAsync The action to run
  73035. * @returns The promise returned by actionAsync or null if the extension does not exist
  73036. */
  73037. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73038. /**
  73039. * Helper method called by a loader extension to load a glTF extra.
  73040. * @param context The context when loading the asset
  73041. * @param property The glTF property to load the extra from
  73042. * @param extensionName The name of the extension to load
  73043. * @param actionAsync The action to run
  73044. * @returns The promise returned by actionAsync or null if the extra does not exist
  73045. */
  73046. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73047. /**
  73048. * Checks for presence of an extension.
  73049. * @param name The name of the extension to check
  73050. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  73051. */
  73052. isExtensionUsed(name: string): boolean;
  73053. /**
  73054. * Increments the indentation level and logs a message.
  73055. * @param message The message to log
  73056. */
  73057. logOpen(message: string): void;
  73058. /**
  73059. * Decrements the indentation level.
  73060. */
  73061. logClose(): void;
  73062. /**
  73063. * Logs a message
  73064. * @param message The message to log
  73065. */
  73066. log(message: string): void;
  73067. /**
  73068. * Starts a performance counter.
  73069. * @param counterName The name of the performance counter
  73070. */
  73071. startPerformanceCounter(counterName: string): void;
  73072. /**
  73073. * Ends a performance counter.
  73074. * @param counterName The name of the performance counter
  73075. */
  73076. endPerformanceCounter(counterName: string): void;
  73077. }
  73078. }
  73079. declare module BABYLON.GLTF2.Loader.Extensions {
  73080. /**
  73081. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  73082. */
  73083. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  73084. /**
  73085. * The name of this extension.
  73086. */
  73087. readonly name: string;
  73088. /**
  73089. * Defines whether this extension is enabled.
  73090. */
  73091. enabled: boolean;
  73092. private _loader;
  73093. private _lights?;
  73094. /** @hidden */
  73095. constructor(loader: GLTFLoader);
  73096. /** @hidden */
  73097. dispose(): void;
  73098. /** @hidden */
  73099. onLoading(): void;
  73100. /** @hidden */
  73101. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73102. private _loadLightAsync;
  73103. }
  73104. }
  73105. declare module BABYLON.GLTF2.Loader.Extensions {
  73106. /**
  73107. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  73108. */
  73109. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  73110. /**
  73111. * The name of this extension.
  73112. */
  73113. readonly name: string;
  73114. /**
  73115. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  73116. */
  73117. dracoCompression?: DracoCompression;
  73118. /**
  73119. * Defines whether this extension is enabled.
  73120. */
  73121. enabled: boolean;
  73122. private _loader;
  73123. /** @hidden */
  73124. constructor(loader: GLTFLoader);
  73125. /** @hidden */
  73126. dispose(): void;
  73127. /** @hidden */
  73128. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73129. }
  73130. }
  73131. declare module BABYLON.GLTF2.Loader.Extensions {
  73132. /**
  73133. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73134. */
  73135. export class KHR_lights implements IGLTFLoaderExtension {
  73136. /**
  73137. * The name of this extension.
  73138. */
  73139. readonly name: string;
  73140. /**
  73141. * Defines whether this extension is enabled.
  73142. */
  73143. enabled: boolean;
  73144. private _loader;
  73145. private _lights?;
  73146. /** @hidden */
  73147. constructor(loader: GLTFLoader);
  73148. /** @hidden */
  73149. dispose(): void;
  73150. /** @hidden */
  73151. onLoading(): void;
  73152. /** @hidden */
  73153. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73154. }
  73155. }
  73156. declare module BABYLON.GLTF2.Loader.Extensions {
  73157. /**
  73158. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  73159. */
  73160. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  73161. /**
  73162. * The name of this extension.
  73163. */
  73164. readonly name: string;
  73165. /**
  73166. * Defines whether this extension is enabled.
  73167. */
  73168. enabled: boolean;
  73169. /**
  73170. * Defines a number that determines the order the extensions are applied.
  73171. */
  73172. order: number;
  73173. private _loader;
  73174. /** @hidden */
  73175. constructor(loader: GLTFLoader);
  73176. /** @hidden */
  73177. dispose(): void;
  73178. /** @hidden */
  73179. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73180. private _loadSpecularGlossinessPropertiesAsync;
  73181. }
  73182. }
  73183. declare module BABYLON.GLTF2.Loader.Extensions {
  73184. /**
  73185. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  73186. */
  73187. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  73188. /**
  73189. * The name of this extension.
  73190. */
  73191. readonly name: string;
  73192. /**
  73193. * Defines whether this extension is enabled.
  73194. */
  73195. enabled: boolean;
  73196. /**
  73197. * Defines a number that determines the order the extensions are applied.
  73198. */
  73199. order: number;
  73200. private _loader;
  73201. /** @hidden */
  73202. constructor(loader: GLTFLoader);
  73203. /** @hidden */
  73204. dispose(): void;
  73205. /** @hidden */
  73206. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73207. private _loadUnlitPropertiesAsync;
  73208. }
  73209. }
  73210. declare module BABYLON.GLTF2.Loader.Extensions {
  73211. /**
  73212. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73213. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  73214. * !!! Experimental Extension Subject to Changes !!!
  73215. */
  73216. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  73217. /**
  73218. * The name of this extension.
  73219. */
  73220. readonly name: string;
  73221. /**
  73222. * Defines whether this extension is enabled.
  73223. */
  73224. enabled: boolean;
  73225. /**
  73226. * Defines a number that determines the order the extensions are applied.
  73227. */
  73228. order: number;
  73229. private _loader;
  73230. /** @hidden */
  73231. constructor(loader: GLTFLoader);
  73232. /** @hidden */
  73233. dispose(): void;
  73234. /** @hidden */
  73235. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73236. private _loadClearCoatPropertiesAsync;
  73237. }
  73238. }
  73239. declare module BABYLON.GLTF2.Loader.Extensions {
  73240. /**
  73241. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  73242. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73243. * !!! Experimental Extension Subject to Changes !!!
  73244. */
  73245. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  73246. /**
  73247. * The name of this extension.
  73248. */
  73249. readonly name: string;
  73250. /**
  73251. * Defines whether this extension is enabled.
  73252. */
  73253. enabled: boolean;
  73254. /**
  73255. * Defines a number that determines the order the extensions are applied.
  73256. */
  73257. order: number;
  73258. private _loader;
  73259. /** @hidden */
  73260. constructor(loader: GLTFLoader);
  73261. /** @hidden */
  73262. dispose(): void;
  73263. /** @hidden */
  73264. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73265. private _loadSheenPropertiesAsync;
  73266. }
  73267. }
  73268. declare module BABYLON.GLTF2.Loader.Extensions {
  73269. /**
  73270. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73271. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73272. * !!! Experimental Extension Subject to Changes !!!
  73273. */
  73274. export class KHR_materials_specular implements IGLTFLoaderExtension {
  73275. /**
  73276. * The name of this extension.
  73277. */
  73278. readonly name: string;
  73279. /**
  73280. * Defines whether this extension is enabled.
  73281. */
  73282. enabled: boolean;
  73283. /**
  73284. * Defines a number that determines the order the extensions are applied.
  73285. */
  73286. order: number;
  73287. private _loader;
  73288. /** @hidden */
  73289. constructor(loader: GLTFLoader);
  73290. /** @hidden */
  73291. dispose(): void;
  73292. /** @hidden */
  73293. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73294. private _loadSpecularPropertiesAsync;
  73295. }
  73296. }
  73297. declare module BABYLON.GLTF2.Loader.Extensions {
  73298. /**
  73299. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  73300. */
  73301. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  73302. /**
  73303. * The name of this extension.
  73304. */
  73305. readonly name: string;
  73306. /**
  73307. * Defines whether this extension is enabled.
  73308. */
  73309. enabled: boolean;
  73310. /** @hidden */
  73311. constructor(loader: GLTFLoader);
  73312. /** @hidden */
  73313. dispose(): void;
  73314. }
  73315. }
  73316. declare module BABYLON.GLTF2.Loader.Extensions {
  73317. /**
  73318. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  73319. */
  73320. export class KHR_texture_transform implements IGLTFLoaderExtension {
  73321. /**
  73322. * The name of this extension.
  73323. */
  73324. readonly name: string;
  73325. /**
  73326. * Defines whether this extension is enabled.
  73327. */
  73328. enabled: boolean;
  73329. private _loader;
  73330. /** @hidden */
  73331. constructor(loader: GLTFLoader);
  73332. /** @hidden */
  73333. dispose(): void;
  73334. /** @hidden */
  73335. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  73336. }
  73337. }
  73338. declare module BABYLON.GLTF2.Loader.Extensions {
  73339. /**
  73340. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  73341. */
  73342. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  73343. /**
  73344. * The name of this extension.
  73345. */
  73346. readonly name: string;
  73347. /**
  73348. * Defines whether this extension is enabled.
  73349. */
  73350. enabled: boolean;
  73351. private _loader;
  73352. private _clips;
  73353. private _emitters;
  73354. /** @hidden */
  73355. constructor(loader: GLTFLoader);
  73356. /** @hidden */
  73357. dispose(): void;
  73358. /** @hidden */
  73359. onLoading(): void;
  73360. /** @hidden */
  73361. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73362. /** @hidden */
  73363. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73364. /** @hidden */
  73365. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  73366. private _loadClipAsync;
  73367. private _loadEmitterAsync;
  73368. private _getEventAction;
  73369. private _loadAnimationEventAsync;
  73370. }
  73371. }
  73372. declare module BABYLON.GLTF2.Loader.Extensions {
  73373. /**
  73374. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  73375. */
  73376. export class MSFT_lod implements IGLTFLoaderExtension {
  73377. /**
  73378. * The name of this extension.
  73379. */
  73380. readonly name: string;
  73381. /**
  73382. * Defines whether this extension is enabled.
  73383. */
  73384. enabled: boolean;
  73385. /**
  73386. * Defines a number that determines the order the extensions are applied.
  73387. */
  73388. order: number;
  73389. /**
  73390. * Maximum number of LODs to load, starting from the lowest LOD.
  73391. */
  73392. maxLODsToLoad: number;
  73393. /**
  73394. * Observable raised when all node LODs of one level are loaded.
  73395. * The event data is the index of the loaded LOD starting from zero.
  73396. * Dispose the loader to cancel the loading of the next level of LODs.
  73397. */
  73398. onNodeLODsLoadedObservable: Observable<number>;
  73399. /**
  73400. * Observable raised when all material LODs of one level are loaded.
  73401. * The event data is the index of the loaded LOD starting from zero.
  73402. * Dispose the loader to cancel the loading of the next level of LODs.
  73403. */
  73404. onMaterialLODsLoadedObservable: Observable<number>;
  73405. private _loader;
  73406. private _nodeIndexLOD;
  73407. private _nodeSignalLODs;
  73408. private _nodePromiseLODs;
  73409. private _materialIndexLOD;
  73410. private _materialSignalLODs;
  73411. private _materialPromiseLODs;
  73412. private _indexLOD;
  73413. private _bufferLODs;
  73414. /** @hidden */
  73415. constructor(loader: GLTFLoader);
  73416. /** @hidden */
  73417. dispose(): void;
  73418. /** @hidden */
  73419. onReady(): void;
  73420. /** @hidden */
  73421. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73422. /** @hidden */
  73423. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  73424. /** @hidden */
  73425. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  73426. /** @hidden */
  73427. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  73428. private _loadBufferLOD;
  73429. /**
  73430. * Gets an array of LOD properties from lowest to highest.
  73431. */
  73432. private _getLODs;
  73433. private _disposeUnusedMaterials;
  73434. }
  73435. }
  73436. declare module BABYLON.GLTF2.Loader.Extensions {
  73437. /** @hidden */
  73438. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  73439. readonly name: string;
  73440. enabled: boolean;
  73441. private _loader;
  73442. constructor(loader: GLTFLoader);
  73443. dispose(): void;
  73444. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73445. }
  73446. }
  73447. declare module BABYLON.GLTF2.Loader.Extensions {
  73448. /** @hidden */
  73449. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  73450. readonly name: string;
  73451. enabled: boolean;
  73452. private _loader;
  73453. constructor(loader: GLTFLoader);
  73454. dispose(): void;
  73455. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73456. }
  73457. }
  73458. declare module BABYLON.GLTF2.Loader.Extensions {
  73459. /**
  73460. * Store glTF extras (if present) in BJS objects' metadata
  73461. */
  73462. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  73463. /**
  73464. * The name of this extension.
  73465. */
  73466. readonly name: string;
  73467. /**
  73468. * Defines whether this extension is enabled.
  73469. */
  73470. enabled: boolean;
  73471. private _loader;
  73472. private _assignExtras;
  73473. /** @hidden */
  73474. constructor(loader: GLTFLoader);
  73475. /** @hidden */
  73476. dispose(): void;
  73477. /** @hidden */
  73478. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73479. /** @hidden */
  73480. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  73481. /** @hidden */
  73482. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  73483. }
  73484. }
  73485. declare module BABYLON {
  73486. /**
  73487. * Class reading and parsing the MTL file bundled with the obj file.
  73488. */
  73489. export class MTLFileLoader {
  73490. /**
  73491. * All material loaded from the mtl will be set here
  73492. */
  73493. materials: StandardMaterial[];
  73494. /**
  73495. * This function will read the mtl file and create each material described inside
  73496. * This function could be improve by adding :
  73497. * -some component missing (Ni, Tf...)
  73498. * -including the specific options available
  73499. *
  73500. * @param scene defines the scene the material will be created in
  73501. * @param data defines the mtl data to parse
  73502. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  73503. */
  73504. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  73505. /**
  73506. * Gets the texture for the material.
  73507. *
  73508. * If the material is imported from input file,
  73509. * We sanitize the url to ensure it takes the textre from aside the material.
  73510. *
  73511. * @param rootUrl The root url to load from
  73512. * @param value The value stored in the mtl
  73513. * @return The Texture
  73514. */
  73515. private static _getTexture;
  73516. }
  73517. /**
  73518. * Options for loading OBJ/MTL files
  73519. */
  73520. type MeshLoadOptions = {
  73521. /**
  73522. * Defines if UVs are optimized by default during load.
  73523. */
  73524. OptimizeWithUV: boolean;
  73525. /**
  73526. * Defines custom scaling of UV coordinates of loaded meshes.
  73527. */
  73528. UVScaling: Vector2;
  73529. /**
  73530. * Invert model on y-axis (does a model scaling inversion)
  73531. */
  73532. InvertY: boolean;
  73533. /**
  73534. * Invert Y-Axis of referenced textures on load
  73535. */
  73536. InvertTextureY: boolean;
  73537. /**
  73538. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73539. */
  73540. ImportVertexColors: boolean;
  73541. /**
  73542. * Compute the normals for the model, even if normals are present in the file.
  73543. */
  73544. ComputeNormals: boolean;
  73545. /**
  73546. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73547. */
  73548. SkipMaterials: boolean;
  73549. /**
  73550. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73551. */
  73552. MaterialLoadingFailsSilently: boolean;
  73553. };
  73554. /**
  73555. * OBJ file type loader.
  73556. * This is a babylon scene loader plugin.
  73557. */
  73558. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73559. /**
  73560. * Defines if UVs are optimized by default during load.
  73561. */
  73562. static OPTIMIZE_WITH_UV: boolean;
  73563. /**
  73564. * Invert model on y-axis (does a model scaling inversion)
  73565. */
  73566. static INVERT_Y: boolean;
  73567. /**
  73568. * Invert Y-Axis of referenced textures on load
  73569. */
  73570. static INVERT_TEXTURE_Y: boolean;
  73571. /**
  73572. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  73573. */
  73574. static IMPORT_VERTEX_COLORS: boolean;
  73575. /**
  73576. * Compute the normals for the model, even if normals are present in the file.
  73577. */
  73578. static COMPUTE_NORMALS: boolean;
  73579. /**
  73580. * Defines custom scaling of UV coordinates of loaded meshes.
  73581. */
  73582. static UV_SCALING: Vector2;
  73583. /**
  73584. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  73585. */
  73586. static SKIP_MATERIALS: boolean;
  73587. /**
  73588. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  73589. *
  73590. * Defaults to true for backwards compatibility.
  73591. */
  73592. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  73593. /**
  73594. * Defines the name of the plugin.
  73595. */
  73596. name: string;
  73597. /**
  73598. * Defines the extension the plugin is able to load.
  73599. */
  73600. extensions: string;
  73601. /** @hidden */
  73602. obj: RegExp;
  73603. /** @hidden */
  73604. group: RegExp;
  73605. /** @hidden */
  73606. mtllib: RegExp;
  73607. /** @hidden */
  73608. usemtl: RegExp;
  73609. /** @hidden */
  73610. smooth: RegExp;
  73611. /** @hidden */
  73612. vertexPattern: RegExp;
  73613. /** @hidden */
  73614. normalPattern: RegExp;
  73615. /** @hidden */
  73616. uvPattern: RegExp;
  73617. /** @hidden */
  73618. facePattern1: RegExp;
  73619. /** @hidden */
  73620. facePattern2: RegExp;
  73621. /** @hidden */
  73622. facePattern3: RegExp;
  73623. /** @hidden */
  73624. facePattern4: RegExp;
  73625. /** @hidden */
  73626. facePattern5: RegExp;
  73627. private _meshLoadOptions;
  73628. /**
  73629. * Creates loader for .OBJ files
  73630. *
  73631. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  73632. */
  73633. constructor(meshLoadOptions?: MeshLoadOptions);
  73634. private static get currentMeshLoadOptions();
  73635. /**
  73636. * Calls synchronously the MTL file attached to this obj.
  73637. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  73638. * Without this function materials are not displayed in the first frame (but displayed after).
  73639. * In consequence it is impossible to get material information in your HTML file
  73640. *
  73641. * @param url The URL of the MTL file
  73642. * @param rootUrl
  73643. * @param onSuccess Callback function to be called when the MTL file is loaded
  73644. * @private
  73645. */
  73646. private _loadMTL;
  73647. /**
  73648. * Instantiates a OBJ file loader plugin.
  73649. * @returns the created plugin
  73650. */
  73651. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  73652. /**
  73653. * If the data string can be loaded directly.
  73654. *
  73655. * @param data string containing the file data
  73656. * @returns if the data can be loaded directly
  73657. */
  73658. canDirectLoad(data: string): boolean;
  73659. /**
  73660. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  73661. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  73662. * @param scene the scene the meshes should be added to
  73663. * @param data the OBJ data to load
  73664. * @param rootUrl root url to load from
  73665. * @param onProgress event that fires when loading progress has occured
  73666. * @param fileName Defines the name of the file to load
  73667. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  73668. */
  73669. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73670. meshes: AbstractMesh[];
  73671. particleSystems: IParticleSystem[];
  73672. skeletons: Skeleton[];
  73673. animationGroups: AnimationGroup[];
  73674. }>;
  73675. /**
  73676. * Imports all objects from the loaded OBJ data and adds them to the scene
  73677. * @param scene the scene the objects should be added to
  73678. * @param data the OBJ data to load
  73679. * @param rootUrl root url to load from
  73680. * @param onProgress event that fires when loading progress has occured
  73681. * @param fileName Defines the name of the file to load
  73682. * @returns a promise which completes when objects have been loaded to the scene
  73683. */
  73684. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73685. /**
  73686. * Load into an asset container.
  73687. * @param scene The scene to load into
  73688. * @param data The data to import
  73689. * @param rootUrl The root url for scene and resources
  73690. * @param onProgress The callback when the load progresses
  73691. * @param fileName Defines the name of the file to load
  73692. * @returns The loaded asset container
  73693. */
  73694. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73695. /**
  73696. * Read the OBJ file and create an Array of meshes.
  73697. * Each mesh contains all information given by the OBJ and the MTL file.
  73698. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  73699. *
  73700. * @param meshesNames
  73701. * @param scene Scene The scene where are displayed the data
  73702. * @param data String The content of the obj file
  73703. * @param rootUrl String The path to the folder
  73704. * @returns Array<AbstractMesh>
  73705. * @private
  73706. */
  73707. private _parseSolid;
  73708. }
  73709. }
  73710. declare module BABYLON {
  73711. /**
  73712. * STL file type loader.
  73713. * This is a babylon scene loader plugin.
  73714. */
  73715. export class STLFileLoader implements ISceneLoaderPlugin {
  73716. /** @hidden */
  73717. solidPattern: RegExp;
  73718. /** @hidden */
  73719. facetsPattern: RegExp;
  73720. /** @hidden */
  73721. normalPattern: RegExp;
  73722. /** @hidden */
  73723. vertexPattern: RegExp;
  73724. /**
  73725. * Defines the name of the plugin.
  73726. */
  73727. name: string;
  73728. /**
  73729. * Defines the extensions the stl loader is able to load.
  73730. * force data to come in as an ArrayBuffer
  73731. * we'll convert to string if it looks like it's an ASCII .stl
  73732. */
  73733. extensions: ISceneLoaderPluginExtensions;
  73734. /**
  73735. * Import meshes into a scene.
  73736. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  73737. * @param scene The scene to import into
  73738. * @param data The data to import
  73739. * @param rootUrl The root url for scene and resources
  73740. * @param meshes The meshes array to import into
  73741. * @param particleSystems The particle systems array to import into
  73742. * @param skeletons The skeletons array to import into
  73743. * @param onError The callback when import fails
  73744. * @returns True if successful or false otherwise
  73745. */
  73746. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  73747. /**
  73748. * Load into a scene.
  73749. * @param scene The scene to load into
  73750. * @param data The data to import
  73751. * @param rootUrl The root url for scene and resources
  73752. * @param onError The callback when import fails
  73753. * @returns true if successful or false otherwise
  73754. */
  73755. load(scene: Scene, data: any, rootUrl: string): boolean;
  73756. /**
  73757. * Load into an asset container.
  73758. * @param scene The scene to load into
  73759. * @param data The data to import
  73760. * @param rootUrl The root url for scene and resources
  73761. * @param onError The callback when import fails
  73762. * @returns The loaded asset container
  73763. */
  73764. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  73765. private _isBinary;
  73766. private _parseBinary;
  73767. private _parseASCII;
  73768. }
  73769. }
  73770. declare module BABYLON {
  73771. /**
  73772. * Class for generating OBJ data from a Babylon scene.
  73773. */
  73774. export class OBJExport {
  73775. /**
  73776. * Exports the geometry of a Mesh array in .OBJ file format (text)
  73777. * @param mesh defines the list of meshes to serialize
  73778. * @param materials defines if materials should be exported
  73779. * @param matlibname defines the name of the associated mtl file
  73780. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  73781. * @returns the OBJ content
  73782. */
  73783. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  73784. /**
  73785. * Exports the material(s) of a mesh in .MTL file format (text)
  73786. * @param mesh defines the mesh to extract the material from
  73787. * @returns the mtl content
  73788. */
  73789. static MTL(mesh: Mesh): string;
  73790. }
  73791. }
  73792. declare module BABYLON {
  73793. /** @hidden */
  73794. export var __IGLTFExporterExtension: number;
  73795. /**
  73796. * Interface for extending the exporter
  73797. * @hidden
  73798. */
  73799. export interface IGLTFExporterExtension {
  73800. /**
  73801. * The name of this extension
  73802. */
  73803. readonly name: string;
  73804. /**
  73805. * Defines whether this extension is enabled
  73806. */
  73807. enabled: boolean;
  73808. /**
  73809. * Defines whether this extension is required
  73810. */
  73811. required: boolean;
  73812. }
  73813. }
  73814. declare module BABYLON.GLTF2.Exporter {
  73815. /** @hidden */
  73816. export var __IGLTFExporterExtensionV2: number;
  73817. /**
  73818. * Interface for a glTF exporter extension
  73819. * @hidden
  73820. */
  73821. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  73822. /**
  73823. * Define this method to modify the default behavior before exporting a texture
  73824. * @param context The context when loading the asset
  73825. * @param babylonTexture The Babylon.js texture
  73826. * @param mimeType The mime-type of the generated image
  73827. * @returns A promise that resolves with the exported texture
  73828. */
  73829. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73830. /**
  73831. * Define this method to get notified when a texture info is created
  73832. * @param context The context when loading the asset
  73833. * @param textureInfo The glTF texture info
  73834. * @param babylonTexture The Babylon.js texture
  73835. */
  73836. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73837. /**
  73838. * Define this method to modify the default behavior when exporting texture info
  73839. * @param context The context when loading the asset
  73840. * @param meshPrimitive glTF mesh primitive
  73841. * @param babylonSubMesh Babylon submesh
  73842. * @param binaryWriter glTF serializer binary writer instance
  73843. * @returns nullable IMeshPrimitive promise
  73844. */
  73845. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  73846. /**
  73847. * Define this method to modify the default behavior when exporting a node
  73848. * @param context The context when exporting the node
  73849. * @param node glTF node
  73850. * @param babylonNode BabylonJS node
  73851. * @returns nullable INode promise
  73852. */
  73853. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73854. /**
  73855. * Define this method to modify the default behavior when exporting a material
  73856. * @param material glTF material
  73857. * @param babylonMaterial BabylonJS material
  73858. * @returns nullable IMaterial promise
  73859. */
  73860. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73861. /**
  73862. * Define this method to return additional textures to export from a material
  73863. * @param material glTF material
  73864. * @param babylonMaterial BabylonJS material
  73865. * @returns List of textures
  73866. */
  73867. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73868. /** Gets a boolean indicating that this extension was used */
  73869. wasUsed: boolean;
  73870. /** Gets a boolean indicating that this extension is required for the file to work */
  73871. required: boolean;
  73872. /**
  73873. * Called after the exporter state changes to EXPORTING
  73874. */
  73875. onExporting?(): void;
  73876. }
  73877. }
  73878. declare module BABYLON.GLTF2.Exporter {
  73879. /**
  73880. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  73881. * @hidden
  73882. */
  73883. export class _GLTFMaterialExporter {
  73884. /**
  73885. * Represents the dielectric specular values for R, G and B
  73886. */
  73887. private static readonly _DielectricSpecular;
  73888. /**
  73889. * Allows the maximum specular power to be defined for material calculations
  73890. */
  73891. private static readonly _MaxSpecularPower;
  73892. /**
  73893. * Mapping to store textures
  73894. */
  73895. private _textureMap;
  73896. /**
  73897. * Numeric tolerance value
  73898. */
  73899. private static readonly _Epsilon;
  73900. /**
  73901. * Reference to the glTF Exporter
  73902. */
  73903. private _exporter;
  73904. constructor(exporter: _Exporter);
  73905. /**
  73906. * Specifies if two colors are approximately equal in value
  73907. * @param color1 first color to compare to
  73908. * @param color2 second color to compare to
  73909. * @param epsilon threshold value
  73910. */
  73911. private static FuzzyEquals;
  73912. /**
  73913. * Gets the materials from a Babylon scene and converts them to glTF materials
  73914. * @param scene babylonjs scene
  73915. * @param mimeType texture mime type
  73916. * @param images array of images
  73917. * @param textures array of textures
  73918. * @param materials array of materials
  73919. * @param imageData mapping of texture names to base64 textures
  73920. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73921. */
  73922. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73923. /**
  73924. * Makes a copy of the glTF material without the texture parameters
  73925. * @param originalMaterial original glTF material
  73926. * @returns glTF material without texture parameters
  73927. */
  73928. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73929. /**
  73930. * Specifies if the material has any texture parameters present
  73931. * @param material glTF Material
  73932. * @returns boolean specifying if texture parameters are present
  73933. */
  73934. _hasTexturesPresent(material: IMaterial): boolean;
  73935. /**
  73936. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73937. * @param babylonStandardMaterial
  73938. * @returns glTF Metallic Roughness Material representation
  73939. */
  73940. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73941. /**
  73942. * Computes the metallic factor
  73943. * @param diffuse diffused value
  73944. * @param specular specular value
  73945. * @param oneMinusSpecularStrength one minus the specular strength
  73946. * @returns metallic value
  73947. */
  73948. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73949. /**
  73950. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73951. * @param glTFMaterial glTF material
  73952. * @param babylonMaterial Babylon material
  73953. */
  73954. private static _SetAlphaMode;
  73955. /**
  73956. * Converts a Babylon Standard Material to a glTF Material
  73957. * @param babylonStandardMaterial BJS Standard Material
  73958. * @param mimeType mime type to use for the textures
  73959. * @param images array of glTF image interfaces
  73960. * @param textures array of glTF texture interfaces
  73961. * @param materials array of glTF material interfaces
  73962. * @param imageData map of image file name to data
  73963. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73964. */
  73965. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73966. private _finishMaterial;
  73967. /**
  73968. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73969. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  73970. * @param mimeType mime type to use for the textures
  73971. * @param images array of glTF image interfaces
  73972. * @param textures array of glTF texture interfaces
  73973. * @param materials array of glTF material interfaces
  73974. * @param imageData map of image file name to data
  73975. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73976. */
  73977. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73978. /**
  73979. * Converts an image typed array buffer to a base64 image
  73980. * @param buffer typed array buffer
  73981. * @param width width of the image
  73982. * @param height height of the image
  73983. * @param mimeType mimetype of the image
  73984. * @returns base64 image string
  73985. */
  73986. private _createBase64FromCanvasAsync;
  73987. /**
  73988. * Generates a white texture based on the specified width and height
  73989. * @param width width of the texture in pixels
  73990. * @param height height of the texture in pixels
  73991. * @param scene babylonjs scene
  73992. * @returns white texture
  73993. */
  73994. private _createWhiteTexture;
  73995. /**
  73996. * 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
  73997. * @param texture1 first texture to resize
  73998. * @param texture2 second texture to resize
  73999. * @param scene babylonjs scene
  74000. * @returns resized textures or null
  74001. */
  74002. private _resizeTexturesToSameDimensions;
  74003. /**
  74004. * Converts an array of pixels to a Float32Array
  74005. * Throws an error if the pixel format is not supported
  74006. * @param pixels - array buffer containing pixel values
  74007. * @returns Float32 of pixels
  74008. */
  74009. private _convertPixelArrayToFloat32;
  74010. /**
  74011. * Convert Specular Glossiness Textures to Metallic Roughness
  74012. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  74013. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  74014. * @param diffuseTexture texture used to store diffuse information
  74015. * @param specularGlossinessTexture texture used to store specular and glossiness information
  74016. * @param factors specular glossiness material factors
  74017. * @param mimeType the mime type to use for the texture
  74018. * @returns pbr metallic roughness interface or null
  74019. */
  74020. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  74021. /**
  74022. * Converts specular glossiness material properties to metallic roughness
  74023. * @param specularGlossiness interface with specular glossiness material properties
  74024. * @returns interface with metallic roughness material properties
  74025. */
  74026. private _convertSpecularGlossinessToMetallicRoughness;
  74027. /**
  74028. * Calculates the surface reflectance, independent of lighting conditions
  74029. * @param color Color source to calculate brightness from
  74030. * @returns number representing the perceived brightness, or zero if color is undefined
  74031. */
  74032. private _getPerceivedBrightness;
  74033. /**
  74034. * Returns the maximum color component value
  74035. * @param color
  74036. * @returns maximum color component value, or zero if color is null or undefined
  74037. */
  74038. private _getMaxComponent;
  74039. /**
  74040. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  74041. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74042. * @param mimeType mime type to use for the textures
  74043. * @param images array of glTF image interfaces
  74044. * @param textures array of glTF texture interfaces
  74045. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74046. * @param imageData map of image file name to data
  74047. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74048. * @returns glTF PBR Metallic Roughness factors
  74049. */
  74050. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  74051. private _getGLTFTextureSampler;
  74052. private _getGLTFTextureWrapMode;
  74053. private _getGLTFTextureWrapModesSampler;
  74054. /**
  74055. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  74056. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74057. * @param mimeType mime type to use for the textures
  74058. * @param images array of glTF image interfaces
  74059. * @param textures array of glTF texture interfaces
  74060. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74061. * @param imageData map of image file name to data
  74062. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74063. * @returns glTF PBR Metallic Roughness factors
  74064. */
  74065. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  74066. /**
  74067. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74068. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74069. * @param mimeType mime type to use for the textures
  74070. * @param images array of glTF image interfaces
  74071. * @param textures array of glTF texture interfaces
  74072. * @param materials array of glTF material interfaces
  74073. * @param imageData map of image file name to data
  74074. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74075. */
  74076. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74077. private setMetallicRoughnessPbrMaterial;
  74078. private getPixelsFromTexture;
  74079. /**
  74080. * Extracts a texture from a Babylon texture into file data and glTF data
  74081. * @param babylonTexture Babylon texture to extract
  74082. * @param mimeType Mime Type of the babylonTexture
  74083. * @return glTF texture info, or null if the texture format is not supported
  74084. */
  74085. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74086. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74087. /**
  74088. * Builds a texture from base64 string
  74089. * @param base64Texture base64 texture string
  74090. * @param baseTextureName Name to use for the texture
  74091. * @param mimeType image mime type for the texture
  74092. * @param images array of images
  74093. * @param textures array of textures
  74094. * @param imageData map of image data
  74095. * @returns glTF texture info, or null if the texture format is not supported
  74096. */
  74097. private _getTextureInfoFromBase64;
  74098. }
  74099. }
  74100. declare module BABYLON {
  74101. /**
  74102. * Class for holding and downloading glTF file data
  74103. */
  74104. export class GLTFData {
  74105. /**
  74106. * Object which contains the file name as the key and its data as the value
  74107. */
  74108. glTFFiles: {
  74109. [fileName: string]: string | Blob;
  74110. };
  74111. /**
  74112. * Initializes the glTF file object
  74113. */
  74114. constructor();
  74115. /**
  74116. * Downloads the glTF data as files based on their names and data
  74117. */
  74118. downloadFiles(): void;
  74119. }
  74120. }
  74121. declare module BABYLON {
  74122. /**
  74123. * Holds a collection of exporter options and parameters
  74124. */
  74125. export interface IExportOptions {
  74126. /**
  74127. * Function which indicates whether a babylon node should be exported or not
  74128. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  74129. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  74130. */
  74131. shouldExportNode?(node: Node): boolean;
  74132. /**
  74133. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  74134. * @param metadata source metadata to read from
  74135. * @returns the data to store to glTF node extras
  74136. */
  74137. metadataSelector?(metadata: any): any;
  74138. /**
  74139. * The sample rate to bake animation curves
  74140. */
  74141. animationSampleRate?: number;
  74142. /**
  74143. * Begin serialization without waiting for the scene to be ready
  74144. */
  74145. exportWithoutWaitingForScene?: boolean;
  74146. }
  74147. /**
  74148. * Class for generating glTF data from a Babylon scene.
  74149. */
  74150. export class GLTF2Export {
  74151. /**
  74152. * Exports the geometry of the scene to .gltf file format asynchronously
  74153. * @param scene Babylon scene with scene hierarchy information
  74154. * @param filePrefix File prefix to use when generating the glTF file
  74155. * @param options Exporter options
  74156. * @returns Returns an object with a .gltf file and associates texture names
  74157. * as keys and their data and paths as values
  74158. */
  74159. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74160. private static _PreExportAsync;
  74161. private static _PostExportAsync;
  74162. /**
  74163. * Exports the geometry of the scene to .glb file format asychronously
  74164. * @param scene Babylon scene with scene hierarchy information
  74165. * @param filePrefix File prefix to use when generating glb file
  74166. * @param options Exporter options
  74167. * @returns Returns an object with a .glb filename as key and data as value
  74168. */
  74169. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74170. }
  74171. }
  74172. declare module BABYLON.GLTF2.Exporter {
  74173. /**
  74174. * @hidden
  74175. */
  74176. export class _GLTFUtilities {
  74177. /**
  74178. * Creates a buffer view based on the supplied arguments
  74179. * @param bufferIndex index value of the specified buffer
  74180. * @param byteOffset byte offset value
  74181. * @param byteLength byte length of the bufferView
  74182. * @param byteStride byte distance between conequential elements
  74183. * @param name name of the buffer view
  74184. * @returns bufferView for glTF
  74185. */
  74186. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  74187. /**
  74188. * Creates an accessor based on the supplied arguments
  74189. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  74190. * @param name The name of the accessor
  74191. * @param type The type of the accessor
  74192. * @param componentType The datatype of components in the attribute
  74193. * @param count The number of attributes referenced by this accessor
  74194. * @param byteOffset The offset relative to the start of the bufferView in bytes
  74195. * @param min Minimum value of each component in this attribute
  74196. * @param max Maximum value of each component in this attribute
  74197. * @returns accessor for glTF
  74198. */
  74199. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  74200. /**
  74201. * Calculates the minimum and maximum values of an array of position floats
  74202. * @param positions Positions array of a mesh
  74203. * @param vertexStart Starting vertex offset to calculate min and max values
  74204. * @param vertexCount Number of vertices to check for min and max values
  74205. * @returns min number array and max number array
  74206. */
  74207. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  74208. min: number[];
  74209. max: number[];
  74210. };
  74211. /**
  74212. * Converts a new right-handed Vector3
  74213. * @param vector vector3 array
  74214. * @returns right-handed Vector3
  74215. */
  74216. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  74217. /**
  74218. * Converts a Vector3 to right-handed
  74219. * @param vector Vector3 to convert to right-handed
  74220. */
  74221. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  74222. /**
  74223. * Converts a three element number array to right-handed
  74224. * @param vector number array to convert to right-handed
  74225. */
  74226. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  74227. /**
  74228. * Converts a new right-handed Vector3
  74229. * @param vector vector3 array
  74230. * @returns right-handed Vector3
  74231. */
  74232. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  74233. /**
  74234. * Converts a Vector3 to right-handed
  74235. * @param vector Vector3 to convert to right-handed
  74236. */
  74237. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  74238. /**
  74239. * Converts a three element number array to right-handed
  74240. * @param vector number array to convert to right-handed
  74241. */
  74242. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  74243. /**
  74244. * Converts a Vector4 to right-handed
  74245. * @param vector Vector4 to convert to right-handed
  74246. */
  74247. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  74248. /**
  74249. * Converts a Vector4 to right-handed
  74250. * @param vector Vector4 to convert to right-handed
  74251. */
  74252. static _GetRightHandedArray4FromRef(vector: number[]): void;
  74253. /**
  74254. * Converts a Quaternion to right-handed
  74255. * @param quaternion Source quaternion to convert to right-handed
  74256. */
  74257. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  74258. /**
  74259. * Converts a Quaternion to right-handed
  74260. * @param quaternion Source quaternion to convert to right-handed
  74261. */
  74262. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  74263. static _NormalizeTangentFromRef(tangent: Vector4): void;
  74264. }
  74265. }
  74266. declare module BABYLON.GLTF2.Exporter {
  74267. /**
  74268. * Converts Babylon Scene into glTF 2.0.
  74269. * @hidden
  74270. */
  74271. export class _Exporter {
  74272. /**
  74273. * Stores the glTF to export
  74274. */
  74275. _glTF: IGLTF;
  74276. /**
  74277. * Stores all generated buffer views, which represents views into the main glTF buffer data
  74278. */
  74279. _bufferViews: IBufferView[];
  74280. /**
  74281. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  74282. */
  74283. _accessors: IAccessor[];
  74284. /**
  74285. * Stores all the generated nodes, which contains transform and/or mesh information per node
  74286. */
  74287. private _nodes;
  74288. /**
  74289. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  74290. */
  74291. private _scenes;
  74292. /**
  74293. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  74294. */
  74295. private _meshes;
  74296. /**
  74297. * Stores all the generated material information, which represents the appearance of each primitive
  74298. */
  74299. _materials: IMaterial[];
  74300. _materialMap: {
  74301. [materialID: number]: number;
  74302. };
  74303. /**
  74304. * Stores all the generated texture information, which is referenced by glTF materials
  74305. */
  74306. _textures: ITexture[];
  74307. /**
  74308. * Stores all the generated image information, which is referenced by glTF textures
  74309. */
  74310. _images: IImage[];
  74311. /**
  74312. * Stores all the texture samplers
  74313. */
  74314. _samplers: ISampler[];
  74315. /**
  74316. * Stores all the generated animation samplers, which is referenced by glTF animations
  74317. */
  74318. /**
  74319. * Stores the animations for glTF models
  74320. */
  74321. private _animations;
  74322. /**
  74323. * Stores the total amount of bytes stored in the glTF buffer
  74324. */
  74325. private _totalByteLength;
  74326. /**
  74327. * Stores a reference to the Babylon scene containing the source geometry and material information
  74328. */
  74329. _babylonScene: Scene;
  74330. /**
  74331. * Stores a map of the image data, where the key is the file name and the value
  74332. * is the image data
  74333. */
  74334. _imageData: {
  74335. [fileName: string]: {
  74336. data: Uint8Array;
  74337. mimeType: ImageMimeType;
  74338. };
  74339. };
  74340. /**
  74341. * Stores a map of the unique id of a node to its index in the node array
  74342. */
  74343. private _nodeMap;
  74344. /**
  74345. * Specifies if the Babylon scene should be converted to right-handed on export
  74346. */
  74347. _convertToRightHandedSystem: boolean;
  74348. /**
  74349. * Baked animation sample rate
  74350. */
  74351. private _animationSampleRate;
  74352. private _options;
  74353. private _localEngine;
  74354. _glTFMaterialExporter: _GLTFMaterialExporter;
  74355. private _extensions;
  74356. private static _ExtensionNames;
  74357. private static _ExtensionFactories;
  74358. private _applyExtension;
  74359. private _applyExtensions;
  74360. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  74361. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  74362. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  74363. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  74364. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  74365. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  74366. private _forEachExtensions;
  74367. private _extensionsOnExporting;
  74368. /**
  74369. * Load glTF serializer extensions
  74370. */
  74371. private _loadExtensions;
  74372. /**
  74373. * Creates a glTF Exporter instance, which can accept optional exporter options
  74374. * @param babylonScene Babylon scene object
  74375. * @param options Options to modify the behavior of the exporter
  74376. */
  74377. constructor(babylonScene: Scene, options?: IExportOptions);
  74378. dispose(): void;
  74379. /**
  74380. * Registers a glTF exporter extension
  74381. * @param name Name of the extension to export
  74382. * @param factory The factory function that creates the exporter extension
  74383. */
  74384. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  74385. /**
  74386. * Un-registers an exporter extension
  74387. * @param name The name fo the exporter extension
  74388. * @returns A boolean indicating whether the extension has been un-registered
  74389. */
  74390. static UnregisterExtension(name: string): boolean;
  74391. /**
  74392. * Lazy load a local engine with premultiplied alpha set to false
  74393. */
  74394. _getLocalEngine(): Engine;
  74395. private reorderIndicesBasedOnPrimitiveMode;
  74396. /**
  74397. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  74398. * clock-wise during export to glTF
  74399. * @param submesh BabylonJS submesh
  74400. * @param primitiveMode Primitive mode of the mesh
  74401. * @param sideOrientation the winding order of the submesh
  74402. * @param vertexBufferKind The type of vertex attribute
  74403. * @param meshAttributeArray The vertex attribute data
  74404. * @param byteOffset The offset to the binary data
  74405. * @param binaryWriter The binary data for the glTF file
  74406. */
  74407. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  74408. /**
  74409. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  74410. * clock-wise during export to glTF
  74411. * @param submesh BabylonJS submesh
  74412. * @param primitiveMode Primitive mode of the mesh
  74413. * @param sideOrientation the winding order of the submesh
  74414. * @param vertexBufferKind The type of vertex attribute
  74415. * @param meshAttributeArray The vertex attribute data
  74416. * @param byteOffset The offset to the binary data
  74417. * @param binaryWriter The binary data for the glTF file
  74418. */
  74419. private reorderTriangleFillMode;
  74420. /**
  74421. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  74422. * clock-wise during export to glTF
  74423. * @param submesh BabylonJS submesh
  74424. * @param primitiveMode Primitive mode of the mesh
  74425. * @param sideOrientation the winding order of the submesh
  74426. * @param vertexBufferKind The type of vertex attribute
  74427. * @param meshAttributeArray The vertex attribute data
  74428. * @param byteOffset The offset to the binary data
  74429. * @param binaryWriter The binary data for the glTF file
  74430. */
  74431. private reorderTriangleStripDrawMode;
  74432. /**
  74433. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  74434. * clock-wise during export to glTF
  74435. * @param submesh BabylonJS submesh
  74436. * @param primitiveMode Primitive mode of the mesh
  74437. * @param sideOrientation the winding order of the submesh
  74438. * @param vertexBufferKind The type of vertex attribute
  74439. * @param meshAttributeArray The vertex attribute data
  74440. * @param byteOffset The offset to the binary data
  74441. * @param binaryWriter The binary data for the glTF file
  74442. */
  74443. private reorderTriangleFanMode;
  74444. /**
  74445. * Writes the vertex attribute data to binary
  74446. * @param vertices The vertices to write to the binary writer
  74447. * @param byteOffset The offset into the binary writer to overwrite binary data
  74448. * @param vertexAttributeKind The vertex attribute type
  74449. * @param meshAttributeArray The vertex attribute data
  74450. * @param binaryWriter The writer containing the binary data
  74451. */
  74452. private writeVertexAttributeData;
  74453. /**
  74454. * Writes mesh attribute data to a data buffer
  74455. * Returns the bytelength of the data
  74456. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  74457. * @param meshAttributeArray Array containing the attribute data
  74458. * @param binaryWriter The buffer to write the binary data to
  74459. * @param indices Used to specify the order of the vertex data
  74460. */
  74461. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  74462. /**
  74463. * Generates glTF json data
  74464. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  74465. * @param glTFPrefix Text to use when prefixing a glTF file
  74466. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  74467. * @returns json data as string
  74468. */
  74469. private generateJSON;
  74470. /**
  74471. * Generates data for .gltf and .bin files based on the glTF prefix string
  74472. * @param glTFPrefix Text to use when prefixing a glTF file
  74473. * @param dispose Dispose the exporter
  74474. * @returns GLTFData with glTF file data
  74475. */
  74476. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74477. /**
  74478. * Creates a binary buffer for glTF
  74479. * @returns array buffer for binary data
  74480. */
  74481. private _generateBinaryAsync;
  74482. /**
  74483. * Pads the number to a multiple of 4
  74484. * @param num number to pad
  74485. * @returns padded number
  74486. */
  74487. private _getPadding;
  74488. /**
  74489. * @hidden
  74490. */
  74491. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  74492. /**
  74493. * Sets the TRS for each node
  74494. * @param node glTF Node for storing the transformation data
  74495. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  74496. */
  74497. private setNodeTransformation;
  74498. private getVertexBufferFromMesh;
  74499. /**
  74500. * Creates a bufferview based on the vertices type for the Babylon mesh
  74501. * @param kind Indicates the type of vertices data
  74502. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  74503. * @param binaryWriter The buffer to write the bufferview data to
  74504. */
  74505. private createBufferViewKind;
  74506. /**
  74507. * The primitive mode of the Babylon mesh
  74508. * @param babylonMesh The BabylonJS mesh
  74509. */
  74510. private getMeshPrimitiveMode;
  74511. /**
  74512. * Sets the primitive mode of the glTF mesh primitive
  74513. * @param meshPrimitive glTF mesh primitive
  74514. * @param primitiveMode The primitive mode
  74515. */
  74516. private setPrimitiveMode;
  74517. /**
  74518. * Sets the vertex attribute accessor based of the glTF mesh primitive
  74519. * @param meshPrimitive glTF mesh primitive
  74520. * @param attributeKind vertex attribute
  74521. * @returns boolean specifying if uv coordinates are present
  74522. */
  74523. private setAttributeKind;
  74524. /**
  74525. * Sets data for the primitive attributes of each submesh
  74526. * @param mesh glTF Mesh object to store the primitive attribute information
  74527. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  74528. * @param binaryWriter Buffer to write the attribute data to
  74529. */
  74530. private setPrimitiveAttributesAsync;
  74531. /**
  74532. * Creates a glTF scene based on the array of meshes
  74533. * Returns the the total byte offset
  74534. * @param babylonScene Babylon scene to get the mesh data from
  74535. * @param binaryWriter Buffer to write binary data to
  74536. */
  74537. private createSceneAsync;
  74538. /**
  74539. * Creates a mapping of Node unique id to node index and handles animations
  74540. * @param babylonScene Babylon Scene
  74541. * @param nodes Babylon transform nodes
  74542. * @param binaryWriter Buffer to write binary data to
  74543. * @returns Node mapping of unique id to index
  74544. */
  74545. private createNodeMapAndAnimationsAsync;
  74546. /**
  74547. * Creates a glTF node from a Babylon mesh
  74548. * @param babylonMesh Source Babylon mesh
  74549. * @param binaryWriter Buffer for storing geometry data
  74550. * @returns glTF node
  74551. */
  74552. private createNodeAsync;
  74553. }
  74554. /**
  74555. * @hidden
  74556. *
  74557. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  74558. */
  74559. export class _BinaryWriter {
  74560. /**
  74561. * Array buffer which stores all binary data
  74562. */
  74563. private _arrayBuffer;
  74564. /**
  74565. * View of the array buffer
  74566. */
  74567. private _dataView;
  74568. /**
  74569. * byte offset of data in array buffer
  74570. */
  74571. private _byteOffset;
  74572. /**
  74573. * Initialize binary writer with an initial byte length
  74574. * @param byteLength Initial byte length of the array buffer
  74575. */
  74576. constructor(byteLength: number);
  74577. /**
  74578. * Resize the array buffer to the specified byte length
  74579. * @param byteLength
  74580. */
  74581. private resizeBuffer;
  74582. /**
  74583. * Get an array buffer with the length of the byte offset
  74584. * @returns ArrayBuffer resized to the byte offset
  74585. */
  74586. getArrayBuffer(): ArrayBuffer;
  74587. /**
  74588. * Get the byte offset of the array buffer
  74589. * @returns byte offset
  74590. */
  74591. getByteOffset(): number;
  74592. /**
  74593. * Stores an UInt8 in the array buffer
  74594. * @param entry
  74595. * @param byteOffset If defined, specifies where to set the value as an offset.
  74596. */
  74597. setUInt8(entry: number, byteOffset?: number): void;
  74598. /**
  74599. * Gets an UInt32 in the array buffer
  74600. * @param entry
  74601. * @param byteOffset If defined, specifies where to set the value as an offset.
  74602. */
  74603. getUInt32(byteOffset: number): number;
  74604. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74605. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  74606. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74607. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  74608. /**
  74609. * Stores a Float32 in the array buffer
  74610. * @param entry
  74611. */
  74612. setFloat32(entry: number, byteOffset?: number): void;
  74613. /**
  74614. * Stores an UInt32 in the array buffer
  74615. * @param entry
  74616. * @param byteOffset If defined, specifies where to set the value as an offset.
  74617. */
  74618. setUInt32(entry: number, byteOffset?: number): void;
  74619. }
  74620. }
  74621. declare module BABYLON.GLTF2.Exporter {
  74622. /**
  74623. * @hidden
  74624. * Interface to store animation data.
  74625. */
  74626. export interface _IAnimationData {
  74627. /**
  74628. * Keyframe data.
  74629. */
  74630. inputs: number[];
  74631. /**
  74632. * Value data.
  74633. */
  74634. outputs: number[][];
  74635. /**
  74636. * Animation interpolation data.
  74637. */
  74638. samplerInterpolation: AnimationSamplerInterpolation;
  74639. /**
  74640. * Minimum keyframe value.
  74641. */
  74642. inputsMin: number;
  74643. /**
  74644. * Maximum keyframe value.
  74645. */
  74646. inputsMax: number;
  74647. }
  74648. /**
  74649. * @hidden
  74650. */
  74651. export interface _IAnimationInfo {
  74652. /**
  74653. * The target channel for the animation
  74654. */
  74655. animationChannelTargetPath: AnimationChannelTargetPath;
  74656. /**
  74657. * The glTF accessor type for the data.
  74658. */
  74659. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  74660. /**
  74661. * Specifies if quaternions should be used.
  74662. */
  74663. useQuaternion: boolean;
  74664. }
  74665. /**
  74666. * @hidden
  74667. * Utility class for generating glTF animation data from BabylonJS.
  74668. */
  74669. export class _GLTFAnimation {
  74670. /**
  74671. * @ignore
  74672. *
  74673. * Creates glTF channel animation from BabylonJS animation.
  74674. * @param babylonTransformNode - BabylonJS mesh.
  74675. * @param animation - animation.
  74676. * @param animationChannelTargetPath - The target animation channel.
  74677. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  74678. * @param useQuaternion - Specifies if quaternions are used.
  74679. * @returns nullable IAnimationData
  74680. */
  74681. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  74682. private static _DeduceAnimationInfo;
  74683. /**
  74684. * @ignore
  74685. * Create node animations from the transform node animations
  74686. * @param babylonNode
  74687. * @param runtimeGLTFAnimation
  74688. * @param idleGLTFAnimations
  74689. * @param nodeMap
  74690. * @param nodes
  74691. * @param binaryWriter
  74692. * @param bufferViews
  74693. * @param accessors
  74694. * @param convertToRightHandedSystem
  74695. */
  74696. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  74697. [key: number]: number;
  74698. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74699. /**
  74700. * @ignore
  74701. * Create node animations from the animation groups
  74702. * @param babylonScene
  74703. * @param glTFAnimations
  74704. * @param nodeMap
  74705. * @param nodes
  74706. * @param binaryWriter
  74707. * @param bufferViews
  74708. * @param accessors
  74709. * @param convertToRightHandedSystem
  74710. */
  74711. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  74712. [key: number]: number;
  74713. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  74714. private static AddAnimation;
  74715. /**
  74716. * Create a baked animation
  74717. * @param babylonTransformNode BabylonJS mesh
  74718. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  74719. * @param animationChannelTargetPath animation target channel
  74720. * @param minFrame minimum animation frame
  74721. * @param maxFrame maximum animation frame
  74722. * @param fps frames per second of the animation
  74723. * @param inputs input key frames of the animation
  74724. * @param outputs output key frame data of the animation
  74725. * @param convertToRightHandedSystem converts the values to right-handed
  74726. * @param useQuaternion specifies if quaternions should be used
  74727. */
  74728. private static _CreateBakedAnimation;
  74729. private static _ConvertFactorToVector3OrQuaternion;
  74730. private static _SetInterpolatedValue;
  74731. /**
  74732. * Creates linear animation from the animation key frames
  74733. * @param babylonTransformNode BabylonJS mesh
  74734. * @param animation BabylonJS animation
  74735. * @param animationChannelTargetPath The target animation channel
  74736. * @param frameDelta The difference between the last and first frame of the animation
  74737. * @param inputs Array to store the key frame times
  74738. * @param outputs Array to store the key frame data
  74739. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74740. * @param useQuaternion Specifies if quaternions are used in the animation
  74741. */
  74742. private static _CreateLinearOrStepAnimation;
  74743. /**
  74744. * Creates cubic spline animation from the animation key frames
  74745. * @param babylonTransformNode BabylonJS mesh
  74746. * @param animation BabylonJS animation
  74747. * @param animationChannelTargetPath The target animation channel
  74748. * @param frameDelta The difference between the last and first frame of the animation
  74749. * @param inputs Array to store the key frame times
  74750. * @param outputs Array to store the key frame data
  74751. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  74752. * @param useQuaternion Specifies if quaternions are used in the animation
  74753. */
  74754. private static _CreateCubicSplineAnimation;
  74755. private static _GetBasePositionRotationOrScale;
  74756. /**
  74757. * Adds a key frame value
  74758. * @param keyFrame
  74759. * @param animation
  74760. * @param outputs
  74761. * @param animationChannelTargetPath
  74762. * @param basePositionRotationOrScale
  74763. * @param convertToRightHandedSystem
  74764. * @param useQuaternion
  74765. */
  74766. private static _AddKeyframeValue;
  74767. /**
  74768. * Determine the interpolation based on the key frames
  74769. * @param keyFrames
  74770. * @param animationChannelTargetPath
  74771. * @param useQuaternion
  74772. */
  74773. private static _DeduceInterpolation;
  74774. /**
  74775. * Adds an input tangent or output tangent to the output data
  74776. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  74777. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  74778. * @param outputs The animation data by keyframe
  74779. * @param animationChannelTargetPath The target animation channel
  74780. * @param interpolation The interpolation type
  74781. * @param keyFrame The key frame with the animation data
  74782. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  74783. * @param useQuaternion Specifies if quaternions are used
  74784. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  74785. */
  74786. private static AddSplineTangent;
  74787. /**
  74788. * Get the minimum and maximum key frames' frame values
  74789. * @param keyFrames animation key frames
  74790. * @returns the minimum and maximum key frame value
  74791. */
  74792. private static calculateMinMaxKeyFrames;
  74793. }
  74794. }
  74795. declare module BABYLON.GLTF2.Exporter {
  74796. /** @hidden */
  74797. export var textureTransformPixelShader: {
  74798. name: string;
  74799. shader: string;
  74800. };
  74801. }
  74802. declare module BABYLON.GLTF2.Exporter.Extensions {
  74803. /**
  74804. * @hidden
  74805. */
  74806. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  74807. private _recordedTextures;
  74808. /** Name of this extension */
  74809. readonly name: string;
  74810. /** Defines whether this extension is enabled */
  74811. enabled: boolean;
  74812. /** Defines whether this extension is required */
  74813. required: boolean;
  74814. /** Reference to the glTF exporter */
  74815. private _wasUsed;
  74816. constructor(exporter: _Exporter);
  74817. dispose(): void;
  74818. /** @hidden */
  74819. get wasUsed(): boolean;
  74820. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74821. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  74822. /**
  74823. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  74824. * @param babylonTexture
  74825. * @param offset
  74826. * @param rotation
  74827. * @param scale
  74828. * @param scene
  74829. */
  74830. private _textureTransformTextureAsync;
  74831. }
  74832. }
  74833. declare module BABYLON.GLTF2.Exporter.Extensions {
  74834. /**
  74835. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74836. */
  74837. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  74838. /** The name of this extension. */
  74839. readonly name: string;
  74840. /** Defines whether this extension is enabled. */
  74841. enabled: boolean;
  74842. /** Defines whether this extension is required */
  74843. required: boolean;
  74844. /** Reference to the glTF exporter */
  74845. private _exporter;
  74846. private _lights;
  74847. /** @hidden */
  74848. constructor(exporter: _Exporter);
  74849. /** @hidden */
  74850. dispose(): void;
  74851. /** @hidden */
  74852. get wasUsed(): boolean;
  74853. /** @hidden */
  74854. onExporting(): void;
  74855. /**
  74856. * Define this method to modify the default behavior when exporting a node
  74857. * @param context The context when exporting the node
  74858. * @param node glTF node
  74859. * @param babylonNode BabylonJS node
  74860. * @returns nullable INode promise
  74861. */
  74862. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  74863. }
  74864. }
  74865. declare module BABYLON.GLTF2.Exporter.Extensions {
  74866. /**
  74867. * @hidden
  74868. */
  74869. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  74870. /** Name of this extension */
  74871. readonly name: string;
  74872. /** Defines whether this extension is enabled */
  74873. enabled: boolean;
  74874. /** Defines whether this extension is required */
  74875. required: boolean;
  74876. /** Reference to the glTF exporter */
  74877. private _textureInfos;
  74878. private _exportedTextures;
  74879. private _wasUsed;
  74880. constructor(exporter: _Exporter);
  74881. dispose(): void;
  74882. /** @hidden */
  74883. get wasUsed(): boolean;
  74884. private _getTextureIndex;
  74885. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  74886. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  74887. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  74888. }
  74889. }
  74890. declare module BABYLON {
  74891. /**
  74892. * Class for generating STL data from a Babylon scene.
  74893. */
  74894. export class STLExport {
  74895. /**
  74896. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  74897. * @param meshes list defines the mesh to serialize
  74898. * @param download triggers the automatic download of the file.
  74899. * @param fileName changes the downloads fileName.
  74900. * @param binary changes the STL to a binary type.
  74901. * @param isLittleEndian toggle for binary type exporter.
  74902. * @returns the STL as UTF8 string
  74903. */
  74904. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  74905. }
  74906. }
  74907. declare module "babylonjs-gltf2interface" {
  74908. export = BABYLON.GLTF2;
  74909. }
  74910. /**
  74911. * Module for glTF 2.0 Interface
  74912. */
  74913. declare module BABYLON.GLTF2 {
  74914. /**
  74915. * The datatype of the components in the attribute
  74916. */
  74917. const enum AccessorComponentType {
  74918. /**
  74919. * Byte
  74920. */
  74921. BYTE = 5120,
  74922. /**
  74923. * Unsigned Byte
  74924. */
  74925. UNSIGNED_BYTE = 5121,
  74926. /**
  74927. * Short
  74928. */
  74929. SHORT = 5122,
  74930. /**
  74931. * Unsigned Short
  74932. */
  74933. UNSIGNED_SHORT = 5123,
  74934. /**
  74935. * Unsigned Int
  74936. */
  74937. UNSIGNED_INT = 5125,
  74938. /**
  74939. * Float
  74940. */
  74941. FLOAT = 5126,
  74942. }
  74943. /**
  74944. * Specifies if the attirbute is a scalar, vector, or matrix
  74945. */
  74946. const enum AccessorType {
  74947. /**
  74948. * Scalar
  74949. */
  74950. SCALAR = "SCALAR",
  74951. /**
  74952. * Vector2
  74953. */
  74954. VEC2 = "VEC2",
  74955. /**
  74956. * Vector3
  74957. */
  74958. VEC3 = "VEC3",
  74959. /**
  74960. * Vector4
  74961. */
  74962. VEC4 = "VEC4",
  74963. /**
  74964. * Matrix2x2
  74965. */
  74966. MAT2 = "MAT2",
  74967. /**
  74968. * Matrix3x3
  74969. */
  74970. MAT3 = "MAT3",
  74971. /**
  74972. * Matrix4x4
  74973. */
  74974. MAT4 = "MAT4",
  74975. }
  74976. /**
  74977. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74978. */
  74979. const enum AnimationChannelTargetPath {
  74980. /**
  74981. * Translation
  74982. */
  74983. TRANSLATION = "translation",
  74984. /**
  74985. * Rotation
  74986. */
  74987. ROTATION = "rotation",
  74988. /**
  74989. * Scale
  74990. */
  74991. SCALE = "scale",
  74992. /**
  74993. * Weights
  74994. */
  74995. WEIGHTS = "weights",
  74996. }
  74997. /**
  74998. * Interpolation algorithm
  74999. */
  75000. const enum AnimationSamplerInterpolation {
  75001. /**
  75002. * The animated values are linearly interpolated between keyframes
  75003. */
  75004. LINEAR = "LINEAR",
  75005. /**
  75006. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  75007. */
  75008. STEP = "STEP",
  75009. /**
  75010. * The animation's interpolation is computed using a cubic spline with specified tangents
  75011. */
  75012. CUBICSPLINE = "CUBICSPLINE",
  75013. }
  75014. /**
  75015. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75016. */
  75017. const enum CameraType {
  75018. /**
  75019. * A perspective camera containing properties to create a perspective projection matrix
  75020. */
  75021. PERSPECTIVE = "perspective",
  75022. /**
  75023. * An orthographic camera containing properties to create an orthographic projection matrix
  75024. */
  75025. ORTHOGRAPHIC = "orthographic",
  75026. }
  75027. /**
  75028. * The mime-type of the image
  75029. */
  75030. const enum ImageMimeType {
  75031. /**
  75032. * JPEG Mime-type
  75033. */
  75034. JPEG = "image/jpeg",
  75035. /**
  75036. * PNG Mime-type
  75037. */
  75038. PNG = "image/png",
  75039. }
  75040. /**
  75041. * The alpha rendering mode of the material
  75042. */
  75043. const enum MaterialAlphaMode {
  75044. /**
  75045. * The alpha value is ignored and the rendered output is fully opaque
  75046. */
  75047. OPAQUE = "OPAQUE",
  75048. /**
  75049. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  75050. */
  75051. MASK = "MASK",
  75052. /**
  75053. * 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)
  75054. */
  75055. BLEND = "BLEND",
  75056. }
  75057. /**
  75058. * The type of the primitives to render
  75059. */
  75060. const enum MeshPrimitiveMode {
  75061. /**
  75062. * Points
  75063. */
  75064. POINTS = 0,
  75065. /**
  75066. * Lines
  75067. */
  75068. LINES = 1,
  75069. /**
  75070. * Line Loop
  75071. */
  75072. LINE_LOOP = 2,
  75073. /**
  75074. * Line Strip
  75075. */
  75076. LINE_STRIP = 3,
  75077. /**
  75078. * Triangles
  75079. */
  75080. TRIANGLES = 4,
  75081. /**
  75082. * Triangle Strip
  75083. */
  75084. TRIANGLE_STRIP = 5,
  75085. /**
  75086. * Triangle Fan
  75087. */
  75088. TRIANGLE_FAN = 6,
  75089. }
  75090. /**
  75091. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75092. */
  75093. const enum TextureMagFilter {
  75094. /**
  75095. * Nearest
  75096. */
  75097. NEAREST = 9728,
  75098. /**
  75099. * Linear
  75100. */
  75101. LINEAR = 9729,
  75102. }
  75103. /**
  75104. * Minification filter. All valid values correspond to WebGL enums
  75105. */
  75106. const enum TextureMinFilter {
  75107. /**
  75108. * Nearest
  75109. */
  75110. NEAREST = 9728,
  75111. /**
  75112. * Linear
  75113. */
  75114. LINEAR = 9729,
  75115. /**
  75116. * Nearest Mip-Map Nearest
  75117. */
  75118. NEAREST_MIPMAP_NEAREST = 9984,
  75119. /**
  75120. * Linear Mipmap Nearest
  75121. */
  75122. LINEAR_MIPMAP_NEAREST = 9985,
  75123. /**
  75124. * Nearest Mipmap Linear
  75125. */
  75126. NEAREST_MIPMAP_LINEAR = 9986,
  75127. /**
  75128. * Linear Mipmap Linear
  75129. */
  75130. LINEAR_MIPMAP_LINEAR = 9987,
  75131. }
  75132. /**
  75133. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75134. */
  75135. const enum TextureWrapMode {
  75136. /**
  75137. * Clamp to Edge
  75138. */
  75139. CLAMP_TO_EDGE = 33071,
  75140. /**
  75141. * Mirrored Repeat
  75142. */
  75143. MIRRORED_REPEAT = 33648,
  75144. /**
  75145. * Repeat
  75146. */
  75147. REPEAT = 10497,
  75148. }
  75149. /**
  75150. * glTF Property
  75151. */
  75152. interface IProperty {
  75153. /**
  75154. * Dictionary object with extension-specific objects
  75155. */
  75156. extensions?: {
  75157. [key: string]: any;
  75158. };
  75159. /**
  75160. * Application-Specific data
  75161. */
  75162. extras?: any;
  75163. }
  75164. /**
  75165. * glTF Child of Root Property
  75166. */
  75167. interface IChildRootProperty extends IProperty {
  75168. /**
  75169. * The user-defined name of this object
  75170. */
  75171. name?: string;
  75172. }
  75173. /**
  75174. * Indices of those attributes that deviate from their initialization value
  75175. */
  75176. interface IAccessorSparseIndices extends IProperty {
  75177. /**
  75178. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75179. */
  75180. bufferView: number;
  75181. /**
  75182. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75183. */
  75184. byteOffset?: number;
  75185. /**
  75186. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  75187. */
  75188. componentType: AccessorComponentType;
  75189. }
  75190. /**
  75191. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  75192. */
  75193. interface IAccessorSparseValues extends IProperty {
  75194. /**
  75195. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75196. */
  75197. bufferView: number;
  75198. /**
  75199. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75200. */
  75201. byteOffset?: number;
  75202. }
  75203. /**
  75204. * Sparse storage of attributes that deviate from their initialization value
  75205. */
  75206. interface IAccessorSparse extends IProperty {
  75207. /**
  75208. * The number of attributes encoded in this sparse accessor
  75209. */
  75210. count: number;
  75211. /**
  75212. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  75213. */
  75214. indices: IAccessorSparseIndices;
  75215. /**
  75216. * 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
  75217. */
  75218. values: IAccessorSparseValues;
  75219. }
  75220. /**
  75221. * 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
  75222. */
  75223. interface IAccessor extends IChildRootProperty {
  75224. /**
  75225. * The index of the bufferview
  75226. */
  75227. bufferView?: number;
  75228. /**
  75229. * The offset relative to the start of the bufferView in bytes
  75230. */
  75231. byteOffset?: number;
  75232. /**
  75233. * The datatype of components in the attribute
  75234. */
  75235. componentType: AccessorComponentType;
  75236. /**
  75237. * Specifies whether integer data values should be normalized
  75238. */
  75239. normalized?: boolean;
  75240. /**
  75241. * The number of attributes referenced by this accessor
  75242. */
  75243. count: number;
  75244. /**
  75245. * Specifies if the attribute is a scalar, vector, or matrix
  75246. */
  75247. type: AccessorType;
  75248. /**
  75249. * Maximum value of each component in this attribute
  75250. */
  75251. max?: number[];
  75252. /**
  75253. * Minimum value of each component in this attribute
  75254. */
  75255. min?: number[];
  75256. /**
  75257. * Sparse storage of attributes that deviate from their initialization value
  75258. */
  75259. sparse?: IAccessorSparse;
  75260. }
  75261. /**
  75262. * Targets an animation's sampler at a node's property
  75263. */
  75264. interface IAnimationChannel extends IProperty {
  75265. /**
  75266. * The index of a sampler in this animation used to compute the value for the target
  75267. */
  75268. sampler: number;
  75269. /**
  75270. * The index of the node and TRS property to target
  75271. */
  75272. target: IAnimationChannelTarget;
  75273. }
  75274. /**
  75275. * The index of the node and TRS property that an animation channel targets
  75276. */
  75277. interface IAnimationChannelTarget extends IProperty {
  75278. /**
  75279. * The index of the node to target
  75280. */
  75281. node: number;
  75282. /**
  75283. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75284. */
  75285. path: AnimationChannelTargetPath;
  75286. }
  75287. /**
  75288. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75289. */
  75290. interface IAnimationSampler extends IProperty {
  75291. /**
  75292. * The index of an accessor containing keyframe input values, e.g., time
  75293. */
  75294. input: number;
  75295. /**
  75296. * Interpolation algorithm
  75297. */
  75298. interpolation?: AnimationSamplerInterpolation;
  75299. /**
  75300. * The index of an accessor, containing keyframe output values
  75301. */
  75302. output: number;
  75303. }
  75304. /**
  75305. * A keyframe animation
  75306. */
  75307. interface IAnimation extends IChildRootProperty {
  75308. /**
  75309. * An array of channels, each of which targets an animation's sampler at a node's property
  75310. */
  75311. channels: IAnimationChannel[];
  75312. /**
  75313. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  75314. */
  75315. samplers: IAnimationSampler[];
  75316. }
  75317. /**
  75318. * Metadata about the glTF asset
  75319. */
  75320. interface IAsset extends IChildRootProperty {
  75321. /**
  75322. * A copyright message suitable for display to credit the content creator
  75323. */
  75324. copyright?: string;
  75325. /**
  75326. * Tool that generated this glTF model. Useful for debugging
  75327. */
  75328. generator?: string;
  75329. /**
  75330. * The glTF version that this asset targets
  75331. */
  75332. version: string;
  75333. /**
  75334. * The minimum glTF version that this asset targets
  75335. */
  75336. minVersion?: string;
  75337. }
  75338. /**
  75339. * A buffer points to binary geometry, animation, or skins
  75340. */
  75341. interface IBuffer extends IChildRootProperty {
  75342. /**
  75343. * 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
  75344. */
  75345. uri?: string;
  75346. /**
  75347. * The length of the buffer in bytes
  75348. */
  75349. byteLength: number;
  75350. }
  75351. /**
  75352. * A view into a buffer generally representing a subset of the buffer
  75353. */
  75354. interface IBufferView extends IChildRootProperty {
  75355. /**
  75356. * The index of the buffer
  75357. */
  75358. buffer: number;
  75359. /**
  75360. * The offset into the buffer in bytes
  75361. */
  75362. byteOffset?: number;
  75363. /**
  75364. * The lenth of the bufferView in bytes
  75365. */
  75366. byteLength: number;
  75367. /**
  75368. * The stride, in bytes
  75369. */
  75370. byteStride?: number;
  75371. }
  75372. /**
  75373. * An orthographic camera containing properties to create an orthographic projection matrix
  75374. */
  75375. interface ICameraOrthographic extends IProperty {
  75376. /**
  75377. * The floating-point horizontal magnification of the view. Must not be zero
  75378. */
  75379. xmag: number;
  75380. /**
  75381. * The floating-point vertical magnification of the view. Must not be zero
  75382. */
  75383. ymag: number;
  75384. /**
  75385. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  75386. */
  75387. zfar: number;
  75388. /**
  75389. * The floating-point distance to the near clipping plane
  75390. */
  75391. znear: number;
  75392. }
  75393. /**
  75394. * A perspective camera containing properties to create a perspective projection matrix
  75395. */
  75396. interface ICameraPerspective extends IProperty {
  75397. /**
  75398. * The floating-point aspect ratio of the field of view
  75399. */
  75400. aspectRatio?: number;
  75401. /**
  75402. * The floating-point vertical field of view in radians
  75403. */
  75404. yfov: number;
  75405. /**
  75406. * The floating-point distance to the far clipping plane
  75407. */
  75408. zfar?: number;
  75409. /**
  75410. * The floating-point distance to the near clipping plane
  75411. */
  75412. znear: number;
  75413. }
  75414. /**
  75415. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75416. */
  75417. interface ICamera extends IChildRootProperty {
  75418. /**
  75419. * An orthographic camera containing properties to create an orthographic projection matrix
  75420. */
  75421. orthographic?: ICameraOrthographic;
  75422. /**
  75423. * A perspective camera containing properties to create a perspective projection matrix
  75424. */
  75425. perspective?: ICameraPerspective;
  75426. /**
  75427. * Specifies if the camera uses a perspective or orthographic projection
  75428. */
  75429. type: CameraType;
  75430. }
  75431. /**
  75432. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  75433. */
  75434. interface IImage extends IChildRootProperty {
  75435. /**
  75436. * 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
  75437. */
  75438. uri?: string;
  75439. /**
  75440. * The image's MIME type
  75441. */
  75442. mimeType?: ImageMimeType;
  75443. /**
  75444. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  75445. */
  75446. bufferView?: number;
  75447. }
  75448. /**
  75449. * Material Normal Texture Info
  75450. */
  75451. interface IMaterialNormalTextureInfo extends ITextureInfo {
  75452. /**
  75453. * The scalar multiplier applied to each normal vector of the normal texture
  75454. */
  75455. scale?: number;
  75456. }
  75457. /**
  75458. * Material Occlusion Texture Info
  75459. */
  75460. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  75461. /**
  75462. * A scalar multiplier controlling the amount of occlusion applied
  75463. */
  75464. strength?: number;
  75465. }
  75466. /**
  75467. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  75468. */
  75469. interface IMaterialPbrMetallicRoughness {
  75470. /**
  75471. * The material's base color factor
  75472. */
  75473. baseColorFactor?: number[];
  75474. /**
  75475. * The base color texture
  75476. */
  75477. baseColorTexture?: ITextureInfo;
  75478. /**
  75479. * The metalness of the material
  75480. */
  75481. metallicFactor?: number;
  75482. /**
  75483. * The roughness of the material
  75484. */
  75485. roughnessFactor?: number;
  75486. /**
  75487. * The metallic-roughness texture
  75488. */
  75489. metallicRoughnessTexture?: ITextureInfo;
  75490. }
  75491. /**
  75492. * The material appearance of a primitive
  75493. */
  75494. interface IMaterial extends IChildRootProperty {
  75495. /**
  75496. * 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
  75497. */
  75498. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75499. /**
  75500. * The normal map texture
  75501. */
  75502. normalTexture?: IMaterialNormalTextureInfo;
  75503. /**
  75504. * The occlusion map texture
  75505. */
  75506. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75507. /**
  75508. * The emissive map texture
  75509. */
  75510. emissiveTexture?: ITextureInfo;
  75511. /**
  75512. * 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
  75513. */
  75514. emissiveFactor?: number[];
  75515. /**
  75516. * The alpha rendering mode of the material
  75517. */
  75518. alphaMode?: MaterialAlphaMode;
  75519. /**
  75520. * The alpha cutoff value of the material
  75521. */
  75522. alphaCutoff?: number;
  75523. /**
  75524. * Specifies whether the material is double sided
  75525. */
  75526. doubleSided?: boolean;
  75527. }
  75528. /**
  75529. * Geometry to be rendered with the given material
  75530. */
  75531. interface IMeshPrimitive extends IProperty {
  75532. /**
  75533. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  75534. */
  75535. attributes: {
  75536. [name: string]: number;
  75537. };
  75538. /**
  75539. * The index of the accessor that contains the indices
  75540. */
  75541. indices?: number;
  75542. /**
  75543. * The index of the material to apply to this primitive when rendering
  75544. */
  75545. material?: number;
  75546. /**
  75547. * The type of primitives to render. All valid values correspond to WebGL enums
  75548. */
  75549. mode?: MeshPrimitiveMode;
  75550. /**
  75551. * 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
  75552. */
  75553. targets?: {
  75554. [name: string]: number;
  75555. }[];
  75556. }
  75557. /**
  75558. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  75559. */
  75560. interface IMesh extends IChildRootProperty {
  75561. /**
  75562. * An array of primitives, each defining geometry to be rendered with a material
  75563. */
  75564. primitives: IMeshPrimitive[];
  75565. /**
  75566. * Array of weights to be applied to the Morph Targets
  75567. */
  75568. weights?: number[];
  75569. }
  75570. /**
  75571. * A node in the node hierarchy
  75572. */
  75573. interface INode extends IChildRootProperty {
  75574. /**
  75575. * The index of the camera referenced by this node
  75576. */
  75577. camera?: number;
  75578. /**
  75579. * The indices of this node's children
  75580. */
  75581. children?: number[];
  75582. /**
  75583. * The index of the skin referenced by this node
  75584. */
  75585. skin?: number;
  75586. /**
  75587. * A floating-point 4x4 transformation matrix stored in column-major order
  75588. */
  75589. matrix?: number[];
  75590. /**
  75591. * The index of the mesh in this node
  75592. */
  75593. mesh?: number;
  75594. /**
  75595. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  75596. */
  75597. rotation?: number[];
  75598. /**
  75599. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  75600. */
  75601. scale?: number[];
  75602. /**
  75603. * The node's translation along the x, y, and z axes
  75604. */
  75605. translation?: number[];
  75606. /**
  75607. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  75608. */
  75609. weights?: number[];
  75610. }
  75611. /**
  75612. * Texture sampler properties for filtering and wrapping modes
  75613. */
  75614. interface ISampler extends IChildRootProperty {
  75615. /**
  75616. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75617. */
  75618. magFilter?: TextureMagFilter;
  75619. /**
  75620. * Minification filter. All valid values correspond to WebGL enums
  75621. */
  75622. minFilter?: TextureMinFilter;
  75623. /**
  75624. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75625. */
  75626. wrapS?: TextureWrapMode;
  75627. /**
  75628. * T (V) wrapping mode. All valid values correspond to WebGL enums
  75629. */
  75630. wrapT?: TextureWrapMode;
  75631. }
  75632. /**
  75633. * The root nodes of a scene
  75634. */
  75635. interface IScene extends IChildRootProperty {
  75636. /**
  75637. * The indices of each root node
  75638. */
  75639. nodes: number[];
  75640. }
  75641. /**
  75642. * Joints and matrices defining a skin
  75643. */
  75644. interface ISkin extends IChildRootProperty {
  75645. /**
  75646. * 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
  75647. */
  75648. inverseBindMatrices?: number;
  75649. /**
  75650. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  75651. */
  75652. skeleton?: number;
  75653. /**
  75654. * 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)
  75655. */
  75656. joints: number[];
  75657. }
  75658. /**
  75659. * A texture and its sampler
  75660. */
  75661. interface ITexture extends IChildRootProperty {
  75662. /**
  75663. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  75664. */
  75665. sampler?: number;
  75666. /**
  75667. * The index of the image used by this texture
  75668. */
  75669. source: number;
  75670. }
  75671. /**
  75672. * Reference to a texture
  75673. */
  75674. interface ITextureInfo extends IProperty {
  75675. /**
  75676. * The index of the texture
  75677. */
  75678. index: number;
  75679. /**
  75680. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  75681. */
  75682. texCoord?: number;
  75683. }
  75684. /**
  75685. * The root object for a glTF asset
  75686. */
  75687. interface IGLTF extends IProperty {
  75688. /**
  75689. * An array of accessors. An accessor is a typed view into a bufferView
  75690. */
  75691. accessors?: IAccessor[];
  75692. /**
  75693. * An array of keyframe animations
  75694. */
  75695. animations?: IAnimation[];
  75696. /**
  75697. * Metadata about the glTF asset
  75698. */
  75699. asset: IAsset;
  75700. /**
  75701. * An array of buffers. A buffer points to binary geometry, animation, or skins
  75702. */
  75703. buffers?: IBuffer[];
  75704. /**
  75705. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  75706. */
  75707. bufferViews?: IBufferView[];
  75708. /**
  75709. * An array of cameras
  75710. */
  75711. cameras?: ICamera[];
  75712. /**
  75713. * Names of glTF extensions used somewhere in this asset
  75714. */
  75715. extensionsUsed?: string[];
  75716. /**
  75717. * Names of glTF extensions required to properly load this asset
  75718. */
  75719. extensionsRequired?: string[];
  75720. /**
  75721. * An array of images. An image defines data used to create a texture
  75722. */
  75723. images?: IImage[];
  75724. /**
  75725. * An array of materials. A material defines the appearance of a primitive
  75726. */
  75727. materials?: IMaterial[];
  75728. /**
  75729. * An array of meshes. A mesh is a set of primitives to be rendered
  75730. */
  75731. meshes?: IMesh[];
  75732. /**
  75733. * An array of nodes
  75734. */
  75735. nodes?: INode[];
  75736. /**
  75737. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  75738. */
  75739. samplers?: ISampler[];
  75740. /**
  75741. * The index of the default scene
  75742. */
  75743. scene?: number;
  75744. /**
  75745. * An array of scenes
  75746. */
  75747. scenes?: IScene[];
  75748. /**
  75749. * An array of skins. A skin is defined by joints and matrices
  75750. */
  75751. skins?: ISkin[];
  75752. /**
  75753. * An array of textures
  75754. */
  75755. textures?: ITexture[];
  75756. }
  75757. /**
  75758. * The glTF validation results
  75759. * @ignore
  75760. */
  75761. interface IGLTFValidationResults {
  75762. info: {
  75763. generator: string;
  75764. hasAnimations: boolean;
  75765. hasDefaultScene: boolean;
  75766. hasMaterials: boolean;
  75767. hasMorphTargets: boolean;
  75768. hasSkins: boolean;
  75769. hasTextures: boolean;
  75770. maxAttributesUsed: number;
  75771. primitivesCount: number
  75772. };
  75773. issues: {
  75774. messages: Array<string>;
  75775. numErrors: number;
  75776. numHints: number;
  75777. numInfos: number;
  75778. numWarnings: number;
  75779. truncated: boolean
  75780. };
  75781. mimeType: string;
  75782. uri: string;
  75783. validatedAt: string;
  75784. validatorVersion: string;
  75785. }
  75786. /**
  75787. * The glTF validation options
  75788. */
  75789. interface IGLTFValidationOptions {
  75790. /** Uri to use */
  75791. uri?: string;
  75792. /** Function used to load external resources */
  75793. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  75794. /** Boolean indicating that we need to validate accessor data */
  75795. validateAccessorData?: boolean;
  75796. /** max number of issues allowed */
  75797. maxIssues?: number;
  75798. /** Ignored issues */
  75799. ignoredIssues?: Array<string>;
  75800. /** Value to override severy settings */
  75801. severityOverrides?: Object;
  75802. }
  75803. /**
  75804. * The glTF validator object
  75805. * @ignore
  75806. */
  75807. interface IGLTFValidator {
  75808. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75809. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  75810. }
  75811. }
  75812. declare module BABYLON {
  75813. /** @hidden */
  75814. export var cellPixelShader: {
  75815. name: string;
  75816. shader: string;
  75817. };
  75818. }
  75819. declare module BABYLON {
  75820. /** @hidden */
  75821. export var cellVertexShader: {
  75822. name: string;
  75823. shader: string;
  75824. };
  75825. }
  75826. declare module BABYLON {
  75827. export class CellMaterial extends BABYLON.PushMaterial {
  75828. private _diffuseTexture;
  75829. diffuseTexture: BABYLON.BaseTexture;
  75830. diffuseColor: BABYLON.Color3;
  75831. _computeHighLevel: boolean;
  75832. computeHighLevel: boolean;
  75833. private _disableLighting;
  75834. disableLighting: boolean;
  75835. private _maxSimultaneousLights;
  75836. maxSimultaneousLights: number;
  75837. private _renderId;
  75838. constructor(name: string, scene: BABYLON.Scene);
  75839. needAlphaBlending(): boolean;
  75840. needAlphaTesting(): boolean;
  75841. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75842. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75843. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75844. getAnimatables(): BABYLON.IAnimatable[];
  75845. getActiveTextures(): BABYLON.BaseTexture[];
  75846. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75847. dispose(forceDisposeEffect?: boolean): void;
  75848. getClassName(): string;
  75849. clone(name: string): CellMaterial;
  75850. serialize(): any;
  75851. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  75852. }
  75853. }
  75854. declare module BABYLON {
  75855. export class CustomShaderStructure {
  75856. FragmentStore: string;
  75857. VertexStore: string;
  75858. constructor();
  75859. }
  75860. export class ShaderSpecialParts {
  75861. constructor();
  75862. Fragment_Begin: string;
  75863. Fragment_Definitions: string;
  75864. Fragment_MainBegin: string;
  75865. Fragment_Custom_Diffuse: string;
  75866. Fragment_Before_Lights: string;
  75867. Fragment_Before_Fog: string;
  75868. Fragment_Custom_Alpha: string;
  75869. Fragment_Before_FragColor: string;
  75870. Vertex_Begin: string;
  75871. Vertex_Definitions: string;
  75872. Vertex_MainBegin: string;
  75873. Vertex_Before_PositionUpdated: string;
  75874. Vertex_Before_NormalUpdated: string;
  75875. Vertex_MainEnd: string;
  75876. }
  75877. export class CustomMaterial extends BABYLON.StandardMaterial {
  75878. static ShaderIndexer: number;
  75879. CustomParts: ShaderSpecialParts;
  75880. _isCreatedShader: boolean;
  75881. _createdShaderName: string;
  75882. _customUniform: string[];
  75883. _newUniforms: string[];
  75884. _newUniformInstances: any[];
  75885. _newSamplerInstances: BABYLON.Texture[];
  75886. FragmentShader: string;
  75887. VertexShader: string;
  75888. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75889. ReviewUniform(name: string, arr: string[]): string[];
  75890. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  75891. constructor(name: string, scene: BABYLON.Scene);
  75892. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  75893. Fragment_Begin(shaderPart: string): CustomMaterial;
  75894. Fragment_Definitions(shaderPart: string): CustomMaterial;
  75895. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  75896. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  75897. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  75898. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  75899. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  75900. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  75901. Vertex_Begin(shaderPart: string): CustomMaterial;
  75902. Vertex_Definitions(shaderPart: string): CustomMaterial;
  75903. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  75904. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  75905. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  75906. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  75907. }
  75908. }
  75909. declare module BABYLON {
  75910. export class ShaderAlebdoParts {
  75911. constructor();
  75912. Fragment_Begin: string;
  75913. Fragment_Definitions: string;
  75914. Fragment_MainBegin: string;
  75915. Fragment_Custom_Albedo: string;
  75916. Fragment_Before_Lights: string;
  75917. Fragment_Custom_MetallicRoughness: string;
  75918. Fragment_Custom_MicroSurface: string;
  75919. Fragment_Before_Fog: string;
  75920. Fragment_Custom_Alpha: string;
  75921. Fragment_Before_FragColor: string;
  75922. Vertex_Begin: string;
  75923. Vertex_Definitions: string;
  75924. Vertex_MainBegin: string;
  75925. Vertex_Before_PositionUpdated: string;
  75926. Vertex_Before_NormalUpdated: string;
  75927. Vertex_MainEnd: string;
  75928. }
  75929. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75930. static ShaderIndexer: number;
  75931. CustomParts: ShaderAlebdoParts;
  75932. _isCreatedShader: boolean;
  75933. _createdShaderName: string;
  75934. _customUniform: string[];
  75935. _newUniforms: string[];
  75936. _newUniformInstances: any[];
  75937. _newSamplerInstances: BABYLON.Texture[];
  75938. FragmentShader: string;
  75939. VertexShader: string;
  75940. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75941. ReviewUniform(name: string, arr: string[]): string[];
  75942. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75943. constructor(name: string, scene: BABYLON.Scene);
  75944. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75945. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75946. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75947. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75948. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75949. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75950. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75951. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75952. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75953. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75954. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75955. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75956. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75957. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75958. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75959. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75960. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75961. }
  75962. }
  75963. declare module BABYLON {
  75964. /** @hidden */
  75965. export var firePixelShader: {
  75966. name: string;
  75967. shader: string;
  75968. };
  75969. }
  75970. declare module BABYLON {
  75971. /** @hidden */
  75972. export var fireVertexShader: {
  75973. name: string;
  75974. shader: string;
  75975. };
  75976. }
  75977. declare module BABYLON {
  75978. export class FireMaterial extends BABYLON.PushMaterial {
  75979. private _diffuseTexture;
  75980. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75981. private _distortionTexture;
  75982. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75983. private _opacityTexture;
  75984. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75985. diffuseColor: BABYLON.Color3;
  75986. speed: number;
  75987. private _scaledDiffuse;
  75988. private _renderId;
  75989. private _lastTime;
  75990. constructor(name: string, scene: BABYLON.Scene);
  75991. needAlphaBlending(): boolean;
  75992. needAlphaTesting(): boolean;
  75993. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75994. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75995. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75996. getAnimatables(): BABYLON.IAnimatable[];
  75997. getActiveTextures(): BABYLON.BaseTexture[];
  75998. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75999. getClassName(): string;
  76000. dispose(forceDisposeEffect?: boolean): void;
  76001. clone(name: string): FireMaterial;
  76002. serialize(): any;
  76003. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  76004. }
  76005. }
  76006. declare module BABYLON {
  76007. /** @hidden */
  76008. export var furPixelShader: {
  76009. name: string;
  76010. shader: string;
  76011. };
  76012. }
  76013. declare module BABYLON {
  76014. /** @hidden */
  76015. export var furVertexShader: {
  76016. name: string;
  76017. shader: string;
  76018. };
  76019. }
  76020. declare module BABYLON {
  76021. export class FurMaterial extends BABYLON.PushMaterial {
  76022. private _diffuseTexture;
  76023. diffuseTexture: BABYLON.BaseTexture;
  76024. private _heightTexture;
  76025. heightTexture: BABYLON.BaseTexture;
  76026. diffuseColor: BABYLON.Color3;
  76027. furLength: number;
  76028. furAngle: number;
  76029. furColor: BABYLON.Color3;
  76030. furOffset: number;
  76031. furSpacing: number;
  76032. furGravity: BABYLON.Vector3;
  76033. furSpeed: number;
  76034. furDensity: number;
  76035. furOcclusion: number;
  76036. furTexture: BABYLON.DynamicTexture;
  76037. private _disableLighting;
  76038. disableLighting: boolean;
  76039. private _maxSimultaneousLights;
  76040. maxSimultaneousLights: number;
  76041. highLevelFur: boolean;
  76042. _meshes: BABYLON.AbstractMesh[];
  76043. private _renderId;
  76044. private _furTime;
  76045. constructor(name: string, scene: BABYLON.Scene);
  76046. get furTime(): number;
  76047. set furTime(furTime: number);
  76048. needAlphaBlending(): boolean;
  76049. needAlphaTesting(): boolean;
  76050. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76051. updateFur(): void;
  76052. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76053. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76054. getAnimatables(): BABYLON.IAnimatable[];
  76055. getActiveTextures(): BABYLON.BaseTexture[];
  76056. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76057. dispose(forceDisposeEffect?: boolean): void;
  76058. clone(name: string): FurMaterial;
  76059. serialize(): any;
  76060. getClassName(): string;
  76061. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  76062. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  76063. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  76064. }
  76065. }
  76066. declare module BABYLON {
  76067. /** @hidden */
  76068. export var gradientPixelShader: {
  76069. name: string;
  76070. shader: string;
  76071. };
  76072. }
  76073. declare module BABYLON {
  76074. /** @hidden */
  76075. export var gradientVertexShader: {
  76076. name: string;
  76077. shader: string;
  76078. };
  76079. }
  76080. declare module BABYLON {
  76081. export class GradientMaterial extends BABYLON.PushMaterial {
  76082. private _maxSimultaneousLights;
  76083. maxSimultaneousLights: number;
  76084. topColor: BABYLON.Color3;
  76085. topColorAlpha: number;
  76086. bottomColor: BABYLON.Color3;
  76087. bottomColorAlpha: number;
  76088. offset: number;
  76089. scale: number;
  76090. smoothness: number;
  76091. private _disableLighting;
  76092. disableLighting: boolean;
  76093. private _renderId;
  76094. constructor(name: string, scene: BABYLON.Scene);
  76095. needAlphaBlending(): boolean;
  76096. needAlphaTesting(): boolean;
  76097. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76098. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76099. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76100. getAnimatables(): BABYLON.IAnimatable[];
  76101. dispose(forceDisposeEffect?: boolean): void;
  76102. clone(name: string): GradientMaterial;
  76103. serialize(): any;
  76104. getClassName(): string;
  76105. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  76106. }
  76107. }
  76108. declare module BABYLON {
  76109. /** @hidden */
  76110. export var gridPixelShader: {
  76111. name: string;
  76112. shader: string;
  76113. };
  76114. }
  76115. declare module BABYLON {
  76116. /** @hidden */
  76117. export var gridVertexShader: {
  76118. name: string;
  76119. shader: string;
  76120. };
  76121. }
  76122. declare module BABYLON {
  76123. /**
  76124. * The grid materials allows you to wrap any shape with a grid.
  76125. * Colors are customizable.
  76126. */
  76127. export class GridMaterial extends BABYLON.PushMaterial {
  76128. /**
  76129. * Main color of the grid (e.g. between lines)
  76130. */
  76131. mainColor: BABYLON.Color3;
  76132. /**
  76133. * Color of the grid lines.
  76134. */
  76135. lineColor: BABYLON.Color3;
  76136. /**
  76137. * The scale of the grid compared to unit.
  76138. */
  76139. gridRatio: number;
  76140. /**
  76141. * Allows setting an offset for the grid lines.
  76142. */
  76143. gridOffset: BABYLON.Vector3;
  76144. /**
  76145. * The frequency of thicker lines.
  76146. */
  76147. majorUnitFrequency: number;
  76148. /**
  76149. * The visibility of minor units in the grid.
  76150. */
  76151. minorUnitVisibility: number;
  76152. /**
  76153. * The grid opacity outside of the lines.
  76154. */
  76155. opacity: number;
  76156. /**
  76157. * Determine RBG output is premultiplied by alpha value.
  76158. */
  76159. preMultiplyAlpha: boolean;
  76160. private _opacityTexture;
  76161. opacityTexture: BABYLON.BaseTexture;
  76162. private _gridControl;
  76163. private _renderId;
  76164. /**
  76165. * constructor
  76166. * @param name The name given to the material in order to identify it afterwards.
  76167. * @param scene The scene the material is used in.
  76168. */
  76169. constructor(name: string, scene: BABYLON.Scene);
  76170. /**
  76171. * Returns wehter or not the grid requires alpha blending.
  76172. */
  76173. needAlphaBlending(): boolean;
  76174. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76175. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76176. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76177. /**
  76178. * Dispose the material and its associated resources.
  76179. * @param forceDisposeEffect will also dispose the used effect when true
  76180. */
  76181. dispose(forceDisposeEffect?: boolean): void;
  76182. clone(name: string): GridMaterial;
  76183. serialize(): any;
  76184. getClassName(): string;
  76185. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  76186. }
  76187. }
  76188. declare module BABYLON {
  76189. /** @hidden */
  76190. export var lavaPixelShader: {
  76191. name: string;
  76192. shader: string;
  76193. };
  76194. }
  76195. declare module BABYLON {
  76196. /** @hidden */
  76197. export var lavaVertexShader: {
  76198. name: string;
  76199. shader: string;
  76200. };
  76201. }
  76202. declare module BABYLON {
  76203. export class LavaMaterial extends BABYLON.PushMaterial {
  76204. private _diffuseTexture;
  76205. diffuseTexture: BABYLON.BaseTexture;
  76206. noiseTexture: BABYLON.BaseTexture;
  76207. fogColor: BABYLON.Color3;
  76208. speed: number;
  76209. movingSpeed: number;
  76210. lowFrequencySpeed: number;
  76211. fogDensity: number;
  76212. private _lastTime;
  76213. diffuseColor: BABYLON.Color3;
  76214. private _disableLighting;
  76215. disableLighting: boolean;
  76216. private _unlit;
  76217. unlit: boolean;
  76218. private _maxSimultaneousLights;
  76219. maxSimultaneousLights: number;
  76220. private _scaledDiffuse;
  76221. private _renderId;
  76222. constructor(name: string, scene: BABYLON.Scene);
  76223. needAlphaBlending(): boolean;
  76224. needAlphaTesting(): boolean;
  76225. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76226. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76227. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76228. getAnimatables(): BABYLON.IAnimatable[];
  76229. getActiveTextures(): BABYLON.BaseTexture[];
  76230. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76231. dispose(forceDisposeEffect?: boolean): void;
  76232. clone(name: string): LavaMaterial;
  76233. serialize(): any;
  76234. getClassName(): string;
  76235. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  76236. }
  76237. }
  76238. declare module BABYLON {
  76239. /** @hidden */
  76240. export var mixPixelShader: {
  76241. name: string;
  76242. shader: string;
  76243. };
  76244. }
  76245. declare module BABYLON {
  76246. /** @hidden */
  76247. export var mixVertexShader: {
  76248. name: string;
  76249. shader: string;
  76250. };
  76251. }
  76252. declare module BABYLON {
  76253. export class MixMaterial extends BABYLON.PushMaterial {
  76254. /**
  76255. * Mix textures
  76256. */
  76257. private _mixTexture1;
  76258. mixTexture1: BABYLON.BaseTexture;
  76259. private _mixTexture2;
  76260. mixTexture2: BABYLON.BaseTexture;
  76261. /**
  76262. * Diffuse textures
  76263. */
  76264. private _diffuseTexture1;
  76265. diffuseTexture1: BABYLON.Texture;
  76266. private _diffuseTexture2;
  76267. diffuseTexture2: BABYLON.Texture;
  76268. private _diffuseTexture3;
  76269. diffuseTexture3: BABYLON.Texture;
  76270. private _diffuseTexture4;
  76271. diffuseTexture4: BABYLON.Texture;
  76272. private _diffuseTexture5;
  76273. diffuseTexture5: BABYLON.Texture;
  76274. private _diffuseTexture6;
  76275. diffuseTexture6: BABYLON.Texture;
  76276. private _diffuseTexture7;
  76277. diffuseTexture7: BABYLON.Texture;
  76278. private _diffuseTexture8;
  76279. diffuseTexture8: BABYLON.Texture;
  76280. /**
  76281. * Uniforms
  76282. */
  76283. diffuseColor: BABYLON.Color3;
  76284. specularColor: BABYLON.Color3;
  76285. specularPower: number;
  76286. private _disableLighting;
  76287. disableLighting: boolean;
  76288. private _maxSimultaneousLights;
  76289. maxSimultaneousLights: number;
  76290. private _renderId;
  76291. constructor(name: string, scene: BABYLON.Scene);
  76292. needAlphaBlending(): boolean;
  76293. needAlphaTesting(): boolean;
  76294. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76295. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76296. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76297. getAnimatables(): BABYLON.IAnimatable[];
  76298. getActiveTextures(): BABYLON.BaseTexture[];
  76299. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76300. dispose(forceDisposeEffect?: boolean): void;
  76301. clone(name: string): MixMaterial;
  76302. serialize(): any;
  76303. getClassName(): string;
  76304. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  76305. }
  76306. }
  76307. declare module BABYLON {
  76308. /** @hidden */
  76309. export var normalPixelShader: {
  76310. name: string;
  76311. shader: string;
  76312. };
  76313. }
  76314. declare module BABYLON {
  76315. /** @hidden */
  76316. export var normalVertexShader: {
  76317. name: string;
  76318. shader: string;
  76319. };
  76320. }
  76321. declare module BABYLON {
  76322. export class NormalMaterial extends BABYLON.PushMaterial {
  76323. private _diffuseTexture;
  76324. diffuseTexture: BABYLON.BaseTexture;
  76325. diffuseColor: BABYLON.Color3;
  76326. private _disableLighting;
  76327. disableLighting: boolean;
  76328. private _maxSimultaneousLights;
  76329. maxSimultaneousLights: number;
  76330. private _renderId;
  76331. constructor(name: string, scene: BABYLON.Scene);
  76332. needAlphaBlending(): boolean;
  76333. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76334. needAlphaTesting(): boolean;
  76335. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76336. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76337. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76338. getAnimatables(): BABYLON.IAnimatable[];
  76339. getActiveTextures(): BABYLON.BaseTexture[];
  76340. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76341. dispose(forceDisposeEffect?: boolean): void;
  76342. clone(name: string): NormalMaterial;
  76343. serialize(): any;
  76344. getClassName(): string;
  76345. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  76346. }
  76347. }
  76348. declare module BABYLON {
  76349. /** @hidden */
  76350. export var shadowOnlyPixelShader: {
  76351. name: string;
  76352. shader: string;
  76353. };
  76354. }
  76355. declare module BABYLON {
  76356. /** @hidden */
  76357. export var shadowOnlyVertexShader: {
  76358. name: string;
  76359. shader: string;
  76360. };
  76361. }
  76362. declare module BABYLON {
  76363. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  76364. private _renderId;
  76365. private _activeLight;
  76366. constructor(name: string, scene: BABYLON.Scene);
  76367. shadowColor: BABYLON.Color3;
  76368. needAlphaBlending(): boolean;
  76369. needAlphaTesting(): boolean;
  76370. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76371. get activeLight(): BABYLON.IShadowLight;
  76372. set activeLight(light: BABYLON.IShadowLight);
  76373. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76374. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76375. clone(name: string): ShadowOnlyMaterial;
  76376. serialize(): any;
  76377. getClassName(): string;
  76378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  76379. }
  76380. }
  76381. declare module BABYLON {
  76382. /** @hidden */
  76383. export var simplePixelShader: {
  76384. name: string;
  76385. shader: string;
  76386. };
  76387. }
  76388. declare module BABYLON {
  76389. /** @hidden */
  76390. export var simpleVertexShader: {
  76391. name: string;
  76392. shader: string;
  76393. };
  76394. }
  76395. declare module BABYLON {
  76396. export class SimpleMaterial extends BABYLON.PushMaterial {
  76397. private _diffuseTexture;
  76398. diffuseTexture: BABYLON.BaseTexture;
  76399. diffuseColor: BABYLON.Color3;
  76400. private _disableLighting;
  76401. disableLighting: boolean;
  76402. private _maxSimultaneousLights;
  76403. maxSimultaneousLights: number;
  76404. private _renderId;
  76405. constructor(name: string, scene: BABYLON.Scene);
  76406. needAlphaBlending(): boolean;
  76407. needAlphaTesting(): boolean;
  76408. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76409. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76410. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76411. getAnimatables(): BABYLON.IAnimatable[];
  76412. getActiveTextures(): BABYLON.BaseTexture[];
  76413. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76414. dispose(forceDisposeEffect?: boolean): void;
  76415. clone(name: string): SimpleMaterial;
  76416. serialize(): any;
  76417. getClassName(): string;
  76418. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  76419. }
  76420. }
  76421. declare module BABYLON {
  76422. /** @hidden */
  76423. export var skyPixelShader: {
  76424. name: string;
  76425. shader: string;
  76426. };
  76427. }
  76428. declare module BABYLON {
  76429. /** @hidden */
  76430. export var skyVertexShader: {
  76431. name: string;
  76432. shader: string;
  76433. };
  76434. }
  76435. declare module BABYLON {
  76436. /**
  76437. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  76438. * @see https://doc.babylonjs.com/extensions/sky
  76439. */
  76440. export class SkyMaterial extends BABYLON.PushMaterial {
  76441. /**
  76442. * Defines the overall luminance of sky in interval ]0, 1[.
  76443. */
  76444. luminance: number;
  76445. /**
  76446. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  76447. */
  76448. turbidity: number;
  76449. /**
  76450. * Defines the sky appearance (light intensity).
  76451. */
  76452. rayleigh: number;
  76453. /**
  76454. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  76455. */
  76456. mieCoefficient: number;
  76457. /**
  76458. * Defines the amount of haze particles following the Mie scattering theory.
  76459. */
  76460. mieDirectionalG: number;
  76461. /**
  76462. * Defines the distance of the sun according to the active scene camera.
  76463. */
  76464. distance: number;
  76465. /**
  76466. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  76467. * "inclined".
  76468. */
  76469. inclination: number;
  76470. /**
  76471. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  76472. * an object direction and a reference direction.
  76473. */
  76474. azimuth: number;
  76475. /**
  76476. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  76477. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  76478. */
  76479. sunPosition: BABYLON.Vector3;
  76480. /**
  76481. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  76482. * .sunPosition property.
  76483. */
  76484. useSunPosition: boolean;
  76485. /**
  76486. * Defines an offset vector used to get a horizon offset.
  76487. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  76488. */
  76489. cameraOffset: BABYLON.Vector3;
  76490. private _cameraPosition;
  76491. private _renderId;
  76492. /**
  76493. * Instantiates a new sky material.
  76494. * This material allows to create dynamic and texture free
  76495. * effects for skyboxes by taking care of the atmosphere state.
  76496. * @see https://doc.babylonjs.com/extensions/sky
  76497. * @param name Define the name of the material in the scene
  76498. * @param scene Define the scene the material belong to
  76499. */
  76500. constructor(name: string, scene: BABYLON.Scene);
  76501. /**
  76502. * Specifies if the material will require alpha blending
  76503. * @returns a boolean specifying if alpha blending is needed
  76504. */
  76505. needAlphaBlending(): boolean;
  76506. /**
  76507. * Specifies if this material should be rendered in alpha test mode
  76508. * @returns false as the sky material doesn't need alpha testing.
  76509. */
  76510. needAlphaTesting(): boolean;
  76511. /**
  76512. * Get the texture used for alpha test purpose.
  76513. * @returns null as the sky material has no texture.
  76514. */
  76515. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76516. /**
  76517. * Get if the submesh is ready to be used and all its information available.
  76518. * Child classes can use it to update shaders
  76519. * @param mesh defines the mesh to check
  76520. * @param subMesh defines which submesh to check
  76521. * @param useInstances specifies that instances should be used
  76522. * @returns a boolean indicating that the submesh is ready or not
  76523. */
  76524. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76525. /**
  76526. * Binds the submesh to this material by preparing the effect and shader to draw
  76527. * @param world defines the world transformation matrix
  76528. * @param mesh defines the mesh containing the submesh
  76529. * @param subMesh defines the submesh to bind the material to
  76530. */
  76531. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76532. /**
  76533. * Get the list of animatables in the material.
  76534. * @returns the list of animatables object used in the material
  76535. */
  76536. getAnimatables(): BABYLON.IAnimatable[];
  76537. /**
  76538. * Disposes the material
  76539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76540. */
  76541. dispose(forceDisposeEffect?: boolean): void;
  76542. /**
  76543. * Makes a duplicate of the material, and gives it a new name
  76544. * @param name defines the new name for the duplicated material
  76545. * @returns the cloned material
  76546. */
  76547. clone(name: string): SkyMaterial;
  76548. /**
  76549. * Serializes this material in a JSON representation
  76550. * @returns the serialized material object
  76551. */
  76552. serialize(): any;
  76553. /**
  76554. * Gets the current class name of the material e.g. "SkyMaterial"
  76555. * Mainly use in serialization.
  76556. * @returns the class name
  76557. */
  76558. getClassName(): string;
  76559. /**
  76560. * Creates a sky material from parsed material data
  76561. * @param source defines the JSON representation of the material
  76562. * @param scene defines the hosting scene
  76563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76564. * @returns a new sky material
  76565. */
  76566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  76567. }
  76568. }
  76569. declare module BABYLON {
  76570. /** @hidden */
  76571. export var terrainPixelShader: {
  76572. name: string;
  76573. shader: string;
  76574. };
  76575. }
  76576. declare module BABYLON {
  76577. /** @hidden */
  76578. export var terrainVertexShader: {
  76579. name: string;
  76580. shader: string;
  76581. };
  76582. }
  76583. declare module BABYLON {
  76584. export class TerrainMaterial extends BABYLON.PushMaterial {
  76585. private _mixTexture;
  76586. mixTexture: BABYLON.BaseTexture;
  76587. private _diffuseTexture1;
  76588. diffuseTexture1: BABYLON.Texture;
  76589. private _diffuseTexture2;
  76590. diffuseTexture2: BABYLON.Texture;
  76591. private _diffuseTexture3;
  76592. diffuseTexture3: BABYLON.Texture;
  76593. private _bumpTexture1;
  76594. bumpTexture1: BABYLON.Texture;
  76595. private _bumpTexture2;
  76596. bumpTexture2: BABYLON.Texture;
  76597. private _bumpTexture3;
  76598. bumpTexture3: BABYLON.Texture;
  76599. diffuseColor: BABYLON.Color3;
  76600. specularColor: BABYLON.Color3;
  76601. specularPower: number;
  76602. private _disableLighting;
  76603. disableLighting: boolean;
  76604. private _maxSimultaneousLights;
  76605. maxSimultaneousLights: number;
  76606. private _renderId;
  76607. constructor(name: string, scene: BABYLON.Scene);
  76608. needAlphaBlending(): boolean;
  76609. needAlphaTesting(): boolean;
  76610. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76611. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76613. getAnimatables(): BABYLON.IAnimatable[];
  76614. getActiveTextures(): BABYLON.BaseTexture[];
  76615. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76616. dispose(forceDisposeEffect?: boolean): void;
  76617. clone(name: string): TerrainMaterial;
  76618. serialize(): any;
  76619. getClassName(): string;
  76620. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  76621. }
  76622. }
  76623. declare module BABYLON {
  76624. /** @hidden */
  76625. export var triplanarPixelShader: {
  76626. name: string;
  76627. shader: string;
  76628. };
  76629. }
  76630. declare module BABYLON {
  76631. /** @hidden */
  76632. export var triplanarVertexShader: {
  76633. name: string;
  76634. shader: string;
  76635. };
  76636. }
  76637. declare module BABYLON {
  76638. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  76639. mixTexture: BABYLON.BaseTexture;
  76640. private _diffuseTextureX;
  76641. diffuseTextureX: BABYLON.BaseTexture;
  76642. private _diffuseTextureY;
  76643. diffuseTextureY: BABYLON.BaseTexture;
  76644. private _diffuseTextureZ;
  76645. diffuseTextureZ: BABYLON.BaseTexture;
  76646. private _normalTextureX;
  76647. normalTextureX: BABYLON.BaseTexture;
  76648. private _normalTextureY;
  76649. normalTextureY: BABYLON.BaseTexture;
  76650. private _normalTextureZ;
  76651. normalTextureZ: BABYLON.BaseTexture;
  76652. tileSize: number;
  76653. diffuseColor: BABYLON.Color3;
  76654. specularColor: BABYLON.Color3;
  76655. specularPower: number;
  76656. private _disableLighting;
  76657. disableLighting: boolean;
  76658. private _maxSimultaneousLights;
  76659. maxSimultaneousLights: number;
  76660. private _renderId;
  76661. constructor(name: string, scene: BABYLON.Scene);
  76662. needAlphaBlending(): boolean;
  76663. needAlphaTesting(): boolean;
  76664. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76665. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76666. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76667. getAnimatables(): BABYLON.IAnimatable[];
  76668. getActiveTextures(): BABYLON.BaseTexture[];
  76669. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76670. dispose(forceDisposeEffect?: boolean): void;
  76671. clone(name: string): TriPlanarMaterial;
  76672. serialize(): any;
  76673. getClassName(): string;
  76674. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  76675. }
  76676. }
  76677. declare module BABYLON {
  76678. /** @hidden */
  76679. export var waterPixelShader: {
  76680. name: string;
  76681. shader: string;
  76682. };
  76683. }
  76684. declare module BABYLON {
  76685. /** @hidden */
  76686. export var waterVertexShader: {
  76687. name: string;
  76688. shader: string;
  76689. };
  76690. }
  76691. declare module BABYLON {
  76692. export class WaterMaterial extends BABYLON.PushMaterial {
  76693. renderTargetSize: BABYLON.Vector2;
  76694. private _bumpTexture;
  76695. bumpTexture: BABYLON.BaseTexture;
  76696. diffuseColor: BABYLON.Color3;
  76697. specularColor: BABYLON.Color3;
  76698. specularPower: number;
  76699. private _disableLighting;
  76700. disableLighting: boolean;
  76701. private _maxSimultaneousLights;
  76702. maxSimultaneousLights: number;
  76703. /**
  76704. * @param {number}: Represents the wind force
  76705. */
  76706. windForce: number;
  76707. /**
  76708. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  76709. */
  76710. windDirection: BABYLON.Vector2;
  76711. /**
  76712. * @param {number}: Wave height, represents the height of the waves
  76713. */
  76714. waveHeight: number;
  76715. /**
  76716. * @param {number}: Bump height, represents the bump height related to the bump map
  76717. */
  76718. bumpHeight: number;
  76719. /**
  76720. * @param {boolean}: Add a smaller moving bump to less steady waves.
  76721. */
  76722. private _bumpSuperimpose;
  76723. bumpSuperimpose: boolean;
  76724. /**
  76725. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  76726. */
  76727. private _fresnelSeparate;
  76728. fresnelSeparate: boolean;
  76729. /**
  76730. * @param {boolean}: bump Waves modify the reflection.
  76731. */
  76732. private _bumpAffectsReflection;
  76733. bumpAffectsReflection: boolean;
  76734. /**
  76735. * @param {number}: The water color blended with the refraction (near)
  76736. */
  76737. waterColor: BABYLON.Color3;
  76738. /**
  76739. * @param {number}: The blend factor related to the water color
  76740. */
  76741. colorBlendFactor: number;
  76742. /**
  76743. * @param {number}: The water color blended with the reflection (far)
  76744. */
  76745. waterColor2: BABYLON.Color3;
  76746. /**
  76747. * @param {number}: The blend factor related to the water color (reflection, far)
  76748. */
  76749. colorBlendFactor2: number;
  76750. /**
  76751. * @param {number}: Represents the maximum length of a wave
  76752. */
  76753. waveLength: number;
  76754. /**
  76755. * @param {number}: Defines the waves speed
  76756. */
  76757. waveSpeed: number;
  76758. /**
  76759. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  76760. * will avoid calculating useless pixels in the pixel shader of the water material.
  76761. */
  76762. disableClipPlane: boolean;
  76763. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  76764. private _mesh;
  76765. private _refractionRTT;
  76766. private _reflectionRTT;
  76767. private _reflectionTransform;
  76768. private _lastTime;
  76769. private _lastDeltaTime;
  76770. private _renderId;
  76771. private _useLogarithmicDepth;
  76772. private _waitingRenderList;
  76773. private _imageProcessingConfiguration;
  76774. private _imageProcessingObserver;
  76775. /**
  76776. * Gets a boolean indicating that current material needs to register RTT
  76777. */
  76778. get hasRenderTargetTextures(): boolean;
  76779. /**
  76780. * Constructor
  76781. */
  76782. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  76783. get useLogarithmicDepth(): boolean;
  76784. set useLogarithmicDepth(value: boolean);
  76785. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76786. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  76787. addToRenderList(node: any): void;
  76788. enableRenderTargets(enable: boolean): void;
  76789. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  76790. get renderTargetsEnabled(): boolean;
  76791. needAlphaBlending(): boolean;
  76792. needAlphaTesting(): boolean;
  76793. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76794. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76795. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76796. private _createRenderTargets;
  76797. getAnimatables(): BABYLON.IAnimatable[];
  76798. getActiveTextures(): BABYLON.BaseTexture[];
  76799. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76800. dispose(forceDisposeEffect?: boolean): void;
  76801. clone(name: string): WaterMaterial;
  76802. serialize(): any;
  76803. getClassName(): string;
  76804. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  76805. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  76806. }
  76807. }
  76808. declare module BABYLON {
  76809. /** @hidden */
  76810. export var asciiartPixelShader: {
  76811. name: string;
  76812. shader: string;
  76813. };
  76814. }
  76815. declare module BABYLON {
  76816. /**
  76817. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  76818. *
  76819. * It basically takes care rendering the font front the given font size to a texture.
  76820. * This is used later on in the postprocess.
  76821. */
  76822. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  76823. private _font;
  76824. private _text;
  76825. private _charSize;
  76826. /**
  76827. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76828. */
  76829. get charSize(): number;
  76830. /**
  76831. * Create a new instance of the Ascii Art FontTexture class
  76832. * @param name the name of the texture
  76833. * @param font the font to use, use the W3C CSS notation
  76834. * @param text the caracter set to use in the rendering.
  76835. * @param scene the scene that owns the texture
  76836. */
  76837. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76838. /**
  76839. * Gets the max char width of a font.
  76840. * @param font the font to use, use the W3C CSS notation
  76841. * @return the max char width
  76842. */
  76843. private getFontWidth;
  76844. /**
  76845. * Gets the max char height of a font.
  76846. * @param font the font to use, use the W3C CSS notation
  76847. * @return the max char height
  76848. */
  76849. private getFontHeight;
  76850. /**
  76851. * Clones the current AsciiArtTexture.
  76852. * @return the clone of the texture.
  76853. */
  76854. clone(): AsciiArtFontTexture;
  76855. /**
  76856. * Parses a json object representing the texture and returns an instance of it.
  76857. * @param source the source JSON representation
  76858. * @param scene the scene to create the texture for
  76859. * @return the parsed texture
  76860. */
  76861. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  76862. }
  76863. /**
  76864. * Option available in the Ascii Art Post Process.
  76865. */
  76866. export interface IAsciiArtPostProcessOptions {
  76867. /**
  76868. * The font to use following the w3c font definition.
  76869. */
  76870. font?: string;
  76871. /**
  76872. * The character set to use in the postprocess.
  76873. */
  76874. characterSet?: string;
  76875. /**
  76876. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76877. * This number is defined between 0 and 1;
  76878. */
  76879. mixToTile?: number;
  76880. /**
  76881. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76882. * This number is defined between 0 and 1;
  76883. */
  76884. mixToNormal?: number;
  76885. }
  76886. /**
  76887. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  76888. *
  76889. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76890. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  76891. */
  76892. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  76893. /**
  76894. * The font texture used to render the char in the post process.
  76895. */
  76896. private _asciiArtFontTexture;
  76897. /**
  76898. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  76899. * This number is defined between 0 and 1;
  76900. */
  76901. mixToTile: number;
  76902. /**
  76903. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  76904. * This number is defined between 0 and 1;
  76905. */
  76906. mixToNormal: number;
  76907. /**
  76908. * Instantiates a new Ascii Art Post Process.
  76909. * @param name the name to give to the postprocess
  76910. * @camera the camera to apply the post process to.
  76911. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76912. */
  76913. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76914. }
  76915. }
  76916. declare module BABYLON {
  76917. /** @hidden */
  76918. export var digitalrainPixelShader: {
  76919. name: string;
  76920. shader: string;
  76921. };
  76922. }
  76923. declare module BABYLON {
  76924. /**
  76925. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76926. *
  76927. * It basically takes care rendering the font front the given font size to a texture.
  76928. * This is used later on in the postprocess.
  76929. */
  76930. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76931. private _font;
  76932. private _text;
  76933. private _charSize;
  76934. /**
  76935. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76936. */
  76937. get charSize(): number;
  76938. /**
  76939. * Create a new instance of the Digital Rain FontTexture class
  76940. * @param name the name of the texture
  76941. * @param font the font to use, use the W3C CSS notation
  76942. * @param text the caracter set to use in the rendering.
  76943. * @param scene the scene that owns the texture
  76944. */
  76945. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76946. /**
  76947. * Gets the max char width of a font.
  76948. * @param font the font to use, use the W3C CSS notation
  76949. * @return the max char width
  76950. */
  76951. private getFontWidth;
  76952. /**
  76953. * Gets the max char height of a font.
  76954. * @param font the font to use, use the W3C CSS notation
  76955. * @return the max char height
  76956. */
  76957. private getFontHeight;
  76958. /**
  76959. * Clones the current DigitalRainFontTexture.
  76960. * @return the clone of the texture.
  76961. */
  76962. clone(): DigitalRainFontTexture;
  76963. /**
  76964. * Parses a json object representing the texture and returns an instance of it.
  76965. * @param source the source JSON representation
  76966. * @param scene the scene to create the texture for
  76967. * @return the parsed texture
  76968. */
  76969. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  76970. }
  76971. /**
  76972. * Option available in the Digital Rain Post Process.
  76973. */
  76974. export interface IDigitalRainPostProcessOptions {
  76975. /**
  76976. * The font to use following the w3c font definition.
  76977. */
  76978. font?: string;
  76979. /**
  76980. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76981. * This number is defined between 0 and 1;
  76982. */
  76983. mixToTile?: number;
  76984. /**
  76985. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76986. * This number is defined between 0 and 1;
  76987. */
  76988. mixToNormal?: number;
  76989. }
  76990. /**
  76991. * DigitalRainPostProcess helps rendering everithing in digital rain.
  76992. *
  76993. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76994. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  76995. */
  76996. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  76997. /**
  76998. * The font texture used to render the char in the post process.
  76999. */
  77000. private _digitalRainFontTexture;
  77001. /**
  77002. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77003. * This number is defined between 0 and 1;
  77004. */
  77005. mixToTile: number;
  77006. /**
  77007. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77008. * This number is defined between 0 and 1;
  77009. */
  77010. mixToNormal: number;
  77011. /**
  77012. * Instantiates a new Digital Rain Post Process.
  77013. * @param name the name to give to the postprocess
  77014. * @camera the camera to apply the post process to.
  77015. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  77016. */
  77017. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  77018. }
  77019. }
  77020. declare module BABYLON {
  77021. /** @hidden */
  77022. export var oceanPostProcessPixelShader: {
  77023. name: string;
  77024. shader: string;
  77025. };
  77026. }
  77027. declare module BABYLON {
  77028. /**
  77029. * Option available in the Ocean Post Process.
  77030. */
  77031. export interface IOceanPostProcessOptions {
  77032. /**
  77033. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77034. */
  77035. reflectionSize?: number | {
  77036. width: number;
  77037. height: number;
  77038. } | {
  77039. ratio: number;
  77040. };
  77041. /**
  77042. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77043. */
  77044. refractionSize?: number | {
  77045. width: number;
  77046. height: number;
  77047. } | {
  77048. ratio: number;
  77049. };
  77050. }
  77051. /**
  77052. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  77053. *
  77054. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77055. * Example usage:
  77056. * var pp = new OceanPostProcess("myOcean", camera);
  77057. * pp.reflectionEnabled = true;
  77058. * pp.refractionEnabled = true;
  77059. */
  77060. export class OceanPostProcess extends BABYLON.PostProcess {
  77061. /**
  77062. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  77063. */
  77064. get reflectionEnabled(): boolean;
  77065. /**
  77066. * Sets weither or not the real-time reflection is enabled on the ocean.
  77067. * Is set to true, the reflection mirror texture will be used as reflection texture.
  77068. */
  77069. set reflectionEnabled(enabled: boolean);
  77070. /**
  77071. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  77072. */
  77073. get refractionEnabled(): boolean;
  77074. /**
  77075. * Sets weither or not the real-time refraction is enabled on the ocean.
  77076. * Is set to true, the refraction render target texture will be used as refraction texture.
  77077. */
  77078. set refractionEnabled(enabled: boolean);
  77079. /**
  77080. * Gets wether or not the post-processes is supported by the running hardware.
  77081. * This requires draw buffer supports.
  77082. */
  77083. get isSupported(): boolean;
  77084. /**
  77085. * This is the reflection mirror texture used to display reflections on the ocean.
  77086. * By default, render list is empty.
  77087. */
  77088. reflectionTexture: BABYLON.MirrorTexture;
  77089. /**
  77090. * This is the refraction render target texture used to display refraction on the ocean.
  77091. * By default, render list is empty.
  77092. */
  77093. refractionTexture: BABYLON.RenderTargetTexture;
  77094. private _time;
  77095. private _cameraRotation;
  77096. private _cameraViewMatrix;
  77097. private _reflectionEnabled;
  77098. private _refractionEnabled;
  77099. private _geometryRenderer;
  77100. /**
  77101. * Instantiates a new Ocean Post Process.
  77102. * @param name the name to give to the postprocess.
  77103. * @camera the camera to apply the post process to.
  77104. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  77105. */
  77106. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  77107. /**
  77108. * Returns the appropriate defines according to the current configuration.
  77109. */
  77110. private _getDefines;
  77111. /**
  77112. * Computes the current camera rotation as the shader requires a camera rotation.
  77113. */
  77114. private _computeCameraRotation;
  77115. }
  77116. }
  77117. declare module BABYLON {
  77118. /** @hidden */
  77119. export var brickProceduralTexturePixelShader: {
  77120. name: string;
  77121. shader: string;
  77122. };
  77123. }
  77124. declare module BABYLON {
  77125. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  77126. private _numberOfBricksHeight;
  77127. private _numberOfBricksWidth;
  77128. private _jointColor;
  77129. private _brickColor;
  77130. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77131. updateShaderUniforms(): void;
  77132. get numberOfBricksHeight(): number;
  77133. set numberOfBricksHeight(value: number);
  77134. get numberOfBricksWidth(): number;
  77135. set numberOfBricksWidth(value: number);
  77136. get jointColor(): BABYLON.Color3;
  77137. set jointColor(value: BABYLON.Color3);
  77138. get brickColor(): BABYLON.Color3;
  77139. set brickColor(value: BABYLON.Color3);
  77140. /**
  77141. * Serializes this brick procedural texture
  77142. * @returns a serialized brick procedural texture object
  77143. */
  77144. serialize(): any;
  77145. /**
  77146. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  77147. * @param parsedTexture defines parsed texture data
  77148. * @param scene defines the current scene
  77149. * @param rootUrl defines the root URL containing brick procedural texture information
  77150. * @returns a parsed Brick Procedural BABYLON.Texture
  77151. */
  77152. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  77153. }
  77154. }
  77155. declare module BABYLON {
  77156. /** @hidden */
  77157. export var cloudProceduralTexturePixelShader: {
  77158. name: string;
  77159. shader: string;
  77160. };
  77161. }
  77162. declare module BABYLON {
  77163. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  77164. private _skyColor;
  77165. private _cloudColor;
  77166. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77167. updateShaderUniforms(): void;
  77168. get skyColor(): BABYLON.Color4;
  77169. set skyColor(value: BABYLON.Color4);
  77170. get cloudColor(): BABYLON.Color4;
  77171. set cloudColor(value: BABYLON.Color4);
  77172. /**
  77173. * Serializes this cloud procedural texture
  77174. * @returns a serialized cloud procedural texture object
  77175. */
  77176. serialize(): any;
  77177. /**
  77178. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  77179. * @param parsedTexture defines parsed texture data
  77180. * @param scene defines the current scene
  77181. * @param rootUrl defines the root URL containing cloud procedural texture information
  77182. * @returns a parsed Cloud Procedural BABYLON.Texture
  77183. */
  77184. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  77185. }
  77186. }
  77187. declare module BABYLON {
  77188. /** @hidden */
  77189. export var fireProceduralTexturePixelShader: {
  77190. name: string;
  77191. shader: string;
  77192. };
  77193. }
  77194. declare module BABYLON {
  77195. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  77196. private _time;
  77197. private _speed;
  77198. private _autoGenerateTime;
  77199. private _fireColors;
  77200. private _alphaThreshold;
  77201. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77202. updateShaderUniforms(): void;
  77203. render(useCameraPostProcess?: boolean): void;
  77204. static get PurpleFireColors(): BABYLON.Color3[];
  77205. static get GreenFireColors(): BABYLON.Color3[];
  77206. static get RedFireColors(): BABYLON.Color3[];
  77207. static get BlueFireColors(): BABYLON.Color3[];
  77208. get autoGenerateTime(): boolean;
  77209. set autoGenerateTime(value: boolean);
  77210. get fireColors(): BABYLON.Color3[];
  77211. set fireColors(value: BABYLON.Color3[]);
  77212. get time(): number;
  77213. set time(value: number);
  77214. get speed(): BABYLON.Vector2;
  77215. set speed(value: BABYLON.Vector2);
  77216. get alphaThreshold(): number;
  77217. set alphaThreshold(value: number);
  77218. /**
  77219. * Serializes this fire procedural texture
  77220. * @returns a serialized fire procedural texture object
  77221. */
  77222. serialize(): any;
  77223. /**
  77224. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  77225. * @param parsedTexture defines parsed texture data
  77226. * @param scene defines the current scene
  77227. * @param rootUrl defines the root URL containing fire procedural texture information
  77228. * @returns a parsed Fire Procedural BABYLON.Texture
  77229. */
  77230. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  77231. }
  77232. }
  77233. declare module BABYLON {
  77234. /** @hidden */
  77235. export var grassProceduralTexturePixelShader: {
  77236. name: string;
  77237. shader: string;
  77238. };
  77239. }
  77240. declare module BABYLON {
  77241. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  77242. private _grassColors;
  77243. private _groundColor;
  77244. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77245. updateShaderUniforms(): void;
  77246. get grassColors(): BABYLON.Color3[];
  77247. set grassColors(value: BABYLON.Color3[]);
  77248. get groundColor(): BABYLON.Color3;
  77249. set groundColor(value: BABYLON.Color3);
  77250. /**
  77251. * Serializes this grass procedural texture
  77252. * @returns a serialized grass procedural texture object
  77253. */
  77254. serialize(): any;
  77255. /**
  77256. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  77257. * @param parsedTexture defines parsed texture data
  77258. * @param scene defines the current scene
  77259. * @param rootUrl defines the root URL containing grass procedural texture information
  77260. * @returns a parsed Grass Procedural BABYLON.Texture
  77261. */
  77262. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  77263. }
  77264. }
  77265. declare module BABYLON {
  77266. /** @hidden */
  77267. export var marbleProceduralTexturePixelShader: {
  77268. name: string;
  77269. shader: string;
  77270. };
  77271. }
  77272. declare module BABYLON {
  77273. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  77274. private _numberOfTilesHeight;
  77275. private _numberOfTilesWidth;
  77276. private _amplitude;
  77277. private _jointColor;
  77278. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77279. updateShaderUniforms(): void;
  77280. get numberOfTilesHeight(): number;
  77281. set numberOfTilesHeight(value: number);
  77282. get amplitude(): number;
  77283. set amplitude(value: number);
  77284. get numberOfTilesWidth(): number;
  77285. set numberOfTilesWidth(value: number);
  77286. get jointColor(): BABYLON.Color3;
  77287. set jointColor(value: BABYLON.Color3);
  77288. /**
  77289. * Serializes this marble procedural texture
  77290. * @returns a serialized marble procedural texture object
  77291. */
  77292. serialize(): any;
  77293. /**
  77294. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  77295. * @param parsedTexture defines parsed texture data
  77296. * @param scene defines the current scene
  77297. * @param rootUrl defines the root URL containing marble procedural texture information
  77298. * @returns a parsed Marble Procedural BABYLON.Texture
  77299. */
  77300. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  77301. }
  77302. }
  77303. declare module BABYLON {
  77304. /** @hidden */
  77305. export var normalMapProceduralTexturePixelShader: {
  77306. name: string;
  77307. shader: string;
  77308. };
  77309. }
  77310. declare module BABYLON {
  77311. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  77312. private _baseTexture;
  77313. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77314. updateShaderUniforms(): void;
  77315. render(useCameraPostProcess?: boolean): void;
  77316. resize(size: any, generateMipMaps: any): void;
  77317. get baseTexture(): BABYLON.Texture;
  77318. set baseTexture(texture: BABYLON.Texture);
  77319. /**
  77320. * Serializes this normal map procedural texture
  77321. * @returns a serialized normal map procedural texture object
  77322. */
  77323. serialize(): any;
  77324. /**
  77325. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  77326. * @param parsedTexture defines parsed texture data
  77327. * @param scene defines the current scene
  77328. * @param rootUrl defines the root URL containing normal map procedural texture information
  77329. * @returns a parsed Normal Map Procedural BABYLON.Texture
  77330. */
  77331. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  77332. }
  77333. }
  77334. declare module BABYLON {
  77335. /** @hidden */
  77336. export var perlinNoiseProceduralTexturePixelShader: {
  77337. name: string;
  77338. shader: string;
  77339. };
  77340. }
  77341. declare module BABYLON {
  77342. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  77343. time: number;
  77344. timeScale: number;
  77345. translationSpeed: number;
  77346. private _currentTranslation;
  77347. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77348. updateShaderUniforms(): void;
  77349. render(useCameraPostProcess?: boolean): void;
  77350. resize(size: any, generateMipMaps: any): void;
  77351. /**
  77352. * Serializes this perlin noise procedural texture
  77353. * @returns a serialized perlin noise procedural texture object
  77354. */
  77355. serialize(): any;
  77356. /**
  77357. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  77358. * @param parsedTexture defines parsed texture data
  77359. * @param scene defines the current scene
  77360. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  77361. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  77362. */
  77363. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  77364. }
  77365. }
  77366. declare module BABYLON {
  77367. /** @hidden */
  77368. export var roadProceduralTexturePixelShader: {
  77369. name: string;
  77370. shader: string;
  77371. };
  77372. }
  77373. declare module BABYLON {
  77374. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  77375. private _roadColor;
  77376. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77377. updateShaderUniforms(): void;
  77378. get roadColor(): BABYLON.Color3;
  77379. set roadColor(value: BABYLON.Color3);
  77380. /**
  77381. * Serializes this road procedural texture
  77382. * @returns a serialized road procedural texture object
  77383. */
  77384. serialize(): any;
  77385. /**
  77386. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  77387. * @param parsedTexture defines parsed texture data
  77388. * @param scene defines the current scene
  77389. * @param rootUrl defines the root URL containing road procedural texture information
  77390. * @returns a parsed Road Procedural BABYLON.Texture
  77391. */
  77392. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  77393. }
  77394. }
  77395. declare module BABYLON {
  77396. /** @hidden */
  77397. export var starfieldProceduralTexturePixelShader: {
  77398. name: string;
  77399. shader: string;
  77400. };
  77401. }
  77402. declare module BABYLON {
  77403. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  77404. private _time;
  77405. private _alpha;
  77406. private _beta;
  77407. private _zoom;
  77408. private _formuparam;
  77409. private _stepsize;
  77410. private _tile;
  77411. private _brightness;
  77412. private _darkmatter;
  77413. private _distfading;
  77414. private _saturation;
  77415. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77416. updateShaderUniforms(): void;
  77417. get time(): number;
  77418. set time(value: number);
  77419. get alpha(): number;
  77420. set alpha(value: number);
  77421. get beta(): number;
  77422. set beta(value: number);
  77423. get formuparam(): number;
  77424. set formuparam(value: number);
  77425. get stepsize(): number;
  77426. set stepsize(value: number);
  77427. get zoom(): number;
  77428. set zoom(value: number);
  77429. get tile(): number;
  77430. set tile(value: number);
  77431. get brightness(): number;
  77432. set brightness(value: number);
  77433. get darkmatter(): number;
  77434. set darkmatter(value: number);
  77435. get distfading(): number;
  77436. set distfading(value: number);
  77437. get saturation(): number;
  77438. set saturation(value: number);
  77439. /**
  77440. * Serializes this starfield procedural texture
  77441. * @returns a serialized starfield procedural texture object
  77442. */
  77443. serialize(): any;
  77444. /**
  77445. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  77446. * @param parsedTexture defines parsed texture data
  77447. * @param scene defines the current scene
  77448. * @param rootUrl defines the root URL containing startfield procedural texture information
  77449. * @returns a parsed Starfield Procedural BABYLON.Texture
  77450. */
  77451. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  77452. }
  77453. }
  77454. declare module BABYLON {
  77455. /** @hidden */
  77456. export var woodProceduralTexturePixelShader: {
  77457. name: string;
  77458. shader: string;
  77459. };
  77460. }
  77461. declare module BABYLON {
  77462. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  77463. private _ampScale;
  77464. private _woodColor;
  77465. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77466. updateShaderUniforms(): void;
  77467. get ampScale(): number;
  77468. set ampScale(value: number);
  77469. get woodColor(): BABYLON.Color3;
  77470. set woodColor(value: BABYLON.Color3);
  77471. /**
  77472. * Serializes this wood procedural texture
  77473. * @returns a serialized wood procedural texture object
  77474. */
  77475. serialize(): any;
  77476. /**
  77477. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  77478. * @param parsedTexture defines parsed texture data
  77479. * @param scene defines the current scene
  77480. * @param rootUrl defines the root URL containing wood procedural texture information
  77481. * @returns a parsed Wood Procedural BABYLON.Texture
  77482. */
  77483. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  77484. }
  77485. }