documentation.d.ts 3.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542
  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 no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: 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. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: 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. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: 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. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Multiplies the Vector3 coordinates by the float "scale"
  2433. * @param scale defines the multiplier factor
  2434. * @returns the current updated Vector3
  2435. */
  2436. scaleInPlace(scale: number): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns a new Vector3
  2441. */
  2442. scale(scale: number): Vector3;
  2443. /**
  2444. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2445. * @param scale defines the multiplier factor
  2446. * @param result defines the Vector3 object where to store the result
  2447. * @returns the current Vector3
  2448. */
  2449. scaleToRef(scale: number, result: Vector3): Vector3;
  2450. /**
  2451. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2452. * @param scale defines the scale factor
  2453. * @param result defines the Vector3 object where to store the result
  2454. * @returns the unmodified current Vector3
  2455. */
  2456. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2457. /**
  2458. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2459. * @param otherVector defines the second operand
  2460. * @returns true if both vectors are equals
  2461. */
  2462. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2465. * @param otherVector defines the second operand
  2466. * @param epsilon defines the minimal distance to define values as equals
  2467. * @returns true if both vectors are distant less than epsilon
  2468. */
  2469. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2470. /**
  2471. * Returns true if the current Vector3 coordinates equals the given floats
  2472. * @param x defines the x coordinate of the operand
  2473. * @param y defines the y coordinate of the operand
  2474. * @param z defines the z coordinate of the operand
  2475. * @returns true if both vectors are equals
  2476. */
  2477. equalsToFloats(x: number, y: number, z: number): boolean;
  2478. /**
  2479. * Multiplies the current Vector3 coordinates by the given ones
  2480. * @param otherVector defines the second operand
  2481. * @returns the current updated Vector3
  2482. */
  2483. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2484. /**
  2485. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2486. * @param otherVector defines the second operand
  2487. * @returns the new Vector3
  2488. */
  2489. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2492. * @param otherVector defines the second operand
  2493. * @param result defines the Vector3 object where to store the result
  2494. * @returns the current Vector3
  2495. */
  2496. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2497. /**
  2498. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2499. * @param x defines the x coordinate of the operand
  2500. * @param y defines the y coordinate of the operand
  2501. * @param z defines the z coordinate of the operand
  2502. * @returns the new Vector3
  2503. */
  2504. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Divides the current Vector3 coordinates by the given ones.
  2520. * @param otherVector defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. divideInPlace(otherVector: Vector3): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2526. * @param other defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2554. * Check if is non uniform within a certain amount of decimal places to account for this
  2555. * @param epsilon the amount the values can differ
  2556. * @returns if the the vector is non uniform to a certain number of decimal places
  2557. */
  2558. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2559. /**
  2560. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2561. */
  2562. get isNonUniform(): boolean;
  2563. /**
  2564. * Gets a new Vector3 from current Vector3 floored values
  2565. * @returns a new Vector3
  2566. */
  2567. floor(): Vector3;
  2568. /**
  2569. * Gets a new Vector3 from current Vector3 floored values
  2570. * @returns a new Vector3
  2571. */
  2572. fract(): Vector3;
  2573. /**
  2574. * Gets the length of the Vector3
  2575. * @returns the length of the Vector3
  2576. */
  2577. length(): number;
  2578. /**
  2579. * Gets the squared length of the Vector3
  2580. * @returns squared length of the Vector3
  2581. */
  2582. lengthSquared(): number;
  2583. /**
  2584. * Normalize the current Vector3.
  2585. * Please note that this is an in place operation.
  2586. * @returns the current updated Vector3
  2587. */
  2588. normalize(): Vector3;
  2589. /**
  2590. * Reorders the x y z properties of the vector in place
  2591. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2592. * @returns the current updated vector
  2593. */
  2594. reorderInPlace(order: string): this;
  2595. /**
  2596. * Rotates the vector around 0,0,0 by a quaternion
  2597. * @param quaternion the rotation quaternion
  2598. * @param result vector to store the result
  2599. * @returns the resulting vector
  2600. */
  2601. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2602. /**
  2603. * Rotates a vector around a given point
  2604. * @param quaternion the rotation quaternion
  2605. * @param point the point to rotate around
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2610. /**
  2611. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2612. * The cross product is then orthogonal to both current and "other"
  2613. * @param other defines the right operand
  2614. * @returns the cross product
  2615. */
  2616. cross(other: Vector3): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 with the given input length.
  2619. * Please note that this is an in place operation.
  2620. * @param len the length of the vector
  2621. * @returns the current updated Vector3
  2622. */
  2623. normalizeFromLength(len: number): Vector3;
  2624. /**
  2625. * Normalize the current Vector3 to a new vector
  2626. * @returns the new Vector3
  2627. */
  2628. normalizeToNew(): Vector3;
  2629. /**
  2630. * Normalize the current Vector3 to the reference
  2631. * @param reference define the Vector3 to update
  2632. * @returns the updated Vector3
  2633. */
  2634. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2635. /**
  2636. * Creates a new Vector3 copied from the current Vector3
  2637. * @returns the new Vector3
  2638. */
  2639. clone(): Vector3;
  2640. /**
  2641. * Copies the given vector coordinates to the current Vector3 ones
  2642. * @param source defines the source Vector3
  2643. * @returns the current updated Vector3
  2644. */
  2645. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Copies the given floats to the current Vector3 coordinates
  2648. * @param x defines the x coordinate of the operand
  2649. * @param y defines the y coordinate of the operand
  2650. * @param z defines the z coordinate of the operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFromFloats(x: number, y: number, z: number): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. set(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given float to the current Vector3 coordinates
  2664. * @param v defines the x, y and z coordinates of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. setAll(v: number): Vector3;
  2668. /**
  2669. * Get the clip factor between two vectors
  2670. * @param vector0 defines the first operand
  2671. * @param vector1 defines the second operand
  2672. * @param axis defines the axis to use
  2673. * @param size defines the size along the axis
  2674. * @returns the clip factor
  2675. */
  2676. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2677. /**
  2678. * Get angle between two vectors
  2679. * @param vector0 angle between vector0 and vector1
  2680. * @param vector1 angle between vector0 and vector1
  2681. * @param normal direction of the normal
  2682. * @return the angle between vector0 and vector1
  2683. */
  2684. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2685. /**
  2686. * Returns a new Vector3 set from the index "offset" of the given array
  2687. * @param array defines the source array
  2688. * @param offset defines the offset in the source array
  2689. * @returns the new Vector3
  2690. */
  2691. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2692. /**
  2693. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2694. * @param array defines the source array
  2695. * @param offset defines the offset in the source array
  2696. * @returns the new Vector3
  2697. * @deprecated Please use FromArray instead.
  2698. */
  2699. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2700. /**
  2701. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @param result defines the Vector3 where to store the result
  2705. */
  2706. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2707. /**
  2708. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2709. * @param array defines the source array
  2710. * @param offset defines the offset in the source array
  2711. * @param result defines the Vector3 where to store the result
  2712. * @deprecated Please use FromArrayToRef instead.
  2713. */
  2714. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the given floats.
  2717. * @param x defines the x coordinate of the source
  2718. * @param y defines the y coordinate of the source
  2719. * @param z defines the z coordinate of the source
  2720. * @param result defines the Vector3 where to store the result
  2721. */
  2722. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2723. /**
  2724. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2725. * @returns a new empty Vector3
  2726. */
  2727. static Zero(): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2730. * @returns a new unit Vector3
  2731. */
  2732. static One(): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2735. * @returns a new up Vector3
  2736. */
  2737. static Up(): Vector3;
  2738. /**
  2739. * Gets a up Vector3 that must not be updated
  2740. */
  2741. static get UpReadOnly(): DeepImmutable<Vector3>;
  2742. /**
  2743. * Gets a zero Vector3 that must not be updated
  2744. */
  2745. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2748. * @returns a new down Vector3
  2749. */
  2750. static Down(): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2753. * @returns a new forward Vector3
  2754. */
  2755. static Forward(): Vector3;
  2756. /**
  2757. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2758. * @returns a new forward Vector3
  2759. */
  2760. static Backward(): Vector3;
  2761. /**
  2762. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2763. * @returns a new right Vector3
  2764. */
  2765. static Right(): Vector3;
  2766. /**
  2767. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2768. * @returns a new left Vector3
  2769. */
  2770. static Left(): Vector3;
  2771. /**
  2772. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2773. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2774. * @param vector defines the Vector3 to transform
  2775. * @param transformation defines the transformation matrix
  2776. * @returns the transformed Vector3
  2777. */
  2778. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2779. /**
  2780. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @param result defines the Vector3 where to store the result
  2785. */
  2786. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2789. * This method computes tranformed coordinates only, not transformed direction vectors
  2790. * @param x define the x coordinate of the source vector
  2791. * @param y define the y coordinate of the source vector
  2792. * @param z define the z coordinate of the source vector
  2793. * @param transformation defines the transformation matrix
  2794. * @param result defines the Vector3 where to store the result
  2795. */
  2796. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2797. /**
  2798. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2800. * @param vector defines the Vector3 to transform
  2801. * @param transformation defines the transformation matrix
  2802. * @returns the new Vector3
  2803. */
  2804. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2805. /**
  2806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @param result defines the Vector3 where to store the result
  2811. */
  2812. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param x define the x coordinate of the source vector
  2817. * @param y define the y coordinate of the source vector
  2818. * @param z define the z coordinate of the source vector
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2825. * @param value1 defines the first control point
  2826. * @param value2 defines the second control point
  2827. * @param value3 defines the third control point
  2828. * @param value4 defines the fourth control point
  2829. * @param amount defines the amount on the spline to use
  2830. * @returns the new Vector3
  2831. */
  2832. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2833. /**
  2834. * 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"
  2835. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2836. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2837. * @param value defines the current value
  2838. * @param min defines the lower range value
  2839. * @param max defines the upper range value
  2840. * @returns the new Vector3
  2841. */
  2842. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2843. /**
  2844. * 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"
  2845. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2846. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2847. * @param value defines the current value
  2848. * @param min defines the lower range value
  2849. * @param max defines the upper range value
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2853. /**
  2854. * Checks if a given vector is inside a specific range
  2855. * @param v defines the vector to test
  2856. * @param min defines the minimum range
  2857. * @param max defines the maximum range
  2858. */
  2859. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2860. /**
  2861. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2862. * @param value1 defines the first control point
  2863. * @param tangent1 defines the first tangent vector
  2864. * @param value2 defines the second control point
  2865. * @param tangent2 defines the second tangent vector
  2866. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2867. * @returns the new Vector3
  2868. */
  2869. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2870. /**
  2871. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2872. * @param start defines the start value
  2873. * @param end defines the end value
  2874. * @param amount max defines amount between both (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @param result defines the Vector3 where to store the result
  2884. */
  2885. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2886. /**
  2887. * Returns the dot product (float) between the vectors "left" and "right"
  2888. * @param left defines the left operand
  2889. * @param right defines the right operand
  2890. * @returns the dot product
  2891. */
  2892. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2895. * The cross product is then orthogonal to both "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the cross product
  2899. */
  2900. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2901. /**
  2902. * Sets the given vector "result" with the cross product of "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2909. /**
  2910. * Returns a new Vector3 as the normalization of the given vector
  2911. * @param vector defines the Vector3 to normalize
  2912. * @returns the new Vector3
  2913. */
  2914. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2915. /**
  2916. * Sets the given vector "result" with the normalization of the given first vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @param result defines the Vector3 where to store the result
  2919. */
  2920. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2921. /**
  2922. * Project a Vector3 onto screen space
  2923. * @param vector defines the Vector3 to project
  2924. * @param world defines the world matrix to use
  2925. * @param transform defines the transform (view x projection) matrix to use
  2926. * @param viewport defines the screen viewport to use
  2927. * @returns the new Vector3
  2928. */
  2929. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2930. /** @hidden */
  2931. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2932. /**
  2933. * Unproject from screen space to object space
  2934. * @param source defines the screen space Vector3 to use
  2935. * @param viewportWidth defines the current width of the viewport
  2936. * @param viewportHeight defines the current height of the viewport
  2937. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @returns the new Vector3
  2940. */
  2941. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2942. /**
  2943. * Unproject from screen space to object space
  2944. * @param source defines the screen space Vector3 to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @param result defines the Vector3 where to store the result
  2962. */
  2963. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param sourceX defines the screen space x coordinate to use
  2967. * @param sourceY defines the screen space y coordinate to use
  2968. * @param sourceZ defines the screen space z coordinate to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Gets the minimal coordinate values between two Vector3
  2979. * @param left defines the first operand
  2980. * @param right defines the second operand
  2981. * @returns the new Vector3
  2982. */
  2983. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2984. /**
  2985. * Gets the maximal coordinate values between two Vector3
  2986. * @param left defines the first operand
  2987. * @param right defines the second operand
  2988. * @returns the new Vector3
  2989. */
  2990. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2991. /**
  2992. * Returns the distance between the vectors "value1" and "value2"
  2993. * @param value1 defines the first operand
  2994. * @param value2 defines the second operand
  2995. * @returns the distance
  2996. */
  2997. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2998. /**
  2999. * Returns the squared distance between the vectors "value1" and "value2"
  3000. * @param value1 defines the first operand
  3001. * @param value2 defines the second operand
  3002. * @returns the squared distance
  3003. */
  3004. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3005. /**
  3006. * Returns a new Vector3 located at the center between "value1" and "value2"
  3007. * @param value1 defines the first operand
  3008. * @param value2 defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3014. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3015. * to something in order to rotate it from its local system to the given target system
  3016. * Note: axis1, axis2 and axis3 are normalized during this operation
  3017. * @param axis1 defines the first axis
  3018. * @param axis2 defines the second axis
  3019. * @param axis3 defines the third axis
  3020. * @returns a new Vector3
  3021. */
  3022. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @param ref defines the Vector3 where to store the result
  3029. */
  3030. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3031. }
  3032. /**
  3033. * Vector4 class created for EulerAngle class conversion to Quaternion
  3034. */
  3035. export class Vector4 {
  3036. /** x value of the vector */
  3037. x: number;
  3038. /** y value of the vector */
  3039. y: number;
  3040. /** z value of the vector */
  3041. z: number;
  3042. /** w value of the vector */
  3043. w: number;
  3044. /**
  3045. * Creates a Vector4 object from the given floats.
  3046. * @param x x value of the vector
  3047. * @param y y value of the vector
  3048. * @param z z value of the vector
  3049. * @param w w value of the vector
  3050. */
  3051. constructor(
  3052. /** x value of the vector */
  3053. x: number,
  3054. /** y value of the vector */
  3055. y: number,
  3056. /** z value of the vector */
  3057. z: number,
  3058. /** w value of the vector */
  3059. w: number);
  3060. /**
  3061. * Returns the string with the Vector4 coordinates.
  3062. * @returns a string containing all the vector values
  3063. */
  3064. toString(): string;
  3065. /**
  3066. * Returns the string "Vector4".
  3067. * @returns "Vector4"
  3068. */
  3069. getClassName(): string;
  3070. /**
  3071. * Returns the Vector4 hash code.
  3072. * @returns a unique hash code
  3073. */
  3074. getHashCode(): number;
  3075. /**
  3076. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3077. * @returns the resulting array
  3078. */
  3079. asArray(): number[];
  3080. /**
  3081. * Populates the given array from the given index with the Vector4 coordinates.
  3082. * @param array array to populate
  3083. * @param index index of the array to start at (default: 0)
  3084. * @returns the Vector4.
  3085. */
  3086. toArray(array: FloatArray, index?: number): Vector4;
  3087. /**
  3088. * Adds the given vector to the current Vector4.
  3089. * @param otherVector the vector to add
  3090. * @returns the updated Vector4.
  3091. */
  3092. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3095. * @param otherVector the vector to add
  3096. * @returns the resulting vector
  3097. */
  3098. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Subtract in place the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @returns the updated Vector4.
  3110. */
  3111. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3114. * @param otherVector the vector to add
  3115. * @returns the new vector with the result
  3116. */
  3117. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to subtract
  3121. * @param result the vector to store the result
  3122. * @returns the current Vector4.
  3123. */
  3124. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. */
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. * @param x value to subtract
  3131. * @param y value to subtract
  3132. * @param z value to subtract
  3133. * @param w value to subtract
  3134. * @returns new vector containing the result
  3135. */
  3136. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3137. /**
  3138. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3139. * @param x value to subtract
  3140. * @param y value to subtract
  3141. * @param z value to subtract
  3142. * @param w value to subtract
  3143. * @param result the vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3147. /**
  3148. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3149. * @returns a new vector with the negated values
  3150. */
  3151. negate(): Vector4;
  3152. /**
  3153. * Multiplies the current Vector4 coordinates by scale (float).
  3154. * @param scale the number to scale with
  3155. * @returns the updated Vector4.
  3156. */
  3157. scaleInPlace(scale: number): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns a new vector with the result
  3162. */
  3163. scale(scale: number): Vector4;
  3164. /**
  3165. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @param result a vector to store the result in
  3168. * @returns the current Vector4.
  3169. */
  3170. scaleToRef(scale: number, result: Vector4): Vector4;
  3171. /**
  3172. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3173. * @param scale defines the scale factor
  3174. * @param result defines the Vector4 object where to store the result
  3175. * @returns the unmodified current Vector4
  3176. */
  3177. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3178. /**
  3179. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3180. * @param otherVector the vector to compare against
  3181. * @returns true if they are equal
  3182. */
  3183. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3186. * @param otherVector vector to compare against
  3187. * @param epsilon (Default: very small number)
  3188. * @returns true if they are equal
  3189. */
  3190. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3191. /**
  3192. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3193. * @param x x value to compare against
  3194. * @param y y value to compare against
  3195. * @param z z value to compare against
  3196. * @param w w value to compare against
  3197. * @returns true if equal
  3198. */
  3199. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3200. /**
  3201. * Multiplies in place the current Vector4 by the given one.
  3202. * @param otherVector vector to multiple with
  3203. * @returns the updated Vector4.
  3204. */
  3205. multiplyInPlace(otherVector: Vector4): Vector4;
  3206. /**
  3207. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns resulting new vector
  3210. */
  3211. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3212. /**
  3213. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @param result vector to store the result
  3216. * @returns the current Vector4.
  3217. */
  3218. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3221. * @param x x value multiply with
  3222. * @param y y value multiply with
  3223. * @param z z value multiply with
  3224. * @param w w value multiply with
  3225. * @returns resulting new vector
  3226. */
  3227. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3228. /**
  3229. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3230. * @param otherVector vector to devide with
  3231. * @returns resulting new vector
  3232. */
  3233. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @param result vector to store the result
  3238. * @returns the current Vector4.
  3239. */
  3240. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3241. /**
  3242. * Divides the current Vector3 coordinates by the given ones.
  3243. * @param otherVector vector to devide with
  3244. * @returns the updated Vector3.
  3245. */
  3246. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3249. * @param other defines the second operand
  3250. * @returns the current updated Vector4
  3251. */
  3252. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Gets a new Vector4 from current Vector4 floored values
  3261. * @returns a new Vector4
  3262. */
  3263. floor(): Vector4;
  3264. /**
  3265. * Gets a new Vector4 from current Vector3 floored values
  3266. * @returns a new Vector4
  3267. */
  3268. fract(): Vector4;
  3269. /**
  3270. * Returns the Vector4 length (float).
  3271. * @returns the length
  3272. */
  3273. length(): number;
  3274. /**
  3275. * Returns the Vector4 squared length (float).
  3276. * @returns the length squared
  3277. */
  3278. lengthSquared(): number;
  3279. /**
  3280. * Normalizes in place the Vector4.
  3281. * @returns the updated Vector4.
  3282. */
  3283. normalize(): Vector4;
  3284. /**
  3285. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3286. * @returns this converted to a new vector3
  3287. */
  3288. toVector3(): Vector3;
  3289. /**
  3290. * Returns a new Vector4 copied from the current one.
  3291. * @returns the new cloned vector
  3292. */
  3293. clone(): Vector4;
  3294. /**
  3295. * Updates the current Vector4 with the given one coordinates.
  3296. * @param source the source vector to copy from
  3297. * @returns the updated Vector4.
  3298. */
  3299. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the current Vector4 coordinates with the given floats.
  3302. * @param x float to copy from
  3303. * @param y float to copy from
  3304. * @param z float to copy from
  3305. * @param w float to copy from
  3306. * @returns the updated Vector4.
  3307. */
  3308. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3309. /**
  3310. * Updates the current Vector4 coordinates with the given floats.
  3311. * @param x float to set from
  3312. * @param y float to set from
  3313. * @param z float to set from
  3314. * @param w float to set from
  3315. * @returns the updated Vector4.
  3316. */
  3317. set(x: number, y: number, z: number, w: number): Vector4;
  3318. /**
  3319. * Copies the given float to the current Vector3 coordinates
  3320. * @param v defines the x, y, z and w coordinates of the operand
  3321. * @returns the current updated Vector3
  3322. */
  3323. setAll(v: number): Vector4;
  3324. /**
  3325. * Returns a new Vector4 set from the starting index of the given array.
  3326. * @param array the array to pull values from
  3327. * @param offset the offset into the array to start at
  3328. * @returns the new vector
  3329. */
  3330. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3331. /**
  3332. * Updates the given vector "result" from the starting index of the given array.
  3333. * @param array the array to pull values from
  3334. * @param offset the offset into the array to start at
  3335. * @param result the vector to store the result in
  3336. */
  3337. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3338. /**
  3339. * Updates the given vector "result" from the starting index of the given Float32Array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @param result the vector to store the result in
  3343. */
  3344. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3345. /**
  3346. * Updates the given vector "result" coordinates from the given floats.
  3347. * @param x float to set from
  3348. * @param y float to set from
  3349. * @param z float to set from
  3350. * @param w float to set from
  3351. * @param result the vector to the floats in
  3352. */
  3353. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3354. /**
  3355. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3356. * @returns the new vector
  3357. */
  3358. static Zero(): Vector4;
  3359. /**
  3360. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3361. * @returns the new vector
  3362. */
  3363. static One(): Vector4;
  3364. /**
  3365. * Returns a new normalized Vector4 from the given one.
  3366. * @param vector the vector to normalize
  3367. * @returns the vector
  3368. */
  3369. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3370. /**
  3371. * Updates the given vector "result" from the normalization of the given one.
  3372. * @param vector the vector to normalize
  3373. * @param result the vector to store the result in
  3374. */
  3375. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3376. /**
  3377. * Returns a vector with the minimum values from the left and right vectors
  3378. * @param left left vector to minimize
  3379. * @param right right vector to minimize
  3380. * @returns a new vector with the minimum of the left and right vector values
  3381. */
  3382. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Returns a vector with the maximum values from the left and right vectors
  3385. * @param left left vector to maximize
  3386. * @param right right vector to maximize
  3387. * @returns a new vector with the maximum of the left and right vector values
  3388. */
  3389. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Returns the distance (float) between the vectors "value1" and "value2".
  3392. * @param value1 value to calulate the distance between
  3393. * @param value2 value to calulate the distance between
  3394. * @return the distance between the two vectors
  3395. */
  3396. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3397. /**
  3398. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3399. * @param value1 value to calulate the distance between
  3400. * @param value2 value to calulate the distance between
  3401. * @return the distance between the two vectors squared
  3402. */
  3403. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3404. /**
  3405. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the center between
  3407. * @param value2 value to calulate the center between
  3408. * @return the center between the two vectors
  3409. */
  3410. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3413. * This methods computes transformed normalized direction vectors only.
  3414. * @param vector the vector to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @returns the new vector
  3417. */
  3418. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3419. /**
  3420. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3421. * This methods computes transformed normalized direction vectors only.
  3422. * @param vector the vector to transform
  3423. * @param transformation the transformation matrix to apply
  3424. * @param result the vector to store the result in
  3425. */
  3426. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3427. /**
  3428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3429. * This methods computes transformed normalized direction vectors only.
  3430. * @param x value to transform
  3431. * @param y value to transform
  3432. * @param z value to transform
  3433. * @param w value to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the results in
  3436. */
  3437. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Creates a new Vector4 from a Vector3
  3440. * @param source defines the source data
  3441. * @param w defines the 4th component (default is 0)
  3442. * @returns a new Vector4
  3443. */
  3444. static FromVector3(source: Vector3, w?: number): Vector4;
  3445. }
  3446. /**
  3447. * Class used to store quaternion data
  3448. * @see https://en.wikipedia.org/wiki/Quaternion
  3449. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3450. */
  3451. export class Quaternion {
  3452. /** defines the first component (0 by default) */
  3453. x: number;
  3454. /** defines the second component (0 by default) */
  3455. y: number;
  3456. /** defines the third component (0 by default) */
  3457. z: number;
  3458. /** defines the fourth component (1.0 by default) */
  3459. w: number;
  3460. /**
  3461. * Creates a new Quaternion from the given floats
  3462. * @param x defines the first component (0 by default)
  3463. * @param y defines the second component (0 by default)
  3464. * @param z defines the third component (0 by default)
  3465. * @param w defines the fourth component (1.0 by default)
  3466. */
  3467. constructor(
  3468. /** defines the first component (0 by default) */
  3469. x?: number,
  3470. /** defines the second component (0 by default) */
  3471. y?: number,
  3472. /** defines the third component (0 by default) */
  3473. z?: number,
  3474. /** defines the fourth component (1.0 by default) */
  3475. w?: number);
  3476. /**
  3477. * Gets a string representation for the current quaternion
  3478. * @returns a string with the Quaternion coordinates
  3479. */
  3480. toString(): string;
  3481. /**
  3482. * Gets the class name of the quaternion
  3483. * @returns the string "Quaternion"
  3484. */
  3485. getClassName(): string;
  3486. /**
  3487. * Gets a hash code for this quaternion
  3488. * @returns the quaternion hash code
  3489. */
  3490. getHashCode(): number;
  3491. /**
  3492. * Copy the quaternion to an array
  3493. * @returns a new array populated with 4 elements from the quaternion coordinates
  3494. */
  3495. asArray(): number[];
  3496. /**
  3497. * Check if two quaternions are equals
  3498. * @param otherQuaternion defines the second operand
  3499. * @return true if the current quaternion and the given one coordinates are strictly equals
  3500. */
  3501. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3502. /**
  3503. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3504. * @param otherQuaternion defines the other quaternion
  3505. * @param epsilon defines the minimal distance to consider equality
  3506. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3507. */
  3508. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3509. /**
  3510. * Clone the current quaternion
  3511. * @returns a new quaternion copied from the current one
  3512. */
  3513. clone(): Quaternion;
  3514. /**
  3515. * Copy a quaternion to the current one
  3516. * @param other defines the other quaternion
  3517. * @returns the updated current quaternion
  3518. */
  3519. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Updates the current quaternion with the given float coordinates
  3522. * @param x defines the x coordinate
  3523. * @param y defines the y coordinate
  3524. * @param z defines the z coordinate
  3525. * @param w defines the w coordinate
  3526. * @returns the updated current quaternion
  3527. */
  3528. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3529. /**
  3530. * Updates the current quaternion from the given float coordinates
  3531. * @param x defines the x coordinate
  3532. * @param y defines the y coordinate
  3533. * @param z defines the z coordinate
  3534. * @param w defines the w coordinate
  3535. * @returns the updated current quaternion
  3536. */
  3537. set(x: number, y: number, z: number, w: number): Quaternion;
  3538. /**
  3539. * Adds two quaternions
  3540. * @param other defines the second operand
  3541. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3542. */
  3543. add(other: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Add a quaternion to the current one
  3546. * @param other defines the quaternion to add
  3547. * @returns the current quaternion
  3548. */
  3549. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Subtract two quaternions
  3552. * @param other defines the second operand
  3553. * @returns a new quaternion as the subtraction result of the given one from the current one
  3554. */
  3555. subtract(other: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies the current quaternion by a scale factor
  3558. * @param value defines the scale factor
  3559. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3560. */
  3561. scale(value: number): Quaternion;
  3562. /**
  3563. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3564. * @param scale defines the scale factor
  3565. * @param result defines the Quaternion object where to store the result
  3566. * @returns the unmodified current quaternion
  3567. */
  3568. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3569. /**
  3570. * Multiplies in place the current quaternion by a scale factor
  3571. * @param value defines the scale factor
  3572. * @returns the current modified quaternion
  3573. */
  3574. scaleInPlace(value: number): Quaternion;
  3575. /**
  3576. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3577. * @param scale defines the scale factor
  3578. * @param result defines the Quaternion object where to store the result
  3579. * @returns the unmodified current quaternion
  3580. */
  3581. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3582. /**
  3583. * Multiplies two quaternions
  3584. * @param q1 defines the second operand
  3585. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3586. */
  3587. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3588. /**
  3589. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3590. * @param q1 defines the second operand
  3591. * @param result defines the target quaternion
  3592. * @returns the current quaternion
  3593. */
  3594. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3595. /**
  3596. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3597. * @param q1 defines the second operand
  3598. * @returns the currentupdated quaternion
  3599. */
  3600. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3601. /**
  3602. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3603. * @param ref defines the target quaternion
  3604. * @returns the current quaternion
  3605. */
  3606. conjugateToRef(ref: Quaternion): Quaternion;
  3607. /**
  3608. * Conjugates in place (1-q) the current quaternion
  3609. * @returns the current updated quaternion
  3610. */
  3611. conjugateInPlace(): Quaternion;
  3612. /**
  3613. * Conjugates in place (1-q) the current quaternion
  3614. * @returns a new quaternion
  3615. */
  3616. conjugate(): Quaternion;
  3617. /**
  3618. * Gets length of current quaternion
  3619. * @returns the quaternion length (float)
  3620. */
  3621. length(): number;
  3622. /**
  3623. * Normalize in place the current quaternion
  3624. * @returns the current updated quaternion
  3625. */
  3626. normalize(): Quaternion;
  3627. /**
  3628. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3629. * @param order is a reserved parameter and is ignore for now
  3630. * @returns a new Vector3 containing the Euler angles
  3631. */
  3632. toEulerAngles(order?: string): Vector3;
  3633. /**
  3634. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3635. * @param result defines the vector which will be filled with the Euler angles
  3636. * @param order is a reserved parameter and is ignore for now
  3637. * @returns the current unchanged quaternion
  3638. */
  3639. toEulerAnglesToRef(result: Vector3): Quaternion;
  3640. /**
  3641. * Updates the given rotation matrix with the current quaternion values
  3642. * @param result defines the target matrix
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toRotationMatrix(result: Matrix): Quaternion;
  3646. /**
  3647. * Updates the current quaternion from the given rotation matrix values
  3648. * @param matrix defines the source matrix
  3649. * @returns the current updated quaternion
  3650. */
  3651. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3652. /**
  3653. * Creates a new quaternion from a rotation matrix
  3654. * @param matrix defines the source matrix
  3655. * @returns a new quaternion created from the given rotation matrix values
  3656. */
  3657. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Updates the given quaternion with the given rotation matrix values
  3660. * @param matrix defines the source matrix
  3661. * @param result defines the target quaternion
  3662. */
  3663. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3664. /**
  3665. * Returns the dot product (float) between the quaternions "left" and "right"
  3666. * @param left defines the left operand
  3667. * @param right defines the right operand
  3668. * @returns the dot product
  3669. */
  3670. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3671. /**
  3672. * Checks if the two quaternions are close to each other
  3673. * @param quat0 defines the first quaternion to check
  3674. * @param quat1 defines the second quaternion to check
  3675. * @returns true if the two quaternions are close to each other
  3676. */
  3677. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3678. /**
  3679. * Creates an empty quaternion
  3680. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3681. */
  3682. static Zero(): Quaternion;
  3683. /**
  3684. * Inverse a given quaternion
  3685. * @param q defines the source quaternion
  3686. * @returns a new quaternion as the inverted current quaternion
  3687. */
  3688. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @param result the quaternion the result will be stored in
  3693. * @returns the result quaternion
  3694. */
  3695. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates an identity quaternion
  3698. * @returns the identity quaternion
  3699. */
  3700. static Identity(): Quaternion;
  3701. /**
  3702. * Gets a boolean indicating if the given quaternion is identity
  3703. * @param quaternion defines the quaternion to check
  3704. * @returns true if the quaternion is identity
  3705. */
  3706. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3707. /**
  3708. * Creates a quaternion from a rotation around an axis
  3709. * @param axis defines the axis to use
  3710. * @param angle defines the angle to use
  3711. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3712. */
  3713. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3714. /**
  3715. * Creates a rotation around an axis and stores it into the given quaternion
  3716. * @param axis defines the axis to use
  3717. * @param angle defines the angle to use
  3718. * @param result defines the target quaternion
  3719. * @returns the target quaternion
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Creates a new quaternion from data stored into an array
  3724. * @param array defines the data source
  3725. * @param offset defines the offset in the source array where the data starts
  3726. * @returns a new quaternion
  3727. */
  3728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3729. /**
  3730. * Create a quaternion from Euler rotation angles
  3731. * @param x Pitch
  3732. * @param y Yaw
  3733. * @param z Roll
  3734. * @returns the new Quaternion
  3735. */
  3736. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3737. /**
  3738. * Updates a quaternion from Euler rotation angles
  3739. * @param x Pitch
  3740. * @param y Yaw
  3741. * @param z Roll
  3742. * @param result the quaternion to store the result
  3743. * @returns the updated quaternion
  3744. */
  3745. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation vector
  3748. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3749. * @returns the new Quaternion
  3750. */
  3751. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3752. /**
  3753. * Updates a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @param result the quaternion to store the result
  3756. * @returns the updated quaternion
  3757. */
  3758. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3761. * @param yaw defines the rotation around Y axis
  3762. * @param pitch defines the rotation around X axis
  3763. * @param roll defines the rotation around Z axis
  3764. * @returns the new quaternion
  3765. */
  3766. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3767. /**
  3768. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3769. * @param yaw defines the rotation around Y axis
  3770. * @param pitch defines the rotation around X axis
  3771. * @param roll defines the rotation around Z axis
  3772. * @param result defines the target quaternion
  3773. */
  3774. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3775. /**
  3776. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3777. * @param alpha defines the rotation around first axis
  3778. * @param beta defines the rotation around second axis
  3779. * @param gamma defines the rotation around third axis
  3780. * @returns the new quaternion
  3781. */
  3782. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3783. /**
  3784. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3785. * @param alpha defines the rotation around first axis
  3786. * @param beta defines the rotation around second axis
  3787. * @param gamma defines the rotation around third axis
  3788. * @param result defines the target quaternion
  3789. */
  3790. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3791. /**
  3792. * 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)
  3793. * @param axis1 defines the first axis
  3794. * @param axis2 defines the second axis
  3795. * @param axis3 defines the third axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3799. /**
  3800. * 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
  3801. * @param axis1 defines the first axis
  3802. * @param axis2 defines the second axis
  3803. * @param axis3 defines the third axis
  3804. * @param ref defines the target quaternion
  3805. */
  3806. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3807. /**
  3808. * Interpolates between two quaternions
  3809. * @param left defines first quaternion
  3810. * @param right defines second quaternion
  3811. * @param amount defines the gradient to use
  3812. * @returns the new interpolated quaternion
  3813. */
  3814. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3815. /**
  3816. * Interpolates between two quaternions and stores it into a target quaternion
  3817. * @param left defines first quaternion
  3818. * @param right defines second quaternion
  3819. * @param amount defines the gradient to use
  3820. * @param result defines the target quaternion
  3821. */
  3822. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3823. /**
  3824. * Interpolate between two quaternions using Hermite interpolation
  3825. * @param value1 defines first quaternion
  3826. * @param tangent1 defines the incoming tangent
  3827. * @param value2 defines second quaternion
  3828. * @param tangent2 defines the outgoing tangent
  3829. * @param amount defines the target quaternion
  3830. * @returns the new interpolated quaternion
  3831. */
  3832. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3833. }
  3834. /**
  3835. * Class used to store matrix data (4x4)
  3836. */
  3837. export class Matrix {
  3838. private static _updateFlagSeed;
  3839. private static _identityReadOnly;
  3840. private _isIdentity;
  3841. private _isIdentityDirty;
  3842. private _isIdentity3x2;
  3843. private _isIdentity3x2Dirty;
  3844. /**
  3845. * Gets the update flag of the matrix which is an unique number for the matrix.
  3846. * It will be incremented every time the matrix data change.
  3847. * You can use it to speed the comparison between two versions of the same matrix.
  3848. */
  3849. updateFlag: number;
  3850. private readonly _m;
  3851. /**
  3852. * Gets the internal data of the matrix
  3853. */
  3854. get m(): DeepImmutable<Float32Array>;
  3855. /** @hidden */
  3856. _markAsUpdated(): void;
  3857. /** @hidden */
  3858. private _updateIdentityStatus;
  3859. /**
  3860. * Creates an empty matrix (filled with zeros)
  3861. */
  3862. constructor();
  3863. /**
  3864. * Check if the current matrix is identity
  3865. * @returns true is the matrix is the identity matrix
  3866. */
  3867. isIdentity(): boolean;
  3868. /**
  3869. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3870. * @returns true is the matrix is the identity matrix
  3871. */
  3872. isIdentityAs3x2(): boolean;
  3873. /**
  3874. * Gets the determinant of the matrix
  3875. * @returns the matrix determinant
  3876. */
  3877. determinant(): number;
  3878. /**
  3879. * Returns the matrix as a Float32Array
  3880. * @returns the matrix underlying array
  3881. */
  3882. toArray(): DeepImmutable<Float32Array>;
  3883. /**
  3884. * Returns the matrix as a Float32Array
  3885. * @returns the matrix underlying array.
  3886. */
  3887. asArray(): DeepImmutable<Float32Array>;
  3888. /**
  3889. * Inverts the current matrix in place
  3890. * @returns the current inverted matrix
  3891. */
  3892. invert(): Matrix;
  3893. /**
  3894. * Sets all the matrix elements to zero
  3895. * @returns the current matrix
  3896. */
  3897. reset(): Matrix;
  3898. /**
  3899. * Adds the current matrix with a second one
  3900. * @param other defines the matrix to add
  3901. * @returns a new matrix as the addition of the current matrix and the given one
  3902. */
  3903. add(other: DeepImmutable<Matrix>): Matrix;
  3904. /**
  3905. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3906. * @param other defines the matrix to add
  3907. * @param result defines the target matrix
  3908. * @returns the current matrix
  3909. */
  3910. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3911. /**
  3912. * Adds in place the given matrix to the current matrix
  3913. * @param other defines the second operand
  3914. * @returns the current updated matrix
  3915. */
  3916. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3917. /**
  3918. * Sets the given matrix to the current inverted Matrix
  3919. * @param other defines the target matrix
  3920. * @returns the unmodified current matrix
  3921. */
  3922. invertToRef(other: Matrix): Matrix;
  3923. /**
  3924. * add a value at the specified position in the current Matrix
  3925. * @param index the index of the value within the matrix. between 0 and 15.
  3926. * @param value the value to be added
  3927. * @returns the current updated matrix
  3928. */
  3929. addAtIndex(index: number, value: number): Matrix;
  3930. /**
  3931. * mutiply the specified position in the current Matrix by a value
  3932. * @param index the index of the value within the matrix. between 0 and 15.
  3933. * @param value the value to be added
  3934. * @returns the current updated matrix
  3935. */
  3936. multiplyAtIndex(index: number, value: number): Matrix;
  3937. /**
  3938. * Inserts the translation vector (using 3 floats) in the current matrix
  3939. * @param x defines the 1st component of the translation
  3940. * @param y defines the 2nd component of the translation
  3941. * @param z defines the 3rd component of the translation
  3942. * @returns the current updated matrix
  3943. */
  3944. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3945. /**
  3946. * Adds the translation vector (using 3 floats) in the current matrix
  3947. * @param x defines the 1st component of the translation
  3948. * @param y defines the 2nd component of the translation
  3949. * @param z defines the 3rd component of the translation
  3950. * @returns the current updated matrix
  3951. */
  3952. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3953. /**
  3954. * Inserts the translation vector in the current matrix
  3955. * @param vector3 defines the translation to insert
  3956. * @returns the current updated matrix
  3957. */
  3958. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3959. /**
  3960. * Gets the translation value of the current matrix
  3961. * @returns a new Vector3 as the extracted translation from the matrix
  3962. */
  3963. getTranslation(): Vector3;
  3964. /**
  3965. * Fill a Vector3 with the extracted translation from the matrix
  3966. * @param result defines the Vector3 where to store the translation
  3967. * @returns the current matrix
  3968. */
  3969. getTranslationToRef(result: Vector3): Matrix;
  3970. /**
  3971. * Remove rotation and scaling part from the matrix
  3972. * @returns the updated matrix
  3973. */
  3974. removeRotationAndScaling(): Matrix;
  3975. /**
  3976. * Multiply two matrices
  3977. * @param other defines the second operand
  3978. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3979. */
  3980. multiply(other: DeepImmutable<Matrix>): Matrix;
  3981. /**
  3982. * Copy the current matrix from the given one
  3983. * @param other defines the source matrix
  3984. * @returns the current updated matrix
  3985. */
  3986. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Populates the given array from the starting index with the current matrix values
  3989. * @param array defines the target array
  3990. * @param offset defines the offset in the target array where to start storing values
  3991. * @returns the current matrix
  3992. */
  3993. copyToArray(array: Float32Array, offset?: number): Matrix;
  3994. /**
  3995. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3996. * @param other defines the second operand
  3997. * @param result defines the matrix where to store the multiplication
  3998. * @returns the current matrix
  3999. */
  4000. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4001. /**
  4002. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4003. * @param other defines the second operand
  4004. * @param result defines the array where to store the multiplication
  4005. * @param offset defines the offset in the target array where to start storing values
  4006. * @returns the current matrix
  4007. */
  4008. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4009. /**
  4010. * Check equality between this matrix and a second one
  4011. * @param value defines the second matrix to compare
  4012. * @returns true is the current matrix and the given one values are strictly equal
  4013. */
  4014. equals(value: DeepImmutable<Matrix>): boolean;
  4015. /**
  4016. * Clone the current matrix
  4017. * @returns a new matrix from the current matrix
  4018. */
  4019. clone(): Matrix;
  4020. /**
  4021. * Returns the name of the current matrix class
  4022. * @returns the string "Matrix"
  4023. */
  4024. getClassName(): string;
  4025. /**
  4026. * Gets the hash code of the current matrix
  4027. * @returns the hash code
  4028. */
  4029. getHashCode(): number;
  4030. /**
  4031. * Decomposes the current Matrix into a translation, rotation and scaling components
  4032. * @param scale defines the scale vector3 given as a reference to update
  4033. * @param rotation defines the rotation quaternion given as a reference to update
  4034. * @param translation defines the translation vector3 given as a reference to update
  4035. * @returns true if operation was successful
  4036. */
  4037. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4038. /**
  4039. * Gets specific row of the matrix
  4040. * @param index defines the number of the row to get
  4041. * @returns the index-th row of the current matrix as a new Vector4
  4042. */
  4043. getRow(index: number): Nullable<Vector4>;
  4044. /**
  4045. * Sets the index-th row of the current matrix to the vector4 values
  4046. * @param index defines the number of the row to set
  4047. * @param row defines the target vector4
  4048. * @returns the updated current matrix
  4049. */
  4050. setRow(index: number, row: Vector4): Matrix;
  4051. /**
  4052. * Compute the transpose of the matrix
  4053. * @returns the new transposed matrix
  4054. */
  4055. transpose(): Matrix;
  4056. /**
  4057. * Compute the transpose of the matrix and store it in a given matrix
  4058. * @param result defines the target matrix
  4059. * @returns the current matrix
  4060. */
  4061. transposeToRef(result: Matrix): Matrix;
  4062. /**
  4063. * Sets the index-th row of the current matrix with the given 4 x float values
  4064. * @param index defines the row index
  4065. * @param x defines the x component to set
  4066. * @param y defines the y component to set
  4067. * @param z defines the z component to set
  4068. * @param w defines the w component to set
  4069. * @returns the updated current matrix
  4070. */
  4071. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4072. /**
  4073. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4074. * @param scale defines the scale factor
  4075. * @returns a new matrix
  4076. */
  4077. scale(scale: number): Matrix;
  4078. /**
  4079. * Scale the current matrix values by a factor to a given result matrix
  4080. * @param scale defines the scale factor
  4081. * @param result defines the matrix to store the result
  4082. * @returns the current matrix
  4083. */
  4084. scaleToRef(scale: number, result: Matrix): Matrix;
  4085. /**
  4086. * Scale the current matrix values by a factor and add the result to a given matrix
  4087. * @param scale defines the scale factor
  4088. * @param result defines the Matrix to store the result
  4089. * @returns the current matrix
  4090. */
  4091. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4092. /**
  4093. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4094. * @param ref matrix to store the result
  4095. */
  4096. toNormalMatrix(ref: Matrix): void;
  4097. /**
  4098. * Gets only rotation part of the current matrix
  4099. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4100. */
  4101. getRotationMatrix(): Matrix;
  4102. /**
  4103. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4104. * @param result defines the target matrix to store data to
  4105. * @returns the current matrix
  4106. */
  4107. getRotationMatrixToRef(result: Matrix): Matrix;
  4108. /**
  4109. * Toggles model matrix from being right handed to left handed in place and vice versa
  4110. */
  4111. toggleModelMatrixHandInPlace(): void;
  4112. /**
  4113. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleProjectionMatrixHandInPlace(): void;
  4116. /**
  4117. * Creates a matrix from an array
  4118. * @param array defines the source array
  4119. * @param offset defines an offset in the source array
  4120. * @returns a new Matrix set from the starting index of the given array
  4121. */
  4122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4123. /**
  4124. * Copy the content of an array into a given matrix
  4125. * @param array defines the source array
  4126. * @param offset defines an offset in the source array
  4127. * @param result defines the target matrix
  4128. */
  4129. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4130. /**
  4131. * Stores an array into a matrix after having multiplied each component by a given factor
  4132. * @param array defines the source array
  4133. * @param offset defines the offset in the source array
  4134. * @param scale defines the scaling factor
  4135. * @param result defines the target matrix
  4136. */
  4137. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4138. /**
  4139. * Gets an identity matrix that must not be updated
  4140. */
  4141. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4142. /**
  4143. * Stores a list of values (16) inside a given matrix
  4144. * @param initialM11 defines 1st value of 1st row
  4145. * @param initialM12 defines 2nd value of 1st row
  4146. * @param initialM13 defines 3rd value of 1st row
  4147. * @param initialM14 defines 4th value of 1st row
  4148. * @param initialM21 defines 1st value of 2nd row
  4149. * @param initialM22 defines 2nd value of 2nd row
  4150. * @param initialM23 defines 3rd value of 2nd row
  4151. * @param initialM24 defines 4th value of 2nd row
  4152. * @param initialM31 defines 1st value of 3rd row
  4153. * @param initialM32 defines 2nd value of 3rd row
  4154. * @param initialM33 defines 3rd value of 3rd row
  4155. * @param initialM34 defines 4th value of 3rd row
  4156. * @param initialM41 defines 1st value of 4th row
  4157. * @param initialM42 defines 2nd value of 4th row
  4158. * @param initialM43 defines 3rd value of 4th row
  4159. * @param initialM44 defines 4th value of 4th row
  4160. * @param result defines the target matrix
  4161. */
  4162. 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;
  4163. /**
  4164. * Creates new matrix from a list of values (16)
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @returns the new matrix
  4182. */
  4183. 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;
  4184. /**
  4185. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4186. * @param scale defines the scale vector3
  4187. * @param rotation defines the rotation quaternion
  4188. * @param translation defines the translation vector3
  4189. * @returns a new matrix
  4190. */
  4191. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4192. /**
  4193. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4194. * @param scale defines the scale vector3
  4195. * @param rotation defines the rotation quaternion
  4196. * @param translation defines the translation vector3
  4197. * @param result defines the target matrix
  4198. */
  4199. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4200. /**
  4201. * Creates a new identity matrix
  4202. * @returns a new identity matrix
  4203. */
  4204. static Identity(): Matrix;
  4205. /**
  4206. * Creates a new identity matrix and stores the result in a given matrix
  4207. * @param result defines the target matrix
  4208. */
  4209. static IdentityToRef(result: Matrix): void;
  4210. /**
  4211. * Creates a new zero matrix
  4212. * @returns a new zero matrix
  4213. */
  4214. static Zero(): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the X axis
  4217. * @param angle defines the angle (in radians) to use
  4218. * @return the new matrix
  4219. */
  4220. static RotationX(angle: number): Matrix;
  4221. /**
  4222. * Creates a new matrix as the invert of a given matrix
  4223. * @param source defines the source matrix
  4224. * @returns the new matrix
  4225. */
  4226. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the Y axis
  4235. * @param angle defines the angle (in radians) to use
  4236. * @return the new matrix
  4237. */
  4238. static RotationY(angle: number): Matrix;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y 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 RotationYToRef(angle: number, result: Matrix): void;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Z axis
  4247. * @param angle defines the angle (in radians) to use
  4248. * @return the new matrix
  4249. */
  4250. static RotationZ(angle: number): Matrix;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4253. * @param angle defines the angle (in radians) to use
  4254. * @param result defines the target matrix
  4255. */
  4256. static RotationZToRef(angle: number, result: Matrix): void;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the given axis
  4259. * @param axis defines the axis to use
  4260. * @param angle defines the angle (in radians) to use
  4261. * @return the new matrix
  4262. */
  4263. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4264. /**
  4265. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4266. * @param axis defines the axis to use
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4271. /**
  4272. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4273. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4274. * @param from defines the vector to align
  4275. * @param to defines the vector to align to
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4279. /**
  4280. * Creates a rotation matrix
  4281. * @param yaw defines the yaw angle in radians (Y axis)
  4282. * @param pitch defines the pitch angle in radians (X axis)
  4283. * @param roll defines the roll angle in radians (X axis)
  4284. * @returns the new rotation matrix
  4285. */
  4286. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4287. /**
  4288. * Creates a rotation matrix and stores it in a given matrix
  4289. * @param yaw defines the yaw angle in radians (Y axis)
  4290. * @param pitch defines the pitch angle in radians (X axis)
  4291. * @param roll defines the roll angle in radians (X axis)
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4295. /**
  4296. * Creates a scaling matrix
  4297. * @param x defines the scale factor on X axis
  4298. * @param y defines the scale factor on Y axis
  4299. * @param z defines the scale factor on Z axis
  4300. * @returns the new matrix
  4301. */
  4302. static Scaling(x: number, y: number, z: number): Matrix;
  4303. /**
  4304. * Creates a scaling matrix and stores it in a given matrix
  4305. * @param x defines the scale factor on X axis
  4306. * @param y defines the scale factor on Y axis
  4307. * @param z defines the scale factor on Z axis
  4308. * @param result defines the target matrix
  4309. */
  4310. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4311. /**
  4312. * Creates a translation matrix
  4313. * @param x defines the translation on X axis
  4314. * @param y defines the translation on Y axis
  4315. * @param z defines the translationon Z axis
  4316. * @returns the new matrix
  4317. */
  4318. static Translation(x: number, y: number, z: number): Matrix;
  4319. /**
  4320. * Creates a translation matrix and stores it in a given matrix
  4321. * @param x defines the translation on X axis
  4322. * @param y defines the translation on Y axis
  4323. * @param z defines the translationon Z axis
  4324. * @param result defines the target matrix
  4325. */
  4326. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4327. /**
  4328. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4329. * @param startValue defines the start value
  4330. * @param endValue defines the end value
  4331. * @param gradient defines the gradient factor
  4332. * @returns the new matrix
  4333. */
  4334. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4335. /**
  4336. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4337. * @param startValue defines the start value
  4338. * @param endValue defines the end value
  4339. * @param gradient defines the gradient factor
  4340. * @param result defines the Matrix object where to store data
  4341. */
  4342. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4343. /**
  4344. * Builds a new matrix whose values are computed by:
  4345. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4346. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4347. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4348. * @param startValue defines the first matrix
  4349. * @param endValue defines the second matrix
  4350. * @param gradient defines the gradient between the two matrices
  4351. * @returns the new matrix
  4352. */
  4353. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4354. /**
  4355. * Update a matrix to values which are computed by:
  4356. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4357. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4358. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4359. * @param startValue defines the first matrix
  4360. * @param endValue defines the second matrix
  4361. * @param gradient defines the gradient between the two matrices
  4362. * @param result defines the target matrix
  4363. */
  4364. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4365. /**
  4366. * 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"
  4367. * This function works in left handed mode
  4368. * @param eye defines the final position of the entity
  4369. * @param target defines where the entity should look at
  4370. * @param up defines the up vector for the entity
  4371. * @returns the new matrix
  4372. */
  4373. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4374. /**
  4375. * 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".
  4376. * This function works in left handed mode
  4377. * @param eye defines the final position of the entity
  4378. * @param target defines where the entity should look at
  4379. * @param up defines the up vector for the entity
  4380. * @param result defines the target matrix
  4381. */
  4382. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4383. /**
  4384. * 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"
  4385. * This function works in right handed mode
  4386. * @param eye defines the final position of the entity
  4387. * @param target defines where the entity should look at
  4388. * @param up defines the up vector for the entity
  4389. * @returns the new matrix
  4390. */
  4391. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4392. /**
  4393. * 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".
  4394. * This function works in right handed mode
  4395. * @param eye defines the final position of the entity
  4396. * @param target defines where the entity should look at
  4397. * @param up defines the up vector for the entity
  4398. * @param result defines the target matrix
  4399. */
  4400. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4401. /**
  4402. * Create a left-handed orthographic projection matrix
  4403. * @param width defines the viewport width
  4404. * @param height defines the viewport height
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @returns a new matrix as a left-handed orthographic projection matrix
  4408. */
  4409. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4410. /**
  4411. * Store a left-handed orthographic projection to a given matrix
  4412. * @param width defines the viewport width
  4413. * @param height defines the viewport height
  4414. * @param znear defines the near clip plane
  4415. * @param zfar defines the far clip plane
  4416. * @param result defines the target matrix
  4417. */
  4418. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4419. /**
  4420. * Create a left-handed orthographic projection matrix
  4421. * @param left defines the viewport left coordinate
  4422. * @param right defines the viewport right coordinate
  4423. * @param bottom defines the viewport bottom coordinate
  4424. * @param top defines the viewport top coordinate
  4425. * @param znear defines the near clip plane
  4426. * @param zfar defines the far clip plane
  4427. * @returns a new matrix as a left-handed orthographic projection matrix
  4428. */
  4429. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4430. /**
  4431. * Stores a left-handed orthographic projection into a given matrix
  4432. * @param left defines the viewport left coordinate
  4433. * @param right defines the viewport right coordinate
  4434. * @param bottom defines the viewport bottom coordinate
  4435. * @param top defines the viewport top coordinate
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @param result defines the target matrix
  4439. */
  4440. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4441. /**
  4442. * Creates a right-handed orthographic projection matrix
  4443. * @param left defines the viewport left coordinate
  4444. * @param right defines the viewport right coordinate
  4445. * @param bottom defines the viewport bottom coordinate
  4446. * @param top defines the viewport top coordinate
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @returns a new matrix as a right-handed orthographic projection matrix
  4450. */
  4451. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4452. /**
  4453. * Stores a right-handed orthographic projection into a given matrix
  4454. * @param left defines the viewport left coordinate
  4455. * @param right defines the viewport right coordinate
  4456. * @param bottom defines the viewport bottom coordinate
  4457. * @param top defines the viewport top coordinate
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. */
  4462. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4463. /**
  4464. * Creates a left-handed perspective projection matrix
  4465. * @param width defines the viewport width
  4466. * @param height defines the viewport height
  4467. * @param znear defines the near clip plane
  4468. * @param zfar defines the far clip plane
  4469. * @returns a new matrix as a left-handed perspective projection matrix
  4470. */
  4471. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4472. /**
  4473. * Creates a left-handed perspective projection matrix
  4474. * @param fov defines the horizontal field of view
  4475. * @param aspect defines the aspect ratio
  4476. * @param znear defines the near clip plane
  4477. * @param zfar defines the far clip plane
  4478. * @returns a new matrix as a left-handed perspective projection matrix
  4479. */
  4480. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4481. /**
  4482. * Stores a left-handed perspective projection into a given matrix
  4483. * @param fov defines the horizontal field of view
  4484. * @param aspect defines the aspect ratio
  4485. * @param znear defines the near clip plane
  4486. * @param zfar defines the far clip plane
  4487. * @param result defines the target matrix
  4488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4489. */
  4490. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4491. /**
  4492. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4493. * @param fov defines the horizontal field of view
  4494. * @param aspect defines the aspect ratio
  4495. * @param znear defines the near clip plane
  4496. * @param zfar not used as infinity is used as far clip
  4497. * @param result defines the target matrix
  4498. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4499. */
  4500. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4501. /**
  4502. * Creates a right-handed perspective projection matrix
  4503. * @param fov defines the horizontal field of view
  4504. * @param aspect defines the aspect ratio
  4505. * @param znear defines the near clip plane
  4506. * @param zfar defines the far clip plane
  4507. * @returns a new matrix as a right-handed perspective projection matrix
  4508. */
  4509. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4510. /**
  4511. * Stores a right-handed perspective projection into a given matrix
  4512. * @param fov defines the horizontal field of view
  4513. * @param aspect defines the aspect ratio
  4514. * @param znear defines the near clip plane
  4515. * @param zfar defines the far clip plane
  4516. * @param result defines the target matrix
  4517. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4518. */
  4519. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4520. /**
  4521. * Stores a right-handed perspective projection into a given matrix
  4522. * @param fov defines the horizontal field of view
  4523. * @param aspect defines the aspect ratio
  4524. * @param znear defines the near clip plane
  4525. * @param zfar not used as infinity is used as far clip
  4526. * @param result defines the target matrix
  4527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4528. */
  4529. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4530. /**
  4531. * Stores a perspective projection for WebVR info a given matrix
  4532. * @param fov defines the field of view
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @param result defines the target matrix
  4536. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4537. */
  4538. static PerspectiveFovWebVRToRef(fov: {
  4539. upDegrees: number;
  4540. downDegrees: number;
  4541. leftDegrees: number;
  4542. rightDegrees: number;
  4543. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4544. /**
  4545. * Computes a complete transformation matrix
  4546. * @param viewport defines the viewport to use
  4547. * @param world defines the world matrix
  4548. * @param view defines the view matrix
  4549. * @param projection defines the projection matrix
  4550. * @param zmin defines the near clip plane
  4551. * @param zmax defines the far clip plane
  4552. * @returns the transformation matrix
  4553. */
  4554. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4555. /**
  4556. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4557. * @param matrix defines the matrix to use
  4558. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4559. */
  4560. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4561. /**
  4562. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Compute the transpose of a given matrix
  4569. * @param matrix defines the matrix to transpose
  4570. * @returns the new matrix
  4571. */
  4572. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4573. /**
  4574. * Compute the transpose of a matrix and store it in a target matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @param result defines the target matrix
  4577. */
  4578. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4579. /**
  4580. * Computes a reflection matrix from a plane
  4581. * @param plane defines the reflection plane
  4582. * @returns a new matrix
  4583. */
  4584. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4591. /**
  4592. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4593. * @param xaxis defines the value of the 1st axis
  4594. * @param yaxis defines the value of the 2nd axis
  4595. * @param zaxis defines the value of the 3rd axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4599. /**
  4600. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4601. * @param quat defines the quaternion to use
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4605. }
  4606. /**
  4607. * @hidden
  4608. */
  4609. export class TmpVectors {
  4610. static Vector2: Vector2[];
  4611. static Vector3: Vector3[];
  4612. static Vector4: Vector4[];
  4613. static Quaternion: Quaternion[];
  4614. static Matrix: Matrix[];
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. /**
  4619. * Defines potential orientation for back face culling
  4620. */
  4621. export enum Orientation {
  4622. /**
  4623. * Clockwise
  4624. */
  4625. CW = 0,
  4626. /** Counter clockwise */
  4627. CCW = 1
  4628. }
  4629. /** Class used to represent a Bezier curve */
  4630. export class BezierCurve {
  4631. /**
  4632. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4633. * @param t defines the time
  4634. * @param x1 defines the left coordinate on X axis
  4635. * @param y1 defines the left coordinate on Y axis
  4636. * @param x2 defines the right coordinate on X axis
  4637. * @param y2 defines the right coordinate on Y axis
  4638. * @returns the interpolated value
  4639. */
  4640. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4641. }
  4642. /**
  4643. * Defines angle representation
  4644. */
  4645. export class Angle {
  4646. private _radians;
  4647. /**
  4648. * Creates an Angle object of "radians" radians (float).
  4649. * @param radians the angle in radians
  4650. */
  4651. constructor(radians: number);
  4652. /**
  4653. * Get value in degrees
  4654. * @returns the Angle value in degrees (float)
  4655. */
  4656. degrees(): number;
  4657. /**
  4658. * Get value in radians
  4659. * @returns the Angle value in radians (float)
  4660. */
  4661. radians(): number;
  4662. /**
  4663. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4664. * @param a defines first vector
  4665. * @param b defines second vector
  4666. * @returns a new Angle
  4667. */
  4668. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4669. /**
  4670. * Gets a new Angle object from the given float in radians
  4671. * @param radians defines the angle value in radians
  4672. * @returns a new Angle
  4673. */
  4674. static FromRadians(radians: number): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in degrees
  4677. * @param degrees defines the angle value in degrees
  4678. * @returns a new Angle
  4679. */
  4680. static FromDegrees(degrees: number): Angle;
  4681. }
  4682. /**
  4683. * This represents an arc in a 2d space.
  4684. */
  4685. export class Arc2 {
  4686. /** Defines the start point of the arc */
  4687. startPoint: Vector2;
  4688. /** Defines the mid point of the arc */
  4689. midPoint: Vector2;
  4690. /** Defines the end point of the arc */
  4691. endPoint: Vector2;
  4692. /**
  4693. * Defines the center point of the arc.
  4694. */
  4695. centerPoint: Vector2;
  4696. /**
  4697. * Defines the radius of the arc.
  4698. */
  4699. radius: number;
  4700. /**
  4701. * Defines the angle of the arc (from mid point to end point).
  4702. */
  4703. angle: Angle;
  4704. /**
  4705. * Defines the start angle of the arc (from start point to middle point).
  4706. */
  4707. startAngle: Angle;
  4708. /**
  4709. * Defines the orientation of the arc (clock wise/counter clock wise).
  4710. */
  4711. orientation: Orientation;
  4712. /**
  4713. * Creates an Arc object from the three given points : start, middle and end.
  4714. * @param startPoint Defines the start point of the arc
  4715. * @param midPoint Defines the midlle point of the arc
  4716. * @param endPoint Defines the end point of the arc
  4717. */
  4718. constructor(
  4719. /** Defines the start point of the arc */
  4720. startPoint: Vector2,
  4721. /** Defines the mid point of the arc */
  4722. midPoint: Vector2,
  4723. /** Defines the end point of the arc */
  4724. endPoint: Vector2);
  4725. }
  4726. /**
  4727. * Represents a 2D path made up of multiple 2D points
  4728. */
  4729. export class Path2 {
  4730. private _points;
  4731. private _length;
  4732. /**
  4733. * If the path start and end point are the same
  4734. */
  4735. closed: boolean;
  4736. /**
  4737. * Creates a Path2 object from the starting 2D coordinates x and y.
  4738. * @param x the starting points x value
  4739. * @param y the starting points y value
  4740. */
  4741. constructor(x: number, y: number);
  4742. /**
  4743. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4744. * @param x the added points x value
  4745. * @param y the added points y value
  4746. * @returns the updated Path2.
  4747. */
  4748. addLineTo(x: number, y: number): Path2;
  4749. /**
  4750. * 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.
  4751. * @param midX middle point x value
  4752. * @param midY middle point y value
  4753. * @param endX end point x value
  4754. * @param endY end point y value
  4755. * @param numberOfSegments (default: 36)
  4756. * @returns the updated Path2.
  4757. */
  4758. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4759. /**
  4760. * Closes the Path2.
  4761. * @returns the Path2.
  4762. */
  4763. close(): Path2;
  4764. /**
  4765. * Gets the sum of the distance between each sequential point in the path
  4766. * @returns the Path2 total length (float).
  4767. */
  4768. length(): number;
  4769. /**
  4770. * Gets the points which construct the path
  4771. * @returns the Path2 internal array of points.
  4772. */
  4773. getPoints(): Vector2[];
  4774. /**
  4775. * Retreives the point at the distance aways from the starting point
  4776. * @param normalizedLengthPosition the length along the path to retreive the point from
  4777. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4778. */
  4779. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4780. /**
  4781. * Creates a new path starting from an x and y position
  4782. * @param x starting x value
  4783. * @param y starting y value
  4784. * @returns a new Path2 starting at the coordinates (x, y).
  4785. */
  4786. static StartingAt(x: number, y: number): Path2;
  4787. }
  4788. /**
  4789. * Represents a 3D path made up of multiple 3D points
  4790. */
  4791. export class Path3D {
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[];
  4796. private _curve;
  4797. private _distances;
  4798. private _tangents;
  4799. private _normals;
  4800. private _binormals;
  4801. private _raw;
  4802. private _alignTangentsWithPath;
  4803. private readonly _pointAtData;
  4804. /**
  4805. * new Path3D(path, normal, raw)
  4806. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4807. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4808. * @param path an array of Vector3, the curve axis of the Path3D
  4809. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4810. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4812. */
  4813. constructor(
  4814. /**
  4815. * an array of Vector3, the curve axis of the Path3D
  4816. */
  4817. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4818. /**
  4819. * Returns the Path3D array of successive Vector3 designing its curve.
  4820. * @returns the Path3D array of successive Vector3 designing its curve.
  4821. */
  4822. getCurve(): Vector3[];
  4823. /**
  4824. * Returns the Path3D array of successive Vector3 designing its curve.
  4825. * @returns the Path3D array of successive Vector3 designing its curve.
  4826. */
  4827. getPoints(): Vector3[];
  4828. /**
  4829. * @returns the computed length (float) of the path.
  4830. */
  4831. length(): number;
  4832. /**
  4833. * Returns an array populated with tangent vectors on each Path3D curve point.
  4834. * @returns an array populated with tangent vectors on each Path3D curve point.
  4835. */
  4836. getTangents(): Vector3[];
  4837. /**
  4838. * Returns an array populated with normal vectors on each Path3D curve point.
  4839. * @returns an array populated with normal vectors on each Path3D curve point.
  4840. */
  4841. getNormals(): Vector3[];
  4842. /**
  4843. * Returns an array populated with binormal vectors on each Path3D curve point.
  4844. * @returns an array populated with binormal vectors on each Path3D curve point.
  4845. */
  4846. getBinormals(): Vector3[];
  4847. /**
  4848. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. */
  4851. getDistances(): number[];
  4852. /**
  4853. * Returns an interpolated point along this path
  4854. * @param position the position of the point along this path, from 0.0 to 1.0
  4855. * @returns a new Vector3 as the point
  4856. */
  4857. getPointAt(position: number): Vector3;
  4858. /**
  4859. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4862. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4863. */
  4864. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4865. /**
  4866. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4867. * @param position the position of the point along this path, from 0.0 to 1.0
  4868. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4869. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4870. */
  4871. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4872. /**
  4873. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4874. * @param position the position of the point along this path, from 0.0 to 1.0
  4875. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4876. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4877. */
  4878. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4879. /**
  4880. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4883. */
  4884. getDistanceAt(position: number): number;
  4885. /**
  4886. * Returns the array index of the previous point of an interpolated point along this path
  4887. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4888. * @returns the array index
  4889. */
  4890. getPreviousPointIndexAt(position: number): number;
  4891. /**
  4892. * 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)
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the sub position
  4895. */
  4896. getSubPositionAt(position: number): number;
  4897. /**
  4898. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4899. * @param target the vector of which to get the closest position to
  4900. * @returns the position of the closest virtual point on this path to the target vector
  4901. */
  4902. getClosestPositionTo(target: Vector3): number;
  4903. /**
  4904. * Returns a sub path (slice) of this path
  4905. * @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
  4906. * @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
  4907. * @returns a sub path (slice) of this path
  4908. */
  4909. slice(start?: number, end?: number): Path3D;
  4910. /**
  4911. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4912. * @param path path which all values are copied into the curves points
  4913. * @param firstNormal which should be projected onto the curve
  4914. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4915. * @returns the same object updated.
  4916. */
  4917. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4918. private _compute;
  4919. private _getFirstNonNullVector;
  4920. private _getLastNonNullVector;
  4921. private _normalVector;
  4922. /**
  4923. * Updates the point at data for an interpolated point along this curve
  4924. * @param position the position of the point along this curve, from 0.0 to 1.0
  4925. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4926. * @returns the (updated) point at data
  4927. */
  4928. private _updatePointAtData;
  4929. /**
  4930. * Updates the point at data from the specified parameters
  4931. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4932. * @param point the interpolated point
  4933. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4934. */
  4935. private _setPointAtData;
  4936. /**
  4937. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4938. */
  4939. private _updateInterpolationMatrix;
  4940. }
  4941. /**
  4942. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4943. * A Curve3 is designed from a series of successive Vector3.
  4944. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4945. */
  4946. export class Curve3 {
  4947. private _points;
  4948. private _length;
  4949. /**
  4950. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4951. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4952. * @param v1 (Vector3) the control point
  4953. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4954. * @param nbPoints (integer) the wanted number of points in the curve
  4955. * @returns the created Curve3
  4956. */
  4957. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4958. /**
  4959. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4960. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4961. * @param v1 (Vector3) the first control point
  4962. * @param v2 (Vector3) the second control point
  4963. * @param v3 (Vector3) the end point of the Cubic Bezier
  4964. * @param nbPoints (integer) the wanted number of points in the curve
  4965. * @returns the created Curve3
  4966. */
  4967. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4968. /**
  4969. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4970. * @param p1 (Vector3) the origin point of the Hermite Spline
  4971. * @param t1 (Vector3) the tangent vector at the origin point
  4972. * @param p2 (Vector3) the end point of the Hermite Spline
  4973. * @param t2 (Vector3) the tangent vector at the end point
  4974. * @param nbPoints (integer) the wanted number of points in the curve
  4975. * @returns the created Curve3
  4976. */
  4977. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4978. /**
  4979. * Returns a Curve3 object along a CatmullRom Spline curve :
  4980. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4981. * @param nbPoints (integer) the wanted number of points between each curve control points
  4982. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4986. /**
  4987. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4988. * A Curve3 is designed from a series of successive Vector3.
  4989. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4990. * @param points points which make up the curve
  4991. */
  4992. constructor(points: Vector3[]);
  4993. /**
  4994. * @returns the Curve3 stored array of successive Vector3
  4995. */
  4996. getPoints(): Vector3[];
  4997. /**
  4998. * @returns the computed length (float) of the curve.
  4999. */
  5000. length(): number;
  5001. /**
  5002. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5003. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5004. * curveA and curveB keep unchanged.
  5005. * @param curve the curve to continue from this curve
  5006. * @returns the newly constructed curve
  5007. */
  5008. continue(curve: DeepImmutable<Curve3>): Curve3;
  5009. private _computeLength;
  5010. }
  5011. }
  5012. declare module BABYLON {
  5013. /**
  5014. * This represents the main contract an easing function should follow.
  5015. * Easing functions are used throughout the animation system.
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export interface IEasingFunction {
  5019. /**
  5020. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5021. * of the easing function.
  5022. * The link below provides some of the most common examples of easing functions.
  5023. * @see https://easings.net/
  5024. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5025. * @returns the corresponding value on the curve defined by the easing function
  5026. */
  5027. ease(gradient: number): number;
  5028. }
  5029. /**
  5030. * Base class used for every default easing function.
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class EasingFunction implements IEasingFunction {
  5034. /**
  5035. * Interpolation follows the mathematical formula associated with the easing function.
  5036. */
  5037. static readonly EASINGMODE_EASEIN: number;
  5038. /**
  5039. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5040. */
  5041. static readonly EASINGMODE_EASEOUT: number;
  5042. /**
  5043. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5044. */
  5045. static readonly EASINGMODE_EASEINOUT: number;
  5046. private _easingMode;
  5047. /**
  5048. * Sets the easing mode of the current function.
  5049. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5050. */
  5051. setEasingMode(easingMode: number): void;
  5052. /**
  5053. * Gets the current easing mode.
  5054. * @returns the easing mode
  5055. */
  5056. getEasingMode(): number;
  5057. /**
  5058. * @hidden
  5059. */
  5060. easeInCore(gradient: number): number;
  5061. /**
  5062. * Given an input gradient between 0 and 1, this returns the corresponding value
  5063. * of the easing function.
  5064. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5065. * @returns the corresponding value on the curve defined by the easing function
  5066. */
  5067. ease(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a circle shape (see link below).
  5071. * @see https://easings.net/#easeInCirc
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class CircleEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a ease back shape (see link below).
  5080. * @see https://easings.net/#easeInBack
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BackEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the amplitude of the function */
  5085. amplitude: number;
  5086. /**
  5087. * Instantiates a back ease easing
  5088. * @see https://easings.net/#easeInBack
  5089. * @param amplitude Defines the amplitude of the function
  5090. */
  5091. constructor(
  5092. /** Defines the amplitude of the function */
  5093. amplitude?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a bouncing shape (see link below).
  5099. * @see https://easings.net/#easeInBounce
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class BounceEase extends EasingFunction implements IEasingFunction {
  5103. /** Defines the number of bounces */
  5104. bounces: number;
  5105. /** Defines the amplitude of the bounce */
  5106. bounciness: number;
  5107. /**
  5108. * Instantiates a bounce easing
  5109. * @see https://easings.net/#easeInBounce
  5110. * @param bounces Defines the number of bounces
  5111. * @param bounciness Defines the amplitude of the bounce
  5112. */
  5113. constructor(
  5114. /** Defines the number of bounces */
  5115. bounces?: number,
  5116. /** Defines the amplitude of the bounce */
  5117. bounciness?: number);
  5118. /** @hidden */
  5119. easeInCore(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a power of 3 shape (see link below).
  5123. * @see https://easings.net/#easeInCubic
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CubicEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an elastic shape (see link below).
  5132. * @see https://easings.net/#easeInElastic
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the number of oscillations*/
  5137. oscillations: number;
  5138. /** Defines the amplitude of the oscillations*/
  5139. springiness: number;
  5140. /**
  5141. * Instantiates an elastic easing function
  5142. * @see https://easings.net/#easeInElastic
  5143. * @param oscillations Defines the number of oscillations
  5144. * @param springiness Defines the amplitude of the oscillations
  5145. */
  5146. constructor(
  5147. /** Defines the number of oscillations*/
  5148. oscillations?: number,
  5149. /** Defines the amplitude of the oscillations*/
  5150. springiness?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with an exponential shape (see link below).
  5156. * @see https://easings.net/#easeInExpo
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the exponent of the function */
  5161. exponent: number;
  5162. /**
  5163. * Instantiates an exponential easing function
  5164. * @see https://easings.net/#easeInExpo
  5165. * @param exponent Defines the exponent of the function
  5166. */
  5167. constructor(
  5168. /** Defines the exponent of the function */
  5169. exponent?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class PowerEase extends EasingFunction implements IEasingFunction {
  5179. /** Defines the power of the function */
  5180. power: number;
  5181. /**
  5182. * Instantiates an power base easing function
  5183. * @see https://easings.net/#easeInQuad
  5184. * @param power Defines the power of the function
  5185. */
  5186. constructor(
  5187. /** Defines the power of the function */
  5188. power?: number);
  5189. /** @hidden */
  5190. easeInCore(gradient: number): number;
  5191. }
  5192. /**
  5193. * Easing function with a power of 2 shape (see link below).
  5194. * @see https://easings.net/#easeInQuad
  5195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5196. */
  5197. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power of 4 shape (see link below).
  5203. * @see https://easings.net/#easeInQuart
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5207. /** @hidden */
  5208. easeInCore(gradient: number): number;
  5209. }
  5210. /**
  5211. * Easing function with a power of 5 shape (see link below).
  5212. * @see https://easings.net/#easeInQuint
  5213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5214. */
  5215. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5216. /** @hidden */
  5217. easeInCore(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a sin shape (see link below).
  5221. * @see https://easings.net/#easeInSine
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class SineEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a bezier shape (see link below).
  5230. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the x component of the start tangent in the bezier curve */
  5235. x1: number;
  5236. /** Defines the y component of the start tangent in the bezier curve */
  5237. y1: number;
  5238. /** Defines the x component of the end tangent in the bezier curve */
  5239. x2: number;
  5240. /** Defines the y component of the end tangent in the bezier curve */
  5241. y2: number;
  5242. /**
  5243. * Instantiates a bezier function
  5244. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5245. * @param x1 Defines the x component of the start tangent in the bezier curve
  5246. * @param y1 Defines the y component of the start tangent in the bezier curve
  5247. * @param x2 Defines the x component of the end tangent in the bezier curve
  5248. * @param y2 Defines the y component of the end tangent in the bezier curve
  5249. */
  5250. constructor(
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1?: number,
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1?: number,
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2?: number,
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2?: number);
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. }
  5263. declare module BABYLON {
  5264. /**
  5265. * Class used to hold a RBG color
  5266. */
  5267. export class Color3 {
  5268. /**
  5269. * Defines the red component (between 0 and 1, default is 0)
  5270. */
  5271. r: number;
  5272. /**
  5273. * Defines the green component (between 0 and 1, default is 0)
  5274. */
  5275. g: number;
  5276. /**
  5277. * Defines the blue component (between 0 and 1, default is 0)
  5278. */
  5279. b: number;
  5280. /**
  5281. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5282. * @param r defines the red component (between 0 and 1, default is 0)
  5283. * @param g defines the green component (between 0 and 1, default is 0)
  5284. * @param b defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. constructor(
  5287. /**
  5288. * Defines the red component (between 0 and 1, default is 0)
  5289. */
  5290. r?: number,
  5291. /**
  5292. * Defines the green component (between 0 and 1, default is 0)
  5293. */
  5294. g?: number,
  5295. /**
  5296. * Defines the blue component (between 0 and 1, default is 0)
  5297. */
  5298. b?: number);
  5299. /**
  5300. * Creates a string with the Color3 current values
  5301. * @returns the string representation of the Color3 object
  5302. */
  5303. toString(): string;
  5304. /**
  5305. * Returns the string "Color3"
  5306. * @returns "Color3"
  5307. */
  5308. getClassName(): string;
  5309. /**
  5310. * Compute the Color3 hash code
  5311. * @returns an unique number that can be used to hash Color3 objects
  5312. */
  5313. getHashCode(): number;
  5314. /**
  5315. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5316. * @param array defines the array where to store the r,g,b components
  5317. * @param index defines an optional index in the target array to define where to start storing values
  5318. * @returns the current Color3 object
  5319. */
  5320. toArray(array: FloatArray, index?: number): Color3;
  5321. /**
  5322. * Returns a new Color4 object from the current Color3 and the given alpha
  5323. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5324. * @returns a new Color4 object
  5325. */
  5326. toColor4(alpha?: number): Color4;
  5327. /**
  5328. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5329. * @returns the new array
  5330. */
  5331. asArray(): number[];
  5332. /**
  5333. * Returns the luminance value
  5334. * @returns a float value
  5335. */
  5336. toLuminance(): number;
  5337. /**
  5338. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5339. * @param otherColor defines the second operand
  5340. * @returns the new Color3 object
  5341. */
  5342. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5343. /**
  5344. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5345. * @param otherColor defines the second operand
  5346. * @param result defines the Color3 object where to store the result
  5347. * @returns the current Color3
  5348. */
  5349. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5350. /**
  5351. * Determines equality between Color3 objects
  5352. * @param otherColor defines the second operand
  5353. * @returns true if the rgb values are equal to the given ones
  5354. */
  5355. equals(otherColor: DeepImmutable<Color3>): boolean;
  5356. /**
  5357. * Determines equality between the current Color3 object and a set of r,b,g values
  5358. * @param r defines the red component to check
  5359. * @param g defines the green component to check
  5360. * @param b defines the blue component to check
  5361. * @returns true if the rgb values are equal to the given ones
  5362. */
  5363. equalsFloats(r: number, g: number, b: number): boolean;
  5364. /**
  5365. * Multiplies in place each rgb value by scale
  5366. * @param scale defines the scaling factor
  5367. * @returns the updated Color3
  5368. */
  5369. scale(scale: number): Color3;
  5370. /**
  5371. * Multiplies the rgb values by scale and stores the result into "result"
  5372. * @param scale defines the scaling factor
  5373. * @param result defines the Color3 object where to store the result
  5374. * @returns the unmodified current Color3
  5375. */
  5376. scaleToRef(scale: number, result: Color3): Color3;
  5377. /**
  5378. * Scale the current Color3 values by a factor and add the result to a given Color3
  5379. * @param scale defines the scale factor
  5380. * @param result defines color to store the result into
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Clamps the rgb values by the min and max values and stores the result into "result"
  5386. * @param min defines minimum clamping value (default is 0)
  5387. * @param max defines maximum clamping value (default is 1)
  5388. * @param result defines color to store the result into
  5389. * @returns the original Color3
  5390. */
  5391. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5392. /**
  5393. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5394. * @param otherColor defines the second operand
  5395. * @returns the new Color3
  5396. */
  5397. add(otherColor: DeepImmutable<Color3>): Color3;
  5398. /**
  5399. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5400. * @param otherColor defines the second operand
  5401. * @param result defines Color3 object to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5405. /**
  5406. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5407. * @param otherColor defines the second operand
  5408. * @returns the new Color3
  5409. */
  5410. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5413. * @param otherColor defines the second operand
  5414. * @param result defines Color3 object to store the result into
  5415. * @returns the unmodified current Color3
  5416. */
  5417. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5418. /**
  5419. * Copy the current object
  5420. * @returns a new Color3 copied the current one
  5421. */
  5422. clone(): Color3;
  5423. /**
  5424. * Copies the rgb values from the source in the current Color3
  5425. * @param source defines the source Color3 object
  5426. * @returns the updated Color3 object
  5427. */
  5428. copyFrom(source: DeepImmutable<Color3>): Color3;
  5429. /**
  5430. * Updates the Color3 rgb values from the given floats
  5431. * @param r defines the red component to read from
  5432. * @param g defines the green component to read from
  5433. * @param b defines the blue component to read from
  5434. * @returns the current Color3 object
  5435. */
  5436. copyFromFloats(r: number, g: number, b: number): Color3;
  5437. /**
  5438. * Updates the Color3 rgb values from the given floats
  5439. * @param r defines the red component to read from
  5440. * @param g defines the green component to read from
  5441. * @param b defines the blue component to read from
  5442. * @returns the current Color3 object
  5443. */
  5444. set(r: number, g: number, b: number): Color3;
  5445. /**
  5446. * Compute the Color3 hexadecimal code as a string
  5447. * @returns a string containing the hexadecimal representation of the Color3 object
  5448. */
  5449. toHexString(): string;
  5450. /**
  5451. * Computes a new Color3 converted from the current one to linear space
  5452. * @returns a new Color3 object
  5453. */
  5454. toLinearSpace(): Color3;
  5455. /**
  5456. * Converts current color in rgb space to HSV values
  5457. * @returns a new color3 representing the HSV values
  5458. */
  5459. toHSV(): Color3;
  5460. /**
  5461. * Converts current color in rgb space to HSV values
  5462. * @param result defines the Color3 where to store the HSV values
  5463. */
  5464. toHSVToRef(result: Color3): void;
  5465. /**
  5466. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5467. * @param convertedColor defines the Color3 object where to store the linear space version
  5468. * @returns the unmodified Color3
  5469. */
  5470. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to gamma space
  5473. * @returns a new Color3 object
  5474. */
  5475. toGammaSpace(): Color3;
  5476. /**
  5477. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5478. * @param convertedColor defines the Color3 object where to store the gamma space version
  5479. * @returns the unmodified Color3
  5480. */
  5481. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5482. private static _BlackReadOnly;
  5483. /**
  5484. * Convert Hue, saturation and value to a Color3 (RGB)
  5485. * @param hue defines the hue
  5486. * @param saturation defines the saturation
  5487. * @param value defines the value
  5488. * @param result defines the Color3 where to store the RGB values
  5489. */
  5490. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5491. /**
  5492. * Creates a new Color3 from the string containing valid hexadecimal values
  5493. * @param hex defines a string containing valid hexadecimal values
  5494. * @returns a new Color3 object
  5495. */
  5496. static FromHexString(hex: string): Color3;
  5497. /**
  5498. * Creates a new Color3 from the starting index of the given array
  5499. * @param array defines the source array
  5500. * @param offset defines an offset in the source array
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5504. /**
  5505. * Creates a new Color3 from integer values (< 256)
  5506. * @param r defines the red component to read from (value between 0 and 255)
  5507. * @param g defines the green component to read from (value between 0 and 255)
  5508. * @param b defines the blue component to read from (value between 0 and 255)
  5509. * @returns a new Color3 object
  5510. */
  5511. static FromInts(r: number, g: number, b: number): Color3;
  5512. /**
  5513. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5514. * @param start defines the start Color3 value
  5515. * @param end defines the end Color3 value
  5516. * @param amount defines the gradient value between start and end
  5517. * @returns a new Color3 object
  5518. */
  5519. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5520. /**
  5521. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5522. * @param left defines the start value
  5523. * @param right defines the end value
  5524. * @param amount defines the gradient factor
  5525. * @param result defines the Color3 object where to store the result
  5526. */
  5527. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5528. /**
  5529. * Returns a Color3 value containing a red color
  5530. * @returns a new Color3 object
  5531. */
  5532. static Red(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a green color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Green(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a blue color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Blue(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a black color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Black(): Color3;
  5548. /**
  5549. * Gets a Color3 value containing a black color that must not be updated
  5550. */
  5551. static get BlackReadOnly(): DeepImmutable<Color3>;
  5552. /**
  5553. * Returns a Color3 value containing a white color
  5554. * @returns a new Color3 object
  5555. */
  5556. static White(): Color3;
  5557. /**
  5558. * Returns a Color3 value containing a purple color
  5559. * @returns a new Color3 object
  5560. */
  5561. static Purple(): Color3;
  5562. /**
  5563. * Returns a Color3 value containing a magenta color
  5564. * @returns a new Color3 object
  5565. */
  5566. static Magenta(): Color3;
  5567. /**
  5568. * Returns a Color3 value containing a yellow color
  5569. * @returns a new Color3 object
  5570. */
  5571. static Yellow(): Color3;
  5572. /**
  5573. * Returns a Color3 value containing a gray color
  5574. * @returns a new Color3 object
  5575. */
  5576. static Gray(): Color3;
  5577. /**
  5578. * Returns a Color3 value containing a teal color
  5579. * @returns a new Color3 object
  5580. */
  5581. static Teal(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a random color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Random(): Color3;
  5587. }
  5588. /**
  5589. * Class used to hold a RBGA color
  5590. */
  5591. export class Color4 {
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r: number;
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g: number;
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b: number;
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a: number;
  5608. /**
  5609. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5610. * @param r defines the red component (between 0 and 1, default is 0)
  5611. * @param g defines the green component (between 0 and 1, default is 0)
  5612. * @param b defines the blue component (between 0 and 1, default is 0)
  5613. * @param a defines the alpha component (between 0 and 1, default is 1)
  5614. */
  5615. constructor(
  5616. /**
  5617. * Defines the red component (between 0 and 1, default is 0)
  5618. */
  5619. r?: number,
  5620. /**
  5621. * Defines the green component (between 0 and 1, default is 0)
  5622. */
  5623. g?: number,
  5624. /**
  5625. * Defines the blue component (between 0 and 1, default is 0)
  5626. */
  5627. b?: number,
  5628. /**
  5629. * Defines the alpha component (between 0 and 1, default is 1)
  5630. */
  5631. a?: number);
  5632. /**
  5633. * Adds in place the given Color4 values to the current Color4 object
  5634. * @param right defines the second operand
  5635. * @returns the current updated Color4 object
  5636. */
  5637. addInPlace(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5640. * @returns the new array
  5641. */
  5642. asArray(): number[];
  5643. /**
  5644. * Stores from the starting index in the given array the Color4 successive values
  5645. * @param array defines the array where to store the r,g,b components
  5646. * @param index defines an optional index in the target array to define where to start storing values
  5647. * @returns the current Color4 object
  5648. */
  5649. toArray(array: number[], index?: number): Color4;
  5650. /**
  5651. * Determines equality between Color4 objects
  5652. * @param otherColor defines the second operand
  5653. * @returns true if the rgba values are equal to the given ones
  5654. */
  5655. equals(otherColor: DeepImmutable<Color4>): boolean;
  5656. /**
  5657. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5658. * @param right defines the second operand
  5659. * @returns a new Color4 object
  5660. */
  5661. add(right: DeepImmutable<Color4>): Color4;
  5662. /**
  5663. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5664. * @param right defines the second operand
  5665. * @returns a new Color4 object
  5666. */
  5667. subtract(right: DeepImmutable<Color4>): Color4;
  5668. /**
  5669. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5670. * @param right defines the second operand
  5671. * @param result defines the Color4 object where to store the result
  5672. * @returns the current Color4 object
  5673. */
  5674. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5675. /**
  5676. * Creates a new Color4 with the current Color4 values multiplied by scale
  5677. * @param scale defines the scaling factor to apply
  5678. * @returns a new Color4 object
  5679. */
  5680. scale(scale: number): Color4;
  5681. /**
  5682. * Multiplies the current Color4 values by scale and stores the result in "result"
  5683. * @param scale defines the scaling factor to apply
  5684. * @param result defines the Color4 object where to store the result
  5685. * @returns the current unmodified Color4
  5686. */
  5687. scaleToRef(scale: number, result: Color4): Color4;
  5688. /**
  5689. * Scale the current Color4 values by a factor and add the result to a given Color4
  5690. * @param scale defines the scale factor
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the unmodified current Color4
  5693. */
  5694. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Clamps the rgb values by the min and max values and stores the result into "result"
  5697. * @param min defines minimum clamping value (default is 0)
  5698. * @param max defines maximum clamping value (default is 1)
  5699. * @param result defines color to store the result into.
  5700. * @returns the cuurent Color4
  5701. */
  5702. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5703. /**
  5704. * Multipy an Color4 value by another and return a new Color4 object
  5705. * @param color defines the Color4 value to multiply by
  5706. * @returns a new Color4 object
  5707. */
  5708. multiply(color: Color4): Color4;
  5709. /**
  5710. * Multipy a Color4 value by another and push the result in a reference value
  5711. * @param color defines the Color4 value to multiply by
  5712. * @param result defines the Color4 to fill the result in
  5713. * @returns the result Color4
  5714. */
  5715. multiplyToRef(color: Color4, result: Color4): Color4;
  5716. /**
  5717. * Creates a string with the Color4 current values
  5718. * @returns the string representation of the Color4 object
  5719. */
  5720. toString(): string;
  5721. /**
  5722. * Returns the string "Color4"
  5723. * @returns "Color4"
  5724. */
  5725. getClassName(): string;
  5726. /**
  5727. * Compute the Color4 hash code
  5728. * @returns an unique number that can be used to hash Color4 objects
  5729. */
  5730. getHashCode(): number;
  5731. /**
  5732. * Creates a new Color4 copied from the current one
  5733. * @returns a new Color4 object
  5734. */
  5735. clone(): Color4;
  5736. /**
  5737. * Copies the given Color4 values into the current one
  5738. * @param source defines the source Color4 object
  5739. * @returns the current updated Color4 object
  5740. */
  5741. copyFrom(source: Color4): Color4;
  5742. /**
  5743. * Copies the given float values into the current one
  5744. * @param r defines the red component to read from
  5745. * @param g defines the green component to read from
  5746. * @param b defines the blue component to read from
  5747. * @param a defines the alpha component to read from
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. set(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Compute the Color4 hexadecimal code as a string
  5762. * @returns a string containing the hexadecimal representation of the Color4 object
  5763. */
  5764. toHexString(): string;
  5765. /**
  5766. * Computes a new Color4 converted from the current one to linear space
  5767. * @returns a new Color4 object
  5768. */
  5769. toLinearSpace(): Color4;
  5770. /**
  5771. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5772. * @param convertedColor defines the Color4 object where to store the linear space version
  5773. * @returns the unmodified Color4
  5774. */
  5775. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5776. /**
  5777. * Computes a new Color4 converted from the current one to gamma space
  5778. * @returns a new Color4 object
  5779. */
  5780. toGammaSpace(): Color4;
  5781. /**
  5782. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5783. * @param convertedColor defines the Color4 object where to store the gamma space version
  5784. * @returns the unmodified Color4
  5785. */
  5786. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5787. /**
  5788. * Creates a new Color4 from the string containing valid hexadecimal values
  5789. * @param hex defines a string containing valid hexadecimal values
  5790. * @returns a new Color4 object
  5791. */
  5792. static FromHexString(hex: string): Color4;
  5793. /**
  5794. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5795. * @param left defines the start value
  5796. * @param right defines the end value
  5797. * @param amount defines the gradient factor
  5798. * @returns a new Color4 object
  5799. */
  5800. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5801. /**
  5802. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5803. * @param left defines the start value
  5804. * @param right defines the end value
  5805. * @param amount defines the gradient factor
  5806. * @param result defines the Color4 object where to store data
  5807. */
  5808. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5809. /**
  5810. * Creates a new Color4 from a Color3 and an alpha value
  5811. * @param color3 defines the source Color3 to read from
  5812. * @param alpha defines the alpha component (1.0 by default)
  5813. * @returns a new Color4 object
  5814. */
  5815. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5816. /**
  5817. * Creates a new Color4 from the starting index element of the given array
  5818. * @param array defines the source array to read from
  5819. * @param offset defines the offset in the source array
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5823. /**
  5824. * Creates a new Color3 from integer values (< 256)
  5825. * @param r defines the red component to read from (value between 0 and 255)
  5826. * @param g defines the green component to read from (value between 0 and 255)
  5827. * @param b defines the blue component to read from (value between 0 and 255)
  5828. * @param a defines the alpha component to read from (value between 0 and 255)
  5829. * @returns a new Color3 object
  5830. */
  5831. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5832. /**
  5833. * Check the content of a given array and convert it to an array containing RGBA data
  5834. * If the original array was already containing count * 4 values then it is returned directly
  5835. * @param colors defines the array to check
  5836. * @param count defines the number of RGBA data to expect
  5837. * @returns an array containing count * 4 values (RGBA)
  5838. */
  5839. static CheckColors4(colors: number[], count: number): number[];
  5840. }
  5841. /**
  5842. * @hidden
  5843. */
  5844. export class TmpColors {
  5845. static Color3: Color3[];
  5846. static Color4: Color4[];
  5847. }
  5848. }
  5849. declare module BABYLON {
  5850. /**
  5851. * Defines an interface which represents an animation key frame
  5852. */
  5853. export interface IAnimationKey {
  5854. /**
  5855. * Frame of the key frame
  5856. */
  5857. frame: number;
  5858. /**
  5859. * Value at the specifies key frame
  5860. */
  5861. value: any;
  5862. /**
  5863. * The input tangent for the cubic hermite spline
  5864. */
  5865. inTangent?: any;
  5866. /**
  5867. * The output tangent for the cubic hermite spline
  5868. */
  5869. outTangent?: any;
  5870. /**
  5871. * The animation interpolation type
  5872. */
  5873. interpolation?: AnimationKeyInterpolation;
  5874. }
  5875. /**
  5876. * Enum for the animation key frame interpolation type
  5877. */
  5878. export enum AnimationKeyInterpolation {
  5879. /**
  5880. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5881. */
  5882. STEP = 1
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Represents the range of an animation
  5888. */
  5889. export class AnimationRange {
  5890. /**The name of the animation range**/
  5891. name: string;
  5892. /**The starting frame of the animation */
  5893. from: number;
  5894. /**The ending frame of the animation*/
  5895. to: number;
  5896. /**
  5897. * Initializes the range of an animation
  5898. * @param name The name of the animation range
  5899. * @param from The starting frame of the animation
  5900. * @param to The ending frame of the animation
  5901. */
  5902. constructor(
  5903. /**The name of the animation range**/
  5904. name: string,
  5905. /**The starting frame of the animation */
  5906. from: number,
  5907. /**The ending frame of the animation*/
  5908. to: number);
  5909. /**
  5910. * Makes a copy of the animation range
  5911. * @returns A copy of the animation range
  5912. */
  5913. clone(): AnimationRange;
  5914. }
  5915. }
  5916. declare module BABYLON {
  5917. /**
  5918. * Composed of a frame, and an action function
  5919. */
  5920. export class AnimationEvent {
  5921. /** The frame for which the event is triggered **/
  5922. frame: number;
  5923. /** The event to perform when triggered **/
  5924. action: (currentFrame: number) => void;
  5925. /** Specifies if the event should be triggered only once**/
  5926. onlyOnce?: boolean | undefined;
  5927. /**
  5928. * Specifies if the animation event is done
  5929. */
  5930. isDone: boolean;
  5931. /**
  5932. * Initializes the animation event
  5933. * @param frame The frame for which the event is triggered
  5934. * @param action The event to perform when triggered
  5935. * @param onlyOnce Specifies if the event should be triggered only once
  5936. */
  5937. constructor(
  5938. /** The frame for which the event is triggered **/
  5939. frame: number,
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void,
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined);
  5944. /** @hidden */
  5945. _clone(): AnimationEvent;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Interface used to define a behavior
  5951. */
  5952. export interface Behavior<T> {
  5953. /** gets or sets behavior's name */
  5954. name: string;
  5955. /**
  5956. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5957. */
  5958. init(): void;
  5959. /**
  5960. * Called when the behavior is attached to a target
  5961. * @param target defines the target where the behavior is attached to
  5962. */
  5963. attach(target: T): void;
  5964. /**
  5965. * Called when the behavior is detached from its target
  5966. */
  5967. detach(): void;
  5968. }
  5969. /**
  5970. * Interface implemented by classes supporting behaviors
  5971. */
  5972. export interface IBehaviorAware<T> {
  5973. /**
  5974. * Attach a behavior
  5975. * @param behavior defines the behavior to attach
  5976. * @returns the current host
  5977. */
  5978. addBehavior(behavior: Behavior<T>): T;
  5979. /**
  5980. * Remove a behavior from the current object
  5981. * @param behavior defines the behavior to detach
  5982. * @returns the current host
  5983. */
  5984. removeBehavior(behavior: Behavior<T>): T;
  5985. /**
  5986. * Gets a behavior using its name to search
  5987. * @param name defines the name to search
  5988. * @returns the behavior or null if not found
  5989. */
  5990. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5991. }
  5992. }
  5993. declare module BABYLON {
  5994. /**
  5995. * Defines an array and its length.
  5996. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5997. */
  5998. export interface ISmartArrayLike<T> {
  5999. /**
  6000. * The data of the array.
  6001. */
  6002. data: Array<T>;
  6003. /**
  6004. * The active length of the array.
  6005. */
  6006. length: number;
  6007. }
  6008. /**
  6009. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6010. */
  6011. export class SmartArray<T> implements ISmartArrayLike<T> {
  6012. /**
  6013. * The full set of data from the array.
  6014. */
  6015. data: Array<T>;
  6016. /**
  6017. * The active length of the array.
  6018. */
  6019. length: number;
  6020. protected _id: number;
  6021. /**
  6022. * Instantiates a Smart Array.
  6023. * @param capacity defines the default capacity of the array.
  6024. */
  6025. constructor(capacity: number);
  6026. /**
  6027. * Pushes a value at the end of the active data.
  6028. * @param value defines the object to push in the array.
  6029. */
  6030. push(value: T): void;
  6031. /**
  6032. * Iterates over the active data and apply the lambda to them.
  6033. * @param func defines the action to apply on each value.
  6034. */
  6035. forEach(func: (content: T) => void): void;
  6036. /**
  6037. * Sorts the full sets of data.
  6038. * @param compareFn defines the comparison function to apply.
  6039. */
  6040. sort(compareFn: (a: T, b: T) => number): void;
  6041. /**
  6042. * Resets the active data to an empty array.
  6043. */
  6044. reset(): void;
  6045. /**
  6046. * Releases all the data from the array as well as the array.
  6047. */
  6048. dispose(): void;
  6049. /**
  6050. * Concats the active data with a given array.
  6051. * @param array defines the data to concatenate with.
  6052. */
  6053. concat(array: any): void;
  6054. /**
  6055. * Returns the position of a value in the active data.
  6056. * @param value defines the value to find the index for
  6057. * @returns the index if found in the active data otherwise -1
  6058. */
  6059. indexOf(value: T): number;
  6060. /**
  6061. * Returns whether an element is part of the active data.
  6062. * @param value defines the value to look for
  6063. * @returns true if found in the active data otherwise false
  6064. */
  6065. contains(value: T): boolean;
  6066. private static _GlobalId;
  6067. }
  6068. /**
  6069. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6070. * The data in this array can only be present once
  6071. */
  6072. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6073. private _duplicateId;
  6074. /**
  6075. * Pushes a value at the end of the active data.
  6076. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6077. * @param value defines the object to push in the array.
  6078. */
  6079. push(value: T): void;
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * If the data is already present, it won t be added again
  6083. * @param value defines the object to push in the array.
  6084. * @returns true if added false if it was already present
  6085. */
  6086. pushNoDuplicate(value: T): boolean;
  6087. /**
  6088. * Resets the active data to an empty array.
  6089. */
  6090. reset(): void;
  6091. /**
  6092. * Concats the active data with a given array.
  6093. * This ensures no dupplicate will be present in the result.
  6094. * @param array defines the data to concatenate with.
  6095. */
  6096. concatWithNoDuplicate(array: any): void;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * @ignore
  6102. * This is a list of all the different input types that are available in the application.
  6103. * Fo instance: ArcRotateCameraGamepadInput...
  6104. */
  6105. export var CameraInputTypes: {};
  6106. /**
  6107. * This is the contract to implement in order to create a new input class.
  6108. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6109. */
  6110. export interface ICameraInput<TCamera extends Camera> {
  6111. /**
  6112. * Defines the camera the input is attached to.
  6113. */
  6114. camera: Nullable<TCamera>;
  6115. /**
  6116. * Gets the class name of the current intput.
  6117. * @returns the class name
  6118. */
  6119. getClassName(): string;
  6120. /**
  6121. * Get the friendly name associated with the input class.
  6122. * @returns the input friendly name
  6123. */
  6124. getSimpleName(): string;
  6125. /**
  6126. * Attach the input controls to a specific dom element to get the input from.
  6127. * @param element Defines the element the controls should be listened from
  6128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6129. */
  6130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6131. /**
  6132. * Detach the current controls from the specified dom element.
  6133. * @param element Defines the element to stop listening the inputs from
  6134. */
  6135. detachControl(element: Nullable<HTMLElement>): void;
  6136. /**
  6137. * Update the current camera state depending on the inputs that have been used this frame.
  6138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6139. */
  6140. checkInputs?: () => void;
  6141. }
  6142. /**
  6143. * Represents a map of input types to input instance or input index to input instance.
  6144. */
  6145. export interface CameraInputsMap<TCamera extends Camera> {
  6146. /**
  6147. * Accessor to the input by input type.
  6148. */
  6149. [name: string]: ICameraInput<TCamera>;
  6150. /**
  6151. * Accessor to the input by input index.
  6152. */
  6153. [idx: number]: ICameraInput<TCamera>;
  6154. }
  6155. /**
  6156. * This represents the input manager used within a camera.
  6157. * It helps dealing with all the different kind of input attached to a camera.
  6158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6159. */
  6160. export class CameraInputsManager<TCamera extends Camera> {
  6161. /**
  6162. * Defines the list of inputs attahed to the camera.
  6163. */
  6164. attached: CameraInputsMap<TCamera>;
  6165. /**
  6166. * Defines the dom element the camera is collecting inputs from.
  6167. * This is null if the controls have not been attached.
  6168. */
  6169. attachedElement: Nullable<HTMLElement>;
  6170. /**
  6171. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6172. */
  6173. noPreventDefault: boolean;
  6174. /**
  6175. * Defined the camera the input manager belongs to.
  6176. */
  6177. camera: TCamera;
  6178. /**
  6179. * Update the current camera state depending on the inputs that have been used this frame.
  6180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6181. */
  6182. checkInputs: () => void;
  6183. /**
  6184. * Instantiate a new Camera Input Manager.
  6185. * @param camera Defines the camera the input manager blongs to
  6186. */
  6187. constructor(camera: TCamera);
  6188. /**
  6189. * Add an input method to a camera
  6190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6191. * @param input camera input method
  6192. */
  6193. add(input: ICameraInput<TCamera>): void;
  6194. /**
  6195. * Remove a specific input method from a camera
  6196. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6197. * @param inputToRemove camera input method
  6198. */
  6199. remove(inputToRemove: ICameraInput<TCamera>): void;
  6200. /**
  6201. * Remove a specific input type from a camera
  6202. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6203. * @param inputType the type of the input to remove
  6204. */
  6205. removeByType(inputType: string): void;
  6206. private _addCheckInputs;
  6207. /**
  6208. * Attach the input controls to the currently attached dom element to listen the events from.
  6209. * @param input Defines the input to attach
  6210. */
  6211. attachInput(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6214. * @param element Defines the dom element to collect the events from
  6215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6216. */
  6217. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6218. /**
  6219. * Detach the current manager inputs controls from a specific dom element.
  6220. * @param element Defines the dom element to collect the events from
  6221. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6222. */
  6223. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6224. /**
  6225. * Rebuild the dynamic inputCheck function from the current list of
  6226. * defined inputs in the manager.
  6227. */
  6228. rebuildInputCheck(): void;
  6229. /**
  6230. * Remove all attached input methods from a camera
  6231. */
  6232. clear(): void;
  6233. /**
  6234. * Serialize the current input manager attached to a camera.
  6235. * This ensures than once parsed,
  6236. * the input associated to the camera will be identical to the current ones
  6237. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6238. */
  6239. serialize(serializedCamera: any): void;
  6240. /**
  6241. * Parses an input manager serialized JSON to restore the previous list of inputs
  6242. * and states associated to a camera.
  6243. * @param parsedCamera Defines the JSON to parse
  6244. */
  6245. parse(parsedCamera: any): void;
  6246. }
  6247. }
  6248. declare module BABYLON {
  6249. /**
  6250. * Class used to store data that will be store in GPU memory
  6251. */
  6252. export class Buffer {
  6253. private _engine;
  6254. private _buffer;
  6255. /** @hidden */
  6256. _data: Nullable<DataArray>;
  6257. private _updatable;
  6258. private _instanced;
  6259. private _divisor;
  6260. /**
  6261. * Gets the byte stride.
  6262. */
  6263. readonly byteStride: number;
  6264. /**
  6265. * Constructor
  6266. * @param engine the engine
  6267. * @param data the data to use for this buffer
  6268. * @param updatable whether the data is updatable
  6269. * @param stride the stride (optional)
  6270. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6271. * @param instanced whether the buffer is instanced (optional)
  6272. * @param useBytes set to true if the stride in in bytes (optional)
  6273. * @param divisor sets an optional divisor for instances (1 by default)
  6274. */
  6275. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6276. /**
  6277. * Create a new VertexBuffer based on the current buffer
  6278. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6279. * @param offset defines offset in the buffer (0 by default)
  6280. * @param size defines the size in floats of attributes (position is 3 for instance)
  6281. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6282. * @param instanced defines if the vertex buffer contains indexed data
  6283. * @param useBytes defines if the offset and stride are in bytes *
  6284. * @param divisor sets an optional divisor for instances (1 by default)
  6285. * @returns the new vertex buffer
  6286. */
  6287. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6288. /**
  6289. * Gets a boolean indicating if the Buffer is updatable?
  6290. * @returns true if the buffer is updatable
  6291. */
  6292. isUpdatable(): boolean;
  6293. /**
  6294. * Gets current buffer's data
  6295. * @returns a DataArray or null
  6296. */
  6297. getData(): Nullable<DataArray>;
  6298. /**
  6299. * Gets underlying native buffer
  6300. * @returns underlying native buffer
  6301. */
  6302. getBuffer(): Nullable<DataBuffer>;
  6303. /**
  6304. * Gets the stride in float32 units (i.e. byte stride / 4).
  6305. * May not be an integer if the byte stride is not divisible by 4.
  6306. * @returns the stride in float32 units
  6307. * @deprecated Please use byteStride instead.
  6308. */
  6309. getStrideSize(): number;
  6310. /**
  6311. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6312. * @param data defines the data to store
  6313. */
  6314. create(data?: Nullable<DataArray>): void;
  6315. /** @hidden */
  6316. _rebuild(): void;
  6317. /**
  6318. * Update current buffer data
  6319. * @param data defines the data to store
  6320. */
  6321. update(data: DataArray): void;
  6322. /**
  6323. * Updates the data directly.
  6324. * @param data the new data
  6325. * @param offset the new offset
  6326. * @param vertexCount the vertex count (optional)
  6327. * @param useBytes set to true if the offset is in bytes
  6328. */
  6329. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6330. /**
  6331. * Release all resources
  6332. */
  6333. dispose(): void;
  6334. }
  6335. /**
  6336. * Specialized buffer used to store vertex data
  6337. */
  6338. export class VertexBuffer {
  6339. /** @hidden */
  6340. _buffer: Buffer;
  6341. private _kind;
  6342. private _size;
  6343. private _ownsBuffer;
  6344. private _instanced;
  6345. private _instanceDivisor;
  6346. /**
  6347. * The byte type.
  6348. */
  6349. static readonly BYTE: number;
  6350. /**
  6351. * The unsigned byte type.
  6352. */
  6353. static readonly UNSIGNED_BYTE: number;
  6354. /**
  6355. * The short type.
  6356. */
  6357. static readonly SHORT: number;
  6358. /**
  6359. * The unsigned short type.
  6360. */
  6361. static readonly UNSIGNED_SHORT: number;
  6362. /**
  6363. * The integer type.
  6364. */
  6365. static readonly INT: number;
  6366. /**
  6367. * The unsigned integer type.
  6368. */
  6369. static readonly UNSIGNED_INT: number;
  6370. /**
  6371. * The float type.
  6372. */
  6373. static readonly FLOAT: number;
  6374. /**
  6375. * Gets or sets the instance divisor when in instanced mode
  6376. */
  6377. get instanceDivisor(): number;
  6378. set instanceDivisor(value: number);
  6379. /**
  6380. * Gets the byte stride.
  6381. */
  6382. readonly byteStride: number;
  6383. /**
  6384. * Gets the byte offset.
  6385. */
  6386. readonly byteOffset: number;
  6387. /**
  6388. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6389. */
  6390. readonly normalized: boolean;
  6391. /**
  6392. * Gets the data type of each component in the array.
  6393. */
  6394. readonly type: number;
  6395. /**
  6396. * Constructor
  6397. * @param engine the engine
  6398. * @param data the data to use for this vertex buffer
  6399. * @param kind the vertex buffer kind
  6400. * @param updatable whether the data is updatable
  6401. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6402. * @param stride the stride (optional)
  6403. * @param instanced whether the buffer is instanced (optional)
  6404. * @param offset the offset of the data (optional)
  6405. * @param size the number of components (optional)
  6406. * @param type the type of the component (optional)
  6407. * @param normalized whether the data contains normalized data (optional)
  6408. * @param useBytes set to true if stride and offset are in bytes (optional)
  6409. * @param divisor defines the instance divisor to use (1 by default)
  6410. */
  6411. 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);
  6412. /** @hidden */
  6413. _rebuild(): void;
  6414. /**
  6415. * Returns the kind of the VertexBuffer (string)
  6416. * @returns a string
  6417. */
  6418. getKind(): string;
  6419. /**
  6420. * Gets a boolean indicating if the VertexBuffer is updatable?
  6421. * @returns true if the buffer is updatable
  6422. */
  6423. isUpdatable(): boolean;
  6424. /**
  6425. * Gets current buffer's data
  6426. * @returns a DataArray or null
  6427. */
  6428. getData(): Nullable<DataArray>;
  6429. /**
  6430. * Gets underlying native buffer
  6431. * @returns underlying native buffer
  6432. */
  6433. getBuffer(): Nullable<DataBuffer>;
  6434. /**
  6435. * Gets the stride in float32 units (i.e. byte stride / 4).
  6436. * May not be an integer if the byte stride is not divisible by 4.
  6437. * @returns the stride in float32 units
  6438. * @deprecated Please use byteStride instead.
  6439. */
  6440. getStrideSize(): number;
  6441. /**
  6442. * Returns the offset as a multiple of the type byte length.
  6443. * @returns the offset in bytes
  6444. * @deprecated Please use byteOffset instead.
  6445. */
  6446. getOffset(): number;
  6447. /**
  6448. * Returns the number of components per vertex attribute (integer)
  6449. * @returns the size in float
  6450. */
  6451. getSize(): number;
  6452. /**
  6453. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6454. * @returns true if this buffer is instanced
  6455. */
  6456. getIsInstanced(): boolean;
  6457. /**
  6458. * Returns the instancing divisor, zero for non-instanced (integer).
  6459. * @returns a number
  6460. */
  6461. getInstanceDivisor(): number;
  6462. /**
  6463. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6464. * @param data defines the data to store
  6465. */
  6466. create(data?: DataArray): void;
  6467. /**
  6468. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6469. * This function will create a new buffer if the current one is not updatable
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6475. * Returns the directly updated WebGLBuffer.
  6476. * @param data the new data
  6477. * @param offset the new offset
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6481. /**
  6482. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6483. */
  6484. dispose(): void;
  6485. /**
  6486. * Enumerates each value of this vertex buffer as numbers.
  6487. * @param count the number of values to enumerate
  6488. * @param callback the callback function called for each value
  6489. */
  6490. forEach(count: number, callback: (value: number, index: number) => void): void;
  6491. /**
  6492. * Positions
  6493. */
  6494. static readonly PositionKind: string;
  6495. /**
  6496. * Normals
  6497. */
  6498. static readonly NormalKind: string;
  6499. /**
  6500. * Tangents
  6501. */
  6502. static readonly TangentKind: string;
  6503. /**
  6504. * Texture coordinates
  6505. */
  6506. static readonly UVKind: string;
  6507. /**
  6508. * Texture coordinates 2
  6509. */
  6510. static readonly UV2Kind: string;
  6511. /**
  6512. * Texture coordinates 3
  6513. */
  6514. static readonly UV3Kind: string;
  6515. /**
  6516. * Texture coordinates 4
  6517. */
  6518. static readonly UV4Kind: string;
  6519. /**
  6520. * Texture coordinates 5
  6521. */
  6522. static readonly UV5Kind: string;
  6523. /**
  6524. * Texture coordinates 6
  6525. */
  6526. static readonly UV6Kind: string;
  6527. /**
  6528. * Colors
  6529. */
  6530. static readonly ColorKind: string;
  6531. /**
  6532. * Matrix indices (for bones)
  6533. */
  6534. static readonly MatricesIndicesKind: string;
  6535. /**
  6536. * Matrix weights (for bones)
  6537. */
  6538. static readonly MatricesWeightsKind: string;
  6539. /**
  6540. * Additional matrix indices (for bones)
  6541. */
  6542. static readonly MatricesIndicesExtraKind: string;
  6543. /**
  6544. * Additional matrix weights (for bones)
  6545. */
  6546. static readonly MatricesWeightsExtraKind: string;
  6547. /**
  6548. * Deduces the stride given a kind.
  6549. * @param kind The kind string to deduce
  6550. * @returns The deduced stride
  6551. */
  6552. static DeduceStride(kind: string): number;
  6553. /**
  6554. * Gets the byte length of the given type.
  6555. * @param type the type
  6556. * @returns the number of bytes
  6557. */
  6558. static GetTypeByteLength(type: number): number;
  6559. /**
  6560. * Enumerates each value of the given parameters as numbers.
  6561. * @param data the data to enumerate
  6562. * @param byteOffset the byte offset of the data
  6563. * @param byteStride the byte stride of the data
  6564. * @param componentCount the number of components per element
  6565. * @param componentType the type of the component
  6566. * @param count the number of values to enumerate
  6567. * @param normalized whether the data is normalized
  6568. * @param callback the callback function called for each value
  6569. */
  6570. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6571. private static _GetFloatValue;
  6572. }
  6573. }
  6574. declare module BABYLON {
  6575. /**
  6576. * @hidden
  6577. */
  6578. export class IntersectionInfo {
  6579. bu: Nullable<number>;
  6580. bv: Nullable<number>;
  6581. distance: number;
  6582. faceId: number;
  6583. subMeshId: number;
  6584. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6585. }
  6586. }
  6587. declare module BABYLON {
  6588. /**
  6589. * Represens a plane by the equation ax + by + cz + d = 0
  6590. */
  6591. export class Plane {
  6592. private static _TmpMatrix;
  6593. /**
  6594. * Normal of the plane (a,b,c)
  6595. */
  6596. normal: Vector3;
  6597. /**
  6598. * d component of the plane
  6599. */
  6600. d: number;
  6601. /**
  6602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6603. * @param a a component of the plane
  6604. * @param b b component of the plane
  6605. * @param c c component of the plane
  6606. * @param d d component of the plane
  6607. */
  6608. constructor(a: number, b: number, c: number, d: number);
  6609. /**
  6610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6611. */
  6612. asArray(): number[];
  6613. /**
  6614. * @returns a new plane copied from the current Plane.
  6615. */
  6616. clone(): Plane;
  6617. /**
  6618. * @returns the string "Plane".
  6619. */
  6620. getClassName(): string;
  6621. /**
  6622. * @returns the Plane hash code.
  6623. */
  6624. getHashCode(): number;
  6625. /**
  6626. * Normalize the current Plane in place.
  6627. * @returns the updated Plane.
  6628. */
  6629. normalize(): Plane;
  6630. /**
  6631. * Applies a transformation the plane and returns the result
  6632. * @param transformation the transformation matrix to be applied to the plane
  6633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6634. */
  6635. transform(transformation: DeepImmutable<Matrix>): Plane;
  6636. /**
  6637. * Calcualtte the dot product between the point and the plane normal
  6638. * @param point point to calculate the dot product with
  6639. * @returns the dot product (float) of the point coordinates and the plane normal.
  6640. */
  6641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6642. /**
  6643. * Updates the current Plane from the plane defined by the three given points.
  6644. * @param point1 one of the points used to contruct the plane
  6645. * @param point2 one of the points used to contruct the plane
  6646. * @param point3 one of the points used to contruct the plane
  6647. * @returns the updated Plane.
  6648. */
  6649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Checks if the plane is facing a given direction
  6652. * @param direction the direction to check if the plane is facing
  6653. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6654. * @returns True is the vector "direction" is the same side than the plane normal.
  6655. */
  6656. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6657. /**
  6658. * Calculates the distance to a point
  6659. * @param point point to calculate distance to
  6660. * @returns the signed distance (float) from the given point to the Plane.
  6661. */
  6662. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6663. /**
  6664. * Creates a plane from an array
  6665. * @param array the array to create a plane from
  6666. * @returns a new Plane from the given array.
  6667. */
  6668. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6669. /**
  6670. * Creates a plane from three points
  6671. * @param point1 point used to create the plane
  6672. * @param point2 point used to create the plane
  6673. * @param point3 point used to create the plane
  6674. * @returns a new Plane defined by the three given points.
  6675. */
  6676. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Creates a plane from an origin point and a normal
  6679. * @param origin origin of the plane to be constructed
  6680. * @param normal normal of the plane to be constructed
  6681. * @returns a new Plane the normal vector to this plane at the given origin point.
  6682. * Note : the vector "normal" is updated because normalized.
  6683. */
  6684. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6685. /**
  6686. * Calculates the distance from a plane and a point
  6687. * @param origin origin of the plane to be constructed
  6688. * @param normal normal of the plane to be constructed
  6689. * @param point point to calculate distance to
  6690. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6691. */
  6692. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. /**
  6697. * Class used to store bounding sphere information
  6698. */
  6699. export class BoundingSphere {
  6700. /**
  6701. * Gets the center of the bounding sphere in local space
  6702. */
  6703. readonly center: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in local space
  6706. */
  6707. radius: number;
  6708. /**
  6709. * Gets the center of the bounding sphere in world space
  6710. */
  6711. readonly centerWorld: Vector3;
  6712. /**
  6713. * Radius of the bounding sphere in world space
  6714. */
  6715. radiusWorld: number;
  6716. /**
  6717. * Gets the minimum vector in local space
  6718. */
  6719. readonly minimum: Vector3;
  6720. /**
  6721. * Gets the maximum vector in local space
  6722. */
  6723. readonly maximum: Vector3;
  6724. private _worldMatrix;
  6725. private static readonly TmpVector3;
  6726. /**
  6727. * Creates a new bounding sphere
  6728. * @param min defines the minimum vector (in local space)
  6729. * @param max defines the maximum vector (in local space)
  6730. * @param worldMatrix defines the new world matrix
  6731. */
  6732. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6733. /**
  6734. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6735. * @param min defines the new minimum vector (in local space)
  6736. * @param max defines the new maximum vector (in local space)
  6737. * @param worldMatrix defines the new world matrix
  6738. */
  6739. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6740. /**
  6741. * Scale the current bounding sphere by applying a scale factor
  6742. * @param factor defines the scale factor to apply
  6743. * @returns the current bounding box
  6744. */
  6745. scale(factor: number): BoundingSphere;
  6746. /**
  6747. * Gets the world matrix of the bounding box
  6748. * @returns a matrix
  6749. */
  6750. getWorldMatrix(): DeepImmutable<Matrix>;
  6751. /** @hidden */
  6752. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6753. /**
  6754. * Tests if the bounding sphere is intersecting the frustum planes
  6755. * @param frustumPlanes defines the frustum planes to test
  6756. * @returns true if there is an intersection
  6757. */
  6758. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6759. /**
  6760. * Tests if the bounding sphere center is in between the frustum planes.
  6761. * Used for optimistic fast inclusion.
  6762. * @param frustumPlanes defines the frustum planes to test
  6763. * @returns true if the sphere center is in between the frustum planes
  6764. */
  6765. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6766. /**
  6767. * Tests if a point is inside the bounding sphere
  6768. * @param point defines the point to test
  6769. * @returns true if the point is inside the bounding sphere
  6770. */
  6771. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6772. /**
  6773. * Checks if two sphere intersct
  6774. * @param sphere0 sphere 0
  6775. * @param sphere1 sphere 1
  6776. * @returns true if the speres intersect
  6777. */
  6778. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6779. }
  6780. }
  6781. declare module BABYLON {
  6782. /**
  6783. * Class used to store bounding box information
  6784. */
  6785. export class BoundingBox implements ICullable {
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in local space
  6788. */
  6789. readonly vectors: Vector3[];
  6790. /**
  6791. * Gets the center of the bounding box in local space
  6792. */
  6793. readonly center: Vector3;
  6794. /**
  6795. * Gets the center of the bounding box in world space
  6796. */
  6797. readonly centerWorld: Vector3;
  6798. /**
  6799. * Gets the extend size in local space
  6800. */
  6801. readonly extendSize: Vector3;
  6802. /**
  6803. * Gets the extend size in world space
  6804. */
  6805. readonly extendSizeWorld: Vector3;
  6806. /**
  6807. * Gets the OBB (object bounding box) directions
  6808. */
  6809. readonly directions: Vector3[];
  6810. /**
  6811. * Gets the 8 vectors representing the bounding box in world space
  6812. */
  6813. readonly vectorsWorld: Vector3[];
  6814. /**
  6815. * Gets the minimum vector in world space
  6816. */
  6817. readonly minimumWorld: Vector3;
  6818. /**
  6819. * Gets the maximum vector in world space
  6820. */
  6821. readonly maximumWorld: Vector3;
  6822. /**
  6823. * Gets the minimum vector in local space
  6824. */
  6825. readonly minimum: Vector3;
  6826. /**
  6827. * Gets the maximum vector in local space
  6828. */
  6829. readonly maximum: Vector3;
  6830. private _worldMatrix;
  6831. private static readonly TmpVector3;
  6832. /**
  6833. * @hidden
  6834. */
  6835. _tag: number;
  6836. /**
  6837. * Creates a new bounding box
  6838. * @param min defines the minimum vector (in local space)
  6839. * @param max defines the maximum vector (in local space)
  6840. * @param worldMatrix defines the new world matrix
  6841. */
  6842. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6843. /**
  6844. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6845. * @param min defines the new minimum vector (in local space)
  6846. * @param max defines the new maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Scale the current bounding box by applying a scale factor
  6852. * @param factor defines the scale factor to apply
  6853. * @returns the current bounding box
  6854. */
  6855. scale(factor: number): BoundingBox;
  6856. /**
  6857. * Gets the world matrix of the bounding box
  6858. * @returns a matrix
  6859. */
  6860. getWorldMatrix(): DeepImmutable<Matrix>;
  6861. /** @hidden */
  6862. _update(world: DeepImmutable<Matrix>): void;
  6863. /**
  6864. * Tests if the bounding box is intersecting the frustum planes
  6865. * @param frustumPlanes defines the frustum planes to test
  6866. * @returns true if there is an intersection
  6867. */
  6868. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6869. /**
  6870. * Tests if the bounding box is entirely inside the frustum planes
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @returns true if there is an inclusion
  6873. */
  6874. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. /**
  6876. * Tests if a point is inside the bounding box
  6877. * @param point defines the point to test
  6878. * @returns true if the point is inside the bounding box
  6879. */
  6880. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6881. /**
  6882. * Tests if the bounding box intersects with a bounding sphere
  6883. * @param sphere defines the sphere to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6887. /**
  6888. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6889. * @param min defines the min vector to use
  6890. * @param max defines the max vector to use
  6891. * @returns true if there is an intersection
  6892. */
  6893. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6894. /**
  6895. * Tests if two bounding boxes are intersections
  6896. * @param box0 defines the first box to test
  6897. * @param box1 defines the second box to test
  6898. * @returns true if there is an intersection
  6899. */
  6900. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6901. /**
  6902. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6903. * @param minPoint defines the minimum vector of the bounding box
  6904. * @param maxPoint defines the maximum vector of the bounding box
  6905. * @param sphereCenter defines the sphere center
  6906. * @param sphereRadius defines the sphere radius
  6907. * @returns true if there is an intersection
  6908. */
  6909. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6910. /**
  6911. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6912. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6913. * @param frustumPlanes defines the frustum planes to test
  6914. * @return true if there is an inclusion
  6915. */
  6916. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6917. /**
  6918. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6919. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @return true if there is an intersection
  6922. */
  6923. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. }
  6925. }
  6926. declare module BABYLON {
  6927. /** @hidden */
  6928. export class Collider {
  6929. /** Define if a collision was found */
  6930. collisionFound: boolean;
  6931. /**
  6932. * Define last intersection point in local space
  6933. */
  6934. intersectionPoint: Vector3;
  6935. /**
  6936. * Define last collided mesh
  6937. */
  6938. collidedMesh: Nullable<AbstractMesh>;
  6939. private _collisionPoint;
  6940. private _planeIntersectionPoint;
  6941. private _tempVector;
  6942. private _tempVector2;
  6943. private _tempVector3;
  6944. private _tempVector4;
  6945. private _edge;
  6946. private _baseToVertex;
  6947. private _destinationPoint;
  6948. private _slidePlaneNormal;
  6949. private _displacementVector;
  6950. /** @hidden */
  6951. _radius: Vector3;
  6952. /** @hidden */
  6953. _retry: number;
  6954. private _velocity;
  6955. private _basePoint;
  6956. private _epsilon;
  6957. /** @hidden */
  6958. _velocityWorldLength: number;
  6959. /** @hidden */
  6960. _basePointWorld: Vector3;
  6961. private _velocityWorld;
  6962. private _normalizedVelocity;
  6963. /** @hidden */
  6964. _initialVelocity: Vector3;
  6965. /** @hidden */
  6966. _initialPosition: Vector3;
  6967. private _nearestDistance;
  6968. private _collisionMask;
  6969. get collisionMask(): number;
  6970. set collisionMask(mask: number);
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. get slidePlaneNormal(): Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Interface for cullable objects
  6992. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6993. */
  6994. export interface ICullable {
  6995. /**
  6996. * Checks if the object or part of the object is in the frustum
  6997. * @param frustumPlanes Camera near/planes
  6998. * @returns true if the object is in frustum otherwise false
  6999. */
  7000. isInFrustum(frustumPlanes: Plane[]): boolean;
  7001. /**
  7002. * Checks if a cullable object (mesh...) is in the camera frustum
  7003. * Unlike isInFrustum this cheks the full bounding box
  7004. * @param frustumPlanes Camera near/planes
  7005. * @returns true if the object is in frustum otherwise false
  7006. */
  7007. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7008. }
  7009. /**
  7010. * Info for a bounding data of a mesh
  7011. */
  7012. export class BoundingInfo implements ICullable {
  7013. /**
  7014. * Bounding box for the mesh
  7015. */
  7016. readonly boundingBox: BoundingBox;
  7017. /**
  7018. * Bounding sphere for the mesh
  7019. */
  7020. readonly boundingSphere: BoundingSphere;
  7021. private _isLocked;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * Constructs bounding info
  7025. * @param minimum min vector of the bounding box/sphere
  7026. * @param maximum max vector of the bounding box/sphere
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7030. /**
  7031. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7032. * @param min defines the new minimum vector (in local space)
  7033. * @param max defines the new maximum vector (in local space)
  7034. * @param worldMatrix defines the new world matrix
  7035. */
  7036. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7037. /**
  7038. * min vector of the bounding box/sphere
  7039. */
  7040. get minimum(): Vector3;
  7041. /**
  7042. * max vector of the bounding box/sphere
  7043. */
  7044. get maximum(): Vector3;
  7045. /**
  7046. * If the info is locked and won't be updated to avoid perf overhead
  7047. */
  7048. get isLocked(): boolean;
  7049. set isLocked(value: boolean);
  7050. /**
  7051. * Updates the bounding sphere and box
  7052. * @param world world matrix to be used to update
  7053. */
  7054. update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7057. * @param center New center of the bounding info
  7058. * @param extend New extend of the bounding info
  7059. * @returns the current bounding info
  7060. */
  7061. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7062. /**
  7063. * Scale the current bounding info by applying a scale factor
  7064. * @param factor defines the scale factor to apply
  7065. * @returns the current bounding info
  7066. */
  7067. scale(factor: number): BoundingInfo;
  7068. /**
  7069. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7070. * @param frustumPlanes defines the frustum to test
  7071. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7072. * @returns true if the bounding info is in the frustum planes
  7073. */
  7074. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7075. /**
  7076. * Gets the world distance between the min and max points of the bounding box
  7077. */
  7078. get diagonalLength(): number;
  7079. /**
  7080. * Checks if a cullable object (mesh...) is in the camera frustum
  7081. * Unlike isInFrustum this cheks the full bounding box
  7082. * @param frustumPlanes Camera near/planes
  7083. * @returns true if the object is in frustum otherwise false
  7084. */
  7085. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7086. /** @hidden */
  7087. _checkCollision(collider: Collider): boolean;
  7088. /**
  7089. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7090. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7091. * @param point the point to check intersection with
  7092. * @returns if the point intersects
  7093. */
  7094. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7095. /**
  7096. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param boundingInfo the bounding info to check intersection with
  7099. * @param precise if the intersection should be done using OBB
  7100. * @returns if the bounding info intersects
  7101. */
  7102. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. /**
  7107. * Extracts minimum and maximum values from a list of indexed positions
  7108. * @param positions defines the positions to use
  7109. * @param indices defines the indices to the positions
  7110. * @param indexStart defines the start index
  7111. * @param indexCount defines the end index
  7112. * @param bias defines bias value to add to the result
  7113. * @return minimum and maximum values
  7114. */
  7115. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7116. minimum: Vector3;
  7117. maximum: Vector3;
  7118. };
  7119. /**
  7120. * Extracts minimum and maximum values from a list of positions
  7121. * @param positions defines the positions to use
  7122. * @param start defines the start index in the positions array
  7123. * @param count defines the number of positions to handle
  7124. * @param bias defines bias value to add to the result
  7125. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7126. * @return minimum and maximum values
  7127. */
  7128. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7129. minimum: Vector3;
  7130. maximum: Vector3;
  7131. };
  7132. }
  7133. declare module BABYLON {
  7134. /** @hidden */
  7135. export class WebGLDataBuffer extends DataBuffer {
  7136. private _buffer;
  7137. constructor(resource: WebGLBuffer);
  7138. get underlyingResource(): any;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class WebGLPipelineContext implements IPipelineContext {
  7144. engine: ThinEngine;
  7145. program: Nullable<WebGLProgram>;
  7146. context?: WebGLRenderingContext;
  7147. vertexShader?: WebGLShader;
  7148. fragmentShader?: WebGLShader;
  7149. isParallelCompiled: boolean;
  7150. onCompiled?: () => void;
  7151. transformFeedback?: WebGLTransformFeedback | null;
  7152. vertexCompilationError: Nullable<string>;
  7153. fragmentCompilationError: Nullable<string>;
  7154. programLinkError: Nullable<string>;
  7155. programValidationError: Nullable<string>;
  7156. get isAsync(): boolean;
  7157. get isReady(): boolean;
  7158. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7159. }
  7160. }
  7161. declare module BABYLON {
  7162. interface ThinEngine {
  7163. /**
  7164. * Create an uniform buffer
  7165. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7166. * @param elements defines the content of the uniform buffer
  7167. * @returns the webGL uniform buffer
  7168. */
  7169. createUniformBuffer(elements: FloatArray): DataBuffer;
  7170. /**
  7171. * Create a dynamic uniform buffer
  7172. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7173. * @param elements defines the content of the uniform buffer
  7174. * @returns the webGL uniform buffer
  7175. */
  7176. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7177. /**
  7178. * Update an existing uniform buffer
  7179. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7180. * @param uniformBuffer defines the target uniform buffer
  7181. * @param elements defines the content to update
  7182. * @param offset defines the offset in the uniform buffer where update should start
  7183. * @param count defines the size of the data to update
  7184. */
  7185. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7186. /**
  7187. * Bind an uniform buffer to the current webGL context
  7188. * @param buffer defines the buffer to bind
  7189. */
  7190. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7191. /**
  7192. * Bind a buffer to the current webGL context at a given location
  7193. * @param buffer defines the buffer to bind
  7194. * @param location defines the index where to bind the buffer
  7195. */
  7196. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7197. /**
  7198. * Bind a specific block at a given index in a specific shader program
  7199. * @param pipelineContext defines the pipeline context to use
  7200. * @param blockName defines the block name
  7201. * @param index defines the index where to bind the block
  7202. */
  7203. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. /**
  7208. * Uniform buffer objects.
  7209. *
  7210. * Handles blocks of uniform on the GPU.
  7211. *
  7212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7213. *
  7214. * For more information, please refer to :
  7215. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7216. */
  7217. export class UniformBuffer {
  7218. private _engine;
  7219. private _buffer;
  7220. private _data;
  7221. private _bufferData;
  7222. private _dynamic?;
  7223. private _uniformLocations;
  7224. private _uniformSizes;
  7225. private _uniformLocationPointer;
  7226. private _needSync;
  7227. private _noUBO;
  7228. private _currentEffect;
  7229. /** @hidden */
  7230. _alreadyBound: boolean;
  7231. private static _MAX_UNIFORM_SIZE;
  7232. private static _tempBuffer;
  7233. /**
  7234. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7239. /**
  7240. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7245. /**
  7246. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7251. /**
  7252. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7257. /**
  7258. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7263. /**
  7264. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7275. /**
  7276. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7281. /**
  7282. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7287. /**
  7288. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7299. /**
  7300. * Instantiates a new Uniform buffer objects.
  7301. *
  7302. * Handles blocks of uniform on the GPU.
  7303. *
  7304. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7305. *
  7306. * For more information, please refer to :
  7307. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7308. * @param engine Define the engine the buffer is associated with
  7309. * @param data Define the data contained in the buffer
  7310. * @param dynamic Define if the buffer is updatable
  7311. */
  7312. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7313. /**
  7314. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7315. * or just falling back on setUniformXXX calls.
  7316. */
  7317. get useUbo(): boolean;
  7318. /**
  7319. * Indicates if the WebGL underlying uniform buffer is in sync
  7320. * with the javascript cache data.
  7321. */
  7322. get isSync(): boolean;
  7323. /**
  7324. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7325. * Also, a dynamic UniformBuffer will disable cache verification and always
  7326. * update the underlying WebGL uniform buffer to the GPU.
  7327. * @returns if Dynamic, otherwise false
  7328. */
  7329. isDynamic(): boolean;
  7330. /**
  7331. * The data cache on JS side.
  7332. * @returns the underlying data as a float array
  7333. */
  7334. getData(): Float32Array;
  7335. /**
  7336. * The underlying WebGL Uniform buffer.
  7337. * @returns the webgl buffer
  7338. */
  7339. getBuffer(): Nullable<DataBuffer>;
  7340. /**
  7341. * std140 layout specifies how to align data within an UBO structure.
  7342. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7343. * for specs.
  7344. */
  7345. private _fillAlignment;
  7346. /**
  7347. * Adds an uniform in the buffer.
  7348. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7349. * for the layout to be correct !
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param size Data size, or data directly.
  7352. */
  7353. addUniform(name: string, size: number | number[]): void;
  7354. /**
  7355. * Adds a Matrix 4x4 to the uniform buffer.
  7356. * @param name Name of the uniform, as used in the uniform block in the shader.
  7357. * @param mat A 4x4 matrix.
  7358. */
  7359. addMatrix(name: string, mat: Matrix): void;
  7360. /**
  7361. * Adds a vec2 to the uniform buffer.
  7362. * @param name Name of the uniform, as used in the uniform block in the shader.
  7363. * @param x Define the x component value of the vec2
  7364. * @param y Define the y component value of the vec2
  7365. */
  7366. addFloat2(name: string, x: number, y: number): void;
  7367. /**
  7368. * Adds a vec3 to the uniform buffer.
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param x Define the x component value of the vec3
  7371. * @param y Define the y component value of the vec3
  7372. * @param z Define the z component value of the vec3
  7373. */
  7374. addFloat3(name: string, x: number, y: number, z: number): void;
  7375. /**
  7376. * Adds a vec3 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. * @param color Define the vec3 from a Color
  7379. */
  7380. addColor3(name: string, color: Color3): void;
  7381. /**
  7382. * Adds a vec4 to the uniform buffer.
  7383. * @param name Name of the uniform, as used in the uniform block in the shader.
  7384. * @param color Define the rgb components from a Color
  7385. * @param alpha Define the a component of the vec4
  7386. */
  7387. addColor4(name: string, color: Color3, alpha: number): void;
  7388. /**
  7389. * Adds a vec3 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param vector Define the vec3 components from a Vector
  7392. */
  7393. addVector3(name: string, vector: Vector3): void;
  7394. /**
  7395. * Adds a Matrix 3x3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. */
  7398. addMatrix3x3(name: string): void;
  7399. /**
  7400. * Adds a Matrix 2x2 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. */
  7403. addMatrix2x2(name: string): void;
  7404. /**
  7405. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7406. */
  7407. create(): void;
  7408. /** @hidden */
  7409. _rebuild(): void;
  7410. /**
  7411. * Updates the WebGL Uniform Buffer on the GPU.
  7412. * If the `dynamic` flag is set to true, no cache comparison is done.
  7413. * Otherwise, the buffer will be updated only if the cache differs.
  7414. */
  7415. update(): void;
  7416. /**
  7417. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7418. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7419. * @param data Define the flattened data
  7420. * @param size Define the size of the data.
  7421. */
  7422. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7423. private _valueCache;
  7424. private _cacheMatrix;
  7425. private _updateMatrix3x3ForUniform;
  7426. private _updateMatrix3x3ForEffect;
  7427. private _updateMatrix2x2ForEffect;
  7428. private _updateMatrix2x2ForUniform;
  7429. private _updateFloatForEffect;
  7430. private _updateFloatForUniform;
  7431. private _updateFloat2ForEffect;
  7432. private _updateFloat2ForUniform;
  7433. private _updateFloat3ForEffect;
  7434. private _updateFloat3ForUniform;
  7435. private _updateFloat4ForEffect;
  7436. private _updateFloat4ForUniform;
  7437. private _updateMatrixForEffect;
  7438. private _updateMatrixForUniform;
  7439. private _updateVector3ForEffect;
  7440. private _updateVector3ForUniform;
  7441. private _updateVector4ForEffect;
  7442. private _updateVector4ForUniform;
  7443. private _updateColor3ForEffect;
  7444. private _updateColor3ForUniform;
  7445. private _updateColor4ForEffect;
  7446. private _updateColor4ForUniform;
  7447. /**
  7448. * Sets a sampler uniform on the effect.
  7449. * @param name Define the name of the sampler.
  7450. * @param texture Define the texture to set in the sampler
  7451. */
  7452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7453. /**
  7454. * Directly updates the value of the uniform in the cache AND on the GPU.
  7455. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7456. * @param data Define the flattened data
  7457. */
  7458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7459. /**
  7460. * Binds this uniform buffer to an effect.
  7461. * @param effect Define the effect to bind the buffer to
  7462. * @param name Name of the uniform block in the shader.
  7463. */
  7464. bindToEffect(effect: Effect, name: string): void;
  7465. /**
  7466. * Disposes the uniform buffer.
  7467. */
  7468. dispose(): void;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * Enum that determines the text-wrapping mode to use.
  7474. */
  7475. export enum InspectableType {
  7476. /**
  7477. * Checkbox for booleans
  7478. */
  7479. Checkbox = 0,
  7480. /**
  7481. * Sliders for numbers
  7482. */
  7483. Slider = 1,
  7484. /**
  7485. * Vector3
  7486. */
  7487. Vector3 = 2,
  7488. /**
  7489. * Quaternions
  7490. */
  7491. Quaternion = 3,
  7492. /**
  7493. * Color3
  7494. */
  7495. Color3 = 4,
  7496. /**
  7497. * String
  7498. */
  7499. String = 5
  7500. }
  7501. /**
  7502. * Interface used to define custom inspectable properties.
  7503. * This interface is used by the inspector to display custom property grids
  7504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7505. */
  7506. export interface IInspectable {
  7507. /**
  7508. * Gets the label to display
  7509. */
  7510. label: string;
  7511. /**
  7512. * Gets the name of the property to edit
  7513. */
  7514. propertyName: string;
  7515. /**
  7516. * Gets the type of the editor to use
  7517. */
  7518. type: InspectableType;
  7519. /**
  7520. * Gets the minimum value of the property when using in "slider" mode
  7521. */
  7522. min?: number;
  7523. /**
  7524. * Gets the maximum value of the property when using in "slider" mode
  7525. */
  7526. max?: number;
  7527. /**
  7528. * Gets the setp to use when using in "slider" mode
  7529. */
  7530. step?: number;
  7531. }
  7532. }
  7533. declare module BABYLON {
  7534. /**
  7535. * Class used to provide helper for timing
  7536. */
  7537. export class TimingTools {
  7538. /**
  7539. * Polyfill for setImmediate
  7540. * @param action defines the action to execute after the current execution block
  7541. */
  7542. static SetImmediate(action: () => void): void;
  7543. }
  7544. }
  7545. declare module BABYLON {
  7546. /**
  7547. * Class used to enable instatition of objects by class name
  7548. */
  7549. export class InstantiationTools {
  7550. /**
  7551. * Use this object to register external classes like custom textures or material
  7552. * to allow the laoders to instantiate them
  7553. */
  7554. static RegisteredExternalClasses: {
  7555. [key: string]: Object;
  7556. };
  7557. /**
  7558. * Tries to instantiate a new object from a given class name
  7559. * @param className defines the class name to instantiate
  7560. * @returns the new object or null if the system was not able to do the instantiation
  7561. */
  7562. static Instantiate(className: string): any;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Define options used to create a depth texture
  7568. */
  7569. export class DepthTextureCreationOptions {
  7570. /** Specifies whether or not a stencil should be allocated in the texture */
  7571. generateStencil?: boolean;
  7572. /** Specifies whether or not bilinear filtering is enable on the texture */
  7573. bilinearFiltering?: boolean;
  7574. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7575. comparisonFunction?: number;
  7576. /** Specifies if the created texture is a cube texture */
  7577. isCube?: boolean;
  7578. }
  7579. }
  7580. declare module BABYLON {
  7581. interface ThinEngine {
  7582. /**
  7583. * Creates a depth stencil cube texture.
  7584. * This is only available in WebGL 2.
  7585. * @param size The size of face edge in the cube texture.
  7586. * @param options The options defining the cube texture.
  7587. * @returns The cube texture
  7588. */
  7589. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7590. /**
  7591. * Creates a cube texture
  7592. * @param rootUrl defines the url where the files to load is located
  7593. * @param scene defines the current scene
  7594. * @param files defines the list of files to load (1 per face)
  7595. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7596. * @param onLoad defines an optional callback raised when the texture is loaded
  7597. * @param onError defines an optional callback raised if there is an issue to load the texture
  7598. * @param format defines the format of the data
  7599. * @param forcedExtension defines the extension to use to pick the right loader
  7600. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7601. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7602. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7603. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7604. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7605. * @returns the cube texture as an InternalTexture
  7606. */
  7607. 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;
  7608. /**
  7609. * Creates a cube texture
  7610. * @param rootUrl defines the url where the files to load is located
  7611. * @param scene defines the current scene
  7612. * @param files defines the list of files to load (1 per face)
  7613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7614. * @param onLoad defines an optional callback raised when the texture is loaded
  7615. * @param onError defines an optional callback raised if there is an issue to load the texture
  7616. * @param format defines the format of the data
  7617. * @param forcedExtension defines the extension to use to pick the right loader
  7618. * @returns the cube texture as an InternalTexture
  7619. */
  7620. 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;
  7621. /**
  7622. * Creates a cube texture
  7623. * @param rootUrl defines the url where the files to load is located
  7624. * @param scene defines the current scene
  7625. * @param files defines the list of files to load (1 per face)
  7626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7627. * @param onLoad defines an optional callback raised when the texture is loaded
  7628. * @param onError defines an optional callback raised if there is an issue to load the texture
  7629. * @param format defines the format of the data
  7630. * @param forcedExtension defines the extension to use to pick the right loader
  7631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @returns the cube texture as an InternalTexture
  7635. */
  7636. 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;
  7637. /** @hidden */
  7638. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7641. /** @hidden */
  7642. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /** @hidden */
  7644. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7645. /**
  7646. * @hidden
  7647. */
  7648. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7649. }
  7650. }
  7651. declare module BABYLON {
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. set boundingBoxSize(value: Vector3);
  7675. /**
  7676. * Returns the bounding box size
  7677. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7678. */
  7679. get boundingBoxSize(): Vector3;
  7680. protected _rotationY: number;
  7681. /**
  7682. * Sets texture matrix rotation angle around Y axis in radians.
  7683. */
  7684. set rotationY(value: number);
  7685. /**
  7686. * Gets texture matrix rotation angle around Y axis radians.
  7687. */
  7688. get rotationY(): number;
  7689. /**
  7690. * Are mip maps generated for this texture or not.
  7691. */
  7692. get noMipmap(): boolean;
  7693. private _noMipmap;
  7694. private _files;
  7695. protected _forcedExtension: Nullable<string>;
  7696. private _extensions;
  7697. private _textureMatrix;
  7698. private _format;
  7699. private _createPolynomials;
  7700. /** @hidden */
  7701. _prefiltered: boolean;
  7702. /**
  7703. * Creates a cube texture from an array of image urls
  7704. * @param files defines an array of image urls
  7705. * @param scene defines the hosting scene
  7706. * @param noMipmap specifies if mip maps are not used
  7707. * @returns a cube texture
  7708. */
  7709. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7710. /**
  7711. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7712. * @param url defines the url of the prefiltered texture
  7713. * @param scene defines the scene the texture is attached to
  7714. * @param forcedExtension defines the extension of the file if different from the url
  7715. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7716. * @return the prefiltered texture
  7717. */
  7718. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7719. /**
  7720. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7721. * as prefiltered data.
  7722. * @param rootUrl defines the url of the texture or the root name of the six images
  7723. * @param scene defines the scene the texture is attached to
  7724. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7725. * @param noMipmap defines if mipmaps should be created or not
  7726. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7727. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7728. * @param onError defines a callback triggered in case of error during load
  7729. * @param format defines the internal format to use for the texture once loaded
  7730. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7731. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7732. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @return the cube texture
  7736. */
  7737. 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);
  7738. /**
  7739. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7740. */
  7741. get isPrefiltered(): boolean;
  7742. /**
  7743. * Get the current class name of the texture useful for serialization or dynamic coding.
  7744. * @returns "CubeTexture"
  7745. */
  7746. getClassName(): string;
  7747. /**
  7748. * Update the url (and optional buffer) of this texture if url was null during construction.
  7749. * @param url the url of the texture
  7750. * @param forcedExtension defines the extension to use
  7751. * @param onLoad callback called when the texture is loaded (defaults to null)
  7752. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7753. */
  7754. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7755. /**
  7756. * Delays loading of the cube texture
  7757. * @param forcedExtension defines the extension to use
  7758. */
  7759. delayLoad(forcedExtension?: string): void;
  7760. /**
  7761. * Returns the reflection texture matrix
  7762. * @returns the reflection texture matrix
  7763. */
  7764. getReflectionTextureMatrix(): Matrix;
  7765. /**
  7766. * Sets the reflection texture matrix
  7767. * @param value Reflection texture matrix
  7768. */
  7769. setReflectionTextureMatrix(value: Matrix): void;
  7770. /**
  7771. * Parses text to create a cube texture
  7772. * @param parsedTexture define the serialized text to read from
  7773. * @param scene defines the hosting scene
  7774. * @param rootUrl defines the root url of the cube texture
  7775. * @returns a cube texture
  7776. */
  7777. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7778. /**
  7779. * Makes a clone, or deep copy, of the cube texture
  7780. * @returns a new cube texture
  7781. */
  7782. clone(): CubeTexture;
  7783. }
  7784. }
  7785. declare module BABYLON {
  7786. /**
  7787. * Manages the defines for the Material
  7788. */
  7789. export class MaterialDefines {
  7790. /** @hidden */
  7791. protected _keys: string[];
  7792. private _isDirty;
  7793. /** @hidden */
  7794. _renderId: number;
  7795. /** @hidden */
  7796. _areLightsDirty: boolean;
  7797. /** @hidden */
  7798. _areLightsDisposed: boolean;
  7799. /** @hidden */
  7800. _areAttributesDirty: boolean;
  7801. /** @hidden */
  7802. _areTexturesDirty: boolean;
  7803. /** @hidden */
  7804. _areFresnelDirty: boolean;
  7805. /** @hidden */
  7806. _areMiscDirty: boolean;
  7807. /** @hidden */
  7808. _areImageProcessingDirty: boolean;
  7809. /** @hidden */
  7810. _normals: boolean;
  7811. /** @hidden */
  7812. _uvs: boolean;
  7813. /** @hidden */
  7814. _needNormals: boolean;
  7815. /** @hidden */
  7816. _needUVs: boolean;
  7817. [id: string]: any;
  7818. /**
  7819. * Specifies if the material needs to be re-calculated
  7820. */
  7821. get isDirty(): boolean;
  7822. /**
  7823. * Marks the material to indicate that it has been re-calculated
  7824. */
  7825. markAsProcessed(): void;
  7826. /**
  7827. * Marks the material to indicate that it needs to be re-calculated
  7828. */
  7829. markAsUnprocessed(): void;
  7830. /**
  7831. * Marks the material to indicate all of its defines need to be re-calculated
  7832. */
  7833. markAllAsDirty(): void;
  7834. /**
  7835. * Marks the material to indicate that image processing needs to be re-calculated
  7836. */
  7837. markAsImageProcessingDirty(): void;
  7838. /**
  7839. * Marks the material to indicate the lights need to be re-calculated
  7840. * @param disposed Defines whether the light is dirty due to dispose or not
  7841. */
  7842. markAsLightDirty(disposed?: boolean): void;
  7843. /**
  7844. * Marks the attribute state as changed
  7845. */
  7846. markAsAttributesDirty(): void;
  7847. /**
  7848. * Marks the texture state as changed
  7849. */
  7850. markAsTexturesDirty(): void;
  7851. /**
  7852. * Marks the fresnel state as changed
  7853. */
  7854. markAsFresnelDirty(): void;
  7855. /**
  7856. * Marks the misc state as changed
  7857. */
  7858. markAsMiscDirty(): void;
  7859. /**
  7860. * Rebuilds the material defines
  7861. */
  7862. rebuild(): void;
  7863. /**
  7864. * Specifies if two material defines are equal
  7865. * @param other - A material define instance to compare to
  7866. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7867. */
  7868. isEqual(other: MaterialDefines): boolean;
  7869. /**
  7870. * Clones this instance's defines to another instance
  7871. * @param other - material defines to clone values to
  7872. */
  7873. cloneTo(other: MaterialDefines): void;
  7874. /**
  7875. * Resets the material define values
  7876. */
  7877. reset(): void;
  7878. /**
  7879. * Converts the material define values to a string
  7880. * @returns - String of material define information
  7881. */
  7882. toString(): string;
  7883. }
  7884. }
  7885. declare module BABYLON {
  7886. /**
  7887. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7888. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7889. * 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;
  7890. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7891. */
  7892. export class ColorCurves {
  7893. private _dirty;
  7894. private _tempColor;
  7895. private _globalCurve;
  7896. private _highlightsCurve;
  7897. private _midtonesCurve;
  7898. private _shadowsCurve;
  7899. private _positiveCurve;
  7900. private _negativeCurve;
  7901. private _globalHue;
  7902. private _globalDensity;
  7903. private _globalSaturation;
  7904. private _globalExposure;
  7905. /**
  7906. * Gets the global Hue value.
  7907. * 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).
  7908. */
  7909. get globalHue(): number;
  7910. /**
  7911. * Sets the global Hue value.
  7912. * 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).
  7913. */
  7914. set globalHue(value: number);
  7915. /**
  7916. * Gets the global Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. get globalDensity(): number;
  7921. /**
  7922. * Sets the global Density value.
  7923. * 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.
  7924. * Values less than zero provide a filter of opposite hue.
  7925. */
  7926. set globalDensity(value: number);
  7927. /**
  7928. * Gets the global Saturation value.
  7929. * 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.
  7930. */
  7931. get globalSaturation(): number;
  7932. /**
  7933. * Sets the global Saturation value.
  7934. * 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.
  7935. */
  7936. set globalSaturation(value: number);
  7937. /**
  7938. * Gets the global Exposure value.
  7939. * 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.
  7940. */
  7941. get globalExposure(): number;
  7942. /**
  7943. * Sets the global Exposure value.
  7944. * 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.
  7945. */
  7946. set globalExposure(value: number);
  7947. private _highlightsHue;
  7948. private _highlightsDensity;
  7949. private _highlightsSaturation;
  7950. private _highlightsExposure;
  7951. /**
  7952. * Gets the highlights Hue value.
  7953. * 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).
  7954. */
  7955. get highlightsHue(): number;
  7956. /**
  7957. * Sets the highlights Hue value.
  7958. * 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).
  7959. */
  7960. set highlightsHue(value: number);
  7961. /**
  7962. * Gets the highlights Density value.
  7963. * 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.
  7964. * Values less than zero provide a filter of opposite hue.
  7965. */
  7966. get highlightsDensity(): number;
  7967. /**
  7968. * Sets the highlights Density value.
  7969. * 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.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. set highlightsDensity(value: number);
  7973. /**
  7974. * Gets the highlights Saturation value.
  7975. * 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.
  7976. */
  7977. get highlightsSaturation(): number;
  7978. /**
  7979. * Sets the highlights Saturation value.
  7980. * 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.
  7981. */
  7982. set highlightsSaturation(value: number);
  7983. /**
  7984. * Gets the highlights Exposure value.
  7985. * 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.
  7986. */
  7987. get highlightsExposure(): number;
  7988. /**
  7989. * Sets the highlights Exposure value.
  7990. * 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.
  7991. */
  7992. set highlightsExposure(value: number);
  7993. private _midtonesHue;
  7994. private _midtonesDensity;
  7995. private _midtonesSaturation;
  7996. private _midtonesExposure;
  7997. /**
  7998. * Gets the midtones Hue value.
  7999. * 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).
  8000. */
  8001. get midtonesHue(): number;
  8002. /**
  8003. * Sets the midtones Hue value.
  8004. * 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).
  8005. */
  8006. set midtonesHue(value: number);
  8007. /**
  8008. * Gets the midtones Density value.
  8009. * 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.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. get midtonesDensity(): number;
  8013. /**
  8014. * Sets the midtones Density value.
  8015. * 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.
  8016. * Values less than zero provide a filter of opposite hue.
  8017. */
  8018. set midtonesDensity(value: number);
  8019. /**
  8020. * Gets the midtones Saturation value.
  8021. * 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.
  8022. */
  8023. get midtonesSaturation(): number;
  8024. /**
  8025. * Sets the midtones Saturation value.
  8026. * 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.
  8027. */
  8028. set midtonesSaturation(value: number);
  8029. /**
  8030. * Gets the midtones Exposure value.
  8031. * 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.
  8032. */
  8033. get midtonesExposure(): number;
  8034. /**
  8035. * Sets the midtones Exposure value.
  8036. * 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.
  8037. */
  8038. set midtonesExposure(value: number);
  8039. private _shadowsHue;
  8040. private _shadowsDensity;
  8041. private _shadowsSaturation;
  8042. private _shadowsExposure;
  8043. /**
  8044. * Gets the shadows Hue value.
  8045. * 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).
  8046. */
  8047. get shadowsHue(): number;
  8048. /**
  8049. * Sets the shadows Hue value.
  8050. * 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).
  8051. */
  8052. set shadowsHue(value: number);
  8053. /**
  8054. * Gets the shadows Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. get shadowsDensity(): number;
  8059. /**
  8060. * Sets the shadows Density value.
  8061. * 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.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. set shadowsDensity(value: number);
  8065. /**
  8066. * Gets the shadows Saturation value.
  8067. * 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.
  8068. */
  8069. get shadowsSaturation(): number;
  8070. /**
  8071. * Sets the shadows Saturation value.
  8072. * 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.
  8073. */
  8074. set shadowsSaturation(value: number);
  8075. /**
  8076. * Gets the shadows Exposure value.
  8077. * 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.
  8078. */
  8079. get shadowsExposure(): number;
  8080. /**
  8081. * Sets the shadows Exposure value.
  8082. * 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.
  8083. */
  8084. set shadowsExposure(value: number);
  8085. /**
  8086. * Returns the class name
  8087. * @returns The class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Binds the color curves to the shader.
  8092. * @param colorCurves The color curve to bind
  8093. * @param effect The effect to bind to
  8094. * @param positiveUniform The positive uniform shader parameter
  8095. * @param neutralUniform The neutral uniform shader parameter
  8096. * @param negativeUniform The negative uniform shader parameter
  8097. */
  8098. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8099. /**
  8100. * Prepare the list of uniforms associated with the ColorCurves effects.
  8101. * @param uniformsList The list of uniforms used in the effect
  8102. */
  8103. static PrepareUniforms(uniformsList: string[]): void;
  8104. /**
  8105. * Returns color grading data based on a hue, density, saturation and exposure value.
  8106. * @param filterHue The hue of the color filter.
  8107. * @param filterDensity The density of the color filter.
  8108. * @param saturation The saturation.
  8109. * @param exposure The exposure.
  8110. * @param result The result data container.
  8111. */
  8112. private getColorGradingDataToRef;
  8113. /**
  8114. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8115. * @param value The input slider value in range [-100,100].
  8116. * @returns Adjusted value.
  8117. */
  8118. private static applyColorGradingSliderNonlinear;
  8119. /**
  8120. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8121. * @param hue The hue (H) input.
  8122. * @param saturation The saturation (S) input.
  8123. * @param brightness The brightness (B) input.
  8124. * @result An RGBA color represented as Vector4.
  8125. */
  8126. private static fromHSBToRef;
  8127. /**
  8128. * Returns a value clamped between min and max
  8129. * @param value The value to clamp
  8130. * @param min The minimum of value
  8131. * @param max The maximum of value
  8132. * @returns The clamped value.
  8133. */
  8134. private static clamp;
  8135. /**
  8136. * Clones the current color curve instance.
  8137. * @return The cloned curves
  8138. */
  8139. clone(): ColorCurves;
  8140. /**
  8141. * Serializes the current color curve instance to a json representation.
  8142. * @return a JSON representation
  8143. */
  8144. serialize(): any;
  8145. /**
  8146. * Parses the color curve from a json representation.
  8147. * @param source the JSON source to parse
  8148. * @return The parsed curves
  8149. */
  8150. static Parse(source: any): ColorCurves;
  8151. }
  8152. }
  8153. declare module BABYLON {
  8154. /**
  8155. * Interface to follow in your material defines to integrate easily the
  8156. * Image proccessing functions.
  8157. * @hidden
  8158. */
  8159. export interface IImageProcessingConfigurationDefines {
  8160. IMAGEPROCESSING: boolean;
  8161. VIGNETTE: boolean;
  8162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8163. VIGNETTEBLENDMODEOPAQUE: boolean;
  8164. TONEMAPPING: boolean;
  8165. TONEMAPPING_ACES: boolean;
  8166. CONTRAST: boolean;
  8167. EXPOSURE: boolean;
  8168. COLORCURVES: boolean;
  8169. COLORGRADING: boolean;
  8170. COLORGRADING3D: boolean;
  8171. SAMPLER3DGREENDEPTH: boolean;
  8172. SAMPLER3DBGRMAP: boolean;
  8173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8174. }
  8175. /**
  8176. * @hidden
  8177. */
  8178. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8179. IMAGEPROCESSING: boolean;
  8180. VIGNETTE: boolean;
  8181. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8182. VIGNETTEBLENDMODEOPAQUE: boolean;
  8183. TONEMAPPING: boolean;
  8184. TONEMAPPING_ACES: boolean;
  8185. CONTRAST: boolean;
  8186. COLORCURVES: boolean;
  8187. COLORGRADING: boolean;
  8188. COLORGRADING3D: boolean;
  8189. SAMPLER3DGREENDEPTH: boolean;
  8190. SAMPLER3DBGRMAP: boolean;
  8191. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8192. EXPOSURE: boolean;
  8193. constructor();
  8194. }
  8195. /**
  8196. * This groups together the common properties used for image processing either in direct forward pass
  8197. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8198. * or not.
  8199. */
  8200. export class ImageProcessingConfiguration {
  8201. /**
  8202. * Default tone mapping applied in BabylonJS.
  8203. */
  8204. static readonly TONEMAPPING_STANDARD: number;
  8205. /**
  8206. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8207. * to other engines rendering to increase portability.
  8208. */
  8209. static readonly TONEMAPPING_ACES: number;
  8210. /**
  8211. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8212. */
  8213. colorCurves: Nullable<ColorCurves>;
  8214. private _colorCurvesEnabled;
  8215. /**
  8216. * Gets wether the color curves effect is enabled.
  8217. */
  8218. get colorCurvesEnabled(): boolean;
  8219. /**
  8220. * Sets wether the color curves effect is enabled.
  8221. */
  8222. set colorCurvesEnabled(value: boolean);
  8223. private _colorGradingTexture;
  8224. /**
  8225. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8226. */
  8227. get colorGradingTexture(): Nullable<BaseTexture>;
  8228. /**
  8229. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8230. */
  8231. set colorGradingTexture(value: Nullable<BaseTexture>);
  8232. private _colorGradingEnabled;
  8233. /**
  8234. * Gets wether the color grading effect is enabled.
  8235. */
  8236. get colorGradingEnabled(): boolean;
  8237. /**
  8238. * Sets wether the color grading effect is enabled.
  8239. */
  8240. set colorGradingEnabled(value: boolean);
  8241. private _colorGradingWithGreenDepth;
  8242. /**
  8243. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8244. */
  8245. get colorGradingWithGreenDepth(): boolean;
  8246. /**
  8247. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8248. */
  8249. set colorGradingWithGreenDepth(value: boolean);
  8250. private _colorGradingBGR;
  8251. /**
  8252. * Gets wether the color grading texture contains BGR values.
  8253. */
  8254. get colorGradingBGR(): boolean;
  8255. /**
  8256. * Sets wether the color grading texture contains BGR values.
  8257. */
  8258. set colorGradingBGR(value: boolean);
  8259. /** @hidden */
  8260. _exposure: number;
  8261. /**
  8262. * Gets the Exposure used in the effect.
  8263. */
  8264. get exposure(): number;
  8265. /**
  8266. * Sets the Exposure used in the effect.
  8267. */
  8268. set exposure(value: number);
  8269. private _toneMappingEnabled;
  8270. /**
  8271. * Gets wether the tone mapping effect is enabled.
  8272. */
  8273. get toneMappingEnabled(): boolean;
  8274. /**
  8275. * Sets wether the tone mapping effect is enabled.
  8276. */
  8277. set toneMappingEnabled(value: boolean);
  8278. private _toneMappingType;
  8279. /**
  8280. * Gets the type of tone mapping effect.
  8281. */
  8282. get toneMappingType(): number;
  8283. /**
  8284. * Sets the type of tone mapping effect used in BabylonJS.
  8285. */
  8286. set toneMappingType(value: number);
  8287. protected _contrast: number;
  8288. /**
  8289. * Gets the contrast used in the effect.
  8290. */
  8291. get contrast(): number;
  8292. /**
  8293. * Sets the contrast used in the effect.
  8294. */
  8295. set contrast(value: number);
  8296. /**
  8297. * Vignette stretch size.
  8298. */
  8299. vignetteStretch: number;
  8300. /**
  8301. * Vignette centre X Offset.
  8302. */
  8303. vignetteCentreX: number;
  8304. /**
  8305. * Vignette centre Y Offset.
  8306. */
  8307. vignetteCentreY: number;
  8308. /**
  8309. * Vignette weight or intensity of the vignette effect.
  8310. */
  8311. vignetteWeight: number;
  8312. /**
  8313. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8314. * if vignetteEnabled is set to true.
  8315. */
  8316. vignetteColor: Color4;
  8317. /**
  8318. * Camera field of view used by the Vignette effect.
  8319. */
  8320. vignetteCameraFov: number;
  8321. private _vignetteBlendMode;
  8322. /**
  8323. * Gets the vignette blend mode allowing different kind of effect.
  8324. */
  8325. get vignetteBlendMode(): number;
  8326. /**
  8327. * Sets the vignette blend mode allowing different kind of effect.
  8328. */
  8329. set vignetteBlendMode(value: number);
  8330. private _vignetteEnabled;
  8331. /**
  8332. * Gets wether the vignette effect is enabled.
  8333. */
  8334. get vignetteEnabled(): boolean;
  8335. /**
  8336. * Sets wether the vignette effect is enabled.
  8337. */
  8338. set vignetteEnabled(value: boolean);
  8339. private _applyByPostProcess;
  8340. /**
  8341. * Gets wether the image processing is applied through a post process or not.
  8342. */
  8343. get applyByPostProcess(): boolean;
  8344. /**
  8345. * Sets wether the image processing is applied through a post process or not.
  8346. */
  8347. set applyByPostProcess(value: boolean);
  8348. private _isEnabled;
  8349. /**
  8350. * Gets wether the image processing is enabled or not.
  8351. */
  8352. get isEnabled(): boolean;
  8353. /**
  8354. * Sets wether the image processing is enabled or not.
  8355. */
  8356. set isEnabled(value: boolean);
  8357. /**
  8358. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8359. */
  8360. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8361. /**
  8362. * Method called each time the image processing information changes requires to recompile the effect.
  8363. */
  8364. protected _updateParameters(): void;
  8365. /**
  8366. * Gets the current class name.
  8367. * @return "ImageProcessingConfiguration"
  8368. */
  8369. getClassName(): string;
  8370. /**
  8371. * Prepare the list of uniforms associated with the Image Processing effects.
  8372. * @param uniforms The list of uniforms used in the effect
  8373. * @param defines the list of defines currently in use
  8374. */
  8375. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8376. /**
  8377. * Prepare the list of samplers associated with the Image Processing effects.
  8378. * @param samplersList The list of uniforms used in the effect
  8379. * @param defines the list of defines currently in use
  8380. */
  8381. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8382. /**
  8383. * Prepare the list of defines associated to the shader.
  8384. * @param defines the list of defines to complete
  8385. * @param forPostProcess Define if we are currently in post process mode or not
  8386. */
  8387. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8388. /**
  8389. * Returns true if all the image processing information are ready.
  8390. * @returns True if ready, otherwise, false
  8391. */
  8392. isReady(): boolean;
  8393. /**
  8394. * Binds the image processing to the shader.
  8395. * @param effect The effect to bind to
  8396. * @param overrideAspectRatio Override the aspect ratio of the effect
  8397. */
  8398. bind(effect: Effect, overrideAspectRatio?: number): void;
  8399. /**
  8400. * Clones the current image processing instance.
  8401. * @return The cloned image processing
  8402. */
  8403. clone(): ImageProcessingConfiguration;
  8404. /**
  8405. * Serializes the current image processing instance to a json representation.
  8406. * @return a JSON representation
  8407. */
  8408. serialize(): any;
  8409. /**
  8410. * Parses the image processing from a json representation.
  8411. * @param source the JSON source to parse
  8412. * @return The parsed image processing
  8413. */
  8414. static Parse(source: any): ImageProcessingConfiguration;
  8415. private static _VIGNETTEMODE_MULTIPLY;
  8416. private static _VIGNETTEMODE_OPAQUE;
  8417. /**
  8418. * Used to apply the vignette as a mix with the pixel color.
  8419. */
  8420. static get VIGNETTEMODE_MULTIPLY(): number;
  8421. /**
  8422. * Used to apply the vignette as a replacement of the pixel color.
  8423. */
  8424. static get VIGNETTEMODE_OPAQUE(): number;
  8425. }
  8426. }
  8427. declare module BABYLON {
  8428. /** @hidden */
  8429. export var postprocessVertexShader: {
  8430. name: string;
  8431. shader: string;
  8432. };
  8433. }
  8434. declare module BABYLON {
  8435. interface ThinEngine {
  8436. /**
  8437. * Creates a new render target texture
  8438. * @param size defines the size of the texture
  8439. * @param options defines the options used to create the texture
  8440. * @returns a new render target texture stored in an InternalTexture
  8441. */
  8442. createRenderTargetTexture(size: number | {
  8443. width: number;
  8444. height: number;
  8445. layers?: number;
  8446. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8447. /**
  8448. * Creates a depth stencil texture.
  8449. * This is only available in WebGL 2 or with the depth texture extension available.
  8450. * @param size The size of face edge in the texture.
  8451. * @param options The options defining the texture.
  8452. * @returns The texture
  8453. */
  8454. createDepthStencilTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. layers?: number;
  8458. }, options: DepthTextureCreationOptions): InternalTexture;
  8459. /** @hidden */
  8460. _createDepthStencilTexture(size: number | {
  8461. width: number;
  8462. height: number;
  8463. layers?: number;
  8464. }, options: DepthTextureCreationOptions): InternalTexture;
  8465. }
  8466. }
  8467. declare module BABYLON {
  8468. /** Defines supported spaces */
  8469. export enum Space {
  8470. /** Local (object) space */
  8471. LOCAL = 0,
  8472. /** World space */
  8473. WORLD = 1,
  8474. /** Bone space */
  8475. BONE = 2
  8476. }
  8477. /** Defines the 3 main axes */
  8478. export class Axis {
  8479. /** X axis */
  8480. static X: Vector3;
  8481. /** Y axis */
  8482. static Y: Vector3;
  8483. /** Z axis */
  8484. static Z: Vector3;
  8485. }
  8486. }
  8487. declare module BABYLON {
  8488. /**
  8489. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8490. * This is the base of the follow, arc rotate cameras and Free camera
  8491. * @see http://doc.babylonjs.com/features/cameras
  8492. */
  8493. export class TargetCamera extends Camera {
  8494. private static _RigCamTransformMatrix;
  8495. private static _TargetTransformMatrix;
  8496. private static _TargetFocalPoint;
  8497. /**
  8498. * Define the current direction the camera is moving to
  8499. */
  8500. cameraDirection: Vector3;
  8501. /**
  8502. * Define the current rotation the camera is rotating to
  8503. */
  8504. cameraRotation: Vector2;
  8505. /**
  8506. * When set, the up vector of the camera will be updated by the rotation of the camera
  8507. */
  8508. updateUpVectorFromRotation: boolean;
  8509. private _tmpQuaternion;
  8510. /**
  8511. * Define the current rotation of the camera
  8512. */
  8513. rotation: Vector3;
  8514. /**
  8515. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8516. */
  8517. rotationQuaternion: Quaternion;
  8518. /**
  8519. * Define the current speed of the camera
  8520. */
  8521. speed: number;
  8522. /**
  8523. * Add constraint to the camera to prevent it to move freely in all directions and
  8524. * around all axis.
  8525. */
  8526. noRotationConstraint: boolean;
  8527. /**
  8528. * Define the current target of the camera as an object or a position.
  8529. */
  8530. lockedTarget: any;
  8531. /** @hidden */
  8532. _currentTarget: Vector3;
  8533. /** @hidden */
  8534. _initialFocalDistance: number;
  8535. /** @hidden */
  8536. _viewMatrix: Matrix;
  8537. /** @hidden */
  8538. _camMatrix: Matrix;
  8539. /** @hidden */
  8540. _cameraTransformMatrix: Matrix;
  8541. /** @hidden */
  8542. _cameraRotationMatrix: Matrix;
  8543. /** @hidden */
  8544. _referencePoint: Vector3;
  8545. /** @hidden */
  8546. _transformedReferencePoint: Vector3;
  8547. protected _globalCurrentTarget: Vector3;
  8548. protected _globalCurrentUpVector: Vector3;
  8549. /** @hidden */
  8550. _reset: () => void;
  8551. private _defaultUp;
  8552. /**
  8553. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8554. * This is the base of the follow, arc rotate cameras and Free camera
  8555. * @see http://doc.babylonjs.com/features/cameras
  8556. * @param name Defines the name of the camera in the scene
  8557. * @param position Defines the start position of the camera in the scene
  8558. * @param scene Defines the scene the camera belongs to
  8559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8560. */
  8561. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8562. /**
  8563. * Gets the position in front of the camera at a given distance.
  8564. * @param distance The distance from the camera we want the position to be
  8565. * @returns the position
  8566. */
  8567. getFrontPosition(distance: number): Vector3;
  8568. /** @hidden */
  8569. _getLockedTargetPosition(): Nullable<Vector3>;
  8570. private _storedPosition;
  8571. private _storedRotation;
  8572. private _storedRotationQuaternion;
  8573. /**
  8574. * Store current camera state of the camera (fov, position, rotation, etc..)
  8575. * @returns the camera
  8576. */
  8577. storeState(): Camera;
  8578. /**
  8579. * Restored camera state. You must call storeState() first
  8580. * @returns whether it was successful or not
  8581. * @hidden
  8582. */
  8583. _restoreStateValues(): boolean;
  8584. /** @hidden */
  8585. _initCache(): void;
  8586. /** @hidden */
  8587. _updateCache(ignoreParentClass?: boolean): void;
  8588. /** @hidden */
  8589. _isSynchronizedViewMatrix(): boolean;
  8590. /** @hidden */
  8591. _computeLocalCameraSpeed(): number;
  8592. /**
  8593. * Defines the target the camera should look at.
  8594. * @param target Defines the new target as a Vector or a mesh
  8595. */
  8596. setTarget(target: Vector3): void;
  8597. /**
  8598. * Return the current target position of the camera. This value is expressed in local space.
  8599. * @returns the target position
  8600. */
  8601. getTarget(): Vector3;
  8602. /** @hidden */
  8603. _decideIfNeedsToMove(): boolean;
  8604. /** @hidden */
  8605. _updatePosition(): void;
  8606. /** @hidden */
  8607. _checkInputs(): void;
  8608. protected _updateCameraRotationMatrix(): void;
  8609. /**
  8610. * 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)
  8611. * @returns the current camera
  8612. */
  8613. private _rotateUpVectorWithCameraRotationMatrix;
  8614. private _cachedRotationZ;
  8615. private _cachedQuaternionRotationZ;
  8616. /** @hidden */
  8617. _getViewMatrix(): Matrix;
  8618. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8619. /**
  8620. * @hidden
  8621. */
  8622. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8623. /**
  8624. * @hidden
  8625. */
  8626. _updateRigCameras(): void;
  8627. private _getRigCamPositionAndTarget;
  8628. /**
  8629. * Gets the current object class name.
  8630. * @return the class name
  8631. */
  8632. getClassName(): string;
  8633. }
  8634. }
  8635. declare module BABYLON {
  8636. /**
  8637. * Gather the list of keyboard event types as constants.
  8638. */
  8639. export class KeyboardEventTypes {
  8640. /**
  8641. * The keydown event is fired when a key becomes active (pressed).
  8642. */
  8643. static readonly KEYDOWN: number;
  8644. /**
  8645. * The keyup event is fired when a key has been released.
  8646. */
  8647. static readonly KEYUP: number;
  8648. }
  8649. /**
  8650. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8651. */
  8652. export class KeyboardInfo {
  8653. /**
  8654. * Defines the type of event (KeyboardEventTypes)
  8655. */
  8656. type: number;
  8657. /**
  8658. * Defines the related dom event
  8659. */
  8660. event: KeyboardEvent;
  8661. /**
  8662. * Instantiates a new keyboard info.
  8663. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8664. * @param type Defines the type of event (KeyboardEventTypes)
  8665. * @param event Defines the related dom event
  8666. */
  8667. constructor(
  8668. /**
  8669. * Defines the type of event (KeyboardEventTypes)
  8670. */
  8671. type: number,
  8672. /**
  8673. * Defines the related dom event
  8674. */
  8675. event: KeyboardEvent);
  8676. }
  8677. /**
  8678. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8679. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8680. */
  8681. export class KeyboardInfoPre extends KeyboardInfo {
  8682. /**
  8683. * Defines the type of event (KeyboardEventTypes)
  8684. */
  8685. type: number;
  8686. /**
  8687. * Defines the related dom event
  8688. */
  8689. event: KeyboardEvent;
  8690. /**
  8691. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8692. */
  8693. skipOnPointerObservable: boolean;
  8694. /**
  8695. * Instantiates a new keyboard pre info.
  8696. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8697. * @param type Defines the type of event (KeyboardEventTypes)
  8698. * @param event Defines the related dom event
  8699. */
  8700. constructor(
  8701. /**
  8702. * Defines the type of event (KeyboardEventTypes)
  8703. */
  8704. type: number,
  8705. /**
  8706. * Defines the related dom event
  8707. */
  8708. event: KeyboardEvent);
  8709. }
  8710. }
  8711. declare module BABYLON {
  8712. /**
  8713. * Manage the keyboard inputs to control the movement of a free camera.
  8714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8715. */
  8716. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8717. /**
  8718. * Defines the camera the input is attached to.
  8719. */
  8720. camera: FreeCamera;
  8721. /**
  8722. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8723. */
  8724. keysUp: number[];
  8725. /**
  8726. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8727. */
  8728. keysDown: number[];
  8729. /**
  8730. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8731. */
  8732. keysLeft: number[];
  8733. /**
  8734. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8735. */
  8736. keysRight: number[];
  8737. private _keys;
  8738. private _onCanvasBlurObserver;
  8739. private _onKeyboardObserver;
  8740. private _engine;
  8741. private _scene;
  8742. /**
  8743. * Attach the input controls to a specific dom element to get the input from.
  8744. * @param element Defines the element the controls should be listened from
  8745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8746. */
  8747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8748. /**
  8749. * Detach the current controls from the specified dom element.
  8750. * @param element Defines the element to stop listening the inputs from
  8751. */
  8752. detachControl(element: Nullable<HTMLElement>): void;
  8753. /**
  8754. * Update the current camera state depending on the inputs that have been used this frame.
  8755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8756. */
  8757. checkInputs(): void;
  8758. /**
  8759. * Gets the class name of the current intput.
  8760. * @returns the class name
  8761. */
  8762. getClassName(): string;
  8763. /** @hidden */
  8764. _onLostFocus(): void;
  8765. /**
  8766. * Get the friendly name associated with the input class.
  8767. * @returns the input friendly name
  8768. */
  8769. getSimpleName(): string;
  8770. }
  8771. }
  8772. declare module BABYLON {
  8773. /**
  8774. * Interface describing all the common properties and methods a shadow light needs to implement.
  8775. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8776. * as well as binding the different shadow properties to the effects.
  8777. */
  8778. export interface IShadowLight extends Light {
  8779. /**
  8780. * The light id in the scene (used in scene.findLighById for instance)
  8781. */
  8782. id: string;
  8783. /**
  8784. * The position the shdow will be casted from.
  8785. */
  8786. position: Vector3;
  8787. /**
  8788. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8789. */
  8790. direction: Vector3;
  8791. /**
  8792. * The transformed position. Position of the light in world space taking parenting in account.
  8793. */
  8794. transformedPosition: Vector3;
  8795. /**
  8796. * The transformed direction. Direction of the light in world space taking parenting in account.
  8797. */
  8798. transformedDirection: Vector3;
  8799. /**
  8800. * The friendly name of the light in the scene.
  8801. */
  8802. name: string;
  8803. /**
  8804. * Defines the shadow projection clipping minimum z value.
  8805. */
  8806. shadowMinZ: number;
  8807. /**
  8808. * Defines the shadow projection clipping maximum z value.
  8809. */
  8810. shadowMaxZ: number;
  8811. /**
  8812. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8813. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8814. */
  8815. computeTransformedInformation(): boolean;
  8816. /**
  8817. * Gets the scene the light belongs to.
  8818. * @returns The scene
  8819. */
  8820. getScene(): Scene;
  8821. /**
  8822. * Callback defining a custom Projection Matrix Builder.
  8823. * This can be used to override the default projection matrix computation.
  8824. */
  8825. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8826. /**
  8827. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8828. * @param matrix The materix to updated with the projection information
  8829. * @param viewMatrix The transform matrix of the light
  8830. * @param renderList The list of mesh to render in the map
  8831. * @returns The current light
  8832. */
  8833. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8834. /**
  8835. * Gets the current depth scale used in ESM.
  8836. * @returns The scale
  8837. */
  8838. getDepthScale(): number;
  8839. /**
  8840. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8841. * @returns true if a cube texture needs to be use
  8842. */
  8843. needCube(): boolean;
  8844. /**
  8845. * Detects if the projection matrix requires to be recomputed this frame.
  8846. * @returns true if it requires to be recomputed otherwise, false.
  8847. */
  8848. needProjectionMatrixCompute(): boolean;
  8849. /**
  8850. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8851. */
  8852. forceProjectionMatrixCompute(): void;
  8853. /**
  8854. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8855. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8856. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8857. */
  8858. getShadowDirection(faceIndex?: number): Vector3;
  8859. /**
  8860. * Gets the minZ used for shadow according to both the scene and the light.
  8861. * @param activeCamera The camera we are returning the min for
  8862. * @returns the depth min z
  8863. */
  8864. getDepthMinZ(activeCamera: Camera): number;
  8865. /**
  8866. * Gets the maxZ used for shadow according to both the scene and the light.
  8867. * @param activeCamera The camera we are returning the max for
  8868. * @returns the depth max z
  8869. */
  8870. getDepthMaxZ(activeCamera: Camera): number;
  8871. }
  8872. /**
  8873. * Base implementation IShadowLight
  8874. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8875. */
  8876. export abstract class ShadowLight extends Light implements IShadowLight {
  8877. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8878. protected _position: Vector3;
  8879. protected _setPosition(value: Vector3): void;
  8880. /**
  8881. * Sets the position the shadow will be casted from. Also use as the light position for both
  8882. * point and spot lights.
  8883. */
  8884. get position(): Vector3;
  8885. /**
  8886. * Sets the position the shadow will be casted from. Also use as the light position for both
  8887. * point and spot lights.
  8888. */
  8889. set position(value: Vector3);
  8890. protected _direction: Vector3;
  8891. protected _setDirection(value: Vector3): void;
  8892. /**
  8893. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8894. * Also use as the light direction on spot and directional lights.
  8895. */
  8896. get direction(): Vector3;
  8897. /**
  8898. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8899. * Also use as the light direction on spot and directional lights.
  8900. */
  8901. set direction(value: Vector3);
  8902. protected _shadowMinZ: number;
  8903. /**
  8904. * Gets the shadow projection clipping minimum z value.
  8905. */
  8906. get shadowMinZ(): number;
  8907. /**
  8908. * Sets the shadow projection clipping minimum z value.
  8909. */
  8910. set shadowMinZ(value: number);
  8911. protected _shadowMaxZ: number;
  8912. /**
  8913. * Sets the shadow projection clipping maximum z value.
  8914. */
  8915. get shadowMaxZ(): number;
  8916. /**
  8917. * Gets the shadow projection clipping maximum z value.
  8918. */
  8919. set shadowMaxZ(value: number);
  8920. /**
  8921. * Callback defining a custom Projection Matrix Builder.
  8922. * This can be used to override the default projection matrix computation.
  8923. */
  8924. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8925. /**
  8926. * The transformed position. Position of the light in world space taking parenting in account.
  8927. */
  8928. transformedPosition: Vector3;
  8929. /**
  8930. * The transformed direction. Direction of the light in world space taking parenting in account.
  8931. */
  8932. transformedDirection: Vector3;
  8933. private _needProjectionMatrixCompute;
  8934. /**
  8935. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8936. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8937. */
  8938. computeTransformedInformation(): boolean;
  8939. /**
  8940. * Return the depth scale used for the shadow map.
  8941. * @returns the depth scale.
  8942. */
  8943. getDepthScale(): number;
  8944. /**
  8945. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8946. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8947. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8948. */
  8949. getShadowDirection(faceIndex?: number): Vector3;
  8950. /**
  8951. * Returns the ShadowLight absolute position in the World.
  8952. * @returns the position vector in world space
  8953. */
  8954. getAbsolutePosition(): Vector3;
  8955. /**
  8956. * Sets the ShadowLight direction toward the passed target.
  8957. * @param target The point to target in local space
  8958. * @returns the updated ShadowLight direction
  8959. */
  8960. setDirectionToTarget(target: Vector3): Vector3;
  8961. /**
  8962. * Returns the light rotation in euler definition.
  8963. * @returns the x y z rotation in local space.
  8964. */
  8965. getRotation(): Vector3;
  8966. /**
  8967. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8968. * @returns true if a cube texture needs to be use
  8969. */
  8970. needCube(): boolean;
  8971. /**
  8972. * Detects if the projection matrix requires to be recomputed this frame.
  8973. * @returns true if it requires to be recomputed otherwise, false.
  8974. */
  8975. needProjectionMatrixCompute(): boolean;
  8976. /**
  8977. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8978. */
  8979. forceProjectionMatrixCompute(): void;
  8980. /** @hidden */
  8981. _initCache(): void;
  8982. /** @hidden */
  8983. _isSynchronized(): boolean;
  8984. /**
  8985. * Computes the world matrix of the node
  8986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8987. * @returns the world matrix
  8988. */
  8989. computeWorldMatrix(force?: boolean): Matrix;
  8990. /**
  8991. * Gets the minZ used for shadow according to both the scene and the light.
  8992. * @param activeCamera The camera we are returning the min for
  8993. * @returns the depth min z
  8994. */
  8995. getDepthMinZ(activeCamera: Camera): number;
  8996. /**
  8997. * Gets the maxZ used for shadow according to both the scene and the light.
  8998. * @param activeCamera The camera we are returning the max for
  8999. * @returns the depth max z
  9000. */
  9001. getDepthMaxZ(activeCamera: Camera): number;
  9002. /**
  9003. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9004. * @param matrix The materix to updated with the projection information
  9005. * @param viewMatrix The transform matrix of the light
  9006. * @param renderList The list of mesh to render in the map
  9007. * @returns The current light
  9008. */
  9009. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9010. }
  9011. }
  9012. declare module BABYLON {
  9013. /**
  9014. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9015. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9016. */
  9017. export class EffectFallbacks implements IEffectFallbacks {
  9018. private _defines;
  9019. private _currentRank;
  9020. private _maxRank;
  9021. private _mesh;
  9022. /**
  9023. * Removes the fallback from the bound mesh.
  9024. */
  9025. unBindMesh(): void;
  9026. /**
  9027. * Adds a fallback on the specified property.
  9028. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9029. * @param define The name of the define in the shader
  9030. */
  9031. addFallback(rank: number, define: string): void;
  9032. /**
  9033. * Sets the mesh to use CPU skinning when needing to fallback.
  9034. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9035. * @param mesh The mesh to use the fallbacks.
  9036. */
  9037. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9038. /**
  9039. * Checks to see if more fallbacks are still availible.
  9040. */
  9041. get hasMoreFallbacks(): boolean;
  9042. /**
  9043. * Removes the defines that should be removed when falling back.
  9044. * @param currentDefines defines the current define statements for the shader.
  9045. * @param effect defines the current effect we try to compile
  9046. * @returns The resulting defines with defines of the current rank removed.
  9047. */
  9048. reduce(currentDefines: string, effect: Effect): string;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. /**
  9053. * "Static Class" containing the most commonly used helper while dealing with material for
  9054. * rendering purpose.
  9055. *
  9056. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9057. *
  9058. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9059. */
  9060. export class MaterialHelper {
  9061. /**
  9062. * Bind the current view position to an effect.
  9063. * @param effect The effect to be bound
  9064. * @param scene The scene the eyes position is used from
  9065. */
  9066. static BindEyePosition(effect: Effect, scene: Scene): void;
  9067. /**
  9068. * Helps preparing the defines values about the UVs in used in the effect.
  9069. * UVs are shared as much as we can accross channels in the shaders.
  9070. * @param texture The texture we are preparing the UVs for
  9071. * @param defines The defines to update
  9072. * @param key The channel key "diffuse", "specular"... used in the shader
  9073. */
  9074. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9075. /**
  9076. * Binds a texture matrix value to its corrsponding uniform
  9077. * @param texture The texture to bind the matrix for
  9078. * @param uniformBuffer The uniform buffer receivin the data
  9079. * @param key The channel key "diffuse", "specular"... used in the shader
  9080. */
  9081. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9082. /**
  9083. * Gets the current status of the fog (should it be enabled?)
  9084. * @param mesh defines the mesh to evaluate for fog support
  9085. * @param scene defines the hosting scene
  9086. * @returns true if fog must be enabled
  9087. */
  9088. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9089. /**
  9090. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9091. * @param mesh defines the current mesh
  9092. * @param scene defines the current scene
  9093. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9094. * @param pointsCloud defines if point cloud rendering has to be turned on
  9095. * @param fogEnabled defines if fog has to be turned on
  9096. * @param alphaTest defines if alpha testing has to be turned on
  9097. * @param defines defines the current list of defines
  9098. */
  9099. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9100. /**
  9101. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9102. * @param scene defines the current scene
  9103. * @param engine defines the current engine
  9104. * @param defines specifies the list of active defines
  9105. * @param useInstances defines if instances have to be turned on
  9106. * @param useClipPlane defines if clip plane have to be turned on
  9107. */
  9108. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9109. /**
  9110. * Prepares the defines for bones
  9111. * @param mesh The mesh containing the geometry data we will draw
  9112. * @param defines The defines to update
  9113. */
  9114. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9115. /**
  9116. * Prepares the defines for morph targets
  9117. * @param mesh The mesh containing the geometry data we will draw
  9118. * @param defines The defines to update
  9119. */
  9120. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9121. /**
  9122. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9123. * @param mesh The mesh containing the geometry data we will draw
  9124. * @param defines The defines to update
  9125. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9126. * @param useBones Precise whether bones should be used or not (override mesh info)
  9127. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9128. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9129. * @returns false if defines are considered not dirty and have not been checked
  9130. */
  9131. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9132. /**
  9133. * Prepares the defines related to multiview
  9134. * @param scene The scene we are intending to draw
  9135. * @param defines The defines to update
  9136. */
  9137. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9138. /**
  9139. * Prepares the defines related to the light information passed in parameter
  9140. * @param scene The scene we are intending to draw
  9141. * @param mesh The mesh the effect is compiling for
  9142. * @param light The light the effect is compiling for
  9143. * @param lightIndex The index of the light
  9144. * @param defines The defines to update
  9145. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9146. * @param state Defines the current state regarding what is needed (normals, etc...)
  9147. */
  9148. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9149. needNormals: boolean;
  9150. needRebuild: boolean;
  9151. shadowEnabled: boolean;
  9152. specularEnabled: boolean;
  9153. lightmapMode: boolean;
  9154. }): void;
  9155. /**
  9156. * Prepares the defines related to the light information passed in parameter
  9157. * @param scene The scene we are intending to draw
  9158. * @param mesh The mesh the effect is compiling for
  9159. * @param defines The defines to update
  9160. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9161. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9162. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9163. * @returns true if normals will be required for the rest of the effect
  9164. */
  9165. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9166. /**
  9167. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9168. * @param lightIndex defines the light index
  9169. * @param uniformsList The uniform list
  9170. * @param samplersList The sampler list
  9171. * @param projectedLightTexture defines if projected texture must be used
  9172. * @param uniformBuffersList defines an optional list of uniform buffers
  9173. */
  9174. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9175. /**
  9176. * Prepares the uniforms and samplers list to be used in the effect
  9177. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9178. * @param samplersList The sampler list
  9179. * @param defines The defines helping in the list generation
  9180. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9181. */
  9182. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9183. /**
  9184. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9185. * @param defines The defines to update while falling back
  9186. * @param fallbacks The authorized effect fallbacks
  9187. * @param maxSimultaneousLights The maximum number of lights allowed
  9188. * @param rank the current rank of the Effect
  9189. * @returns The newly affected rank
  9190. */
  9191. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9192. private static _TmpMorphInfluencers;
  9193. /**
  9194. * Prepares the list of attributes required for morph targets according to the effect defines.
  9195. * @param attribs The current list of supported attribs
  9196. * @param mesh The mesh to prepare the morph targets attributes for
  9197. * @param influencers The number of influencers
  9198. */
  9199. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9200. /**
  9201. * Prepares the list of attributes required for morph targets according to the effect defines.
  9202. * @param attribs The current list of supported attribs
  9203. * @param mesh The mesh to prepare the morph targets attributes for
  9204. * @param defines The current Defines of the effect
  9205. */
  9206. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9207. /**
  9208. * Prepares the list of attributes required for bones according to the effect defines.
  9209. * @param attribs The current list of supported attribs
  9210. * @param mesh The mesh to prepare the bones attributes for
  9211. * @param defines The current Defines of the effect
  9212. * @param fallbacks The current efffect fallback strategy
  9213. */
  9214. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9215. /**
  9216. * Check and prepare the list of attributes required for instances according to the effect defines.
  9217. * @param attribs The current list of supported attribs
  9218. * @param defines The current MaterialDefines of the effect
  9219. */
  9220. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9221. /**
  9222. * Add the list of attributes required for instances to the attribs array.
  9223. * @param attribs The current list of supported attribs
  9224. */
  9225. static PushAttributesForInstances(attribs: string[]): void;
  9226. /**
  9227. * Binds the light information to the effect.
  9228. * @param light The light containing the generator
  9229. * @param effect The effect we are binding the data to
  9230. * @param lightIndex The light index in the effect used to render
  9231. */
  9232. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9233. /**
  9234. * Binds the lights information from the scene to the effect for the given mesh.
  9235. * @param light Light to bind
  9236. * @param lightIndex Light index
  9237. * @param scene The scene where the light belongs to
  9238. * @param effect The effect we are binding the data to
  9239. * @param useSpecular Defines if specular is supported
  9240. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9241. */
  9242. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9243. /**
  9244. * Binds the lights information from the scene to the effect for the given mesh.
  9245. * @param scene The scene the lights belongs to
  9246. * @param mesh The mesh we are binding the information to render
  9247. * @param effect The effect we are binding the data to
  9248. * @param defines The generated defines for the effect
  9249. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9250. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9251. */
  9252. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9253. private static _tempFogColor;
  9254. /**
  9255. * Binds the fog information from the scene to the effect for the given mesh.
  9256. * @param scene The scene the lights belongs to
  9257. * @param mesh The mesh we are binding the information to render
  9258. * @param effect The effect we are binding the data to
  9259. * @param linearSpace Defines if the fog effect is applied in linear space
  9260. */
  9261. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9262. /**
  9263. * Binds the bones information from the mesh to the effect.
  9264. * @param mesh The mesh we are binding the information to render
  9265. * @param effect The effect we are binding the data to
  9266. */
  9267. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9268. /**
  9269. * Binds the morph targets information from the mesh to the effect.
  9270. * @param abstractMesh The mesh we are binding the information to render
  9271. * @param effect The effect we are binding the data to
  9272. */
  9273. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9274. /**
  9275. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9276. * @param defines The generated defines used in the effect
  9277. * @param effect The effect we are binding the data to
  9278. * @param scene The scene we are willing to render with logarithmic scale for
  9279. */
  9280. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9281. /**
  9282. * Binds the clip plane information from the scene to the effect.
  9283. * @param scene The scene the clip plane information are extracted from
  9284. * @param effect The effect we are binding the data to
  9285. */
  9286. static BindClipPlane(effect: Effect, scene: Scene): void;
  9287. }
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var packingFunctions: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var shadowMapPixelShader: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var bonesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var morphTargetsVertexGlobalDeclaration: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var morphTargetsVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var instancesDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var helperFunctions: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var morphTargetsVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var instancesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var bonesVertex: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapVertexShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var depthBoxBlurPixelShader: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /**
  9375. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9376. */
  9377. export interface ICustomShaderOptions {
  9378. /**
  9379. * Gets or sets the custom shader name to use
  9380. */
  9381. shaderName: string;
  9382. /**
  9383. * The list of attribute names used in the shader
  9384. */
  9385. attributes?: string[];
  9386. /**
  9387. * The list of unifrom names used in the shader
  9388. */
  9389. uniforms?: string[];
  9390. /**
  9391. * The list of sampler names used in the shader
  9392. */
  9393. samplers?: string[];
  9394. /**
  9395. * The list of defines used in the shader
  9396. */
  9397. defines?: string[];
  9398. }
  9399. /**
  9400. * Interface to implement to create a shadow generator compatible with BJS.
  9401. */
  9402. export interface IShadowGenerator {
  9403. /**
  9404. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9405. * @returns The render target texture if present otherwise, null
  9406. */
  9407. getShadowMap(): Nullable<RenderTargetTexture>;
  9408. /**
  9409. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9410. * @param subMesh The submesh we want to render in the shadow map
  9411. * @param useInstances Defines wether will draw in the map using instances
  9412. * @returns true if ready otherwise, false
  9413. */
  9414. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9415. /**
  9416. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9417. * @param defines Defines of the material we want to update
  9418. * @param lightIndex Index of the light in the enabled light list of the material
  9419. */
  9420. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9421. /**
  9422. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9423. * defined in the generator but impacting the effect).
  9424. * It implies the unifroms available on the materials are the standard BJS ones.
  9425. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9426. * @param effect The effect we are binfing the information for
  9427. */
  9428. bindShadowLight(lightIndex: string, effect: Effect): void;
  9429. /**
  9430. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9431. * (eq to shadow prjection matrix * light transform matrix)
  9432. * @returns The transform matrix used to create the shadow map
  9433. */
  9434. getTransformMatrix(): Matrix;
  9435. /**
  9436. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9437. * Cube and 2D textures for instance.
  9438. */
  9439. recreateShadowMap(): void;
  9440. /**
  9441. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9442. * @param onCompiled Callback triggered at the and of the effects compilation
  9443. * @param options Sets of optional options forcing the compilation with different modes
  9444. */
  9445. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9446. useInstances: boolean;
  9447. }>): void;
  9448. /**
  9449. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9450. * @param options Sets of optional options forcing the compilation with different modes
  9451. * @returns A promise that resolves when the compilation completes
  9452. */
  9453. forceCompilationAsync(options?: Partial<{
  9454. useInstances: boolean;
  9455. }>): Promise<void>;
  9456. /**
  9457. * Serializes the shadow generator setup to a json object.
  9458. * @returns The serialized JSON object
  9459. */
  9460. serialize(): any;
  9461. /**
  9462. * Disposes the Shadow map and related Textures and effects.
  9463. */
  9464. dispose(): void;
  9465. }
  9466. /**
  9467. * Default implementation IShadowGenerator.
  9468. * This is the main object responsible of generating shadows in the framework.
  9469. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9470. */
  9471. export class ShadowGenerator implements IShadowGenerator {
  9472. /**
  9473. * Shadow generator mode None: no filtering applied.
  9474. */
  9475. static readonly FILTER_NONE: number;
  9476. /**
  9477. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9478. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9479. */
  9480. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9481. /**
  9482. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9483. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9484. */
  9485. static readonly FILTER_POISSONSAMPLING: number;
  9486. /**
  9487. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9488. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9489. */
  9490. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9491. /**
  9492. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9493. * edge artifacts on steep falloff.
  9494. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9495. */
  9496. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9497. /**
  9498. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9499. * edge artifacts on steep falloff.
  9500. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9501. */
  9502. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9503. /**
  9504. * Shadow generator mode PCF: Percentage Closer Filtering
  9505. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9506. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9507. */
  9508. static readonly FILTER_PCF: number;
  9509. /**
  9510. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9511. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9512. * Contact Hardening
  9513. */
  9514. static readonly FILTER_PCSS: number;
  9515. /**
  9516. * Reserved for PCF and PCSS
  9517. * Highest Quality.
  9518. *
  9519. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9520. *
  9521. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9522. */
  9523. static readonly QUALITY_HIGH: number;
  9524. /**
  9525. * Reserved for PCF and PCSS
  9526. * Good tradeoff for quality/perf cross devices
  9527. *
  9528. * Execute PCF on a 3*3 kernel.
  9529. *
  9530. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9531. */
  9532. static readonly QUALITY_MEDIUM: number;
  9533. /**
  9534. * Reserved for PCF and PCSS
  9535. * The lowest quality but the fastest.
  9536. *
  9537. * Execute PCF on a 1*1 kernel.
  9538. *
  9539. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9540. */
  9541. static readonly QUALITY_LOW: number;
  9542. /** Gets or sets the custom shader name to use */
  9543. customShaderOptions: ICustomShaderOptions;
  9544. /**
  9545. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9546. */
  9547. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9548. /**
  9549. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9550. */
  9551. onAfterShadowMapRenderObservable: Observable<Effect>;
  9552. /**
  9553. * Observable triggered before a mesh is rendered in the shadow map.
  9554. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9555. */
  9556. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9557. /**
  9558. * Observable triggered after a mesh is rendered in the shadow map.
  9559. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9560. */
  9561. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9562. private _bias;
  9563. /**
  9564. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9565. */
  9566. get bias(): number;
  9567. /**
  9568. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9569. */
  9570. set bias(bias: number);
  9571. private _normalBias;
  9572. /**
  9573. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9574. */
  9575. get normalBias(): number;
  9576. /**
  9577. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9578. */
  9579. set normalBias(normalBias: number);
  9580. private _blurBoxOffset;
  9581. /**
  9582. * Gets the blur box offset: offset applied during the blur pass.
  9583. * Only useful if useKernelBlur = false
  9584. */
  9585. get blurBoxOffset(): number;
  9586. /**
  9587. * Sets the blur box offset: offset applied during the blur pass.
  9588. * Only useful if useKernelBlur = false
  9589. */
  9590. set blurBoxOffset(value: number);
  9591. private _blurScale;
  9592. /**
  9593. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9594. * 2 means half of the size.
  9595. */
  9596. get blurScale(): number;
  9597. /**
  9598. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9599. * 2 means half of the size.
  9600. */
  9601. set blurScale(value: number);
  9602. private _blurKernel;
  9603. /**
  9604. * Gets the blur kernel: kernel size of the blur pass.
  9605. * Only useful if useKernelBlur = true
  9606. */
  9607. get blurKernel(): number;
  9608. /**
  9609. * Sets the blur kernel: kernel size of the blur pass.
  9610. * Only useful if useKernelBlur = true
  9611. */
  9612. set blurKernel(value: number);
  9613. private _useKernelBlur;
  9614. /**
  9615. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9616. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9617. */
  9618. get useKernelBlur(): boolean;
  9619. /**
  9620. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9621. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9622. */
  9623. set useKernelBlur(value: boolean);
  9624. private _depthScale;
  9625. /**
  9626. * Gets the depth scale used in ESM mode.
  9627. */
  9628. get depthScale(): number;
  9629. /**
  9630. * Sets the depth scale used in ESM mode.
  9631. * This can override the scale stored on the light.
  9632. */
  9633. set depthScale(value: number);
  9634. private _filter;
  9635. /**
  9636. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9637. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9638. */
  9639. get filter(): number;
  9640. /**
  9641. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9642. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9643. */
  9644. set filter(value: number);
  9645. /**
  9646. * Gets if the current filter is set to Poisson Sampling.
  9647. */
  9648. get usePoissonSampling(): boolean;
  9649. /**
  9650. * Sets the current filter to Poisson Sampling.
  9651. */
  9652. set usePoissonSampling(value: boolean);
  9653. /**
  9654. * Gets if the current filter is set to ESM.
  9655. */
  9656. get useExponentialShadowMap(): boolean;
  9657. /**
  9658. * Sets the current filter is to ESM.
  9659. */
  9660. set useExponentialShadowMap(value: boolean);
  9661. /**
  9662. * Gets if the current filter is set to filtered ESM.
  9663. */
  9664. get useBlurExponentialShadowMap(): boolean;
  9665. /**
  9666. * Gets if the current filter is set to filtered ESM.
  9667. */
  9668. set useBlurExponentialShadowMap(value: boolean);
  9669. /**
  9670. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9671. * exponential to prevent steep falloff artifacts).
  9672. */
  9673. get useCloseExponentialShadowMap(): boolean;
  9674. /**
  9675. * Sets the current filter to "close ESM" (using the inverse of the
  9676. * exponential to prevent steep falloff artifacts).
  9677. */
  9678. set useCloseExponentialShadowMap(value: boolean);
  9679. /**
  9680. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9681. * exponential to prevent steep falloff artifacts).
  9682. */
  9683. get useBlurCloseExponentialShadowMap(): boolean;
  9684. /**
  9685. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9686. * exponential to prevent steep falloff artifacts).
  9687. */
  9688. set useBlurCloseExponentialShadowMap(value: boolean);
  9689. /**
  9690. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9691. */
  9692. get usePercentageCloserFiltering(): boolean;
  9693. /**
  9694. * Sets the current filter to "PCF" (percentage closer filtering).
  9695. */
  9696. set usePercentageCloserFiltering(value: boolean);
  9697. private _filteringQuality;
  9698. /**
  9699. * Gets the PCF or PCSS Quality.
  9700. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9701. */
  9702. get filteringQuality(): number;
  9703. /**
  9704. * Sets the PCF or PCSS Quality.
  9705. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9706. */
  9707. set filteringQuality(filteringQuality: number);
  9708. /**
  9709. * Gets if the current filter is set to "PCSS" (contact hardening).
  9710. */
  9711. get useContactHardeningShadow(): boolean;
  9712. /**
  9713. * Sets the current filter to "PCSS" (contact hardening).
  9714. */
  9715. set useContactHardeningShadow(value: boolean);
  9716. private _contactHardeningLightSizeUVRatio;
  9717. /**
  9718. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9719. * Using a ratio helps keeping shape stability independently of the map size.
  9720. *
  9721. * It does not account for the light projection as it was having too much
  9722. * instability during the light setup or during light position changes.
  9723. *
  9724. * Only valid if useContactHardeningShadow is true.
  9725. */
  9726. get contactHardeningLightSizeUVRatio(): number;
  9727. /**
  9728. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9729. * Using a ratio helps keeping shape stability independently of the map size.
  9730. *
  9731. * It does not account for the light projection as it was having too much
  9732. * instability during the light setup or during light position changes.
  9733. *
  9734. * Only valid if useContactHardeningShadow is true.
  9735. */
  9736. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9737. private _darkness;
  9738. /** Gets or sets the actual darkness of a shadow */
  9739. get darkness(): number;
  9740. set darkness(value: number);
  9741. /**
  9742. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9743. * 0 means strongest and 1 would means no shadow.
  9744. * @returns the darkness.
  9745. */
  9746. getDarkness(): number;
  9747. /**
  9748. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9749. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9750. * @returns the shadow generator allowing fluent coding.
  9751. */
  9752. setDarkness(darkness: number): ShadowGenerator;
  9753. private _transparencyShadow;
  9754. /** Gets or sets the ability to have transparent shadow */
  9755. get transparencyShadow(): boolean;
  9756. set transparencyShadow(value: boolean);
  9757. /**
  9758. * Sets the ability to have transparent shadow (boolean).
  9759. * @param transparent True if transparent else False
  9760. * @returns the shadow generator allowing fluent coding
  9761. */
  9762. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9763. private _shadowMap;
  9764. private _shadowMap2;
  9765. /**
  9766. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9767. * @returns The render target texture if present otherwise, null
  9768. */
  9769. getShadowMap(): Nullable<RenderTargetTexture>;
  9770. /**
  9771. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9772. * @returns The render target texture if the shadow map is present otherwise, null
  9773. */
  9774. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9775. /**
  9776. * Gets the class name of that object
  9777. * @returns "ShadowGenerator"
  9778. */
  9779. getClassName(): string;
  9780. /**
  9781. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9782. * @param mesh Mesh to add
  9783. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9784. * @returns the Shadow Generator itself
  9785. */
  9786. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9787. /**
  9788. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9789. * @param mesh Mesh to remove
  9790. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9791. * @returns the Shadow Generator itself
  9792. */
  9793. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9794. /**
  9795. * Controls the extent to which the shadows fade out at the edge of the frustum
  9796. * Used only by directionals and spots
  9797. */
  9798. frustumEdgeFalloff: number;
  9799. private _light;
  9800. /**
  9801. * Returns the associated light object.
  9802. * @returns the light generating the shadow
  9803. */
  9804. getLight(): IShadowLight;
  9805. /**
  9806. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9807. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9808. * It might on the other hand introduce peter panning.
  9809. */
  9810. forceBackFacesOnly: boolean;
  9811. private _scene;
  9812. private _lightDirection;
  9813. private _effect;
  9814. private _viewMatrix;
  9815. private _projectionMatrix;
  9816. private _transformMatrix;
  9817. private _cachedPosition;
  9818. private _cachedDirection;
  9819. private _cachedDefines;
  9820. private _currentRenderID;
  9821. private _boxBlurPostprocess;
  9822. private _kernelBlurXPostprocess;
  9823. private _kernelBlurYPostprocess;
  9824. private _blurPostProcesses;
  9825. private _mapSize;
  9826. private _currentFaceIndex;
  9827. private _currentFaceIndexCache;
  9828. private _textureType;
  9829. private _defaultTextureMatrix;
  9830. private _storedUniqueId;
  9831. /** @hidden */
  9832. static _SceneComponentInitialization: (scene: Scene) => void;
  9833. /**
  9834. * Creates a ShadowGenerator object.
  9835. * A ShadowGenerator is the required tool to use the shadows.
  9836. * Each light casting shadows needs to use its own ShadowGenerator.
  9837. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9838. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9839. * @param light The light object generating the shadows.
  9840. * @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.
  9841. */
  9842. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9843. private _initializeGenerator;
  9844. private _initializeShadowMap;
  9845. private _initializeBlurRTTAndPostProcesses;
  9846. private _renderForShadowMap;
  9847. private _renderSubMeshForShadowMap;
  9848. private _applyFilterValues;
  9849. /**
  9850. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9851. * @param onCompiled Callback triggered at the and of the effects compilation
  9852. * @param options Sets of optional options forcing the compilation with different modes
  9853. */
  9854. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9855. useInstances: boolean;
  9856. }>): void;
  9857. /**
  9858. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9859. * @param options Sets of optional options forcing the compilation with different modes
  9860. * @returns A promise that resolves when the compilation completes
  9861. */
  9862. forceCompilationAsync(options?: Partial<{
  9863. useInstances: boolean;
  9864. }>): Promise<void>;
  9865. /**
  9866. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9867. * @param subMesh The submesh we want to render in the shadow map
  9868. * @param useInstances Defines wether will draw in the map using instances
  9869. * @returns true if ready otherwise, false
  9870. */
  9871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9872. /**
  9873. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9874. * @param defines Defines of the material we want to update
  9875. * @param lightIndex Index of the light in the enabled light list of the material
  9876. */
  9877. prepareDefines(defines: any, lightIndex: number): void;
  9878. /**
  9879. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9880. * defined in the generator but impacting the effect).
  9881. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9882. * @param effect The effect we are binfing the information for
  9883. */
  9884. bindShadowLight(lightIndex: string, effect: Effect): void;
  9885. /**
  9886. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9887. * (eq to shadow prjection matrix * light transform matrix)
  9888. * @returns The transform matrix used to create the shadow map
  9889. */
  9890. getTransformMatrix(): Matrix;
  9891. /**
  9892. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9893. * Cube and 2D textures for instance.
  9894. */
  9895. recreateShadowMap(): void;
  9896. private _disposeBlurPostProcesses;
  9897. private _disposeRTTandPostProcesses;
  9898. /**
  9899. * Disposes the ShadowGenerator.
  9900. * Returns nothing.
  9901. */
  9902. dispose(): void;
  9903. /**
  9904. * Serializes the shadow generator setup to a json object.
  9905. * @returns The serialized JSON object
  9906. */
  9907. serialize(): any;
  9908. /**
  9909. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9910. * @param parsedShadowGenerator The JSON object to parse
  9911. * @param scene The scene to create the shadow map for
  9912. * @returns The parsed shadow generator
  9913. */
  9914. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9915. }
  9916. }
  9917. declare module BABYLON {
  9918. /**
  9919. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9920. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9921. * 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.
  9922. */
  9923. export abstract class Light extends Node {
  9924. /**
  9925. * Falloff Default: light is falling off following the material specification:
  9926. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9927. */
  9928. static readonly FALLOFF_DEFAULT: number;
  9929. /**
  9930. * Falloff Physical: light is falling off following the inverse squared distance law.
  9931. */
  9932. static readonly FALLOFF_PHYSICAL: number;
  9933. /**
  9934. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9935. * to enhance interoperability with other engines.
  9936. */
  9937. static readonly FALLOFF_GLTF: number;
  9938. /**
  9939. * Falloff Standard: light is falling off like in the standard material
  9940. * to enhance interoperability with other materials.
  9941. */
  9942. static readonly FALLOFF_STANDARD: number;
  9943. /**
  9944. * If every light affecting the material is in this lightmapMode,
  9945. * material.lightmapTexture adds or multiplies
  9946. * (depends on material.useLightmapAsShadowmap)
  9947. * after every other light calculations.
  9948. */
  9949. static readonly LIGHTMAP_DEFAULT: number;
  9950. /**
  9951. * material.lightmapTexture as only diffuse lighting from this light
  9952. * adds only specular lighting from this light
  9953. * adds dynamic shadows
  9954. */
  9955. static readonly LIGHTMAP_SPECULAR: number;
  9956. /**
  9957. * material.lightmapTexture as only lighting
  9958. * no light calculation from this light
  9959. * only adds dynamic shadows from this light
  9960. */
  9961. static readonly LIGHTMAP_SHADOWSONLY: number;
  9962. /**
  9963. * Each light type uses the default quantity according to its type:
  9964. * point/spot lights use luminous intensity
  9965. * directional lights use illuminance
  9966. */
  9967. static readonly INTENSITYMODE_AUTOMATIC: number;
  9968. /**
  9969. * lumen (lm)
  9970. */
  9971. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9972. /**
  9973. * candela (lm/sr)
  9974. */
  9975. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9976. /**
  9977. * lux (lm/m^2)
  9978. */
  9979. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9980. /**
  9981. * nit (cd/m^2)
  9982. */
  9983. static readonly INTENSITYMODE_LUMINANCE: number;
  9984. /**
  9985. * Light type const id of the point light.
  9986. */
  9987. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9988. /**
  9989. * Light type const id of the directional light.
  9990. */
  9991. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9992. /**
  9993. * Light type const id of the spot light.
  9994. */
  9995. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9996. /**
  9997. * Light type const id of the hemispheric light.
  9998. */
  9999. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10000. /**
  10001. * Diffuse gives the basic color to an object.
  10002. */
  10003. diffuse: Color3;
  10004. /**
  10005. * Specular produces a highlight color on an object.
  10006. * Note: This is note affecting PBR materials.
  10007. */
  10008. specular: Color3;
  10009. /**
  10010. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10011. * falling off base on range or angle.
  10012. * This can be set to any values in Light.FALLOFF_x.
  10013. *
  10014. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10015. * other types of materials.
  10016. */
  10017. falloffType: number;
  10018. /**
  10019. * Strength of the light.
  10020. * Note: By default it is define in the framework own unit.
  10021. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10022. */
  10023. intensity: number;
  10024. private _range;
  10025. protected _inverseSquaredRange: number;
  10026. /**
  10027. * Defines how far from the source the light is impacting in scene units.
  10028. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10029. */
  10030. get range(): number;
  10031. /**
  10032. * Defines how far from the source the light is impacting in scene units.
  10033. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10034. */
  10035. set range(value: number);
  10036. /**
  10037. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10038. * of light.
  10039. */
  10040. private _photometricScale;
  10041. private _intensityMode;
  10042. /**
  10043. * Gets the photometric scale used to interpret the intensity.
  10044. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10045. */
  10046. get intensityMode(): number;
  10047. /**
  10048. * Sets the photometric scale used to interpret the intensity.
  10049. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10050. */
  10051. set intensityMode(value: number);
  10052. private _radius;
  10053. /**
  10054. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10055. */
  10056. get radius(): number;
  10057. /**
  10058. * sets the light radius used by PBR Materials to simulate soft area lights.
  10059. */
  10060. set radius(value: number);
  10061. private _renderPriority;
  10062. /**
  10063. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10064. * exceeding the number allowed of the materials.
  10065. */
  10066. renderPriority: number;
  10067. private _shadowEnabled;
  10068. /**
  10069. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10070. * the current shadow generator.
  10071. */
  10072. get shadowEnabled(): boolean;
  10073. /**
  10074. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10075. * the current shadow generator.
  10076. */
  10077. set shadowEnabled(value: boolean);
  10078. private _includedOnlyMeshes;
  10079. /**
  10080. * Gets the only meshes impacted by this light.
  10081. */
  10082. get includedOnlyMeshes(): AbstractMesh[];
  10083. /**
  10084. * Sets the only meshes impacted by this light.
  10085. */
  10086. set includedOnlyMeshes(value: AbstractMesh[]);
  10087. private _excludedMeshes;
  10088. /**
  10089. * Gets the meshes not impacted by this light.
  10090. */
  10091. get excludedMeshes(): AbstractMesh[];
  10092. /**
  10093. * Sets the meshes not impacted by this light.
  10094. */
  10095. set excludedMeshes(value: AbstractMesh[]);
  10096. private _excludeWithLayerMask;
  10097. /**
  10098. * Gets the layer id use to find what meshes are not impacted by the light.
  10099. * Inactive if 0
  10100. */
  10101. get excludeWithLayerMask(): number;
  10102. /**
  10103. * Sets the layer id use to find what meshes are not impacted by the light.
  10104. * Inactive if 0
  10105. */
  10106. set excludeWithLayerMask(value: number);
  10107. private _includeOnlyWithLayerMask;
  10108. /**
  10109. * Gets the layer id use to find what meshes are impacted by the light.
  10110. * Inactive if 0
  10111. */
  10112. get includeOnlyWithLayerMask(): number;
  10113. /**
  10114. * Sets the layer id use to find what meshes are impacted by the light.
  10115. * Inactive if 0
  10116. */
  10117. set includeOnlyWithLayerMask(value: number);
  10118. private _lightmapMode;
  10119. /**
  10120. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10121. */
  10122. get lightmapMode(): number;
  10123. /**
  10124. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10125. */
  10126. set lightmapMode(value: number);
  10127. /**
  10128. * Shadow generator associted to the light.
  10129. * @hidden Internal use only.
  10130. */
  10131. _shadowGenerator: Nullable<IShadowGenerator>;
  10132. /**
  10133. * @hidden Internal use only.
  10134. */
  10135. _excludedMeshesIds: string[];
  10136. /**
  10137. * @hidden Internal use only.
  10138. */
  10139. _includedOnlyMeshesIds: string[];
  10140. /**
  10141. * The current light unifom buffer.
  10142. * @hidden Internal use only.
  10143. */
  10144. _uniformBuffer: UniformBuffer;
  10145. /** @hidden */
  10146. _renderId: number;
  10147. /**
  10148. * Creates a Light object in the scene.
  10149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10150. * @param name The firendly name of the light
  10151. * @param scene The scene the light belongs too
  10152. */
  10153. constructor(name: string, scene: Scene);
  10154. protected abstract _buildUniformLayout(): void;
  10155. /**
  10156. * Sets the passed Effect "effect" with the Light information.
  10157. * @param effect The effect to update
  10158. * @param lightIndex The index of the light in the effect to update
  10159. * @returns The light
  10160. */
  10161. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10162. /**
  10163. * Sets the passed Effect "effect" with the Light textures.
  10164. * @param effect The effect to update
  10165. * @param lightIndex The index of the light in the effect to update
  10166. * @returns The light
  10167. */
  10168. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10169. /**
  10170. * Binds the lights information from the scene to the effect for the given mesh.
  10171. * @param lightIndex Light index
  10172. * @param scene The scene where the light belongs to
  10173. * @param effect The effect we are binding the data to
  10174. * @param useSpecular Defines if specular is supported
  10175. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10176. */
  10177. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10178. /**
  10179. * Sets the passed Effect "effect" with the Light information.
  10180. * @param effect The effect to update
  10181. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10182. * @returns The light
  10183. */
  10184. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10185. /**
  10186. * Returns the string "Light".
  10187. * @returns the class name
  10188. */
  10189. getClassName(): string;
  10190. /** @hidden */
  10191. readonly _isLight: boolean;
  10192. /**
  10193. * Converts the light information to a readable string for debug purpose.
  10194. * @param fullDetails Supports for multiple levels of logging within scene loading
  10195. * @returns the human readable light info
  10196. */
  10197. toString(fullDetails?: boolean): string;
  10198. /** @hidden */
  10199. protected _syncParentEnabledState(): void;
  10200. /**
  10201. * Set the enabled state of this node.
  10202. * @param value - the new enabled state
  10203. */
  10204. setEnabled(value: boolean): void;
  10205. /**
  10206. * Returns the Light associated shadow generator if any.
  10207. * @return the associated shadow generator.
  10208. */
  10209. getShadowGenerator(): Nullable<IShadowGenerator>;
  10210. /**
  10211. * Returns a Vector3, the absolute light position in the World.
  10212. * @returns the world space position of the light
  10213. */
  10214. getAbsolutePosition(): Vector3;
  10215. /**
  10216. * Specifies if the light will affect the passed mesh.
  10217. * @param mesh The mesh to test against the light
  10218. * @return true the mesh is affected otherwise, false.
  10219. */
  10220. canAffectMesh(mesh: AbstractMesh): boolean;
  10221. /**
  10222. * Sort function to order lights for rendering.
  10223. * @param a First Light object to compare to second.
  10224. * @param b Second Light object to compare first.
  10225. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10226. */
  10227. static CompareLightsPriority(a: Light, b: Light): number;
  10228. /**
  10229. * Releases resources associated with this node.
  10230. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10231. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10232. */
  10233. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10234. /**
  10235. * Returns the light type ID (integer).
  10236. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10237. */
  10238. getTypeID(): number;
  10239. /**
  10240. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10241. * @returns the scaled intensity in intensity mode unit
  10242. */
  10243. getScaledIntensity(): number;
  10244. /**
  10245. * Returns a new Light object, named "name", from the current one.
  10246. * @param name The name of the cloned light
  10247. * @returns the new created light
  10248. */
  10249. clone(name: string): Nullable<Light>;
  10250. /**
  10251. * Serializes the current light into a Serialization object.
  10252. * @returns the serialized object.
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10257. * This new light is named "name" and added to the passed scene.
  10258. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10259. * @param name The friendly name of the light
  10260. * @param scene The scene the new light will belong to
  10261. * @returns the constructor function
  10262. */
  10263. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10264. /**
  10265. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10266. * @param parsedLight The JSON representation of the light
  10267. * @param scene The scene to create the parsed light in
  10268. * @returns the created light after parsing
  10269. */
  10270. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10271. private _hookArrayForExcluded;
  10272. private _hookArrayForIncludedOnly;
  10273. private _resyncMeshes;
  10274. /**
  10275. * Forces the meshes to update their light related information in their rendering used effects
  10276. * @hidden Internal Use Only
  10277. */
  10278. _markMeshesAsLightDirty(): void;
  10279. /**
  10280. * Recomputes the cached photometric scale if needed.
  10281. */
  10282. private _computePhotometricScale;
  10283. /**
  10284. * Returns the Photometric Scale according to the light type and intensity mode.
  10285. */
  10286. private _getPhotometricScale;
  10287. /**
  10288. * Reorder the light in the scene according to their defined priority.
  10289. * @hidden Internal Use Only
  10290. */
  10291. _reorderLightsInScene(): void;
  10292. /**
  10293. * Prepares the list of defines specific to the light type.
  10294. * @param defines the list of defines
  10295. * @param lightIndex defines the index of the light for the effect
  10296. */
  10297. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10298. }
  10299. }
  10300. declare module BABYLON {
  10301. /**
  10302. * Interface used to define Action
  10303. */
  10304. export interface IAction {
  10305. /**
  10306. * Trigger for the action
  10307. */
  10308. trigger: number;
  10309. /** Options of the trigger */
  10310. triggerOptions: any;
  10311. /**
  10312. * Gets the trigger parameters
  10313. * @returns the trigger parameters
  10314. */
  10315. getTriggerParameter(): any;
  10316. /**
  10317. * Internal only - executes current action event
  10318. * @hidden
  10319. */
  10320. _executeCurrent(evt?: ActionEvent): void;
  10321. /**
  10322. * Serialize placeholder for child classes
  10323. * @param parent of child
  10324. * @returns the serialized object
  10325. */
  10326. serialize(parent: any): any;
  10327. /**
  10328. * Internal only
  10329. * @hidden
  10330. */
  10331. _prepare(): void;
  10332. /**
  10333. * Internal only - manager for action
  10334. * @hidden
  10335. */
  10336. _actionManager: AbstractActionManager;
  10337. /**
  10338. * Adds action to chain of actions, may be a DoNothingAction
  10339. * @param action defines the next action to execute
  10340. * @returns The action passed in
  10341. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10342. */
  10343. then(action: IAction): IAction;
  10344. }
  10345. /**
  10346. * The action to be carried out following a trigger
  10347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10348. */
  10349. export class Action implements IAction {
  10350. /** the trigger, with or without parameters, for the action */
  10351. triggerOptions: any;
  10352. /**
  10353. * Trigger for the action
  10354. */
  10355. trigger: number;
  10356. /**
  10357. * Internal only - manager for action
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. private _nextActiveAction;
  10362. private _child;
  10363. private _condition?;
  10364. private _triggerParameter;
  10365. /**
  10366. * An event triggered prior to action being executed.
  10367. */
  10368. onBeforeExecuteObservable: Observable<Action>;
  10369. /**
  10370. * Creates a new Action
  10371. * @param triggerOptions the trigger, with or without parameters, for the action
  10372. * @param condition an optional determinant of action
  10373. */
  10374. constructor(
  10375. /** the trigger, with or without parameters, for the action */
  10376. triggerOptions: any, condition?: Condition);
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. _prepare(): void;
  10382. /**
  10383. * Gets the trigger parameters
  10384. * @returns the trigger parameters
  10385. */
  10386. getTriggerParameter(): any;
  10387. /**
  10388. * Internal only - executes current action event
  10389. * @hidden
  10390. */
  10391. _executeCurrent(evt?: ActionEvent): void;
  10392. /**
  10393. * Execute placeholder for child classes
  10394. * @param evt optional action event
  10395. */
  10396. execute(evt?: ActionEvent): void;
  10397. /**
  10398. * Skips to next active action
  10399. */
  10400. skipToNextActiveAction(): void;
  10401. /**
  10402. * Adds action to chain of actions, may be a DoNothingAction
  10403. * @param action defines the next action to execute
  10404. * @returns The action passed in
  10405. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10406. */
  10407. then(action: Action): Action;
  10408. /**
  10409. * Internal only
  10410. * @hidden
  10411. */
  10412. _getProperty(propertyPath: string): string;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. _getEffectiveTarget(target: any, propertyPath: string): any;
  10418. /**
  10419. * Serialize placeholder for child classes
  10420. * @param parent of child
  10421. * @returns the serialized object
  10422. */
  10423. serialize(parent: any): any;
  10424. /**
  10425. * Internal only called by serialize
  10426. * @hidden
  10427. */
  10428. protected _serialize(serializedAction: any, parent?: any): any;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. static _SerializeValueAsString: (value: any) => string;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. static _GetTargetProperty: (target: Node | Scene) => {
  10439. name: string;
  10440. targetType: string;
  10441. value: string;
  10442. };
  10443. }
  10444. }
  10445. declare module BABYLON {
  10446. /**
  10447. * A Condition applied to an Action
  10448. */
  10449. export class Condition {
  10450. /**
  10451. * Internal only - manager for action
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _evaluationId: number;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _currentResult: boolean;
  10465. /**
  10466. * Creates a new Condition
  10467. * @param actionManager the manager of the action the condition is applied to
  10468. */
  10469. constructor(actionManager: ActionManager);
  10470. /**
  10471. * Check if the current condition is valid
  10472. * @returns a boolean
  10473. */
  10474. isValid(): boolean;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. _getProperty(propertyPath: string): string;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. _getEffectiveTarget(target: any, propertyPath: string): any;
  10485. /**
  10486. * Serialize placeholder for child classes
  10487. * @returns the serialized object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. protected _serialize(serializedCondition: any): any;
  10495. }
  10496. /**
  10497. * Defines specific conditional operators as extensions of Condition
  10498. */
  10499. export class ValueCondition extends Condition {
  10500. /** path to specify the property of the target the conditional operator uses */
  10501. propertyPath: string;
  10502. /** the value compared by the conditional operator against the current value of the property */
  10503. value: any;
  10504. /** the conditional operator, default ValueCondition.IsEqual */
  10505. operator: number;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private static _IsEqual;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. private static _IsDifferent;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. private static _IsGreater;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. private static _IsLesser;
  10526. /**
  10527. * returns the number for IsEqual
  10528. */
  10529. static get IsEqual(): number;
  10530. /**
  10531. * Returns the number for IsDifferent
  10532. */
  10533. static get IsDifferent(): number;
  10534. /**
  10535. * Returns the number for IsGreater
  10536. */
  10537. static get IsGreater(): number;
  10538. /**
  10539. * Returns the number for IsLesser
  10540. */
  10541. static get IsLesser(): number;
  10542. /**
  10543. * Internal only The action manager for the condition
  10544. * @hidden
  10545. */
  10546. _actionManager: ActionManager;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private _target;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _effectiveTarget;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private _property;
  10562. /**
  10563. * Creates a new ValueCondition
  10564. * @param actionManager manager for the action the condition applies to
  10565. * @param target for the action
  10566. * @param propertyPath path to specify the property of the target the conditional operator uses
  10567. * @param value the value compared by the conditional operator against the current value of the property
  10568. * @param operator the conditional operator, default ValueCondition.IsEqual
  10569. */
  10570. constructor(actionManager: ActionManager, target: any,
  10571. /** path to specify the property of the target the conditional operator uses */
  10572. propertyPath: string,
  10573. /** the value compared by the conditional operator against the current value of the property */
  10574. value: any,
  10575. /** the conditional operator, default ValueCondition.IsEqual */
  10576. operator?: number);
  10577. /**
  10578. * Compares the given value with the property value for the specified conditional operator
  10579. * @returns the result of the comparison
  10580. */
  10581. isValid(): boolean;
  10582. /**
  10583. * Serialize the ValueCondition into a JSON compatible object
  10584. * @returns serialization object
  10585. */
  10586. serialize(): any;
  10587. /**
  10588. * Gets the name of the conditional operator for the ValueCondition
  10589. * @param operator the conditional operator
  10590. * @returns the name
  10591. */
  10592. static GetOperatorName(operator: number): string;
  10593. }
  10594. /**
  10595. * Defines a predicate condition as an extension of Condition
  10596. */
  10597. export class PredicateCondition extends Condition {
  10598. /** defines the predicate function used to validate the condition */
  10599. predicate: () => boolean;
  10600. /**
  10601. * Internal only - manager for action
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Creates a new PredicateCondition
  10607. * @param actionManager manager for the action the condition applies to
  10608. * @param predicate defines the predicate function used to validate the condition
  10609. */
  10610. constructor(actionManager: ActionManager,
  10611. /** defines the predicate function used to validate the condition */
  10612. predicate: () => boolean);
  10613. /**
  10614. * @returns the validity of the predicate condition
  10615. */
  10616. isValid(): boolean;
  10617. }
  10618. /**
  10619. * Defines a state condition as an extension of Condition
  10620. */
  10621. export class StateCondition extends Condition {
  10622. /** Value to compare with target state */
  10623. value: string;
  10624. /**
  10625. * Internal only - manager for action
  10626. * @hidden
  10627. */
  10628. _actionManager: ActionManager;
  10629. /**
  10630. * Internal only
  10631. * @hidden
  10632. */
  10633. private _target;
  10634. /**
  10635. * Creates a new StateCondition
  10636. * @param actionManager manager for the action the condition applies to
  10637. * @param target of the condition
  10638. * @param value to compare with target state
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** Value to compare with target state */
  10642. value: string);
  10643. /**
  10644. * Gets a boolean indicating if the current condition is met
  10645. * @returns the validity of the state
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Serialize the StateCondition into a JSON compatible object
  10650. * @returns serialization object
  10651. */
  10652. serialize(): any;
  10653. }
  10654. }
  10655. declare module BABYLON {
  10656. /**
  10657. * This defines an action responsible to toggle a boolean once triggered.
  10658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10659. */
  10660. export class SwitchBooleanAction extends Action {
  10661. /**
  10662. * The path to the boolean property in the target object
  10663. */
  10664. propertyPath: string;
  10665. private _target;
  10666. private _effectiveTarget;
  10667. private _property;
  10668. /**
  10669. * Instantiate the action
  10670. * @param triggerOptions defines the trigger options
  10671. * @param target defines the object containing the boolean
  10672. * @param propertyPath defines the path to the boolean property in the target object
  10673. * @param condition defines the trigger related conditions
  10674. */
  10675. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10676. /** @hidden */
  10677. _prepare(): void;
  10678. /**
  10679. * Execute the action toggle the boolean value.
  10680. */
  10681. execute(): void;
  10682. /**
  10683. * Serializes the actions and its related information.
  10684. * @param parent defines the object to serialize in
  10685. * @returns the serialized object
  10686. */
  10687. serialize(parent: any): any;
  10688. }
  10689. /**
  10690. * This defines an action responsible to set a the state field of the target
  10691. * to a desired value once triggered.
  10692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10693. */
  10694. export class SetStateAction extends Action {
  10695. /**
  10696. * The value to store in the state field.
  10697. */
  10698. value: string;
  10699. private _target;
  10700. /**
  10701. * Instantiate the action
  10702. * @param triggerOptions defines the trigger options
  10703. * @param target defines the object containing the state property
  10704. * @param value defines the value to store in the state field
  10705. * @param condition defines the trigger related conditions
  10706. */
  10707. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10708. /**
  10709. * Execute the action and store the value on the target state property.
  10710. */
  10711. execute(): void;
  10712. /**
  10713. * Serializes the actions and its related information.
  10714. * @param parent defines the object to serialize in
  10715. * @returns the serialized object
  10716. */
  10717. serialize(parent: any): any;
  10718. }
  10719. /**
  10720. * This defines an action responsible to set a property of the target
  10721. * to a desired value once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class SetValueAction extends Action {
  10725. /**
  10726. * The path of the property to set in the target.
  10727. */
  10728. propertyPath: string;
  10729. /**
  10730. * The value to set in the property
  10731. */
  10732. value: any;
  10733. private _target;
  10734. private _effectiveTarget;
  10735. private _property;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the property
  10740. * @param propertyPath defines the path of the property to set in the target
  10741. * @param value defines the value to set in the property
  10742. * @param condition defines the trigger related conditions
  10743. */
  10744. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10745. /** @hidden */
  10746. _prepare(): void;
  10747. /**
  10748. * Execute the action and set the targetted property to the desired value.
  10749. */
  10750. execute(): void;
  10751. /**
  10752. * Serializes the actions and its related information.
  10753. * @param parent defines the object to serialize in
  10754. * @returns the serialized object
  10755. */
  10756. serialize(parent: any): any;
  10757. }
  10758. /**
  10759. * This defines an action responsible to increment the target value
  10760. * to a desired value once triggered.
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10762. */
  10763. export class IncrementValueAction extends Action {
  10764. /**
  10765. * The path of the property to increment in the target.
  10766. */
  10767. propertyPath: string;
  10768. /**
  10769. * The value we should increment the property by.
  10770. */
  10771. value: any;
  10772. private _target;
  10773. private _effectiveTarget;
  10774. private _property;
  10775. /**
  10776. * Instantiate the action
  10777. * @param triggerOptions defines the trigger options
  10778. * @param target defines the object containing the property
  10779. * @param propertyPath defines the path of the property to increment in the target
  10780. * @param value defines the value value we should increment the property by
  10781. * @param condition defines the trigger related conditions
  10782. */
  10783. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10784. /** @hidden */
  10785. _prepare(): void;
  10786. /**
  10787. * Execute the action and increment the target of the value amount.
  10788. */
  10789. execute(): void;
  10790. /**
  10791. * Serializes the actions and its related information.
  10792. * @param parent defines the object to serialize in
  10793. * @returns the serialized object
  10794. */
  10795. serialize(parent: any): any;
  10796. }
  10797. /**
  10798. * This defines an action responsible to start an animation once triggered.
  10799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10800. */
  10801. export class PlayAnimationAction extends Action {
  10802. /**
  10803. * Where the animation should start (animation frame)
  10804. */
  10805. from: number;
  10806. /**
  10807. * Where the animation should stop (animation frame)
  10808. */
  10809. to: number;
  10810. /**
  10811. * Define if the animation should loop or stop after the first play.
  10812. */
  10813. loop?: boolean;
  10814. private _target;
  10815. /**
  10816. * Instantiate the action
  10817. * @param triggerOptions defines the trigger options
  10818. * @param target defines the target animation or animation name
  10819. * @param from defines from where the animation should start (animation frame)
  10820. * @param end defines where the animation should stop (animation frame)
  10821. * @param loop defines if the animation should loop or stop after the first play
  10822. * @param condition defines the trigger related conditions
  10823. */
  10824. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10825. /** @hidden */
  10826. _prepare(): void;
  10827. /**
  10828. * Execute the action and play the animation.
  10829. */
  10830. execute(): void;
  10831. /**
  10832. * Serializes the actions and its related information.
  10833. * @param parent defines the object to serialize in
  10834. * @returns the serialized object
  10835. */
  10836. serialize(parent: any): any;
  10837. }
  10838. /**
  10839. * This defines an action responsible to stop an animation once triggered.
  10840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10841. */
  10842. export class StopAnimationAction extends Action {
  10843. private _target;
  10844. /**
  10845. * Instantiate the action
  10846. * @param triggerOptions defines the trigger options
  10847. * @param target defines the target animation or animation name
  10848. * @param condition defines the trigger related conditions
  10849. */
  10850. constructor(triggerOptions: any, target: any, condition?: Condition);
  10851. /** @hidden */
  10852. _prepare(): void;
  10853. /**
  10854. * Execute the action and stop the animation.
  10855. */
  10856. execute(): void;
  10857. /**
  10858. * Serializes the actions and its related information.
  10859. * @param parent defines the object to serialize in
  10860. * @returns the serialized object
  10861. */
  10862. serialize(parent: any): any;
  10863. }
  10864. /**
  10865. * This defines an action responsible that does nothing once triggered.
  10866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10867. */
  10868. export class DoNothingAction extends Action {
  10869. /**
  10870. * Instantiate the action
  10871. * @param triggerOptions defines the trigger options
  10872. * @param condition defines the trigger related conditions
  10873. */
  10874. constructor(triggerOptions?: any, condition?: Condition);
  10875. /**
  10876. * Execute the action and do nothing.
  10877. */
  10878. execute(): void;
  10879. /**
  10880. * Serializes the actions and its related information.
  10881. * @param parent defines the object to serialize in
  10882. * @returns the serialized object
  10883. */
  10884. serialize(parent: any): any;
  10885. }
  10886. /**
  10887. * This defines an action responsible to trigger several actions once triggered.
  10888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10889. */
  10890. export class CombineAction extends Action {
  10891. /**
  10892. * The list of aggregated animations to run.
  10893. */
  10894. children: Action[];
  10895. /**
  10896. * Instantiate the action
  10897. * @param triggerOptions defines the trigger options
  10898. * @param children defines the list of aggregated animations to run
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10902. /** @hidden */
  10903. _prepare(): void;
  10904. /**
  10905. * Execute the action and executes all the aggregated actions.
  10906. */
  10907. execute(evt: ActionEvent): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible to run code (external event) once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class ExecuteCodeAction extends Action {
  10920. /**
  10921. * The callback function to run.
  10922. */
  10923. func: (evt: ActionEvent) => void;
  10924. /**
  10925. * Instantiate the action
  10926. * @param triggerOptions defines the trigger options
  10927. * @param func defines the callback function to run
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10931. /**
  10932. * Execute the action and run the attached code.
  10933. */
  10934. execute(evt: ActionEvent): void;
  10935. }
  10936. /**
  10937. * This defines an action responsible to set the parent property of the target once triggered.
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10939. */
  10940. export class SetParentAction extends Action {
  10941. private _parent;
  10942. private _target;
  10943. /**
  10944. * Instantiate the action
  10945. * @param triggerOptions defines the trigger options
  10946. * @param target defines the target containing the parent property
  10947. * @param parent defines from where the animation should start (animation frame)
  10948. * @param condition defines the trigger related conditions
  10949. */
  10950. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10951. /** @hidden */
  10952. _prepare(): void;
  10953. /**
  10954. * Execute the action and set the parent property.
  10955. */
  10956. execute(): void;
  10957. /**
  10958. * Serializes the actions and its related information.
  10959. * @param parent defines the object to serialize in
  10960. * @returns the serialized object
  10961. */
  10962. serialize(parent: any): any;
  10963. }
  10964. }
  10965. declare module BABYLON {
  10966. /**
  10967. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10968. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10970. */
  10971. export class ActionManager extends AbstractActionManager {
  10972. /**
  10973. * Nothing
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10975. */
  10976. static readonly NothingTrigger: number;
  10977. /**
  10978. * On pick
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10980. */
  10981. static readonly OnPickTrigger: number;
  10982. /**
  10983. * On left pick
  10984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10985. */
  10986. static readonly OnLeftPickTrigger: number;
  10987. /**
  10988. * On right pick
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10990. */
  10991. static readonly OnRightPickTrigger: number;
  10992. /**
  10993. * On center pick
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10995. */
  10996. static readonly OnCenterPickTrigger: number;
  10997. /**
  10998. * On pick down
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11000. */
  11001. static readonly OnPickDownTrigger: number;
  11002. /**
  11003. * On double pick
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11005. */
  11006. static readonly OnDoublePickTrigger: number;
  11007. /**
  11008. * On pick up
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly OnPickUpTrigger: number;
  11012. /**
  11013. * On pick out.
  11014. * This trigger will only be raised if you also declared a OnPickDown
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnPickOutTrigger: number;
  11018. /**
  11019. * On long press
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnLongPressTrigger: number;
  11023. /**
  11024. * On pointer over
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnPointerOverTrigger: number;
  11028. /**
  11029. * On pointer out
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnPointerOutTrigger: number;
  11033. /**
  11034. * On every frame
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnEveryFrameTrigger: number;
  11038. /**
  11039. * On intersection enter
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnIntersectionEnterTrigger: number;
  11043. /**
  11044. * On intersection exit
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnIntersectionExitTrigger: number;
  11048. /**
  11049. * On key down
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnKeyDownTrigger: number;
  11053. /**
  11054. * On key up
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnKeyUpTrigger: number;
  11058. private _scene;
  11059. /**
  11060. * Creates a new action manager
  11061. * @param scene defines the hosting scene
  11062. */
  11063. constructor(scene: Scene);
  11064. /**
  11065. * Releases all associated resources
  11066. */
  11067. dispose(): void;
  11068. /**
  11069. * Gets hosting scene
  11070. * @returns the hosting scene
  11071. */
  11072. getScene(): Scene;
  11073. /**
  11074. * Does this action manager handles actions of any of the given triggers
  11075. * @param triggers defines the triggers to be tested
  11076. * @return a boolean indicating whether one (or more) of the triggers is handled
  11077. */
  11078. hasSpecificTriggers(triggers: number[]): boolean;
  11079. /**
  11080. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11081. * speed.
  11082. * @param triggerA defines the trigger to be tested
  11083. * @param triggerB defines the trigger to be tested
  11084. * @return a boolean indicating whether one (or more) of the triggers is handled
  11085. */
  11086. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11087. /**
  11088. * Does this action manager handles actions of a given trigger
  11089. * @param trigger defines the trigger to be tested
  11090. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11091. * @return whether the trigger is handled
  11092. */
  11093. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11094. /**
  11095. * Does this action manager has pointer triggers
  11096. */
  11097. get hasPointerTriggers(): boolean;
  11098. /**
  11099. * Does this action manager has pick triggers
  11100. */
  11101. get hasPickTriggers(): boolean;
  11102. /**
  11103. * Registers an action to this action manager
  11104. * @param action defines the action to be registered
  11105. * @return the action amended (prepared) after registration
  11106. */
  11107. registerAction(action: IAction): Nullable<IAction>;
  11108. /**
  11109. * Unregisters an action to this action manager
  11110. * @param action defines the action to be unregistered
  11111. * @return a boolean indicating whether the action has been unregistered
  11112. */
  11113. unregisterAction(action: IAction): Boolean;
  11114. /**
  11115. * Process a specific trigger
  11116. * @param trigger defines the trigger to process
  11117. * @param evt defines the event details to be processed
  11118. */
  11119. processTrigger(trigger: number, evt?: IActionEvent): void;
  11120. /** @hidden */
  11121. _getEffectiveTarget(target: any, propertyPath: string): any;
  11122. /** @hidden */
  11123. _getProperty(propertyPath: string): string;
  11124. /**
  11125. * Serialize this manager to a JSON object
  11126. * @param name defines the property name to store this manager
  11127. * @returns a JSON representation of this manager
  11128. */
  11129. serialize(name: string): any;
  11130. /**
  11131. * Creates a new ActionManager from a JSON data
  11132. * @param parsedActions defines the JSON data to read from
  11133. * @param object defines the hosting mesh
  11134. * @param scene defines the hosting scene
  11135. */
  11136. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11137. /**
  11138. * Get a trigger name by index
  11139. * @param trigger defines the trigger index
  11140. * @returns a trigger name
  11141. */
  11142. static GetTriggerName(trigger: number): string;
  11143. }
  11144. }
  11145. declare module BABYLON {
  11146. /**
  11147. * Class representing a ray with position and direction
  11148. */
  11149. export class Ray {
  11150. /** origin point */
  11151. origin: Vector3;
  11152. /** direction */
  11153. direction: Vector3;
  11154. /** length of the ray */
  11155. length: number;
  11156. private static readonly TmpVector3;
  11157. private _tmpRay;
  11158. /**
  11159. * Creates a new ray
  11160. * @param origin origin point
  11161. * @param direction direction
  11162. * @param length length of the ray
  11163. */
  11164. constructor(
  11165. /** origin point */
  11166. origin: Vector3,
  11167. /** direction */
  11168. direction: Vector3,
  11169. /** length of the ray */
  11170. length?: number);
  11171. /**
  11172. * Checks if the ray intersects a box
  11173. * @param minimum bound of the box
  11174. * @param maximum bound of the box
  11175. * @param intersectionTreshold extra extend to be added to the box in all direction
  11176. * @returns if the box was hit
  11177. */
  11178. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11179. /**
  11180. * Checks if the ray intersects a box
  11181. * @param box the bounding box to check
  11182. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11183. * @returns if the box was hit
  11184. */
  11185. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11186. /**
  11187. * If the ray hits a sphere
  11188. * @param sphere the bounding sphere to check
  11189. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11190. * @returns true if it hits the sphere
  11191. */
  11192. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11193. /**
  11194. * If the ray hits a triange
  11195. * @param vertex0 triangle vertex
  11196. * @param vertex1 triangle vertex
  11197. * @param vertex2 triangle vertex
  11198. * @returns intersection information if hit
  11199. */
  11200. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11201. /**
  11202. * Checks if ray intersects a plane
  11203. * @param plane the plane to check
  11204. * @returns the distance away it was hit
  11205. */
  11206. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11207. /**
  11208. * Calculate the intercept of a ray on a given axis
  11209. * @param axis to check 'x' | 'y' | 'z'
  11210. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11211. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11212. */
  11213. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11214. /**
  11215. * Checks if ray intersects a mesh
  11216. * @param mesh the mesh to check
  11217. * @param fastCheck if only the bounding box should checked
  11218. * @returns picking info of the intersecton
  11219. */
  11220. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11221. /**
  11222. * Checks if ray intersects a mesh
  11223. * @param meshes the meshes to check
  11224. * @param fastCheck if only the bounding box should checked
  11225. * @param results array to store result in
  11226. * @returns Array of picking infos
  11227. */
  11228. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11229. private _comparePickingInfo;
  11230. private static smallnum;
  11231. private static rayl;
  11232. /**
  11233. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11234. * @param sega the first point of the segment to test the intersection against
  11235. * @param segb the second point of the segment to test the intersection against
  11236. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11237. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11238. */
  11239. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11240. /**
  11241. * Update the ray from viewport position
  11242. * @param x position
  11243. * @param y y position
  11244. * @param viewportWidth viewport width
  11245. * @param viewportHeight viewport height
  11246. * @param world world matrix
  11247. * @param view view matrix
  11248. * @param projection projection matrix
  11249. * @returns this ray updated
  11250. */
  11251. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11252. /**
  11253. * Creates a ray with origin and direction of 0,0,0
  11254. * @returns the new ray
  11255. */
  11256. static Zero(): Ray;
  11257. /**
  11258. * Creates a new ray from screen space and viewport
  11259. * @param x position
  11260. * @param y y position
  11261. * @param viewportWidth viewport width
  11262. * @param viewportHeight viewport height
  11263. * @param world world matrix
  11264. * @param view view matrix
  11265. * @param projection projection matrix
  11266. * @returns new ray
  11267. */
  11268. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11269. /**
  11270. * 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
  11271. * transformed to the given world matrix.
  11272. * @param origin The origin point
  11273. * @param end The end point
  11274. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11275. * @returns the new ray
  11276. */
  11277. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11278. /**
  11279. * Transforms a ray by a matrix
  11280. * @param ray ray to transform
  11281. * @param matrix matrix to apply
  11282. * @returns the resulting new ray
  11283. */
  11284. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11285. /**
  11286. * Transforms a ray by a matrix
  11287. * @param ray ray to transform
  11288. * @param matrix matrix to apply
  11289. * @param result ray to store result in
  11290. */
  11291. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11292. /**
  11293. * Unproject a ray from screen space to object space
  11294. * @param sourceX defines the screen space x coordinate to use
  11295. * @param sourceY defines the screen space y coordinate to use
  11296. * @param viewportWidth defines the current width of the viewport
  11297. * @param viewportHeight defines the current height of the viewport
  11298. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11299. * @param view defines the view matrix to use
  11300. * @param projection defines the projection matrix to use
  11301. */
  11302. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11303. }
  11304. /**
  11305. * Type used to define predicate used to select faces when a mesh intersection is detected
  11306. */
  11307. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11308. interface Scene {
  11309. /** @hidden */
  11310. _tempPickingRay: Nullable<Ray>;
  11311. /** @hidden */
  11312. _cachedRayForTransform: Ray;
  11313. /** @hidden */
  11314. _pickWithRayInverseMatrix: Matrix;
  11315. /** @hidden */
  11316. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11317. /** @hidden */
  11318. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11319. }
  11320. }
  11321. declare module BABYLON {
  11322. /**
  11323. * Groups all the scene component constants in one place to ease maintenance.
  11324. * @hidden
  11325. */
  11326. export class SceneComponentConstants {
  11327. static readonly NAME_EFFECTLAYER: string;
  11328. static readonly NAME_LAYER: string;
  11329. static readonly NAME_LENSFLARESYSTEM: string;
  11330. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11331. static readonly NAME_PARTICLESYSTEM: string;
  11332. static readonly NAME_GAMEPAD: string;
  11333. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11334. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11335. static readonly NAME_DEPTHRENDERER: string;
  11336. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11337. static readonly NAME_SPRITE: string;
  11338. static readonly NAME_OUTLINERENDERER: string;
  11339. static readonly NAME_PROCEDURALTEXTURE: string;
  11340. static readonly NAME_SHADOWGENERATOR: string;
  11341. static readonly NAME_OCTREE: string;
  11342. static readonly NAME_PHYSICSENGINE: string;
  11343. static readonly NAME_AUDIO: string;
  11344. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11345. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11346. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11347. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11348. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11349. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11350. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11351. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11352. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11353. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11354. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11355. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11356. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11357. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11358. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11359. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11360. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11361. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11362. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11363. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11364. static readonly STEP_AFTERRENDER_AUDIO: number;
  11365. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11366. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11367. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11368. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11369. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11370. static readonly STEP_POINTERMOVE_SPRITE: number;
  11371. static readonly STEP_POINTERDOWN_SPRITE: number;
  11372. static readonly STEP_POINTERUP_SPRITE: number;
  11373. }
  11374. /**
  11375. * This represents a scene component.
  11376. *
  11377. * This is used to decouple the dependency the scene is having on the different workloads like
  11378. * layers, post processes...
  11379. */
  11380. export interface ISceneComponent {
  11381. /**
  11382. * The name of the component. Each component must have a unique name.
  11383. */
  11384. name: string;
  11385. /**
  11386. * The scene the component belongs to.
  11387. */
  11388. scene: Scene;
  11389. /**
  11390. * Register the component to one instance of a scene.
  11391. */
  11392. register(): void;
  11393. /**
  11394. * Rebuilds the elements related to this component in case of
  11395. * context lost for instance.
  11396. */
  11397. rebuild(): void;
  11398. /**
  11399. * Disposes the component and the associated ressources.
  11400. */
  11401. dispose(): void;
  11402. }
  11403. /**
  11404. * This represents a SERIALIZABLE scene component.
  11405. *
  11406. * This extends Scene Component to add Serialization methods on top.
  11407. */
  11408. export interface ISceneSerializableComponent extends ISceneComponent {
  11409. /**
  11410. * Adds all the elements from the container to the scene
  11411. * @param container the container holding the elements
  11412. */
  11413. addFromContainer(container: AbstractScene): void;
  11414. /**
  11415. * Removes all the elements in the container from the scene
  11416. * @param container contains the elements to remove
  11417. * @param dispose if the removed element should be disposed (default: false)
  11418. */
  11419. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11420. /**
  11421. * Serializes the component data to the specified json object
  11422. * @param serializationObject The object to serialize to
  11423. */
  11424. serialize(serializationObject: any): void;
  11425. }
  11426. /**
  11427. * Strong typing of a Mesh related stage step action
  11428. */
  11429. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11430. /**
  11431. * Strong typing of a Evaluate Sub Mesh related stage step action
  11432. */
  11433. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11434. /**
  11435. * Strong typing of a Active Mesh related stage step action
  11436. */
  11437. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11438. /**
  11439. * Strong typing of a Camera related stage step action
  11440. */
  11441. export type CameraStageAction = (camera: Camera) => void;
  11442. /**
  11443. * Strong typing of a Camera Frame buffer related stage step action
  11444. */
  11445. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11446. /**
  11447. * Strong typing of a Render Target related stage step action
  11448. */
  11449. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11450. /**
  11451. * Strong typing of a RenderingGroup related stage step action
  11452. */
  11453. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11454. /**
  11455. * Strong typing of a Mesh Render related stage step action
  11456. */
  11457. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11458. /**
  11459. * Strong typing of a simple stage step action
  11460. */
  11461. export type SimpleStageAction = () => void;
  11462. /**
  11463. * Strong typing of a render target action.
  11464. */
  11465. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11466. /**
  11467. * Strong typing of a pointer move action.
  11468. */
  11469. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11470. /**
  11471. * Strong typing of a pointer up/down action.
  11472. */
  11473. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11474. /**
  11475. * Representation of a stage in the scene (Basically a list of ordered steps)
  11476. * @hidden
  11477. */
  11478. export class Stage<T extends Function> extends Array<{
  11479. index: number;
  11480. component: ISceneComponent;
  11481. action: T;
  11482. }> {
  11483. /**
  11484. * Hide ctor from the rest of the world.
  11485. * @param items The items to add.
  11486. */
  11487. private constructor();
  11488. /**
  11489. * Creates a new Stage.
  11490. * @returns A new instance of a Stage
  11491. */
  11492. static Create<T extends Function>(): Stage<T>;
  11493. /**
  11494. * Registers a step in an ordered way in the targeted stage.
  11495. * @param index Defines the position to register the step in
  11496. * @param component Defines the component attached to the step
  11497. * @param action Defines the action to launch during the step
  11498. */
  11499. registerStep(index: number, component: ISceneComponent, action: T): void;
  11500. /**
  11501. * Clears all the steps from the stage.
  11502. */
  11503. clear(): void;
  11504. }
  11505. }
  11506. declare module BABYLON {
  11507. interface Scene {
  11508. /** @hidden */
  11509. _pointerOverSprite: Nullable<Sprite>;
  11510. /** @hidden */
  11511. _pickedDownSprite: Nullable<Sprite>;
  11512. /** @hidden */
  11513. _tempSpritePickingRay: Nullable<Ray>;
  11514. /**
  11515. * All of the sprite managers added to this scene
  11516. * @see http://doc.babylonjs.com/babylon101/sprites
  11517. */
  11518. spriteManagers: Array<ISpriteManager>;
  11519. /**
  11520. * An event triggered when sprites rendering is about to start
  11521. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11522. */
  11523. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11524. /**
  11525. * An event triggered when sprites rendering is done
  11526. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11527. */
  11528. onAfterSpritesRenderingObservable: Observable<Scene>;
  11529. /** @hidden */
  11530. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11531. /** Launch a ray to try to pick a sprite in the scene
  11532. * @param x position on screen
  11533. * @param y position on screen
  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 for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11537. * @returns a PickingInfo
  11538. */
  11539. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11540. /** Use the given ray to pick a sprite in the scene
  11541. * @param ray The ray (in world space) to use to pick meshes
  11542. * @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
  11543. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11544. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11545. * @returns a PickingInfo
  11546. */
  11547. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11548. /** @hidden */
  11549. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11550. /** Launch a ray to try to pick sprites in the scene
  11551. * @param x position on screen
  11552. * @param y position on screen
  11553. * @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
  11554. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11555. * @returns a PickingInfo array
  11556. */
  11557. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11558. /** Use the given ray to pick sprites in the scene
  11559. * @param ray The ray (in world space) to use to pick meshes
  11560. * @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
  11561. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11562. * @returns a PickingInfo array
  11563. */
  11564. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11565. /**
  11566. * Force the sprite under the pointer
  11567. * @param sprite defines the sprite to use
  11568. */
  11569. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11570. /**
  11571. * Gets the sprite under the pointer
  11572. * @returns a Sprite or null if no sprite is under the pointer
  11573. */
  11574. getPointerOverSprite(): Nullable<Sprite>;
  11575. }
  11576. /**
  11577. * Defines the sprite scene component responsible to manage sprites
  11578. * in a given scene.
  11579. */
  11580. export class SpriteSceneComponent implements ISceneComponent {
  11581. /**
  11582. * The component name helpfull to identify the component in the list of scene components.
  11583. */
  11584. readonly name: string;
  11585. /**
  11586. * The scene the component belongs to.
  11587. */
  11588. scene: Scene;
  11589. /** @hidden */
  11590. private _spritePredicate;
  11591. /**
  11592. * Creates a new instance of the component for the given scene
  11593. * @param scene Defines the scene to register the component in
  11594. */
  11595. constructor(scene: Scene);
  11596. /**
  11597. * Registers the component in a given scene
  11598. */
  11599. register(): void;
  11600. /**
  11601. * Rebuilds the elements related to this component in case of
  11602. * context lost for instance.
  11603. */
  11604. rebuild(): void;
  11605. /**
  11606. * Disposes the component and the associated ressources.
  11607. */
  11608. dispose(): void;
  11609. private _pickSpriteButKeepRay;
  11610. private _pointerMove;
  11611. private _pointerDown;
  11612. private _pointerUp;
  11613. }
  11614. }
  11615. declare module BABYLON {
  11616. /** @hidden */
  11617. export var fogFragmentDeclaration: {
  11618. name: string;
  11619. shader: string;
  11620. };
  11621. }
  11622. declare module BABYLON {
  11623. /** @hidden */
  11624. export var fogFragment: {
  11625. name: string;
  11626. shader: string;
  11627. };
  11628. }
  11629. declare module BABYLON {
  11630. /** @hidden */
  11631. export var spritesPixelShader: {
  11632. name: string;
  11633. shader: string;
  11634. };
  11635. }
  11636. declare module BABYLON {
  11637. /** @hidden */
  11638. export var fogVertexDeclaration: {
  11639. name: string;
  11640. shader: string;
  11641. };
  11642. }
  11643. declare module BABYLON {
  11644. /** @hidden */
  11645. export var spritesVertexShader: {
  11646. name: string;
  11647. shader: string;
  11648. };
  11649. }
  11650. declare module BABYLON {
  11651. /**
  11652. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11653. */
  11654. export interface ISpriteManager extends IDisposable {
  11655. /**
  11656. * Restricts the camera to viewing objects with the same layerMask.
  11657. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11658. */
  11659. layerMask: number;
  11660. /**
  11661. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11662. */
  11663. isPickable: boolean;
  11664. /**
  11665. * Specifies the rendering group id for this mesh (0 by default)
  11666. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11667. */
  11668. renderingGroupId: number;
  11669. /**
  11670. * Defines the list of sprites managed by the manager.
  11671. */
  11672. sprites: Array<Sprite>;
  11673. /**
  11674. * Tests the intersection of a sprite with a specific ray.
  11675. * @param ray The ray we are sending to test the collision
  11676. * @param camera The camera space we are sending rays in
  11677. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11678. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11679. * @returns picking info or null.
  11680. */
  11681. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11682. /**
  11683. * Intersects the sprites with a ray
  11684. * @param ray defines the ray to intersect with
  11685. * @param camera defines the current active camera
  11686. * @param predicate defines a predicate used to select candidate sprites
  11687. * @returns null if no hit or a PickingInfo array
  11688. */
  11689. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11690. /**
  11691. * Renders the list of sprites on screen.
  11692. */
  11693. render(): void;
  11694. }
  11695. /**
  11696. * Class used to manage multiple sprites on the same spritesheet
  11697. * @see http://doc.babylonjs.com/babylon101/sprites
  11698. */
  11699. export class SpriteManager implements ISpriteManager {
  11700. /** defines the manager's name */
  11701. name: string;
  11702. /** Gets the list of sprites */
  11703. sprites: Sprite[];
  11704. /** Gets or sets the rendering group id (0 by default) */
  11705. renderingGroupId: number;
  11706. /** Gets or sets camera layer mask */
  11707. layerMask: number;
  11708. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11709. fogEnabled: boolean;
  11710. /** Gets or sets a boolean indicating if the sprites are pickable */
  11711. isPickable: boolean;
  11712. /** Defines the default width of a cell in the spritesheet */
  11713. cellWidth: number;
  11714. /** Defines the default height of a cell in the spritesheet */
  11715. cellHeight: number;
  11716. /** Associative array from JSON sprite data file */
  11717. private _cellData;
  11718. /** Array of sprite names from JSON sprite data file */
  11719. private _spriteMap;
  11720. /** True when packed cell data from JSON file is ready*/
  11721. private _packedAndReady;
  11722. /**
  11723. * An event triggered when the manager is disposed.
  11724. */
  11725. onDisposeObservable: Observable<SpriteManager>;
  11726. private _onDisposeObserver;
  11727. /**
  11728. * Callback called when the manager is disposed
  11729. */
  11730. set onDispose(callback: () => void);
  11731. private _capacity;
  11732. private _fromPacked;
  11733. private _spriteTexture;
  11734. private _epsilon;
  11735. private _scene;
  11736. private _vertexData;
  11737. private _buffer;
  11738. private _vertexBuffers;
  11739. private _indexBuffer;
  11740. private _effectBase;
  11741. private _effectFog;
  11742. /**
  11743. * Gets or sets the spritesheet texture
  11744. */
  11745. get texture(): Texture;
  11746. set texture(value: Texture);
  11747. /**
  11748. * Creates a new sprite manager
  11749. * @param name defines the manager's name
  11750. * @param imgUrl defines the sprite sheet url
  11751. * @param capacity defines the maximum allowed number of sprites
  11752. * @param cellSize defines the size of a sprite cell
  11753. * @param scene defines the hosting scene
  11754. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11755. * @param samplingMode defines the smapling mode to use with spritesheet
  11756. * @param fromPacked set to false; do not alter
  11757. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11758. */
  11759. constructor(
  11760. /** defines the manager's name */
  11761. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11762. private _makePacked;
  11763. private _appendSpriteVertex;
  11764. /**
  11765. * Intersects the sprites with a ray
  11766. * @param ray defines the ray to intersect with
  11767. * @param camera defines the current active camera
  11768. * @param predicate defines a predicate used to select candidate sprites
  11769. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11770. * @returns null if no hit or a PickingInfo
  11771. */
  11772. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11773. /**
  11774. * Intersects the sprites with a ray
  11775. * @param ray defines the ray to intersect with
  11776. * @param camera defines the current active camera
  11777. * @param predicate defines a predicate used to select candidate sprites
  11778. * @returns null if no hit or a PickingInfo array
  11779. */
  11780. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11781. /**
  11782. * Render all child sprites
  11783. */
  11784. render(): void;
  11785. /**
  11786. * Release associated resources
  11787. */
  11788. dispose(): void;
  11789. }
  11790. }
  11791. declare module BABYLON {
  11792. /**
  11793. * Class used to represent a sprite
  11794. * @see http://doc.babylonjs.com/babylon101/sprites
  11795. */
  11796. export class Sprite {
  11797. /** defines the name */
  11798. name: string;
  11799. /** Gets or sets the current world position */
  11800. position: Vector3;
  11801. /** Gets or sets the main color */
  11802. color: Color4;
  11803. /** Gets or sets the width */
  11804. width: number;
  11805. /** Gets or sets the height */
  11806. height: number;
  11807. /** Gets or sets rotation angle */
  11808. angle: number;
  11809. /** Gets or sets the cell index in the sprite sheet */
  11810. cellIndex: number;
  11811. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11812. cellRef: string;
  11813. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11814. invertU: number;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11816. invertV: number;
  11817. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11818. disposeWhenFinishedAnimating: boolean;
  11819. /** Gets the list of attached animations */
  11820. animations: Animation[];
  11821. /** Gets or sets a boolean indicating if the sprite can be picked */
  11822. isPickable: boolean;
  11823. /**
  11824. * Gets or sets the associated action manager
  11825. */
  11826. actionManager: Nullable<ActionManager>;
  11827. private _animationStarted;
  11828. private _loopAnimation;
  11829. private _fromIndex;
  11830. private _toIndex;
  11831. private _delay;
  11832. private _direction;
  11833. private _manager;
  11834. private _time;
  11835. private _onAnimationEnd;
  11836. /**
  11837. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11838. */
  11839. isVisible: boolean;
  11840. /**
  11841. * Gets or sets the sprite size
  11842. */
  11843. get size(): number;
  11844. set size(value: number);
  11845. /**
  11846. * Creates a new Sprite
  11847. * @param name defines the name
  11848. * @param manager defines the manager
  11849. */
  11850. constructor(
  11851. /** defines the name */
  11852. name: string, manager: ISpriteManager);
  11853. /**
  11854. * Starts an animation
  11855. * @param from defines the initial key
  11856. * @param to defines the end key
  11857. * @param loop defines if the animation must loop
  11858. * @param delay defines the start delay (in ms)
  11859. * @param onAnimationEnd defines a callback to call when animation ends
  11860. */
  11861. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11862. /** Stops current animation (if any) */
  11863. stopAnimation(): void;
  11864. /** @hidden */
  11865. _animate(deltaTime: number): void;
  11866. /** Release associated resources */
  11867. dispose(): void;
  11868. }
  11869. }
  11870. declare module BABYLON {
  11871. /**
  11872. * Information about the result of picking within a scene
  11873. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11874. */
  11875. export class PickingInfo {
  11876. /** @hidden */
  11877. _pickingUnavailable: boolean;
  11878. /**
  11879. * If the pick collided with an object
  11880. */
  11881. hit: boolean;
  11882. /**
  11883. * Distance away where the pick collided
  11884. */
  11885. distance: number;
  11886. /**
  11887. * The location of pick collision
  11888. */
  11889. pickedPoint: Nullable<Vector3>;
  11890. /**
  11891. * The mesh corresponding the the pick collision
  11892. */
  11893. pickedMesh: Nullable<AbstractMesh>;
  11894. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11895. bu: number;
  11896. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11897. bv: number;
  11898. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11899. faceId: number;
  11900. /** Id of the the submesh that was picked */
  11901. subMeshId: number;
  11902. /** If a sprite was picked, this will be the sprite the pick collided with */
  11903. pickedSprite: Nullable<Sprite>;
  11904. /**
  11905. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11906. */
  11907. originMesh: Nullable<AbstractMesh>;
  11908. /**
  11909. * The ray that was used to perform the picking.
  11910. */
  11911. ray: Nullable<Ray>;
  11912. /**
  11913. * Gets the normal correspodning to the face the pick collided with
  11914. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11915. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11916. * @returns The normal correspodning to the face the pick collided with
  11917. */
  11918. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11919. /**
  11920. * Gets the texture coordinates of where the pick occured
  11921. * @returns the vector containing the coordnates of the texture
  11922. */
  11923. getTextureCoordinates(): Nullable<Vector2>;
  11924. }
  11925. }
  11926. declare module BABYLON {
  11927. /**
  11928. * Gather the list of pointer event types as constants.
  11929. */
  11930. export class PointerEventTypes {
  11931. /**
  11932. * 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.
  11933. */
  11934. static readonly POINTERDOWN: number;
  11935. /**
  11936. * The pointerup event is fired when a pointer is no longer active.
  11937. */
  11938. static readonly POINTERUP: number;
  11939. /**
  11940. * The pointermove event is fired when a pointer changes coordinates.
  11941. */
  11942. static readonly POINTERMOVE: number;
  11943. /**
  11944. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11945. */
  11946. static readonly POINTERWHEEL: number;
  11947. /**
  11948. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11949. */
  11950. static readonly POINTERPICK: number;
  11951. /**
  11952. * The pointertap event is fired when a the object has been touched and released without drag.
  11953. */
  11954. static readonly POINTERTAP: number;
  11955. /**
  11956. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11957. */
  11958. static readonly POINTERDOUBLETAP: number;
  11959. }
  11960. /**
  11961. * Base class of pointer info types.
  11962. */
  11963. export class PointerInfoBase {
  11964. /**
  11965. * Defines the type of event (PointerEventTypes)
  11966. */
  11967. type: number;
  11968. /**
  11969. * Defines the related dom event
  11970. */
  11971. event: PointerEvent | MouseWheelEvent;
  11972. /**
  11973. * Instantiates the base class of pointers info.
  11974. * @param type Defines the type of event (PointerEventTypes)
  11975. * @param event Defines the related dom event
  11976. */
  11977. constructor(
  11978. /**
  11979. * Defines the type of event (PointerEventTypes)
  11980. */
  11981. type: number,
  11982. /**
  11983. * Defines the related dom event
  11984. */
  11985. event: PointerEvent | MouseWheelEvent);
  11986. }
  11987. /**
  11988. * This class is used to store pointer related info for the onPrePointerObservable event.
  11989. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11990. */
  11991. export class PointerInfoPre extends PointerInfoBase {
  11992. /**
  11993. * Ray from a pointer if availible (eg. 6dof controller)
  11994. */
  11995. ray: Nullable<Ray>;
  11996. /**
  11997. * Defines the local position of the pointer on the canvas.
  11998. */
  11999. localPosition: Vector2;
  12000. /**
  12001. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12002. */
  12003. skipOnPointerObservable: boolean;
  12004. /**
  12005. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12006. * @param type Defines the type of event (PointerEventTypes)
  12007. * @param event Defines the related dom event
  12008. * @param localX Defines the local x coordinates of the pointer when the event occured
  12009. * @param localY Defines the local y coordinates of the pointer when the event occured
  12010. */
  12011. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12012. }
  12013. /**
  12014. * This type contains all the data related to a pointer event in Babylon.js.
  12015. * 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.
  12016. */
  12017. export class PointerInfo extends PointerInfoBase {
  12018. /**
  12019. * Defines the picking info associated to the info (if any)\
  12020. */
  12021. pickInfo: Nullable<PickingInfo>;
  12022. /**
  12023. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12024. * @param type Defines the type of event (PointerEventTypes)
  12025. * @param event Defines the related dom event
  12026. * @param pickInfo Defines the picking info associated to the info (if any)\
  12027. */
  12028. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12029. /**
  12030. * Defines the picking info associated to the info (if any)\
  12031. */
  12032. pickInfo: Nullable<PickingInfo>);
  12033. }
  12034. /**
  12035. * Data relating to a touch event on the screen.
  12036. */
  12037. export interface PointerTouch {
  12038. /**
  12039. * X coordinate of touch.
  12040. */
  12041. x: number;
  12042. /**
  12043. * Y coordinate of touch.
  12044. */
  12045. y: number;
  12046. /**
  12047. * Id of touch. Unique for each finger.
  12048. */
  12049. pointerId: number;
  12050. /**
  12051. * Event type passed from DOM.
  12052. */
  12053. type: any;
  12054. }
  12055. }
  12056. declare module BABYLON {
  12057. /**
  12058. * Manage the mouse inputs to control the movement of a free camera.
  12059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12060. */
  12061. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12062. /**
  12063. * Define if touch is enabled in the mouse input
  12064. */
  12065. touchEnabled: boolean;
  12066. /**
  12067. * Defines the camera the input is attached to.
  12068. */
  12069. camera: FreeCamera;
  12070. /**
  12071. * Defines the buttons associated with the input to handle camera move.
  12072. */
  12073. buttons: number[];
  12074. /**
  12075. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12076. */
  12077. angularSensibility: number;
  12078. private _pointerInput;
  12079. private _onMouseMove;
  12080. private _observer;
  12081. private previousPosition;
  12082. /**
  12083. * Observable for when a pointer move event occurs containing the move offset
  12084. */
  12085. onPointerMovedObservable: Observable<{
  12086. offsetX: number;
  12087. offsetY: number;
  12088. }>;
  12089. /**
  12090. * @hidden
  12091. * If the camera should be rotated automatically based on pointer movement
  12092. */
  12093. _allowCameraRotation: boolean;
  12094. /**
  12095. * Manage the mouse inputs to control the movement of a free camera.
  12096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12097. * @param touchEnabled Defines if touch is enabled or not
  12098. */
  12099. constructor(
  12100. /**
  12101. * Define if touch is enabled in the mouse input
  12102. */
  12103. touchEnabled?: boolean);
  12104. /**
  12105. * Attach the input controls to a specific dom element to get the input from.
  12106. * @param element Defines the element the controls should be listened from
  12107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12108. */
  12109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12110. /**
  12111. * Called on JS contextmenu event.
  12112. * Override this method to provide functionality.
  12113. */
  12114. protected onContextMenu(evt: PointerEvent): void;
  12115. /**
  12116. * Detach the current controls from the specified dom element.
  12117. * @param element Defines the element to stop listening the inputs from
  12118. */
  12119. detachControl(element: Nullable<HTMLElement>): void;
  12120. /**
  12121. * Gets the class name of the current intput.
  12122. * @returns the class name
  12123. */
  12124. getClassName(): string;
  12125. /**
  12126. * Get the friendly name associated with the input class.
  12127. * @returns the input friendly name
  12128. */
  12129. getSimpleName(): string;
  12130. }
  12131. }
  12132. declare module BABYLON {
  12133. /**
  12134. * Manage the touch inputs to control the movement of a free camera.
  12135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12136. */
  12137. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12138. /**
  12139. * Defines the camera the input is attached to.
  12140. */
  12141. camera: FreeCamera;
  12142. /**
  12143. * Defines the touch sensibility for rotation.
  12144. * The higher the faster.
  12145. */
  12146. touchAngularSensibility: number;
  12147. /**
  12148. * Defines the touch sensibility for move.
  12149. * The higher the faster.
  12150. */
  12151. touchMoveSensibility: number;
  12152. private _offsetX;
  12153. private _offsetY;
  12154. private _pointerPressed;
  12155. private _pointerInput;
  12156. private _observer;
  12157. private _onLostFocus;
  12158. /**
  12159. * Attach the input controls to a specific dom element to get the input from.
  12160. * @param element Defines the element the controls should be listened from
  12161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12162. */
  12163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12164. /**
  12165. * Detach the current controls from the specified dom element.
  12166. * @param element Defines the element to stop listening the inputs from
  12167. */
  12168. detachControl(element: Nullable<HTMLElement>): void;
  12169. /**
  12170. * Update the current camera state depending on the inputs that have been used this frame.
  12171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12172. */
  12173. checkInputs(): void;
  12174. /**
  12175. * Gets the class name of the current intput.
  12176. * @returns the class name
  12177. */
  12178. getClassName(): string;
  12179. /**
  12180. * Get the friendly name associated with the input class.
  12181. * @returns the input friendly name
  12182. */
  12183. getSimpleName(): string;
  12184. }
  12185. }
  12186. declare module BABYLON {
  12187. /**
  12188. * Default Inputs manager for the FreeCamera.
  12189. * It groups all the default supported inputs for ease of use.
  12190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12191. */
  12192. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12193. /**
  12194. * @hidden
  12195. */
  12196. _mouseInput: Nullable<FreeCameraMouseInput>;
  12197. /**
  12198. * Instantiates a new FreeCameraInputsManager.
  12199. * @param camera Defines the camera the inputs belong to
  12200. */
  12201. constructor(camera: FreeCamera);
  12202. /**
  12203. * Add keyboard input support to the input manager.
  12204. * @returns the current input manager
  12205. */
  12206. addKeyboard(): FreeCameraInputsManager;
  12207. /**
  12208. * Add mouse input support to the input manager.
  12209. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12210. * @returns the current input manager
  12211. */
  12212. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12213. /**
  12214. * Removes the mouse input support from the manager
  12215. * @returns the current input manager
  12216. */
  12217. removeMouse(): FreeCameraInputsManager;
  12218. /**
  12219. * Add touch input support to the input manager.
  12220. * @returns the current input manager
  12221. */
  12222. addTouch(): FreeCameraInputsManager;
  12223. /**
  12224. * Remove all attached input methods from a camera
  12225. */
  12226. clear(): void;
  12227. }
  12228. }
  12229. declare module BABYLON {
  12230. /**
  12231. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12232. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12233. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12234. */
  12235. export class FreeCamera extends TargetCamera {
  12236. /**
  12237. * Define the collision ellipsoid of the camera.
  12238. * This is helpful to simulate a camera body like the player body around the camera
  12239. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12240. */
  12241. ellipsoid: Vector3;
  12242. /**
  12243. * Define an offset for the position of the ellipsoid around the camera.
  12244. * This can be helpful to determine the center of the body near the gravity center of the body
  12245. * instead of its head.
  12246. */
  12247. ellipsoidOffset: Vector3;
  12248. /**
  12249. * Enable or disable collisions of the camera with the rest of the scene objects.
  12250. */
  12251. checkCollisions: boolean;
  12252. /**
  12253. * Enable or disable gravity on the camera.
  12254. */
  12255. applyGravity: boolean;
  12256. /**
  12257. * Define the input manager associated to the camera.
  12258. */
  12259. inputs: FreeCameraInputsManager;
  12260. /**
  12261. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12262. * Higher values reduce sensitivity.
  12263. */
  12264. get angularSensibility(): number;
  12265. /**
  12266. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12267. * Higher values reduce sensitivity.
  12268. */
  12269. set angularSensibility(value: number);
  12270. /**
  12271. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12272. */
  12273. get keysUp(): number[];
  12274. set keysUp(value: number[]);
  12275. /**
  12276. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12277. */
  12278. get keysDown(): number[];
  12279. set keysDown(value: number[]);
  12280. /**
  12281. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12282. */
  12283. get keysLeft(): number[];
  12284. set keysLeft(value: number[]);
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12287. */
  12288. get keysRight(): number[];
  12289. set keysRight(value: number[]);
  12290. /**
  12291. * Event raised when the camera collide with a mesh in the scene.
  12292. */
  12293. onCollide: (collidedMesh: AbstractMesh) => void;
  12294. private _collider;
  12295. private _needMoveForGravity;
  12296. private _oldPosition;
  12297. private _diffPosition;
  12298. private _newPosition;
  12299. /** @hidden */
  12300. _localDirection: Vector3;
  12301. /** @hidden */
  12302. _transformedDirection: Vector3;
  12303. /**
  12304. * Instantiates a Free Camera.
  12305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12306. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12308. * @param name Define the name of the camera in the scene
  12309. * @param position Define the start position of the camera in the scene
  12310. * @param scene Define the scene the camera belongs to
  12311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12312. */
  12313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12314. /**
  12315. * Attached controls to the current camera.
  12316. * @param element Defines the element the controls should be listened from
  12317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12318. */
  12319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12320. /**
  12321. * Detach the current controls from the camera.
  12322. * The camera will stop reacting to inputs.
  12323. * @param element Defines the element to stop listening the inputs from
  12324. */
  12325. detachControl(element: HTMLElement): void;
  12326. private _collisionMask;
  12327. /**
  12328. * Define a collision mask to limit the list of object the camera can collide with
  12329. */
  12330. get collisionMask(): number;
  12331. set collisionMask(mask: number);
  12332. /** @hidden */
  12333. _collideWithWorld(displacement: Vector3): void;
  12334. private _onCollisionPositionChange;
  12335. /** @hidden */
  12336. _checkInputs(): void;
  12337. /** @hidden */
  12338. _decideIfNeedsToMove(): boolean;
  12339. /** @hidden */
  12340. _updatePosition(): void;
  12341. /**
  12342. * Destroy the camera and release the current resources hold by it.
  12343. */
  12344. dispose(): void;
  12345. /**
  12346. * Gets the current object class name.
  12347. * @return the class name
  12348. */
  12349. getClassName(): string;
  12350. }
  12351. }
  12352. declare module BABYLON {
  12353. /**
  12354. * Represents a gamepad control stick position
  12355. */
  12356. export class StickValues {
  12357. /**
  12358. * The x component of the control stick
  12359. */
  12360. x: number;
  12361. /**
  12362. * The y component of the control stick
  12363. */
  12364. y: number;
  12365. /**
  12366. * Initializes the gamepad x and y control stick values
  12367. * @param x The x component of the gamepad control stick value
  12368. * @param y The y component of the gamepad control stick value
  12369. */
  12370. constructor(
  12371. /**
  12372. * The x component of the control stick
  12373. */
  12374. x: number,
  12375. /**
  12376. * The y component of the control stick
  12377. */
  12378. y: number);
  12379. }
  12380. /**
  12381. * An interface which manages callbacks for gamepad button changes
  12382. */
  12383. export interface GamepadButtonChanges {
  12384. /**
  12385. * Called when a gamepad has been changed
  12386. */
  12387. changed: boolean;
  12388. /**
  12389. * Called when a gamepad press event has been triggered
  12390. */
  12391. pressChanged: boolean;
  12392. /**
  12393. * Called when a touch event has been triggered
  12394. */
  12395. touchChanged: boolean;
  12396. /**
  12397. * Called when a value has changed
  12398. */
  12399. valueChanged: boolean;
  12400. }
  12401. /**
  12402. * Represents a gamepad
  12403. */
  12404. export class Gamepad {
  12405. /**
  12406. * The id of the gamepad
  12407. */
  12408. id: string;
  12409. /**
  12410. * The index of the gamepad
  12411. */
  12412. index: number;
  12413. /**
  12414. * The browser gamepad
  12415. */
  12416. browserGamepad: any;
  12417. /**
  12418. * Specifies what type of gamepad this represents
  12419. */
  12420. type: number;
  12421. private _leftStick;
  12422. private _rightStick;
  12423. /** @hidden */
  12424. _isConnected: boolean;
  12425. private _leftStickAxisX;
  12426. private _leftStickAxisY;
  12427. private _rightStickAxisX;
  12428. private _rightStickAxisY;
  12429. /**
  12430. * Triggered when the left control stick has been changed
  12431. */
  12432. private _onleftstickchanged;
  12433. /**
  12434. * Triggered when the right control stick has been changed
  12435. */
  12436. private _onrightstickchanged;
  12437. /**
  12438. * Represents a gamepad controller
  12439. */
  12440. static GAMEPAD: number;
  12441. /**
  12442. * Represents a generic controller
  12443. */
  12444. static GENERIC: number;
  12445. /**
  12446. * Represents an XBox controller
  12447. */
  12448. static XBOX: number;
  12449. /**
  12450. * Represents a pose-enabled controller
  12451. */
  12452. static POSE_ENABLED: number;
  12453. /**
  12454. * Represents an Dual Shock controller
  12455. */
  12456. static DUALSHOCK: number;
  12457. /**
  12458. * Specifies whether the left control stick should be Y-inverted
  12459. */
  12460. protected _invertLeftStickY: boolean;
  12461. /**
  12462. * Specifies if the gamepad has been connected
  12463. */
  12464. get isConnected(): boolean;
  12465. /**
  12466. * Initializes the gamepad
  12467. * @param id The id of the gamepad
  12468. * @param index The index of the gamepad
  12469. * @param browserGamepad The browser gamepad
  12470. * @param leftStickX The x component of the left joystick
  12471. * @param leftStickY The y component of the left joystick
  12472. * @param rightStickX The x component of the right joystick
  12473. * @param rightStickY The y component of the right joystick
  12474. */
  12475. constructor(
  12476. /**
  12477. * The id of the gamepad
  12478. */
  12479. id: string,
  12480. /**
  12481. * The index of the gamepad
  12482. */
  12483. index: number,
  12484. /**
  12485. * The browser gamepad
  12486. */
  12487. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12488. /**
  12489. * Callback triggered when the left joystick has changed
  12490. * @param callback
  12491. */
  12492. onleftstickchanged(callback: (values: StickValues) => void): void;
  12493. /**
  12494. * Callback triggered when the right joystick has changed
  12495. * @param callback
  12496. */
  12497. onrightstickchanged(callback: (values: StickValues) => void): void;
  12498. /**
  12499. * Gets the left joystick
  12500. */
  12501. get leftStick(): StickValues;
  12502. /**
  12503. * Sets the left joystick values
  12504. */
  12505. set leftStick(newValues: StickValues);
  12506. /**
  12507. * Gets the right joystick
  12508. */
  12509. get rightStick(): StickValues;
  12510. /**
  12511. * Sets the right joystick value
  12512. */
  12513. set rightStick(newValues: StickValues);
  12514. /**
  12515. * Updates the gamepad joystick positions
  12516. */
  12517. update(): void;
  12518. /**
  12519. * Disposes the gamepad
  12520. */
  12521. dispose(): void;
  12522. }
  12523. /**
  12524. * Represents a generic gamepad
  12525. */
  12526. export class GenericPad extends Gamepad {
  12527. private _buttons;
  12528. private _onbuttondown;
  12529. private _onbuttonup;
  12530. /**
  12531. * Observable triggered when a button has been pressed
  12532. */
  12533. onButtonDownObservable: Observable<number>;
  12534. /**
  12535. * Observable triggered when a button has been released
  12536. */
  12537. onButtonUpObservable: Observable<number>;
  12538. /**
  12539. * Callback triggered when a button has been pressed
  12540. * @param callback Called when a button has been pressed
  12541. */
  12542. onbuttondown(callback: (buttonPressed: number) => void): void;
  12543. /**
  12544. * Callback triggered when a button has been released
  12545. * @param callback Called when a button has been released
  12546. */
  12547. onbuttonup(callback: (buttonReleased: number) => void): void;
  12548. /**
  12549. * Initializes the generic gamepad
  12550. * @param id The id of the generic gamepad
  12551. * @param index The index of the generic gamepad
  12552. * @param browserGamepad The browser gamepad
  12553. */
  12554. constructor(id: string, index: number, browserGamepad: any);
  12555. private _setButtonValue;
  12556. /**
  12557. * Updates the generic gamepad
  12558. */
  12559. update(): void;
  12560. /**
  12561. * Disposes the generic gamepad
  12562. */
  12563. dispose(): void;
  12564. }
  12565. }
  12566. declare module BABYLON {
  12567. interface Engine {
  12568. /**
  12569. * Creates a raw texture
  12570. * @param data defines the data to store in the texture
  12571. * @param width defines the width of the texture
  12572. * @param height defines the height of the texture
  12573. * @param format defines the format of the data
  12574. * @param generateMipMaps defines if the engine should generate the mip levels
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12577. * @param compression defines the compression used (null by default)
  12578. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12579. * @returns the raw texture inside an InternalTexture
  12580. */
  12581. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  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. */
  12589. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12590. /**
  12591. * Update a raw texture
  12592. * @param texture defines the texture to update
  12593. * @param data defines the data to store in the texture
  12594. * @param format defines the format of the data
  12595. * @param invertY defines if data must be stored with Y axis inverted
  12596. * @param compression defines the compression used (null by default)
  12597. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12598. */
  12599. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12600. /**
  12601. * Creates a new raw cube texture
  12602. * @param data defines the array of data to use to create each face
  12603. * @param size defines the size of the textures
  12604. * @param format defines the format of the data
  12605. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12606. * @param generateMipMaps defines if the engine should generate the mip levels
  12607. * @param invertY defines if data must be stored with Y axis inverted
  12608. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12609. * @param compression defines the compression used (null by default)
  12610. * @returns the cube texture as an InternalTexture
  12611. */
  12612. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12613. /**
  12614. * Update a raw cube texture
  12615. * @param texture defines the texture to udpdate
  12616. * @param data defines the data to store
  12617. * @param format defines the data format
  12618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12619. * @param invertY defines if data must be stored with Y axis inverted
  12620. */
  12621. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12622. /**
  12623. * Update a raw cube texture
  12624. * @param texture defines the texture to udpdate
  12625. * @param data defines the data to store
  12626. * @param format defines the data format
  12627. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12628. * @param invertY defines if data must be stored with Y axis inverted
  12629. * @param compression defines the compression used (null by default)
  12630. */
  12631. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12632. /**
  12633. * Update a raw cube texture
  12634. * @param texture defines the texture to udpdate
  12635. * @param data defines the data to store
  12636. * @param format defines the data format
  12637. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12638. * @param invertY defines if data must be stored with Y axis inverted
  12639. * @param compression defines the compression used (null by default)
  12640. * @param level defines which level of the texture to update
  12641. */
  12642. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12643. /**
  12644. * Creates a new raw cube texture from a specified url
  12645. * @param url defines the url where the data is located
  12646. * @param scene defines the current scene
  12647. * @param size defines the size of the textures
  12648. * @param format defines the format of the data
  12649. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12650. * @param noMipmap defines if the engine should avoid generating the mip levels
  12651. * @param callback defines a callback used to extract texture data from loaded data
  12652. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12653. * @param onLoad defines a callback called when texture is loaded
  12654. * @param onError defines a callback called if there is an error
  12655. * @returns the cube texture as an InternalTexture
  12656. */
  12657. 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;
  12658. /**
  12659. * Creates a new raw cube texture from a specified url
  12660. * @param url defines the url where the data is located
  12661. * @param scene defines the current scene
  12662. * @param size defines the size of the textures
  12663. * @param format defines the format of the data
  12664. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12665. * @param noMipmap defines if the engine should avoid generating the mip levels
  12666. * @param callback defines a callback used to extract texture data from loaded data
  12667. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12668. * @param onLoad defines a callback called when texture is loaded
  12669. * @param onError defines a callback called if there is an error
  12670. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12671. * @param invertY defines if data must be stored with Y axis inverted
  12672. * @returns the cube texture as an InternalTexture
  12673. */
  12674. 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;
  12675. /**
  12676. * Creates a new raw 3D texture
  12677. * @param data defines the data used to create the texture
  12678. * @param width defines the width of the texture
  12679. * @param height defines the height of the texture
  12680. * @param depth defines the depth of the texture
  12681. * @param format defines the format of the texture
  12682. * @param generateMipMaps defines if the engine must generate mip levels
  12683. * @param invertY defines if data must be stored with Y axis inverted
  12684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12685. * @param compression defines the compressed used (can be null)
  12686. * @param textureType defines the compressed used (can be null)
  12687. * @returns a new raw 3D texture (stored in an InternalTexture)
  12688. */
  12689. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  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. */
  12697. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12698. /**
  12699. * Update a raw 3D texture
  12700. * @param texture defines the texture to update
  12701. * @param data defines the data to store
  12702. * @param format defines the data format
  12703. * @param invertY defines if data must be stored with Y axis inverted
  12704. * @param compression defines the used compression (can be null)
  12705. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12706. */
  12707. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12708. /**
  12709. * Creates a new raw 2D array texture
  12710. * @param data defines the data used to create the texture
  12711. * @param width defines the width of the texture
  12712. * @param height defines the height of the texture
  12713. * @param depth defines the number of layers of the texture
  12714. * @param format defines the format of the texture
  12715. * @param generateMipMaps defines if the engine must generate mip levels
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12718. * @param compression defines the compressed used (can be null)
  12719. * @param textureType defines the compressed used (can be null)
  12720. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12721. */
  12722. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  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. */
  12730. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12731. /**
  12732. * Update a raw 2D array texture
  12733. * @param texture defines the texture to update
  12734. * @param data defines the data to store
  12735. * @param format defines the data format
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. * @param compression defines the used compression (can be null)
  12738. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12739. */
  12740. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12741. }
  12742. }
  12743. declare module BABYLON {
  12744. /**
  12745. * Raw texture can help creating a texture directly from an array of data.
  12746. * This can be super useful if you either get the data from an uncompressed source or
  12747. * if you wish to create your texture pixel by pixel.
  12748. */
  12749. export class RawTexture extends Texture {
  12750. /**
  12751. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12752. */
  12753. format: number;
  12754. private _engine;
  12755. /**
  12756. * Instantiates a new RawTexture.
  12757. * Raw texture can help creating a texture directly from an array of data.
  12758. * This can be super useful if you either get the data from an uncompressed source or
  12759. * if you wish to create your texture pixel by pixel.
  12760. * @param data define the array of data to use to create the texture
  12761. * @param width define the width of the texture
  12762. * @param height define the height of the texture
  12763. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12764. * @param scene define the scene the texture belongs to
  12765. * @param generateMipMaps define whether mip maps should be generated or not
  12766. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12767. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12768. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12769. */
  12770. constructor(data: ArrayBufferView, width: number, height: number,
  12771. /**
  12772. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12773. */
  12774. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12775. /**
  12776. * Updates the texture underlying data.
  12777. * @param data Define the new data of the texture
  12778. */
  12779. update(data: ArrayBufferView): void;
  12780. /**
  12781. * Creates a luminance texture from some data.
  12782. * @param data Define the texture data
  12783. * @param width Define the width of the texture
  12784. * @param height Define the height of the texture
  12785. * @param scene Define the scene the texture belongs to
  12786. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12787. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12788. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12789. * @returns the luminance texture
  12790. */
  12791. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12792. /**
  12793. * Creates a luminance alpha texture from some data.
  12794. * @param data Define the texture data
  12795. * @param width Define the width of the texture
  12796. * @param height Define the height of the texture
  12797. * @param scene Define the scene the texture belongs to
  12798. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12799. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12800. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12801. * @returns the luminance alpha texture
  12802. */
  12803. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12804. /**
  12805. * Creates an alpha texture from some data.
  12806. * @param data Define the texture data
  12807. * @param width Define the width of the texture
  12808. * @param height Define the height of the texture
  12809. * @param scene Define the scene the texture belongs to
  12810. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12811. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12812. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12813. * @returns the alpha texture
  12814. */
  12815. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12816. /**
  12817. * Creates a RGB texture from some data.
  12818. * @param data Define the texture data
  12819. * @param width Define the width of the texture
  12820. * @param height Define the height of the texture
  12821. * @param scene Define the scene the texture belongs to
  12822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12825. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12826. * @returns the RGB alpha texture
  12827. */
  12828. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12829. /**
  12830. * Creates a RGBA texture from some data.
  12831. * @param data Define the texture data
  12832. * @param width Define the width of the texture
  12833. * @param height Define the height of the texture
  12834. * @param scene Define the scene the texture belongs to
  12835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12838. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12839. * @returns the RGBA texture
  12840. */
  12841. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12842. /**
  12843. * Creates a R texture from some data.
  12844. * @param data Define the texture data
  12845. * @param width Define the width of the texture
  12846. * @param height Define the height of the texture
  12847. * @param scene Define the scene the texture belongs to
  12848. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12851. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12852. * @returns the R texture
  12853. */
  12854. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12855. }
  12856. }
  12857. declare module BABYLON {
  12858. /**
  12859. * Interface for the size containing width and height
  12860. */
  12861. export interface ISize {
  12862. /**
  12863. * Width
  12864. */
  12865. width: number;
  12866. /**
  12867. * Heighht
  12868. */
  12869. height: number;
  12870. }
  12871. /**
  12872. * Size containing widht and height
  12873. */
  12874. export class Size implements ISize {
  12875. /**
  12876. * Width
  12877. */
  12878. width: number;
  12879. /**
  12880. * Height
  12881. */
  12882. height: number;
  12883. /**
  12884. * Creates a Size object from the given width and height (floats).
  12885. * @param width width of the new size
  12886. * @param height height of the new size
  12887. */
  12888. constructor(width: number, height: number);
  12889. /**
  12890. * Returns a string with the Size width and height
  12891. * @returns a string with the Size width and height
  12892. */
  12893. toString(): string;
  12894. /**
  12895. * "Size"
  12896. * @returns the string "Size"
  12897. */
  12898. getClassName(): string;
  12899. /**
  12900. * Returns the Size hash code.
  12901. * @returns a hash code for a unique width and height
  12902. */
  12903. getHashCode(): number;
  12904. /**
  12905. * Updates the current size from the given one.
  12906. * @param src the given size
  12907. */
  12908. copyFrom(src: Size): void;
  12909. /**
  12910. * Updates in place the current Size from the given floats.
  12911. * @param width width of the new size
  12912. * @param height height of the new size
  12913. * @returns the updated Size.
  12914. */
  12915. copyFromFloats(width: number, height: number): Size;
  12916. /**
  12917. * Updates in place the current Size from the given floats.
  12918. * @param width width to set
  12919. * @param height height to set
  12920. * @returns the updated Size.
  12921. */
  12922. set(width: number, height: number): Size;
  12923. /**
  12924. * Multiplies the width and height by numbers
  12925. * @param w factor to multiple the width by
  12926. * @param h factor to multiple the height by
  12927. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12928. */
  12929. multiplyByFloats(w: number, h: number): Size;
  12930. /**
  12931. * Clones the size
  12932. * @returns a new Size copied from the given one.
  12933. */
  12934. clone(): Size;
  12935. /**
  12936. * True if the current Size and the given one width and height are strictly equal.
  12937. * @param other the other size to compare against
  12938. * @returns True if the current Size and the given one width and height are strictly equal.
  12939. */
  12940. equals(other: Size): boolean;
  12941. /**
  12942. * The surface of the Size : width * height (float).
  12943. */
  12944. get surface(): number;
  12945. /**
  12946. * Create a new size of zero
  12947. * @returns a new Size set to (0.0, 0.0)
  12948. */
  12949. static Zero(): Size;
  12950. /**
  12951. * Sums the width and height of two sizes
  12952. * @param otherSize size to add to this size
  12953. * @returns a new Size set as the addition result of the current Size and the given one.
  12954. */
  12955. add(otherSize: Size): Size;
  12956. /**
  12957. * Subtracts the width and height of two
  12958. * @param otherSize size to subtract to this size
  12959. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12960. */
  12961. subtract(otherSize: Size): Size;
  12962. /**
  12963. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12964. * @param start starting size to lerp between
  12965. * @param end end size to lerp between
  12966. * @param amount amount to lerp between the start and end values
  12967. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12968. */
  12969. static Lerp(start: Size, end: Size, amount: number): Size;
  12970. }
  12971. }
  12972. declare module BABYLON {
  12973. /**
  12974. * Defines a runtime animation
  12975. */
  12976. export class RuntimeAnimation {
  12977. private _events;
  12978. /**
  12979. * The current frame of the runtime animation
  12980. */
  12981. private _currentFrame;
  12982. /**
  12983. * The animation used by the runtime animation
  12984. */
  12985. private _animation;
  12986. /**
  12987. * The target of the runtime animation
  12988. */
  12989. private _target;
  12990. /**
  12991. * The initiating animatable
  12992. */
  12993. private _host;
  12994. /**
  12995. * The original value of the runtime animation
  12996. */
  12997. private _originalValue;
  12998. /**
  12999. * The original blend value of the runtime animation
  13000. */
  13001. private _originalBlendValue;
  13002. /**
  13003. * The offsets cache of the runtime animation
  13004. */
  13005. private _offsetsCache;
  13006. /**
  13007. * The high limits cache of the runtime animation
  13008. */
  13009. private _highLimitsCache;
  13010. /**
  13011. * Specifies if the runtime animation has been stopped
  13012. */
  13013. private _stopped;
  13014. /**
  13015. * The blending factor of the runtime animation
  13016. */
  13017. private _blendingFactor;
  13018. /**
  13019. * The BabylonJS scene
  13020. */
  13021. private _scene;
  13022. /**
  13023. * The current value of the runtime animation
  13024. */
  13025. private _currentValue;
  13026. /** @hidden */
  13027. _animationState: _IAnimationState;
  13028. /**
  13029. * The active target of the runtime animation
  13030. */
  13031. private _activeTargets;
  13032. private _currentActiveTarget;
  13033. private _directTarget;
  13034. /**
  13035. * The target path of the runtime animation
  13036. */
  13037. private _targetPath;
  13038. /**
  13039. * The weight of the runtime animation
  13040. */
  13041. private _weight;
  13042. /**
  13043. * The ratio offset of the runtime animation
  13044. */
  13045. private _ratioOffset;
  13046. /**
  13047. * The previous delay of the runtime animation
  13048. */
  13049. private _previousDelay;
  13050. /**
  13051. * The previous ratio of the runtime animation
  13052. */
  13053. private _previousRatio;
  13054. private _enableBlending;
  13055. private _keys;
  13056. private _minFrame;
  13057. private _maxFrame;
  13058. private _minValue;
  13059. private _maxValue;
  13060. private _targetIsArray;
  13061. /**
  13062. * Gets the current frame of the runtime animation
  13063. */
  13064. get currentFrame(): number;
  13065. /**
  13066. * Gets the weight of the runtime animation
  13067. */
  13068. get weight(): number;
  13069. /**
  13070. * Gets the current value of the runtime animation
  13071. */
  13072. get currentValue(): any;
  13073. /**
  13074. * Gets the target path of the runtime animation
  13075. */
  13076. get targetPath(): string;
  13077. /**
  13078. * Gets the actual target of the runtime animation
  13079. */
  13080. get target(): any;
  13081. /** @hidden */
  13082. _onLoop: () => void;
  13083. /**
  13084. * Create a new RuntimeAnimation object
  13085. * @param target defines the target of the animation
  13086. * @param animation defines the source animation object
  13087. * @param scene defines the hosting scene
  13088. * @param host defines the initiating Animatable
  13089. */
  13090. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13091. private _preparePath;
  13092. /**
  13093. * Gets the animation from the runtime animation
  13094. */
  13095. get animation(): Animation;
  13096. /**
  13097. * Resets the runtime animation to the beginning
  13098. * @param restoreOriginal defines whether to restore the target property to the original value
  13099. */
  13100. reset(restoreOriginal?: boolean): void;
  13101. /**
  13102. * Specifies if the runtime animation is stopped
  13103. * @returns Boolean specifying if the runtime animation is stopped
  13104. */
  13105. isStopped(): boolean;
  13106. /**
  13107. * Disposes of the runtime animation
  13108. */
  13109. dispose(): void;
  13110. /**
  13111. * Apply the interpolated value to the target
  13112. * @param currentValue defines the value computed by the animation
  13113. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13114. */
  13115. setValue(currentValue: any, weight: number): void;
  13116. private _getOriginalValues;
  13117. private _setValue;
  13118. /**
  13119. * Gets the loop pmode of the runtime animation
  13120. * @returns Loop Mode
  13121. */
  13122. private _getCorrectLoopMode;
  13123. /**
  13124. * Move the current animation to a given frame
  13125. * @param frame defines the frame to move to
  13126. */
  13127. goToFrame(frame: number): void;
  13128. /**
  13129. * @hidden Internal use only
  13130. */
  13131. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13132. /**
  13133. * Execute the current animation
  13134. * @param delay defines the delay to add to the current frame
  13135. * @param from defines the lower bound of the animation range
  13136. * @param to defines the upper bound of the animation range
  13137. * @param loop defines if the current animation must loop
  13138. * @param speedRatio defines the current speed ratio
  13139. * @param weight defines the weight of the animation (default is -1 so no weight)
  13140. * @param onLoop optional callback called when animation loops
  13141. * @returns a boolean indicating if the animation is running
  13142. */
  13143. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13144. }
  13145. }
  13146. declare module BABYLON {
  13147. /**
  13148. * Class used to store an actual running animation
  13149. */
  13150. export class Animatable {
  13151. /** defines the target object */
  13152. target: any;
  13153. /** defines the starting frame number (default is 0) */
  13154. fromFrame: number;
  13155. /** defines the ending frame number (default is 100) */
  13156. toFrame: number;
  13157. /** defines if the animation must loop (default is false) */
  13158. loopAnimation: boolean;
  13159. /** defines a callback to call when animation ends if it is not looping */
  13160. onAnimationEnd?: (() => void) | null | undefined;
  13161. /** defines a callback to call when animation loops */
  13162. onAnimationLoop?: (() => void) | null | undefined;
  13163. private _localDelayOffset;
  13164. private _pausedDelay;
  13165. private _runtimeAnimations;
  13166. private _paused;
  13167. private _scene;
  13168. private _speedRatio;
  13169. private _weight;
  13170. private _syncRoot;
  13171. /**
  13172. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13173. * This will only apply for non looping animation (default is true)
  13174. */
  13175. disposeOnEnd: boolean;
  13176. /**
  13177. * Gets a boolean indicating if the animation has started
  13178. */
  13179. animationStarted: boolean;
  13180. /**
  13181. * Observer raised when the animation ends
  13182. */
  13183. onAnimationEndObservable: Observable<Animatable>;
  13184. /**
  13185. * Observer raised when the animation loops
  13186. */
  13187. onAnimationLoopObservable: Observable<Animatable>;
  13188. /**
  13189. * Gets the root Animatable used to synchronize and normalize animations
  13190. */
  13191. get syncRoot(): Nullable<Animatable>;
  13192. /**
  13193. * Gets the current frame of the first RuntimeAnimation
  13194. * Used to synchronize Animatables
  13195. */
  13196. get masterFrame(): number;
  13197. /**
  13198. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13199. */
  13200. get weight(): number;
  13201. set weight(value: number);
  13202. /**
  13203. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13204. */
  13205. get speedRatio(): number;
  13206. set speedRatio(value: number);
  13207. /**
  13208. * Creates a new Animatable
  13209. * @param scene defines the hosting scene
  13210. * @param target defines the target object
  13211. * @param fromFrame defines the starting frame number (default is 0)
  13212. * @param toFrame defines the ending frame number (default is 100)
  13213. * @param loopAnimation defines if the animation must loop (default is false)
  13214. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13215. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13216. * @param animations defines a group of animation to add to the new Animatable
  13217. * @param onAnimationLoop defines a callback to call when animation loops
  13218. */
  13219. constructor(scene: Scene,
  13220. /** defines the target object */
  13221. target: any,
  13222. /** defines the starting frame number (default is 0) */
  13223. fromFrame?: number,
  13224. /** defines the ending frame number (default is 100) */
  13225. toFrame?: number,
  13226. /** defines if the animation must loop (default is false) */
  13227. loopAnimation?: boolean, speedRatio?: number,
  13228. /** defines a callback to call when animation ends if it is not looping */
  13229. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13230. /** defines a callback to call when animation loops */
  13231. onAnimationLoop?: (() => void) | null | undefined);
  13232. /**
  13233. * Synchronize and normalize current Animatable with a source Animatable
  13234. * This is useful when using animation weights and when animations are not of the same length
  13235. * @param root defines the root Animatable to synchronize with
  13236. * @returns the current Animatable
  13237. */
  13238. syncWith(root: Animatable): Animatable;
  13239. /**
  13240. * Gets the list of runtime animations
  13241. * @returns an array of RuntimeAnimation
  13242. */
  13243. getAnimations(): RuntimeAnimation[];
  13244. /**
  13245. * Adds more animations to the current animatable
  13246. * @param target defines the target of the animations
  13247. * @param animations defines the new animations to add
  13248. */
  13249. appendAnimations(target: any, animations: Animation[]): void;
  13250. /**
  13251. * Gets the source animation for a specific property
  13252. * @param property defines the propertyu to look for
  13253. * @returns null or the source animation for the given property
  13254. */
  13255. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13256. /**
  13257. * Gets the runtime animation for a specific property
  13258. * @param property defines the propertyu to look for
  13259. * @returns null or the runtime animation for the given property
  13260. */
  13261. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13262. /**
  13263. * Resets the animatable to its original state
  13264. */
  13265. reset(): void;
  13266. /**
  13267. * Allows the animatable to blend with current running animations
  13268. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13269. * @param blendingSpeed defines the blending speed to use
  13270. */
  13271. enableBlending(blendingSpeed: number): void;
  13272. /**
  13273. * Disable animation blending
  13274. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13275. */
  13276. disableBlending(): void;
  13277. /**
  13278. * Jump directly to a given frame
  13279. * @param frame defines the frame to jump to
  13280. */
  13281. goToFrame(frame: number): void;
  13282. /**
  13283. * Pause the animation
  13284. */
  13285. pause(): void;
  13286. /**
  13287. * Restart the animation
  13288. */
  13289. restart(): void;
  13290. private _raiseOnAnimationEnd;
  13291. /**
  13292. * Stop and delete the current animation
  13293. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13294. * @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)
  13295. */
  13296. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13297. /**
  13298. * Wait asynchronously for the animation to end
  13299. * @returns a promise which will be fullfilled when the animation ends
  13300. */
  13301. waitAsync(): Promise<Animatable>;
  13302. /** @hidden */
  13303. _animate(delay: number): boolean;
  13304. }
  13305. interface Scene {
  13306. /** @hidden */
  13307. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13308. /** @hidden */
  13309. _processLateAnimationBindingsForMatrices(holder: {
  13310. totalWeight: number;
  13311. animations: RuntimeAnimation[];
  13312. originalValue: Matrix;
  13313. }): any;
  13314. /** @hidden */
  13315. _processLateAnimationBindingsForQuaternions(holder: {
  13316. totalWeight: number;
  13317. animations: RuntimeAnimation[];
  13318. originalValue: Quaternion;
  13319. }, refQuaternion: Quaternion): Quaternion;
  13320. /** @hidden */
  13321. _processLateAnimationBindings(): void;
  13322. /**
  13323. * Will start the animation sequence of a given target
  13324. * @param target defines the target
  13325. * @param from defines from which frame should animation start
  13326. * @param to defines until which frame should animation run.
  13327. * @param weight defines the weight to apply to the animation (1.0 by default)
  13328. * @param loop defines if the animation loops
  13329. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13330. * @param onAnimationEnd defines the function to be executed when the animation ends
  13331. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13332. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13333. * @param onAnimationLoop defines the callback to call when an animation loops
  13334. * @returns the animatable object created for this animation
  13335. */
  13336. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13337. /**
  13338. * Will start the animation sequence of a given target
  13339. * @param target defines the target
  13340. * @param from defines from which frame should animation start
  13341. * @param to defines until which frame should animation run.
  13342. * @param loop defines if the animation loops
  13343. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13344. * @param onAnimationEnd defines the function to be executed when the animation ends
  13345. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13346. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13347. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13348. * @param onAnimationLoop defines the callback to call when an animation loops
  13349. * @returns the animatable object created for this animation
  13350. */
  13351. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13352. /**
  13353. * Will start the animation sequence of a given target and its hierarchy
  13354. * @param target defines the target
  13355. * @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.
  13356. * @param from defines from which frame should animation start
  13357. * @param to defines until which frame should animation run.
  13358. * @param loop defines if the animation loops
  13359. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13360. * @param onAnimationEnd defines the function to be executed when the animation ends
  13361. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13362. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13363. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13364. * @param onAnimationLoop defines the callback to call when an animation loops
  13365. * @returns the list of created animatables
  13366. */
  13367. 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[];
  13368. /**
  13369. * Begin a new animation on a given node
  13370. * @param target defines the target where the animation will take place
  13371. * @param animations defines the list of animations to start
  13372. * @param from defines the initial value
  13373. * @param to defines the final value
  13374. * @param loop defines if you want animation to loop (off by default)
  13375. * @param speedRatio defines the speed ratio to apply to all animations
  13376. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13377. * @param onAnimationLoop defines the callback to call when an animation loops
  13378. * @returns the list of created animatables
  13379. */
  13380. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13381. /**
  13382. * Begin a new animation on a given node and its hierarchy
  13383. * @param target defines the root node where the animation will take place
  13384. * @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.
  13385. * @param animations defines the list of animations to start
  13386. * @param from defines the initial value
  13387. * @param to defines the final value
  13388. * @param loop defines if you want animation to loop (off by default)
  13389. * @param speedRatio defines the speed ratio to apply to all animations
  13390. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13391. * @param onAnimationLoop defines the callback to call when an animation loops
  13392. * @returns the list of animatables created for all nodes
  13393. */
  13394. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13395. /**
  13396. * Gets the animatable associated with a specific target
  13397. * @param target defines the target of the animatable
  13398. * @returns the required animatable if found
  13399. */
  13400. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13401. /**
  13402. * Gets all animatables associated with a given target
  13403. * @param target defines the target to look animatables for
  13404. * @returns an array of Animatables
  13405. */
  13406. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13407. /**
  13408. * Stops and removes all animations that have been applied to the scene
  13409. */
  13410. stopAllAnimations(): void;
  13411. /**
  13412. * Gets the current delta time used by animation engine
  13413. */
  13414. deltaTime: number;
  13415. }
  13416. interface Bone {
  13417. /**
  13418. * Copy an animation range from another bone
  13419. * @param source defines the source bone
  13420. * @param rangeName defines the range name to copy
  13421. * @param frameOffset defines the frame offset
  13422. * @param rescaleAsRequired defines if rescaling must be applied if required
  13423. * @param skelDimensionsRatio defines the scaling ratio
  13424. * @returns true if operation was successful
  13425. */
  13426. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13427. }
  13428. }
  13429. declare module BABYLON {
  13430. /**
  13431. * Class used to override all child animations of a given target
  13432. */
  13433. export class AnimationPropertiesOverride {
  13434. /**
  13435. * Gets or sets a value indicating if animation blending must be used
  13436. */
  13437. enableBlending: boolean;
  13438. /**
  13439. * Gets or sets the blending speed to use when enableBlending is true
  13440. */
  13441. blendingSpeed: number;
  13442. /**
  13443. * Gets or sets the default loop mode to use
  13444. */
  13445. loopMode: number;
  13446. }
  13447. }
  13448. declare module BABYLON {
  13449. /**
  13450. * Class used to handle skinning animations
  13451. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13452. */
  13453. export class Skeleton implements IAnimatable {
  13454. /** defines the skeleton name */
  13455. name: string;
  13456. /** defines the skeleton Id */
  13457. id: string;
  13458. /**
  13459. * Defines the list of child bones
  13460. */
  13461. bones: Bone[];
  13462. /**
  13463. * Defines an estimate of the dimension of the skeleton at rest
  13464. */
  13465. dimensionsAtRest: Vector3;
  13466. /**
  13467. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13468. */
  13469. needInitialSkinMatrix: boolean;
  13470. /**
  13471. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13472. */
  13473. overrideMesh: Nullable<AbstractMesh>;
  13474. /**
  13475. * Gets the list of animations attached to this skeleton
  13476. */
  13477. animations: Array<Animation>;
  13478. private _scene;
  13479. private _isDirty;
  13480. private _transformMatrices;
  13481. private _transformMatrixTexture;
  13482. private _meshesWithPoseMatrix;
  13483. private _animatables;
  13484. private _identity;
  13485. private _synchronizedWithMesh;
  13486. private _ranges;
  13487. private _lastAbsoluteTransformsUpdateId;
  13488. private _canUseTextureForBones;
  13489. private _uniqueId;
  13490. /** @hidden */
  13491. _numBonesWithLinkedTransformNode: number;
  13492. /** @hidden */
  13493. _hasWaitingData: Nullable<boolean>;
  13494. /**
  13495. * Specifies if the skeleton should be serialized
  13496. */
  13497. doNotSerialize: boolean;
  13498. private _useTextureToStoreBoneMatrices;
  13499. /**
  13500. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13501. * Please note that this option is not available if the hardware does not support it
  13502. */
  13503. get useTextureToStoreBoneMatrices(): boolean;
  13504. set useTextureToStoreBoneMatrices(value: boolean);
  13505. private _animationPropertiesOverride;
  13506. /**
  13507. * Gets or sets the animation properties override
  13508. */
  13509. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13510. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13511. /**
  13512. * List of inspectable custom properties (used by the Inspector)
  13513. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13514. */
  13515. inspectableCustomProperties: IInspectable[];
  13516. /**
  13517. * An observable triggered before computing the skeleton's matrices
  13518. */
  13519. onBeforeComputeObservable: Observable<Skeleton>;
  13520. /**
  13521. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13522. */
  13523. get isUsingTextureForMatrices(): boolean;
  13524. /**
  13525. * Gets the unique ID of this skeleton
  13526. */
  13527. get uniqueId(): number;
  13528. /**
  13529. * Creates a new skeleton
  13530. * @param name defines the skeleton name
  13531. * @param id defines the skeleton Id
  13532. * @param scene defines the hosting scene
  13533. */
  13534. constructor(
  13535. /** defines the skeleton name */
  13536. name: string,
  13537. /** defines the skeleton Id */
  13538. id: string, scene: Scene);
  13539. /**
  13540. * Gets the current object class name.
  13541. * @return the class name
  13542. */
  13543. getClassName(): string;
  13544. /**
  13545. * Returns an array containing the root bones
  13546. * @returns an array containing the root bones
  13547. */
  13548. getChildren(): Array<Bone>;
  13549. /**
  13550. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13551. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13552. * @returns a Float32Array containing matrices data
  13553. */
  13554. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13555. /**
  13556. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13557. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13558. * @returns a raw texture containing the data
  13559. */
  13560. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13561. /**
  13562. * Gets the current hosting scene
  13563. * @returns a scene object
  13564. */
  13565. getScene(): Scene;
  13566. /**
  13567. * Gets a string representing the current skeleton data
  13568. * @param fullDetails defines a boolean indicating if we want a verbose version
  13569. * @returns a string representing the current skeleton data
  13570. */
  13571. toString(fullDetails?: boolean): string;
  13572. /**
  13573. * Get bone's index searching by name
  13574. * @param name defines bone's name to search for
  13575. * @return the indice of the bone. Returns -1 if not found
  13576. */
  13577. getBoneIndexByName(name: string): number;
  13578. /**
  13579. * Creater a new animation range
  13580. * @param name defines the name of the range
  13581. * @param from defines the start key
  13582. * @param to defines the end key
  13583. */
  13584. createAnimationRange(name: string, from: number, to: number): void;
  13585. /**
  13586. * Delete a specific animation range
  13587. * @param name defines the name of the range
  13588. * @param deleteFrames defines if frames must be removed as well
  13589. */
  13590. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13591. /**
  13592. * Gets a specific animation range
  13593. * @param name defines the name of the range to look for
  13594. * @returns the requested animation range or null if not found
  13595. */
  13596. getAnimationRange(name: string): Nullable<AnimationRange>;
  13597. /**
  13598. * Gets the list of all animation ranges defined on this skeleton
  13599. * @returns an array
  13600. */
  13601. getAnimationRanges(): Nullable<AnimationRange>[];
  13602. /**
  13603. * Copy animation range from a source skeleton.
  13604. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13605. * @param source defines the source skeleton
  13606. * @param name defines the name of the range to copy
  13607. * @param rescaleAsRequired defines if rescaling must be applied if required
  13608. * @returns true if operation was successful
  13609. */
  13610. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13611. /**
  13612. * Forces the skeleton to go to rest pose
  13613. */
  13614. returnToRest(): void;
  13615. private _getHighestAnimationFrame;
  13616. /**
  13617. * Begin a specific animation range
  13618. * @param name defines the name of the range to start
  13619. * @param loop defines if looping must be turned on (false by default)
  13620. * @param speedRatio defines the speed ratio to apply (1 by default)
  13621. * @param onAnimationEnd defines a callback which will be called when animation will end
  13622. * @returns a new animatable
  13623. */
  13624. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13625. /** @hidden */
  13626. _markAsDirty(): void;
  13627. /** @hidden */
  13628. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13629. /** @hidden */
  13630. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13631. private _computeTransformMatrices;
  13632. /**
  13633. * Build all resources required to render a skeleton
  13634. */
  13635. prepare(): void;
  13636. /**
  13637. * Gets the list of animatables currently running for this skeleton
  13638. * @returns an array of animatables
  13639. */
  13640. getAnimatables(): IAnimatable[];
  13641. /**
  13642. * Clone the current skeleton
  13643. * @param name defines the name of the new skeleton
  13644. * @param id defines the id of the new skeleton
  13645. * @returns the new skeleton
  13646. */
  13647. clone(name: string, id?: string): Skeleton;
  13648. /**
  13649. * Enable animation blending for this skeleton
  13650. * @param blendingSpeed defines the blending speed to apply
  13651. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13652. */
  13653. enableBlending(blendingSpeed?: number): void;
  13654. /**
  13655. * Releases all resources associated with the current skeleton
  13656. */
  13657. dispose(): void;
  13658. /**
  13659. * Serialize the skeleton in a JSON object
  13660. * @returns a JSON object
  13661. */
  13662. serialize(): any;
  13663. /**
  13664. * Creates a new skeleton from serialized data
  13665. * @param parsedSkeleton defines the serialized data
  13666. * @param scene defines the hosting scene
  13667. * @returns a new skeleton
  13668. */
  13669. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13670. /**
  13671. * Compute all node absolute transforms
  13672. * @param forceUpdate defines if computation must be done even if cache is up to date
  13673. */
  13674. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13675. /**
  13676. * Gets the root pose matrix
  13677. * @returns a matrix
  13678. */
  13679. getPoseMatrix(): Nullable<Matrix>;
  13680. /**
  13681. * Sorts bones per internal index
  13682. */
  13683. sortBones(): void;
  13684. private _sortBones;
  13685. }
  13686. }
  13687. declare module BABYLON {
  13688. /**
  13689. * Class used to store bone information
  13690. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13691. */
  13692. export class Bone extends Node {
  13693. /**
  13694. * defines the bone name
  13695. */
  13696. name: string;
  13697. private static _tmpVecs;
  13698. private static _tmpQuat;
  13699. private static _tmpMats;
  13700. /**
  13701. * Gets the list of child bones
  13702. */
  13703. children: Bone[];
  13704. /** Gets the animations associated with this bone */
  13705. animations: Animation[];
  13706. /**
  13707. * Gets or sets bone length
  13708. */
  13709. length: number;
  13710. /**
  13711. * @hidden Internal only
  13712. * Set this value to map this bone to a different index in the transform matrices
  13713. * Set this value to -1 to exclude the bone from the transform matrices
  13714. */
  13715. _index: Nullable<number>;
  13716. private _skeleton;
  13717. private _localMatrix;
  13718. private _restPose;
  13719. private _baseMatrix;
  13720. private _absoluteTransform;
  13721. private _invertedAbsoluteTransform;
  13722. private _parent;
  13723. private _scalingDeterminant;
  13724. private _worldTransform;
  13725. private _localScaling;
  13726. private _localRotation;
  13727. private _localPosition;
  13728. private _needToDecompose;
  13729. private _needToCompose;
  13730. /** @hidden */
  13731. _linkedTransformNode: Nullable<TransformNode>;
  13732. /** @hidden */
  13733. _waitingTransformNodeId: Nullable<string>;
  13734. /** @hidden */
  13735. get _matrix(): Matrix;
  13736. /** @hidden */
  13737. set _matrix(value: Matrix);
  13738. /**
  13739. * Create a new bone
  13740. * @param name defines the bone name
  13741. * @param skeleton defines the parent skeleton
  13742. * @param parentBone defines the parent (can be null if the bone is the root)
  13743. * @param localMatrix defines the local matrix
  13744. * @param restPose defines the rest pose matrix
  13745. * @param baseMatrix defines the base matrix
  13746. * @param index defines index of the bone in the hiearchy
  13747. */
  13748. constructor(
  13749. /**
  13750. * defines the bone name
  13751. */
  13752. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13753. /**
  13754. * Gets the current object class name.
  13755. * @return the class name
  13756. */
  13757. getClassName(): string;
  13758. /**
  13759. * Gets the parent skeleton
  13760. * @returns a skeleton
  13761. */
  13762. getSkeleton(): Skeleton;
  13763. /**
  13764. * Gets parent bone
  13765. * @returns a bone or null if the bone is the root of the bone hierarchy
  13766. */
  13767. getParent(): Nullable<Bone>;
  13768. /**
  13769. * Returns an array containing the root bones
  13770. * @returns an array containing the root bones
  13771. */
  13772. getChildren(): Array<Bone>;
  13773. /**
  13774. * Gets the node index in matrix array generated for rendering
  13775. * @returns the node index
  13776. */
  13777. getIndex(): number;
  13778. /**
  13779. * Sets the parent bone
  13780. * @param parent defines the parent (can be null if the bone is the root)
  13781. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13782. */
  13783. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13784. /**
  13785. * Gets the local matrix
  13786. * @returns a matrix
  13787. */
  13788. getLocalMatrix(): Matrix;
  13789. /**
  13790. * Gets the base matrix (initial matrix which remains unchanged)
  13791. * @returns a matrix
  13792. */
  13793. getBaseMatrix(): Matrix;
  13794. /**
  13795. * Gets the rest pose matrix
  13796. * @returns a matrix
  13797. */
  13798. getRestPose(): Matrix;
  13799. /**
  13800. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13801. */
  13802. getWorldMatrix(): Matrix;
  13803. /**
  13804. * Sets the local matrix to rest pose matrix
  13805. */
  13806. returnToRest(): void;
  13807. /**
  13808. * Gets the inverse of the absolute transform matrix.
  13809. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13810. * @returns a matrix
  13811. */
  13812. getInvertedAbsoluteTransform(): Matrix;
  13813. /**
  13814. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13815. * @returns a matrix
  13816. */
  13817. getAbsoluteTransform(): Matrix;
  13818. /**
  13819. * Links with the given transform node.
  13820. * The local matrix of this bone is copied from the transform node every frame.
  13821. * @param transformNode defines the transform node to link to
  13822. */
  13823. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13824. /**
  13825. * Gets the node used to drive the bone's transformation
  13826. * @returns a transform node or null
  13827. */
  13828. getTransformNode(): Nullable<TransformNode>;
  13829. /** Gets or sets current position (in local space) */
  13830. get position(): Vector3;
  13831. set position(newPosition: Vector3);
  13832. /** Gets or sets current rotation (in local space) */
  13833. get rotation(): Vector3;
  13834. set rotation(newRotation: Vector3);
  13835. /** Gets or sets current rotation quaternion (in local space) */
  13836. get rotationQuaternion(): Quaternion;
  13837. set rotationQuaternion(newRotation: Quaternion);
  13838. /** Gets or sets current scaling (in local space) */
  13839. get scaling(): Vector3;
  13840. set scaling(newScaling: Vector3);
  13841. /**
  13842. * Gets the animation properties override
  13843. */
  13844. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13845. private _decompose;
  13846. private _compose;
  13847. /**
  13848. * Update the base and local matrices
  13849. * @param matrix defines the new base or local matrix
  13850. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13851. * @param updateLocalMatrix defines if the local matrix should be updated
  13852. */
  13853. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13854. /** @hidden */
  13855. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13856. /**
  13857. * Flag the bone as dirty (Forcing it to update everything)
  13858. */
  13859. markAsDirty(): void;
  13860. /** @hidden */
  13861. _markAsDirtyAndCompose(): void;
  13862. private _markAsDirtyAndDecompose;
  13863. /**
  13864. * Translate the bone in local or world space
  13865. * @param vec The amount to translate the bone
  13866. * @param space The space that the translation is in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. */
  13869. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13870. /**
  13871. * Set the postion of the bone in local or world space
  13872. * @param position The position to set the bone
  13873. * @param space The space that the position is in
  13874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13875. */
  13876. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13877. /**
  13878. * Set the absolute position of the bone (world space)
  13879. * @param position The position to set the bone
  13880. * @param mesh The mesh that this bone is attached to
  13881. */
  13882. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13883. /**
  13884. * Scale the bone on the x, y and z axes (in local space)
  13885. * @param x The amount to scale the bone on the x axis
  13886. * @param y The amount to scale the bone on the y axis
  13887. * @param z The amount to scale the bone on the z axis
  13888. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13889. */
  13890. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13891. /**
  13892. * Set the bone scaling in local space
  13893. * @param scale defines the scaling vector
  13894. */
  13895. setScale(scale: Vector3): void;
  13896. /**
  13897. * Gets the current scaling in local space
  13898. * @returns the current scaling vector
  13899. */
  13900. getScale(): Vector3;
  13901. /**
  13902. * Gets the current scaling in local space and stores it in a target vector
  13903. * @param result defines the target vector
  13904. */
  13905. getScaleToRef(result: Vector3): void;
  13906. /**
  13907. * Set the yaw, pitch, and roll of the bone in local or world space
  13908. * @param yaw The rotation of the bone on the y axis
  13909. * @param pitch The rotation of the bone on the x axis
  13910. * @param roll The rotation of the bone on the z axis
  13911. * @param space The space that the axes of rotation are in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. */
  13914. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13915. /**
  13916. * Add a rotation to the bone on an axis in local or world space
  13917. * @param axis The axis to rotate the bone on
  13918. * @param amount The amount to rotate the bone
  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. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Set the rotation of the bone to a particular axis angle in local or world space
  13925. * @param axis The axis to rotate the bone on
  13926. * @param angle The angle that the bone should be rotated to
  13927. * @param space The space that the axis is in
  13928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13929. */
  13930. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13931. /**
  13932. * Set the euler rotation of the bone in local of world space
  13933. * @param rotation The euler rotation that the bone should be set to
  13934. * @param space The space that the rotation is in
  13935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13936. */
  13937. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13938. /**
  13939. * Set the quaternion rotation of the bone in local of world space
  13940. * @param quat The quaternion rotation that the bone should be set to
  13941. * @param space The space that the rotation is in
  13942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13943. */
  13944. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13945. /**
  13946. * Set the rotation matrix of the bone in local of world space
  13947. * @param rotMat The rotation matrix that the bone should be set to
  13948. * @param space The space that the rotation is in
  13949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13950. */
  13951. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13952. private _rotateWithMatrix;
  13953. private _getNegativeRotationToRef;
  13954. /**
  13955. * Get the position of the bone in local or world space
  13956. * @param space The space that the returned position is in
  13957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13958. * @returns The position of the bone
  13959. */
  13960. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13961. /**
  13962. * Copy the position of the bone to a vector3 in local or world space
  13963. * @param space The space that the returned position is in
  13964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13965. * @param result The vector3 to copy the position to
  13966. */
  13967. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13968. /**
  13969. * Get the absolute position of the bone (world space)
  13970. * @param mesh The mesh that this bone is attached to
  13971. * @returns The absolute position of the bone
  13972. */
  13973. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13974. /**
  13975. * Copy the absolute position of the bone (world space) to the result param
  13976. * @param mesh The mesh that this bone is attached to
  13977. * @param result The vector3 to copy the absolute position to
  13978. */
  13979. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13980. /**
  13981. * Compute the absolute transforms of this bone and its children
  13982. */
  13983. computeAbsoluteTransforms(): void;
  13984. /**
  13985. * Get the world direction from an axis that is in the local space of the bone
  13986. * @param localAxis The local direction that is used to compute the world direction
  13987. * @param mesh The mesh that this bone is attached to
  13988. * @returns The world direction
  13989. */
  13990. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13991. /**
  13992. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13993. * @param localAxis The local direction that is used to compute the world direction
  13994. * @param mesh The mesh that this bone is attached to
  13995. * @param result The vector3 that the world direction will be copied to
  13996. */
  13997. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13998. /**
  13999. * Get the euler rotation of the bone in local or world space
  14000. * @param space The space that the rotation should be in
  14001. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14002. * @returns The euler rotation
  14003. */
  14004. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14005. /**
  14006. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14007. * @param space The space that the rotation should be in
  14008. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14009. * @param result The vector3 that the rotation should be copied to
  14010. */
  14011. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14012. /**
  14013. * Get the quaternion rotation of the bone in either local or world space
  14014. * @param space The space that the rotation should be in
  14015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14016. * @returns The quaternion rotation
  14017. */
  14018. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14019. /**
  14020. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14021. * @param space The space that the rotation should be in
  14022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14023. * @param result The quaternion that the rotation should be copied to
  14024. */
  14025. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14026. /**
  14027. * Get the rotation matrix of the bone in local or world space
  14028. * @param space The space that the rotation should be in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. * @returns The rotation matrix
  14031. */
  14032. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14033. /**
  14034. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14035. * @param space The space that the rotation should be in
  14036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14037. * @param result The quaternion that the rotation should be copied to
  14038. */
  14039. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14040. /**
  14041. * Get the world position of a point that is in the local space of the bone
  14042. * @param position The local position
  14043. * @param mesh The mesh that this bone is attached to
  14044. * @returns The world position
  14045. */
  14046. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14047. /**
  14048. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14049. * @param position The local position
  14050. * @param mesh The mesh that this bone is attached to
  14051. * @param result The vector3 that the world position should be copied to
  14052. */
  14053. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14054. /**
  14055. * Get the local position of a point that is in world space
  14056. * @param position The world position
  14057. * @param mesh The mesh that this bone is attached to
  14058. * @returns The local position
  14059. */
  14060. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14061. /**
  14062. * Get the local position of a point that is in world space and copy it to the result param
  14063. * @param position The world position
  14064. * @param mesh The mesh that this bone is attached to
  14065. * @param result The vector3 that the local position should be copied to
  14066. */
  14067. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14068. }
  14069. }
  14070. declare module BABYLON {
  14071. /**
  14072. * 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.
  14073. * @see https://doc.babylonjs.com/how_to/transformnode
  14074. */
  14075. export class TransformNode extends Node {
  14076. /**
  14077. * Object will not rotate to face the camera
  14078. */
  14079. static BILLBOARDMODE_NONE: number;
  14080. /**
  14081. * Object will rotate to face the camera but only on the x axis
  14082. */
  14083. static BILLBOARDMODE_X: number;
  14084. /**
  14085. * Object will rotate to face the camera but only on the y axis
  14086. */
  14087. static BILLBOARDMODE_Y: number;
  14088. /**
  14089. * Object will rotate to face the camera but only on the z axis
  14090. */
  14091. static BILLBOARDMODE_Z: number;
  14092. /**
  14093. * Object will rotate to face the camera
  14094. */
  14095. static BILLBOARDMODE_ALL: number;
  14096. /**
  14097. * Object will rotate to face the camera's position instead of orientation
  14098. */
  14099. static BILLBOARDMODE_USE_POSITION: number;
  14100. private _forward;
  14101. private _forwardInverted;
  14102. private _up;
  14103. private _right;
  14104. private _rightInverted;
  14105. private _position;
  14106. private _rotation;
  14107. private _rotationQuaternion;
  14108. protected _scaling: Vector3;
  14109. protected _isDirty: boolean;
  14110. private _transformToBoneReferal;
  14111. private _isAbsoluteSynced;
  14112. private _billboardMode;
  14113. /**
  14114. * Gets or sets the billboard mode. Default is 0.
  14115. *
  14116. * | Value | Type | Description |
  14117. * | --- | --- | --- |
  14118. * | 0 | BILLBOARDMODE_NONE | |
  14119. * | 1 | BILLBOARDMODE_X | |
  14120. * | 2 | BILLBOARDMODE_Y | |
  14121. * | 4 | BILLBOARDMODE_Z | |
  14122. * | 7 | BILLBOARDMODE_ALL | |
  14123. *
  14124. */
  14125. get billboardMode(): number;
  14126. set billboardMode(value: number);
  14127. private _preserveParentRotationForBillboard;
  14128. /**
  14129. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14130. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14131. */
  14132. get preserveParentRotationForBillboard(): boolean;
  14133. set preserveParentRotationForBillboard(value: boolean);
  14134. /**
  14135. * 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
  14136. */
  14137. scalingDeterminant: number;
  14138. private _infiniteDistance;
  14139. /**
  14140. * Gets or sets the distance of the object to max, often used by skybox
  14141. */
  14142. get infiniteDistance(): boolean;
  14143. set infiniteDistance(value: boolean);
  14144. /**
  14145. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14146. * By default the system will update normals to compensate
  14147. */
  14148. ignoreNonUniformScaling: boolean;
  14149. /**
  14150. * 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
  14151. */
  14152. reIntegrateRotationIntoRotationQuaternion: boolean;
  14153. /** @hidden */
  14154. _poseMatrix: Nullable<Matrix>;
  14155. /** @hidden */
  14156. _localMatrix: Matrix;
  14157. private _usePivotMatrix;
  14158. private _absolutePosition;
  14159. private _absoluteScaling;
  14160. private _absoluteRotationQuaternion;
  14161. private _pivotMatrix;
  14162. private _pivotMatrixInverse;
  14163. protected _postMultiplyPivotMatrix: boolean;
  14164. protected _isWorldMatrixFrozen: boolean;
  14165. /** @hidden */
  14166. _indexInSceneTransformNodesArray: number;
  14167. /**
  14168. * An event triggered after the world matrix is updated
  14169. */
  14170. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14171. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14172. /**
  14173. * Gets a string identifying the name of the class
  14174. * @returns "TransformNode" string
  14175. */
  14176. getClassName(): string;
  14177. /**
  14178. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14179. */
  14180. get position(): Vector3;
  14181. set position(newPosition: Vector3);
  14182. /**
  14183. * 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)).
  14184. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14185. */
  14186. get rotation(): Vector3;
  14187. set rotation(newRotation: Vector3);
  14188. /**
  14189. * 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)).
  14190. */
  14191. get scaling(): Vector3;
  14192. set scaling(newScaling: Vector3);
  14193. /**
  14194. * 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).
  14195. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14196. */
  14197. get rotationQuaternion(): Nullable<Quaternion>;
  14198. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14199. /**
  14200. * The forward direction of that transform in world space.
  14201. */
  14202. get forward(): Vector3;
  14203. /**
  14204. * The up direction of that transform in world space.
  14205. */
  14206. get up(): Vector3;
  14207. /**
  14208. * The right direction of that transform in world space.
  14209. */
  14210. get right(): Vector3;
  14211. /**
  14212. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14213. * @param matrix the matrix to copy the pose from
  14214. * @returns this TransformNode.
  14215. */
  14216. updatePoseMatrix(matrix: Matrix): TransformNode;
  14217. /**
  14218. * Returns the mesh Pose matrix.
  14219. * @returns the pose matrix
  14220. */
  14221. getPoseMatrix(): Matrix;
  14222. /** @hidden */
  14223. _isSynchronized(): boolean;
  14224. /** @hidden */
  14225. _initCache(): void;
  14226. /**
  14227. * Flag the transform node as dirty (Forcing it to update everything)
  14228. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14229. * @returns this transform node
  14230. */
  14231. markAsDirty(property: string): TransformNode;
  14232. /**
  14233. * Returns the current mesh absolute position.
  14234. * Returns a Vector3.
  14235. */
  14236. get absolutePosition(): Vector3;
  14237. /**
  14238. * Returns the current mesh absolute scaling.
  14239. * Returns a Vector3.
  14240. */
  14241. get absoluteScaling(): Vector3;
  14242. /**
  14243. * Returns the current mesh absolute rotation.
  14244. * Returns a Quaternion.
  14245. */
  14246. get absoluteRotationQuaternion(): Quaternion;
  14247. /**
  14248. * Sets a new matrix to apply before all other transformation
  14249. * @param matrix defines the transform matrix
  14250. * @returns the current TransformNode
  14251. */
  14252. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14253. /**
  14254. * Sets a new pivot matrix to the current node
  14255. * @param matrix defines the new pivot matrix to use
  14256. * @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
  14257. * @returns the current TransformNode
  14258. */
  14259. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14260. /**
  14261. * Returns the mesh pivot matrix.
  14262. * Default : Identity.
  14263. * @returns the matrix
  14264. */
  14265. getPivotMatrix(): Matrix;
  14266. /**
  14267. * Instantiate (when possible) or clone that node with its hierarchy
  14268. * @param newParent defines the new parent to use for the instance (or clone)
  14269. * @param options defines options to configure how copy is done
  14270. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14271. * @returns an instance (or a clone) of the current node with its hiearchy
  14272. */
  14273. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14274. doNotInstantiate: boolean;
  14275. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14276. /**
  14277. * Prevents the World matrix to be computed any longer
  14278. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14279. * @returns the TransformNode.
  14280. */
  14281. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14282. /**
  14283. * Allows back the World matrix computation.
  14284. * @returns the TransformNode.
  14285. */
  14286. unfreezeWorldMatrix(): this;
  14287. /**
  14288. * True if the World matrix has been frozen.
  14289. */
  14290. get isWorldMatrixFrozen(): boolean;
  14291. /**
  14292. * Retuns the mesh absolute position in the World.
  14293. * @returns a Vector3.
  14294. */
  14295. getAbsolutePosition(): Vector3;
  14296. /**
  14297. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14298. * @param absolutePosition the absolute position to set
  14299. * @returns the TransformNode.
  14300. */
  14301. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14302. /**
  14303. * Sets the mesh position in its local space.
  14304. * @param vector3 the position to set in localspace
  14305. * @returns the TransformNode.
  14306. */
  14307. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14308. /**
  14309. * Returns the mesh position in the local space from the current World matrix values.
  14310. * @returns a new Vector3.
  14311. */
  14312. getPositionExpressedInLocalSpace(): Vector3;
  14313. /**
  14314. * Translates the mesh along the passed Vector3 in its local space.
  14315. * @param vector3 the distance to translate in localspace
  14316. * @returns the TransformNode.
  14317. */
  14318. locallyTranslate(vector3: Vector3): TransformNode;
  14319. private static _lookAtVectorCache;
  14320. /**
  14321. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14322. * @param targetPoint the position (must be in same space as current mesh) to look at
  14323. * @param yawCor optional yaw (y-axis) correction in radians
  14324. * @param pitchCor optional pitch (x-axis) correction in radians
  14325. * @param rollCor optional roll (z-axis) correction in radians
  14326. * @param space the choosen space of the target
  14327. * @returns the TransformNode.
  14328. */
  14329. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14330. /**
  14331. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14332. * This Vector3 is expressed in the World space.
  14333. * @param localAxis axis to rotate
  14334. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14335. */
  14336. getDirection(localAxis: Vector3): Vector3;
  14337. /**
  14338. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14339. * localAxis is expressed in the mesh local space.
  14340. * result is computed in the Wordl space from the mesh World matrix.
  14341. * @param localAxis axis to rotate
  14342. * @param result the resulting transformnode
  14343. * @returns this TransformNode.
  14344. */
  14345. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14346. /**
  14347. * Sets this transform node rotation to the given local axis.
  14348. * @param localAxis the axis in local space
  14349. * @param yawCor optional yaw (y-axis) correction in radians
  14350. * @param pitchCor optional pitch (x-axis) correction in radians
  14351. * @param rollCor optional roll (z-axis) correction in radians
  14352. * @returns this TransformNode
  14353. */
  14354. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14355. /**
  14356. * Sets a new pivot point to the current node
  14357. * @param point defines the new pivot point to use
  14358. * @param space defines if the point is in world or local space (local by default)
  14359. * @returns the current TransformNode
  14360. */
  14361. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14362. /**
  14363. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14364. * @returns the pivot point
  14365. */
  14366. getPivotPoint(): Vector3;
  14367. /**
  14368. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14369. * @param result the vector3 to store the result
  14370. * @returns this TransformNode.
  14371. */
  14372. getPivotPointToRef(result: Vector3): TransformNode;
  14373. /**
  14374. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14375. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14376. */
  14377. getAbsolutePivotPoint(): Vector3;
  14378. /**
  14379. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14380. * @param result vector3 to store the result
  14381. * @returns this TransformNode.
  14382. */
  14383. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14384. /**
  14385. * Defines the passed node as the parent of the current node.
  14386. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14387. * @see https://doc.babylonjs.com/how_to/parenting
  14388. * @param node the node ot set as the parent
  14389. * @returns this TransformNode.
  14390. */
  14391. setParent(node: Nullable<Node>): TransformNode;
  14392. private _nonUniformScaling;
  14393. /**
  14394. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14395. */
  14396. get nonUniformScaling(): boolean;
  14397. /** @hidden */
  14398. _updateNonUniformScalingState(value: boolean): boolean;
  14399. /**
  14400. * Attach the current TransformNode to another TransformNode associated with a bone
  14401. * @param bone Bone affecting the TransformNode
  14402. * @param affectedTransformNode TransformNode associated with the bone
  14403. * @returns this object
  14404. */
  14405. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14406. /**
  14407. * Detach the transform node if its associated with a bone
  14408. * @returns this object
  14409. */
  14410. detachFromBone(): TransformNode;
  14411. private static _rotationAxisCache;
  14412. /**
  14413. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14414. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14415. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14416. * The passed axis is also normalized.
  14417. * @param axis the axis to rotate around
  14418. * @param amount the amount to rotate in radians
  14419. * @param space Space to rotate in (Default: local)
  14420. * @returns the TransformNode.
  14421. */
  14422. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14423. /**
  14424. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14425. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14426. * The passed axis is also normalized. .
  14427. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14428. * @param point the point to rotate around
  14429. * @param axis the axis to rotate around
  14430. * @param amount the amount to rotate in radians
  14431. * @returns the TransformNode
  14432. */
  14433. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14434. /**
  14435. * Translates the mesh along the axis vector for the passed distance in the given space.
  14436. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14437. * @param axis the axis to translate in
  14438. * @param distance the distance to translate
  14439. * @param space Space to rotate in (Default: local)
  14440. * @returns the TransformNode.
  14441. */
  14442. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14443. /**
  14444. * Adds a rotation step to the mesh current rotation.
  14445. * x, y, z are Euler angles expressed in radians.
  14446. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14447. * This means this rotation is made in the mesh local space only.
  14448. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14449. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14450. * ```javascript
  14451. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14452. * ```
  14453. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14454. * 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.
  14455. * @param x Rotation to add
  14456. * @param y Rotation to add
  14457. * @param z Rotation to add
  14458. * @returns the TransformNode.
  14459. */
  14460. addRotation(x: number, y: number, z: number): TransformNode;
  14461. /**
  14462. * @hidden
  14463. */
  14464. protected _getEffectiveParent(): Nullable<Node>;
  14465. /**
  14466. * Computes the world matrix of the node
  14467. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14468. * @returns the world matrix
  14469. */
  14470. computeWorldMatrix(force?: boolean): Matrix;
  14471. protected _afterComputeWorldMatrix(): void;
  14472. /**
  14473. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14474. * @param func callback function to add
  14475. *
  14476. * @returns the TransformNode.
  14477. */
  14478. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14479. /**
  14480. * Removes a registered callback function.
  14481. * @param func callback function to remove
  14482. * @returns the TransformNode.
  14483. */
  14484. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14485. /**
  14486. * Gets the position of the current mesh in camera space
  14487. * @param camera defines the camera to use
  14488. * @returns a position
  14489. */
  14490. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14491. /**
  14492. * Returns the distance from the mesh to the active camera
  14493. * @param camera defines the camera to use
  14494. * @returns the distance
  14495. */
  14496. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14497. /**
  14498. * Clone the current transform node
  14499. * @param name Name of the new clone
  14500. * @param newParent New parent for the clone
  14501. * @param doNotCloneChildren Do not clone children hierarchy
  14502. * @returns the new transform node
  14503. */
  14504. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14505. /**
  14506. * Serializes the objects information.
  14507. * @param currentSerializationObject defines the object to serialize in
  14508. * @returns the serialized object
  14509. */
  14510. serialize(currentSerializationObject?: any): any;
  14511. /**
  14512. * Returns a new TransformNode object parsed from the source provided.
  14513. * @param parsedTransformNode is the source.
  14514. * @param scene the scne the object belongs to
  14515. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14516. * @returns a new TransformNode object parsed from the source provided.
  14517. */
  14518. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14519. /**
  14520. * Get all child-transformNodes of this node
  14521. * @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
  14522. * @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
  14523. * @returns an array of TransformNode
  14524. */
  14525. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14526. /**
  14527. * Releases resources associated with this transform node.
  14528. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14529. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14530. */
  14531. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14532. /**
  14533. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14534. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14535. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14536. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14537. * @returns the current mesh
  14538. */
  14539. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14540. private _syncAbsoluteScalingAndRotation;
  14541. }
  14542. }
  14543. declare module BABYLON {
  14544. /**
  14545. * Defines the types of pose enabled controllers that are supported
  14546. */
  14547. export enum PoseEnabledControllerType {
  14548. /**
  14549. * HTC Vive
  14550. */
  14551. VIVE = 0,
  14552. /**
  14553. * Oculus Rift
  14554. */
  14555. OCULUS = 1,
  14556. /**
  14557. * Windows mixed reality
  14558. */
  14559. WINDOWS = 2,
  14560. /**
  14561. * Samsung gear VR
  14562. */
  14563. GEAR_VR = 3,
  14564. /**
  14565. * Google Daydream
  14566. */
  14567. DAYDREAM = 4,
  14568. /**
  14569. * Generic
  14570. */
  14571. GENERIC = 5
  14572. }
  14573. /**
  14574. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14575. */
  14576. export interface MutableGamepadButton {
  14577. /**
  14578. * Value of the button/trigger
  14579. */
  14580. value: number;
  14581. /**
  14582. * If the button/trigger is currently touched
  14583. */
  14584. touched: boolean;
  14585. /**
  14586. * If the button/trigger is currently pressed
  14587. */
  14588. pressed: boolean;
  14589. }
  14590. /**
  14591. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14592. * @hidden
  14593. */
  14594. export interface ExtendedGamepadButton extends GamepadButton {
  14595. /**
  14596. * If the button/trigger is currently pressed
  14597. */
  14598. readonly pressed: boolean;
  14599. /**
  14600. * If the button/trigger is currently touched
  14601. */
  14602. readonly touched: boolean;
  14603. /**
  14604. * Value of the button/trigger
  14605. */
  14606. readonly value: number;
  14607. }
  14608. /** @hidden */
  14609. export interface _GamePadFactory {
  14610. /**
  14611. * Returns wether or not the current gamepad can be created for this type of controller.
  14612. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14613. * @returns true if it can be created, otherwise false
  14614. */
  14615. canCreate(gamepadInfo: any): boolean;
  14616. /**
  14617. * Creates a new instance of the Gamepad.
  14618. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14619. * @returns the new gamepad instance
  14620. */
  14621. create(gamepadInfo: any): Gamepad;
  14622. }
  14623. /**
  14624. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14625. */
  14626. export class PoseEnabledControllerHelper {
  14627. /** @hidden */
  14628. static _ControllerFactories: _GamePadFactory[];
  14629. /** @hidden */
  14630. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14631. /**
  14632. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14633. * @param vrGamepad the gamepad to initialized
  14634. * @returns a vr controller of the type the gamepad identified as
  14635. */
  14636. static InitiateController(vrGamepad: any): Gamepad;
  14637. }
  14638. /**
  14639. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14640. */
  14641. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14642. /**
  14643. * If the controller is used in a webXR session
  14644. */
  14645. isXR: boolean;
  14646. private _deviceRoomPosition;
  14647. private _deviceRoomRotationQuaternion;
  14648. /**
  14649. * The device position in babylon space
  14650. */
  14651. devicePosition: Vector3;
  14652. /**
  14653. * The device rotation in babylon space
  14654. */
  14655. deviceRotationQuaternion: Quaternion;
  14656. /**
  14657. * The scale factor of the device in babylon space
  14658. */
  14659. deviceScaleFactor: number;
  14660. /**
  14661. * (Likely devicePosition should be used instead) The device position in its room space
  14662. */
  14663. position: Vector3;
  14664. /**
  14665. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14666. */
  14667. rotationQuaternion: Quaternion;
  14668. /**
  14669. * The type of controller (Eg. Windows mixed reality)
  14670. */
  14671. controllerType: PoseEnabledControllerType;
  14672. protected _calculatedPosition: Vector3;
  14673. private _calculatedRotation;
  14674. /**
  14675. * The raw pose from the device
  14676. */
  14677. rawPose: DevicePose;
  14678. private _trackPosition;
  14679. private _maxRotationDistFromHeadset;
  14680. private _draggedRoomRotation;
  14681. /**
  14682. * @hidden
  14683. */
  14684. _disableTrackPosition(fixedPosition: Vector3): void;
  14685. /**
  14686. * Internal, the mesh attached to the controller
  14687. * @hidden
  14688. */
  14689. _mesh: Nullable<AbstractMesh>;
  14690. private _poseControlledCamera;
  14691. private _leftHandSystemQuaternion;
  14692. /**
  14693. * Internal, matrix used to convert room space to babylon space
  14694. * @hidden
  14695. */
  14696. _deviceToWorld: Matrix;
  14697. /**
  14698. * Node to be used when casting a ray from the controller
  14699. * @hidden
  14700. */
  14701. _pointingPoseNode: Nullable<TransformNode>;
  14702. /**
  14703. * Name of the child mesh that can be used to cast a ray from the controller
  14704. */
  14705. static readonly POINTING_POSE: string;
  14706. /**
  14707. * Creates a new PoseEnabledController from a gamepad
  14708. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14709. */
  14710. constructor(browserGamepad: any);
  14711. private _workingMatrix;
  14712. /**
  14713. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14714. */
  14715. update(): void;
  14716. /**
  14717. * Updates only the pose device and mesh without doing any button event checking
  14718. */
  14719. protected _updatePoseAndMesh(): void;
  14720. /**
  14721. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14722. * @param poseData raw pose fromthe device
  14723. */
  14724. updateFromDevice(poseData: DevicePose): void;
  14725. /**
  14726. * @hidden
  14727. */
  14728. _meshAttachedObservable: Observable<AbstractMesh>;
  14729. /**
  14730. * Attaches a mesh to the controller
  14731. * @param mesh the mesh to be attached
  14732. */
  14733. attachToMesh(mesh: AbstractMesh): void;
  14734. /**
  14735. * Attaches the controllers mesh to a camera
  14736. * @param camera the camera the mesh should be attached to
  14737. */
  14738. attachToPoseControlledCamera(camera: TargetCamera): void;
  14739. /**
  14740. * Disposes of the controller
  14741. */
  14742. dispose(): void;
  14743. /**
  14744. * The mesh that is attached to the controller
  14745. */
  14746. get mesh(): Nullable<AbstractMesh>;
  14747. /**
  14748. * Gets the ray of the controller in the direction the controller is pointing
  14749. * @param length the length the resulting ray should be
  14750. * @returns a ray in the direction the controller is pointing
  14751. */
  14752. getForwardRay(length?: number): Ray;
  14753. }
  14754. }
  14755. declare module BABYLON {
  14756. /**
  14757. * Defines the WebVRController object that represents controllers tracked in 3D space
  14758. */
  14759. export abstract class WebVRController extends PoseEnabledController {
  14760. /**
  14761. * Internal, the default controller model for the controller
  14762. */
  14763. protected _defaultModel: Nullable<AbstractMesh>;
  14764. /**
  14765. * Fired when the trigger state has changed
  14766. */
  14767. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14768. /**
  14769. * Fired when the main button state has changed
  14770. */
  14771. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14772. /**
  14773. * Fired when the secondary button state has changed
  14774. */
  14775. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14776. /**
  14777. * Fired when the pad state has changed
  14778. */
  14779. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14780. /**
  14781. * Fired when controllers stick values have changed
  14782. */
  14783. onPadValuesChangedObservable: Observable<StickValues>;
  14784. /**
  14785. * Array of button availible on the controller
  14786. */
  14787. protected _buttons: Array<MutableGamepadButton>;
  14788. private _onButtonStateChange;
  14789. /**
  14790. * Fired when a controller button's state has changed
  14791. * @param callback the callback containing the button that was modified
  14792. */
  14793. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14794. /**
  14795. * X and Y axis corresponding to the controllers joystick
  14796. */
  14797. pad: StickValues;
  14798. /**
  14799. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14800. */
  14801. hand: string;
  14802. /**
  14803. * The default controller model for the controller
  14804. */
  14805. get defaultModel(): Nullable<AbstractMesh>;
  14806. /**
  14807. * Creates a new WebVRController from a gamepad
  14808. * @param vrGamepad the gamepad that the WebVRController should be created from
  14809. */
  14810. constructor(vrGamepad: any);
  14811. /**
  14812. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14813. */
  14814. update(): void;
  14815. /**
  14816. * Function to be called when a button is modified
  14817. */
  14818. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14819. /**
  14820. * Loads a mesh and attaches it to the controller
  14821. * @param scene the scene the mesh should be added to
  14822. * @param meshLoaded callback for when the mesh has been loaded
  14823. */
  14824. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14825. private _setButtonValue;
  14826. private _changes;
  14827. private _checkChanges;
  14828. /**
  14829. * Disposes of th webVRCOntroller
  14830. */
  14831. dispose(): void;
  14832. }
  14833. }
  14834. declare module BABYLON {
  14835. /**
  14836. * The HemisphericLight simulates the ambient environment light,
  14837. * so the passed direction is the light reflection direction, not the incoming direction.
  14838. */
  14839. export class HemisphericLight extends Light {
  14840. /**
  14841. * The groundColor is the light in the opposite direction to the one specified during creation.
  14842. * 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.
  14843. */
  14844. groundColor: Color3;
  14845. /**
  14846. * The light reflection direction, not the incoming direction.
  14847. */
  14848. direction: Vector3;
  14849. /**
  14850. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14851. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14852. * The HemisphericLight can't cast shadows.
  14853. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14854. * @param name The friendly name of the light
  14855. * @param direction The direction of the light reflection
  14856. * @param scene The scene the light belongs to
  14857. */
  14858. constructor(name: string, direction: Vector3, scene: Scene);
  14859. protected _buildUniformLayout(): void;
  14860. /**
  14861. * Returns the string "HemisphericLight".
  14862. * @return The class name
  14863. */
  14864. getClassName(): string;
  14865. /**
  14866. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14867. * Returns the updated direction.
  14868. * @param target The target the direction should point to
  14869. * @return The computed direction
  14870. */
  14871. setDirectionToTarget(target: Vector3): Vector3;
  14872. /**
  14873. * Returns the shadow generator associated to the light.
  14874. * @returns Always null for hemispheric lights because it does not support shadows.
  14875. */
  14876. getShadowGenerator(): Nullable<IShadowGenerator>;
  14877. /**
  14878. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14879. * @param effect The effect to update
  14880. * @param lightIndex The index of the light in the effect to update
  14881. * @returns The hemispheric light
  14882. */
  14883. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14884. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14885. /**
  14886. * Computes the world matrix of the node
  14887. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14888. * @param useWasUpdatedFlag defines a reserved property
  14889. * @returns the world matrix
  14890. */
  14891. computeWorldMatrix(): Matrix;
  14892. /**
  14893. * Returns the integer 3.
  14894. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14895. */
  14896. getTypeID(): number;
  14897. /**
  14898. * Prepares the list of defines specific to the light type.
  14899. * @param defines the list of defines
  14900. * @param lightIndex defines the index of the light for the effect
  14901. */
  14902. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14903. }
  14904. }
  14905. declare module BABYLON {
  14906. /** @hidden */
  14907. export var vrMultiviewToSingleviewPixelShader: {
  14908. name: string;
  14909. shader: string;
  14910. };
  14911. }
  14912. declare module BABYLON {
  14913. /**
  14914. * Renders to multiple views with a single draw call
  14915. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14916. */
  14917. export class MultiviewRenderTarget extends RenderTargetTexture {
  14918. /**
  14919. * Creates a multiview render target
  14920. * @param scene scene used with the render target
  14921. * @param size the size of the render target (used for each view)
  14922. */
  14923. constructor(scene: Scene, size?: number | {
  14924. width: number;
  14925. height: number;
  14926. } | {
  14927. ratio: number;
  14928. });
  14929. /**
  14930. * @hidden
  14931. * @param faceIndex the face index, if its a cube texture
  14932. */
  14933. _bindFrameBuffer(faceIndex?: number): void;
  14934. /**
  14935. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14936. * @returns the view count
  14937. */
  14938. getViewCount(): number;
  14939. }
  14940. }
  14941. declare module BABYLON {
  14942. /**
  14943. * Represents a camera frustum
  14944. */
  14945. export class Frustum {
  14946. /**
  14947. * Gets the planes representing the frustum
  14948. * @param transform matrix to be applied to the returned planes
  14949. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14950. */
  14951. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14952. /**
  14953. * Gets the near frustum plane transformed by the transform matrix
  14954. * @param transform transformation matrix to be applied to the resulting frustum plane
  14955. * @param frustumPlane the resuling frustum plane
  14956. */
  14957. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14958. /**
  14959. * Gets the far frustum plane transformed by the transform matrix
  14960. * @param transform transformation matrix to be applied to the resulting frustum plane
  14961. * @param frustumPlane the resuling frustum plane
  14962. */
  14963. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14964. /**
  14965. * Gets the left frustum plane transformed by the transform matrix
  14966. * @param transform transformation matrix to be applied to the resulting frustum plane
  14967. * @param frustumPlane the resuling frustum plane
  14968. */
  14969. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14970. /**
  14971. * Gets the right frustum plane transformed by the transform matrix
  14972. * @param transform transformation matrix to be applied to the resulting frustum plane
  14973. * @param frustumPlane the resuling frustum plane
  14974. */
  14975. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14976. /**
  14977. * Gets the top frustum plane transformed by the transform matrix
  14978. * @param transform transformation matrix to be applied to the resulting frustum plane
  14979. * @param frustumPlane the resuling frustum plane
  14980. */
  14981. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14982. /**
  14983. * Gets the bottom frustum plane transformed by the transform matrix
  14984. * @param transform transformation matrix to be applied to the resulting frustum plane
  14985. * @param frustumPlane the resuling frustum plane
  14986. */
  14987. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14988. /**
  14989. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14990. * @param transform transformation matrix to be applied to the resulting frustum planes
  14991. * @param frustumPlanes the resuling frustum planes
  14992. */
  14993. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14994. }
  14995. }
  14996. declare module BABYLON {
  14997. interface Engine {
  14998. /**
  14999. * Creates a new multiview render target
  15000. * @param width defines the width of the texture
  15001. * @param height defines the height of the texture
  15002. * @returns the created multiview texture
  15003. */
  15004. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15005. /**
  15006. * Binds a multiview framebuffer to be drawn to
  15007. * @param multiviewTexture texture to bind
  15008. */
  15009. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15010. }
  15011. interface Camera {
  15012. /**
  15013. * @hidden
  15014. * 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)
  15015. */
  15016. _useMultiviewToSingleView: boolean;
  15017. /**
  15018. * @hidden
  15019. * 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)
  15020. */
  15021. _multiviewTexture: Nullable<RenderTargetTexture>;
  15022. /**
  15023. * @hidden
  15024. * ensures the multiview texture of the camera exists and has the specified width/height
  15025. * @param width height to set on the multiview texture
  15026. * @param height width to set on the multiview texture
  15027. */
  15028. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15029. }
  15030. interface Scene {
  15031. /** @hidden */
  15032. _transformMatrixR: Matrix;
  15033. /** @hidden */
  15034. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15035. /** @hidden */
  15036. _createMultiviewUbo(): void;
  15037. /** @hidden */
  15038. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15039. /** @hidden */
  15040. _renderMultiviewToSingleView(camera: Camera): void;
  15041. }
  15042. }
  15043. declare module BABYLON {
  15044. /**
  15045. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15046. * This will not be used for webXR as it supports displaying texture arrays directly
  15047. */
  15048. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15049. /**
  15050. * Initializes a VRMultiviewToSingleview
  15051. * @param name name of the post process
  15052. * @param camera camera to be applied to
  15053. * @param scaleFactor scaling factor to the size of the output texture
  15054. */
  15055. constructor(name: string, camera: Camera, scaleFactor: number);
  15056. }
  15057. }
  15058. declare module BABYLON {
  15059. /**
  15060. * Interface used to define additional presentation attributes
  15061. */
  15062. export interface IVRPresentationAttributes {
  15063. /**
  15064. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15065. */
  15066. highRefreshRate: boolean;
  15067. /**
  15068. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15069. */
  15070. foveationLevel: number;
  15071. }
  15072. interface Engine {
  15073. /** @hidden */
  15074. _vrDisplay: any;
  15075. /** @hidden */
  15076. _vrSupported: boolean;
  15077. /** @hidden */
  15078. _oldSize: Size;
  15079. /** @hidden */
  15080. _oldHardwareScaleFactor: number;
  15081. /** @hidden */
  15082. _vrExclusivePointerMode: boolean;
  15083. /** @hidden */
  15084. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15085. /** @hidden */
  15086. _onVRDisplayPointerRestricted: () => void;
  15087. /** @hidden */
  15088. _onVRDisplayPointerUnrestricted: () => void;
  15089. /** @hidden */
  15090. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15091. /** @hidden */
  15092. _onVrDisplayDisconnect: Nullable<() => void>;
  15093. /** @hidden */
  15094. _onVrDisplayPresentChange: Nullable<() => void>;
  15095. /**
  15096. * Observable signaled when VR display mode changes
  15097. */
  15098. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15099. /**
  15100. * Observable signaled when VR request present is complete
  15101. */
  15102. onVRRequestPresentComplete: Observable<boolean>;
  15103. /**
  15104. * Observable signaled when VR request present starts
  15105. */
  15106. onVRRequestPresentStart: Observable<Engine>;
  15107. /**
  15108. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15109. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15110. */
  15111. isInVRExclusivePointerMode: boolean;
  15112. /**
  15113. * Gets a boolean indicating if a webVR device was detected
  15114. * @returns true if a webVR device was detected
  15115. */
  15116. isVRDevicePresent(): boolean;
  15117. /**
  15118. * Gets the current webVR device
  15119. * @returns the current webVR device (or null)
  15120. */
  15121. getVRDevice(): any;
  15122. /**
  15123. * Initializes a webVR display and starts listening to display change events
  15124. * The onVRDisplayChangedObservable will be notified upon these changes
  15125. * @returns A promise containing a VRDisplay and if vr is supported
  15126. */
  15127. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15128. /** @hidden */
  15129. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15130. /**
  15131. * Gets or sets the presentation attributes used to configure VR rendering
  15132. */
  15133. vrPresentationAttributes?: IVRPresentationAttributes;
  15134. /**
  15135. * Call this function to switch to webVR mode
  15136. * Will do nothing if webVR is not supported or if there is no webVR device
  15137. * @param options the webvr options provided to the camera. mainly used for multiview
  15138. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15139. */
  15140. enableVR(options: WebVROptions): void;
  15141. /** @hidden */
  15142. _onVRFullScreenTriggered(): void;
  15143. }
  15144. }
  15145. declare module BABYLON {
  15146. /**
  15147. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15148. * IMPORTANT!! The data is right-hand data.
  15149. * @export
  15150. * @interface DevicePose
  15151. */
  15152. export interface DevicePose {
  15153. /**
  15154. * The position of the device, values in array are [x,y,z].
  15155. */
  15156. readonly position: Nullable<Float32Array>;
  15157. /**
  15158. * The linearVelocity of the device, values in array are [x,y,z].
  15159. */
  15160. readonly linearVelocity: Nullable<Float32Array>;
  15161. /**
  15162. * The linearAcceleration of the device, values in array are [x,y,z].
  15163. */
  15164. readonly linearAcceleration: Nullable<Float32Array>;
  15165. /**
  15166. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15167. */
  15168. readonly orientation: Nullable<Float32Array>;
  15169. /**
  15170. * The angularVelocity of the device, values in array are [x,y,z].
  15171. */
  15172. readonly angularVelocity: Nullable<Float32Array>;
  15173. /**
  15174. * The angularAcceleration of the device, values in array are [x,y,z].
  15175. */
  15176. readonly angularAcceleration: Nullable<Float32Array>;
  15177. }
  15178. /**
  15179. * Interface representing a pose controlled object in Babylon.
  15180. * A pose controlled object has both regular pose values as well as pose values
  15181. * from an external device such as a VR head mounted display
  15182. */
  15183. export interface PoseControlled {
  15184. /**
  15185. * The position of the object in babylon space.
  15186. */
  15187. position: Vector3;
  15188. /**
  15189. * The rotation quaternion of the object in babylon space.
  15190. */
  15191. rotationQuaternion: Quaternion;
  15192. /**
  15193. * The position of the device in babylon space.
  15194. */
  15195. devicePosition?: Vector3;
  15196. /**
  15197. * The rotation quaternion of the device in babylon space.
  15198. */
  15199. deviceRotationQuaternion: Quaternion;
  15200. /**
  15201. * The raw pose coming from the device.
  15202. */
  15203. rawPose: Nullable<DevicePose>;
  15204. /**
  15205. * The scale of the device to be used when translating from device space to babylon space.
  15206. */
  15207. deviceScaleFactor: number;
  15208. /**
  15209. * Updates the poseControlled values based on the input device pose.
  15210. * @param poseData the pose data to update the object with
  15211. */
  15212. updateFromDevice(poseData: DevicePose): void;
  15213. }
  15214. /**
  15215. * Set of options to customize the webVRCamera
  15216. */
  15217. export interface WebVROptions {
  15218. /**
  15219. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15220. */
  15221. trackPosition?: boolean;
  15222. /**
  15223. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15224. */
  15225. positionScale?: number;
  15226. /**
  15227. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15228. */
  15229. displayName?: string;
  15230. /**
  15231. * Should the native controller meshes be initialized. (default: true)
  15232. */
  15233. controllerMeshes?: boolean;
  15234. /**
  15235. * Creating a default HemiLight only on controllers. (default: true)
  15236. */
  15237. defaultLightingOnControllers?: boolean;
  15238. /**
  15239. * If you don't want to use the default VR button of the helper. (default: false)
  15240. */
  15241. useCustomVRButton?: boolean;
  15242. /**
  15243. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15244. */
  15245. customVRButton?: HTMLButtonElement;
  15246. /**
  15247. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15248. */
  15249. rayLength?: number;
  15250. /**
  15251. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15252. */
  15253. defaultHeight?: number;
  15254. /**
  15255. * If multiview should be used if availible (default: false)
  15256. */
  15257. useMultiview?: boolean;
  15258. }
  15259. /**
  15260. * This represents a WebVR camera.
  15261. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15262. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15263. */
  15264. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15265. private webVROptions;
  15266. /**
  15267. * @hidden
  15268. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15269. */
  15270. _vrDevice: any;
  15271. /**
  15272. * The rawPose of the vrDevice.
  15273. */
  15274. rawPose: Nullable<DevicePose>;
  15275. private _onVREnabled;
  15276. private _specsVersion;
  15277. private _attached;
  15278. private _frameData;
  15279. protected _descendants: Array<Node>;
  15280. private _deviceRoomPosition;
  15281. /** @hidden */
  15282. _deviceRoomRotationQuaternion: Quaternion;
  15283. private _standingMatrix;
  15284. /**
  15285. * Represents device position in babylon space.
  15286. */
  15287. devicePosition: Vector3;
  15288. /**
  15289. * Represents device rotation in babylon space.
  15290. */
  15291. deviceRotationQuaternion: Quaternion;
  15292. /**
  15293. * The scale of the device to be used when translating from device space to babylon space.
  15294. */
  15295. deviceScaleFactor: number;
  15296. private _deviceToWorld;
  15297. private _worldToDevice;
  15298. /**
  15299. * References to the webVR controllers for the vrDevice.
  15300. */
  15301. controllers: Array<WebVRController>;
  15302. /**
  15303. * Emits an event when a controller is attached.
  15304. */
  15305. onControllersAttachedObservable: Observable<WebVRController[]>;
  15306. /**
  15307. * Emits an event when a controller's mesh has been loaded;
  15308. */
  15309. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15310. /**
  15311. * Emits an event when the HMD's pose has been updated.
  15312. */
  15313. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15314. private _poseSet;
  15315. /**
  15316. * If the rig cameras be used as parent instead of this camera.
  15317. */
  15318. rigParenting: boolean;
  15319. private _lightOnControllers;
  15320. private _defaultHeight?;
  15321. /**
  15322. * Instantiates a WebVRFreeCamera.
  15323. * @param name The name of the WebVRFreeCamera
  15324. * @param position The starting anchor position for the camera
  15325. * @param scene The scene the camera belongs to
  15326. * @param webVROptions a set of customizable options for the webVRCamera
  15327. */
  15328. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15329. /**
  15330. * Gets the device distance from the ground in meters.
  15331. * @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.
  15332. */
  15333. deviceDistanceToRoomGround(): number;
  15334. /**
  15335. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15336. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15337. */
  15338. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15339. /**
  15340. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15341. * @returns A promise with a boolean set to if the standing matrix is supported.
  15342. */
  15343. useStandingMatrixAsync(): Promise<boolean>;
  15344. /**
  15345. * Disposes the camera
  15346. */
  15347. dispose(): void;
  15348. /**
  15349. * Gets a vrController by name.
  15350. * @param name The name of the controller to retreive
  15351. * @returns the controller matching the name specified or null if not found
  15352. */
  15353. getControllerByName(name: string): Nullable<WebVRController>;
  15354. private _leftController;
  15355. /**
  15356. * The controller corresponding to the users left hand.
  15357. */
  15358. get leftController(): Nullable<WebVRController>;
  15359. private _rightController;
  15360. /**
  15361. * The controller corresponding to the users right hand.
  15362. */
  15363. get rightController(): Nullable<WebVRController>;
  15364. /**
  15365. * Casts a ray forward from the vrCamera's gaze.
  15366. * @param length Length of the ray (default: 100)
  15367. * @returns the ray corresponding to the gaze
  15368. */
  15369. getForwardRay(length?: number): Ray;
  15370. /**
  15371. * @hidden
  15372. * Updates the camera based on device's frame data
  15373. */
  15374. _checkInputs(): void;
  15375. /**
  15376. * Updates the poseControlled values based on the input device pose.
  15377. * @param poseData Pose coming from the device
  15378. */
  15379. updateFromDevice(poseData: DevicePose): void;
  15380. private _htmlElementAttached;
  15381. private _detachIfAttached;
  15382. /**
  15383. * WebVR's attach control will start broadcasting frames to the device.
  15384. * Note that in certain browsers (chrome for example) this function must be called
  15385. * within a user-interaction callback. Example:
  15386. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15387. *
  15388. * @param element html element to attach the vrDevice to
  15389. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15390. */
  15391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15392. /**
  15393. * Detaches the camera from the html element and disables VR
  15394. *
  15395. * @param element html element to detach from
  15396. */
  15397. detachControl(element: HTMLElement): void;
  15398. /**
  15399. * @returns the name of this class
  15400. */
  15401. getClassName(): string;
  15402. /**
  15403. * Calls resetPose on the vrDisplay
  15404. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15405. */
  15406. resetToCurrentRotation(): void;
  15407. /**
  15408. * @hidden
  15409. * Updates the rig cameras (left and right eye)
  15410. */
  15411. _updateRigCameras(): void;
  15412. private _workingVector;
  15413. private _oneVector;
  15414. private _workingMatrix;
  15415. private updateCacheCalled;
  15416. private _correctPositionIfNotTrackPosition;
  15417. /**
  15418. * @hidden
  15419. * Updates the cached values of the camera
  15420. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15421. */
  15422. _updateCache(ignoreParentClass?: boolean): void;
  15423. /**
  15424. * @hidden
  15425. * Get current device position in babylon world
  15426. */
  15427. _computeDevicePosition(): void;
  15428. /**
  15429. * Updates the current device position and rotation in the babylon world
  15430. */
  15431. update(): void;
  15432. /**
  15433. * @hidden
  15434. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15435. * @returns an identity matrix
  15436. */
  15437. _getViewMatrix(): Matrix;
  15438. private _tmpMatrix;
  15439. /**
  15440. * This function is called by the two RIG cameras.
  15441. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15442. * @hidden
  15443. */
  15444. _getWebVRViewMatrix(): Matrix;
  15445. /** @hidden */
  15446. _getWebVRProjectionMatrix(): Matrix;
  15447. private _onGamepadConnectedObserver;
  15448. private _onGamepadDisconnectedObserver;
  15449. private _updateCacheWhenTrackingDisabledObserver;
  15450. /**
  15451. * Initializes the controllers and their meshes
  15452. */
  15453. initControllers(): void;
  15454. }
  15455. }
  15456. declare module BABYLON {
  15457. /**
  15458. * Size options for a post process
  15459. */
  15460. export type PostProcessOptions = {
  15461. width: number;
  15462. height: number;
  15463. };
  15464. /**
  15465. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15466. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15467. */
  15468. export class PostProcess {
  15469. /** Name of the PostProcess. */
  15470. name: string;
  15471. /**
  15472. * Gets or sets the unique id of the post process
  15473. */
  15474. uniqueId: number;
  15475. /**
  15476. * Width of the texture to apply the post process on
  15477. */
  15478. width: number;
  15479. /**
  15480. * Height of the texture to apply the post process on
  15481. */
  15482. height: number;
  15483. /**
  15484. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15485. * @hidden
  15486. */
  15487. _outputTexture: Nullable<InternalTexture>;
  15488. /**
  15489. * Sampling mode used by the shader
  15490. * See https://doc.babylonjs.com/classes/3.1/texture
  15491. */
  15492. renderTargetSamplingMode: number;
  15493. /**
  15494. * Clear color to use when screen clearing
  15495. */
  15496. clearColor: Color4;
  15497. /**
  15498. * If the buffer needs to be cleared before applying the post process. (default: true)
  15499. * Should be set to false if shader will overwrite all previous pixels.
  15500. */
  15501. autoClear: boolean;
  15502. /**
  15503. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15504. */
  15505. alphaMode: number;
  15506. /**
  15507. * Sets the setAlphaBlendConstants of the babylon engine
  15508. */
  15509. alphaConstants: Color4;
  15510. /**
  15511. * Animations to be used for the post processing
  15512. */
  15513. animations: Animation[];
  15514. /**
  15515. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15516. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15517. */
  15518. enablePixelPerfectMode: boolean;
  15519. /**
  15520. * Force the postprocess to be applied without taking in account viewport
  15521. */
  15522. forceFullscreenViewport: boolean;
  15523. /**
  15524. * List of inspectable custom properties (used by the Inspector)
  15525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15526. */
  15527. inspectableCustomProperties: IInspectable[];
  15528. /**
  15529. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15530. *
  15531. * | Value | Type | Description |
  15532. * | ----- | ----------------------------------- | ----------- |
  15533. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15534. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15535. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15536. *
  15537. */
  15538. scaleMode: number;
  15539. /**
  15540. * Force textures to be a power of two (default: false)
  15541. */
  15542. alwaysForcePOT: boolean;
  15543. private _samples;
  15544. /**
  15545. * Number of sample textures (default: 1)
  15546. */
  15547. get samples(): number;
  15548. set samples(n: number);
  15549. /**
  15550. * Modify the scale of the post process to be the same as the viewport (default: false)
  15551. */
  15552. adaptScaleToCurrentViewport: boolean;
  15553. private _camera;
  15554. private _scene;
  15555. private _engine;
  15556. private _options;
  15557. private _reusable;
  15558. private _textureType;
  15559. private _textureFormat;
  15560. /**
  15561. * Smart array of input and output textures for the post process.
  15562. * @hidden
  15563. */
  15564. _textures: SmartArray<InternalTexture>;
  15565. /**
  15566. * The index in _textures that corresponds to the output texture.
  15567. * @hidden
  15568. */
  15569. _currentRenderTextureInd: number;
  15570. private _effect;
  15571. private _samplers;
  15572. private _fragmentUrl;
  15573. private _vertexUrl;
  15574. private _parameters;
  15575. private _scaleRatio;
  15576. protected _indexParameters: any;
  15577. private _shareOutputWithPostProcess;
  15578. private _texelSize;
  15579. private _forcedOutputTexture;
  15580. /**
  15581. * Returns the fragment url or shader name used in the post process.
  15582. * @returns the fragment url or name in the shader store.
  15583. */
  15584. getEffectName(): string;
  15585. /**
  15586. * An event triggered when the postprocess is activated.
  15587. */
  15588. onActivateObservable: Observable<Camera>;
  15589. private _onActivateObserver;
  15590. /**
  15591. * A function that is added to the onActivateObservable
  15592. */
  15593. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15594. /**
  15595. * An event triggered when the postprocess changes its size.
  15596. */
  15597. onSizeChangedObservable: Observable<PostProcess>;
  15598. private _onSizeChangedObserver;
  15599. /**
  15600. * A function that is added to the onSizeChangedObservable
  15601. */
  15602. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15603. /**
  15604. * An event triggered when the postprocess applies its effect.
  15605. */
  15606. onApplyObservable: Observable<Effect>;
  15607. private _onApplyObserver;
  15608. /**
  15609. * A function that is added to the onApplyObservable
  15610. */
  15611. set onApply(callback: (effect: Effect) => void);
  15612. /**
  15613. * An event triggered before rendering the postprocess
  15614. */
  15615. onBeforeRenderObservable: Observable<Effect>;
  15616. private _onBeforeRenderObserver;
  15617. /**
  15618. * A function that is added to the onBeforeRenderObservable
  15619. */
  15620. set onBeforeRender(callback: (effect: Effect) => void);
  15621. /**
  15622. * An event triggered after rendering the postprocess
  15623. */
  15624. onAfterRenderObservable: Observable<Effect>;
  15625. private _onAfterRenderObserver;
  15626. /**
  15627. * A function that is added to the onAfterRenderObservable
  15628. */
  15629. set onAfterRender(callback: (efect: Effect) => void);
  15630. /**
  15631. * 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
  15632. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15633. */
  15634. get inputTexture(): InternalTexture;
  15635. set inputTexture(value: InternalTexture);
  15636. /**
  15637. * Gets the camera which post process is applied to.
  15638. * @returns The camera the post process is applied to.
  15639. */
  15640. getCamera(): Camera;
  15641. /**
  15642. * Gets the texel size of the postprocess.
  15643. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15644. */
  15645. get texelSize(): Vector2;
  15646. /**
  15647. * Creates a new instance PostProcess
  15648. * @param name The name of the PostProcess.
  15649. * @param fragmentUrl The url of the fragment shader to be used.
  15650. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15651. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15652. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15653. * @param camera The camera to apply the render pass to.
  15654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15655. * @param engine The engine which the post process will be applied. (default: current engine)
  15656. * @param reusable If the post process can be reused on the same frame. (default: false)
  15657. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15658. * @param textureType Type of textures used when performing the post process. (default: 0)
  15659. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15660. * @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
  15661. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15662. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  15663. */
  15664. constructor(
  15665. /** Name of the PostProcess. */
  15666. 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, textureFormat?: number);
  15667. /**
  15668. * Gets a string idenfifying the name of the class
  15669. * @returns "PostProcess" string
  15670. */
  15671. getClassName(): string;
  15672. /**
  15673. * Gets the engine which this post process belongs to.
  15674. * @returns The engine the post process was enabled with.
  15675. */
  15676. getEngine(): Engine;
  15677. /**
  15678. * The effect that is created when initializing the post process.
  15679. * @returns The created effect corresponding the the postprocess.
  15680. */
  15681. getEffect(): Effect;
  15682. /**
  15683. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15684. * @param postProcess The post process to share the output with.
  15685. * @returns This post process.
  15686. */
  15687. shareOutputWith(postProcess: PostProcess): PostProcess;
  15688. /**
  15689. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15690. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15691. */
  15692. useOwnOutput(): void;
  15693. /**
  15694. * Updates the effect with the current post process compile time values and recompiles the shader.
  15695. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15696. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15697. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15698. * @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
  15699. * @param onCompiled Called when the shader has been compiled.
  15700. * @param onError Called if there is an error when compiling a shader.
  15701. */
  15702. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15703. /**
  15704. * The post process is reusable if it can be used multiple times within one frame.
  15705. * @returns If the post process is reusable
  15706. */
  15707. isReusable(): boolean;
  15708. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15709. markTextureDirty(): void;
  15710. /**
  15711. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15712. * 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.
  15713. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15714. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15715. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15716. * @returns The target texture that was bound to be written to.
  15717. */
  15718. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15719. /**
  15720. * If the post process is supported.
  15721. */
  15722. get isSupported(): boolean;
  15723. /**
  15724. * The aspect ratio of the output texture.
  15725. */
  15726. get aspectRatio(): number;
  15727. /**
  15728. * Get a value indicating if the post-process is ready to be used
  15729. * @returns true if the post-process is ready (shader is compiled)
  15730. */
  15731. isReady(): boolean;
  15732. /**
  15733. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15734. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15735. */
  15736. apply(): Nullable<Effect>;
  15737. private _disposeTextures;
  15738. /**
  15739. * Disposes the post process.
  15740. * @param camera The camera to dispose the post process on.
  15741. */
  15742. dispose(camera?: Camera): void;
  15743. }
  15744. }
  15745. declare module BABYLON {
  15746. /** @hidden */
  15747. export var kernelBlurVaryingDeclaration: {
  15748. name: string;
  15749. shader: string;
  15750. };
  15751. }
  15752. declare module BABYLON {
  15753. /** @hidden */
  15754. export var kernelBlurFragment: {
  15755. name: string;
  15756. shader: string;
  15757. };
  15758. }
  15759. declare module BABYLON {
  15760. /** @hidden */
  15761. export var kernelBlurFragment2: {
  15762. name: string;
  15763. shader: string;
  15764. };
  15765. }
  15766. declare module BABYLON {
  15767. /** @hidden */
  15768. export var kernelBlurPixelShader: {
  15769. name: string;
  15770. shader: string;
  15771. };
  15772. }
  15773. declare module BABYLON {
  15774. /** @hidden */
  15775. export var kernelBlurVertex: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module BABYLON {
  15781. /** @hidden */
  15782. export var kernelBlurVertexShader: {
  15783. name: string;
  15784. shader: string;
  15785. };
  15786. }
  15787. declare module BABYLON {
  15788. /**
  15789. * The Blur Post Process which blurs an image based on a kernel and direction.
  15790. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15791. */
  15792. export class BlurPostProcess extends PostProcess {
  15793. /** The direction in which to blur the image. */
  15794. direction: Vector2;
  15795. private blockCompilation;
  15796. protected _kernel: number;
  15797. protected _idealKernel: number;
  15798. protected _packedFloat: boolean;
  15799. private _staticDefines;
  15800. /**
  15801. * Sets the length in pixels of the blur sample region
  15802. */
  15803. set kernel(v: number);
  15804. /**
  15805. * Gets the length in pixels of the blur sample region
  15806. */
  15807. get kernel(): number;
  15808. /**
  15809. * Sets wether or not the blur needs to unpack/repack floats
  15810. */
  15811. set packedFloat(v: boolean);
  15812. /**
  15813. * Gets wether or not the blur is unpacking/repacking floats
  15814. */
  15815. get packedFloat(): boolean;
  15816. /**
  15817. * Creates a new instance BlurPostProcess
  15818. * @param name The name of the effect.
  15819. * @param direction The direction in which to blur the image.
  15820. * @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.
  15821. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15822. * @param camera The camera to apply the render pass to.
  15823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15824. * @param engine The engine which the post process will be applied. (default: current engine)
  15825. * @param reusable If the post process can be reused on the same frame. (default: false)
  15826. * @param textureType Type of textures used when performing the post process. (default: 0)
  15827. * @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)
  15828. */
  15829. constructor(name: string,
  15830. /** The direction in which to blur the image. */
  15831. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15832. /**
  15833. * Updates the effect with the current post process compile time values and recompiles the shader.
  15834. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15835. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15836. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15837. * @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
  15838. * @param onCompiled Called when the shader has been compiled.
  15839. * @param onError Called if there is an error when compiling a shader.
  15840. */
  15841. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15843. /**
  15844. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15845. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15846. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15847. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15848. * The gaps between physical kernels are compensated for in the weighting of the samples
  15849. * @param idealKernel Ideal blur kernel.
  15850. * @return Nearest best kernel.
  15851. */
  15852. protected _nearestBestKernel(idealKernel: number): number;
  15853. /**
  15854. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15855. * @param x The point on the Gaussian distribution to sample.
  15856. * @return the value of the Gaussian function at x.
  15857. */
  15858. protected _gaussianWeight(x: number): number;
  15859. /**
  15860. * Generates a string that can be used as a floating point number in GLSL.
  15861. * @param x Value to print.
  15862. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15863. * @return GLSL float string.
  15864. */
  15865. protected _glslFloat(x: number, decimalFigures?: number): string;
  15866. }
  15867. }
  15868. declare module BABYLON {
  15869. /**
  15870. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15871. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15872. * You can then easily use it as a reflectionTexture on a flat surface.
  15873. * In case the surface is not a plane, please consider relying on reflection probes.
  15874. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15875. */
  15876. export class MirrorTexture extends RenderTargetTexture {
  15877. private scene;
  15878. /**
  15879. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15880. * 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.
  15881. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15882. */
  15883. mirrorPlane: Plane;
  15884. /**
  15885. * Define the blur ratio used to blur the reflection if needed.
  15886. */
  15887. set blurRatio(value: number);
  15888. get blurRatio(): number;
  15889. /**
  15890. * Define the adaptive blur kernel used to blur the reflection if needed.
  15891. * This will autocompute the closest best match for the `blurKernel`
  15892. */
  15893. set adaptiveBlurKernel(value: number);
  15894. /**
  15895. * Define the blur kernel used to blur the reflection if needed.
  15896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15897. */
  15898. set blurKernel(value: number);
  15899. /**
  15900. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15901. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15902. */
  15903. set blurKernelX(value: number);
  15904. get blurKernelX(): number;
  15905. /**
  15906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15908. */
  15909. set blurKernelY(value: number);
  15910. get blurKernelY(): number;
  15911. private _autoComputeBlurKernel;
  15912. protected _onRatioRescale(): void;
  15913. private _updateGammaSpace;
  15914. private _imageProcessingConfigChangeObserver;
  15915. private _transformMatrix;
  15916. private _mirrorMatrix;
  15917. private _savedViewMatrix;
  15918. private _blurX;
  15919. private _blurY;
  15920. private _adaptiveBlurKernel;
  15921. private _blurKernelX;
  15922. private _blurKernelY;
  15923. private _blurRatio;
  15924. /**
  15925. * Instantiates a Mirror Texture.
  15926. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15927. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15928. * You can then easily use it as a reflectionTexture on a flat surface.
  15929. * In case the surface is not a plane, please consider relying on reflection probes.
  15930. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15931. * @param name
  15932. * @param size
  15933. * @param scene
  15934. * @param generateMipMaps
  15935. * @param type
  15936. * @param samplingMode
  15937. * @param generateDepthBuffer
  15938. */
  15939. constructor(name: string, size: number | {
  15940. width: number;
  15941. height: number;
  15942. } | {
  15943. ratio: number;
  15944. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15945. private _preparePostProcesses;
  15946. /**
  15947. * Clone the mirror texture.
  15948. * @returns the cloned texture
  15949. */
  15950. clone(): MirrorTexture;
  15951. /**
  15952. * Serialize the texture to a JSON representation you could use in Parse later on
  15953. * @returns the serialized JSON representation
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Dispose the texture and release its associated resources.
  15958. */
  15959. dispose(): void;
  15960. }
  15961. }
  15962. declare module BABYLON {
  15963. /**
  15964. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15965. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15966. */
  15967. export class Texture extends BaseTexture {
  15968. /**
  15969. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15970. */
  15971. static SerializeBuffers: boolean;
  15972. /** @hidden */
  15973. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15974. /** @hidden */
  15975. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15976. /** @hidden */
  15977. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15978. /** nearest is mag = nearest and min = nearest and mip = linear */
  15979. static readonly NEAREST_SAMPLINGMODE: number;
  15980. /** nearest is mag = nearest and min = nearest and mip = linear */
  15981. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15982. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15983. static readonly BILINEAR_SAMPLINGMODE: number;
  15984. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15985. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15986. /** Trilinear is mag = linear and min = linear and mip = linear */
  15987. static readonly TRILINEAR_SAMPLINGMODE: number;
  15988. /** Trilinear is mag = linear and min = linear and mip = linear */
  15989. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15990. /** mag = nearest and min = nearest and mip = nearest */
  15991. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15992. /** mag = nearest and min = linear and mip = nearest */
  15993. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15994. /** mag = nearest and min = linear and mip = linear */
  15995. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15996. /** mag = nearest and min = linear and mip = none */
  15997. static readonly NEAREST_LINEAR: number;
  15998. /** mag = nearest and min = nearest and mip = none */
  15999. static readonly NEAREST_NEAREST: number;
  16000. /** mag = linear and min = nearest and mip = nearest */
  16001. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16002. /** mag = linear and min = nearest and mip = linear */
  16003. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16004. /** mag = linear and min = linear and mip = none */
  16005. static readonly LINEAR_LINEAR: number;
  16006. /** mag = linear and min = nearest and mip = none */
  16007. static readonly LINEAR_NEAREST: number;
  16008. /** Explicit coordinates mode */
  16009. static readonly EXPLICIT_MODE: number;
  16010. /** Spherical coordinates mode */
  16011. static readonly SPHERICAL_MODE: number;
  16012. /** Planar coordinates mode */
  16013. static readonly PLANAR_MODE: number;
  16014. /** Cubic coordinates mode */
  16015. static readonly CUBIC_MODE: number;
  16016. /** Projection coordinates mode */
  16017. static readonly PROJECTION_MODE: number;
  16018. /** Inverse Cubic coordinates mode */
  16019. static readonly SKYBOX_MODE: number;
  16020. /** Inverse Cubic coordinates mode */
  16021. static readonly INVCUBIC_MODE: number;
  16022. /** Equirectangular coordinates mode */
  16023. static readonly EQUIRECTANGULAR_MODE: number;
  16024. /** Equirectangular Fixed coordinates mode */
  16025. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16026. /** Equirectangular Fixed Mirrored coordinates mode */
  16027. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16028. /** Texture is not repeating outside of 0..1 UVs */
  16029. static readonly CLAMP_ADDRESSMODE: number;
  16030. /** Texture is repeating outside of 0..1 UVs */
  16031. static readonly WRAP_ADDRESSMODE: number;
  16032. /** Texture is repeating and mirrored */
  16033. static readonly MIRROR_ADDRESSMODE: number;
  16034. /**
  16035. * 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
  16036. */
  16037. static UseSerializedUrlIfAny: boolean;
  16038. /**
  16039. * Define the url of the texture.
  16040. */
  16041. url: Nullable<string>;
  16042. /**
  16043. * Define an offset on the texture to offset the u coordinates of the UVs
  16044. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16045. */
  16046. uOffset: number;
  16047. /**
  16048. * Define an offset on the texture to offset the v coordinates of the UVs
  16049. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16050. */
  16051. vOffset: number;
  16052. /**
  16053. * Define an offset on the texture to scale the u coordinates of the UVs
  16054. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16055. */
  16056. uScale: number;
  16057. /**
  16058. * Define an offset on the texture to scale the v coordinates of the UVs
  16059. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16060. */
  16061. vScale: number;
  16062. /**
  16063. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16064. * @see http://doc.babylonjs.com/how_to/more_materials
  16065. */
  16066. uAng: number;
  16067. /**
  16068. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16069. * @see http://doc.babylonjs.com/how_to/more_materials
  16070. */
  16071. vAng: number;
  16072. /**
  16073. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16074. * @see http://doc.babylonjs.com/how_to/more_materials
  16075. */
  16076. wAng: number;
  16077. /**
  16078. * Defines the center of rotation (U)
  16079. */
  16080. uRotationCenter: number;
  16081. /**
  16082. * Defines the center of rotation (V)
  16083. */
  16084. vRotationCenter: number;
  16085. /**
  16086. * Defines the center of rotation (W)
  16087. */
  16088. wRotationCenter: number;
  16089. /**
  16090. * Are mip maps generated for this texture or not.
  16091. */
  16092. get noMipmap(): boolean;
  16093. /**
  16094. * List of inspectable custom properties (used by the Inspector)
  16095. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16096. */
  16097. inspectableCustomProperties: Nullable<IInspectable[]>;
  16098. private _noMipmap;
  16099. /** @hidden */
  16100. _invertY: boolean;
  16101. private _rowGenerationMatrix;
  16102. private _cachedTextureMatrix;
  16103. private _projectionModeMatrix;
  16104. private _t0;
  16105. private _t1;
  16106. private _t2;
  16107. private _cachedUOffset;
  16108. private _cachedVOffset;
  16109. private _cachedUScale;
  16110. private _cachedVScale;
  16111. private _cachedUAng;
  16112. private _cachedVAng;
  16113. private _cachedWAng;
  16114. private _cachedProjectionMatrixId;
  16115. private _cachedCoordinatesMode;
  16116. /** @hidden */
  16117. protected _initialSamplingMode: number;
  16118. /** @hidden */
  16119. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16120. private _deleteBuffer;
  16121. protected _format: Nullable<number>;
  16122. private _delayedOnLoad;
  16123. private _delayedOnError;
  16124. private _mimeType?;
  16125. /**
  16126. * Observable triggered once the texture has been loaded.
  16127. */
  16128. onLoadObservable: Observable<Texture>;
  16129. protected _isBlocking: boolean;
  16130. /**
  16131. * Is the texture preventing material to render while loading.
  16132. * If false, a default texture will be used instead of the loading one during the preparation step.
  16133. */
  16134. set isBlocking(value: boolean);
  16135. get isBlocking(): boolean;
  16136. /**
  16137. * Get the current sampling mode associated with the texture.
  16138. */
  16139. get samplingMode(): number;
  16140. /**
  16141. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16142. */
  16143. get invertY(): boolean;
  16144. /**
  16145. * Instantiates a new texture.
  16146. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16147. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16148. * @param url defines the url of the picture to load as a texture
  16149. * @param scene defines the scene or engine the texture will belong to
  16150. * @param noMipmap defines if the texture will require mip maps or not
  16151. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16152. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16153. * @param onLoad defines a callback triggered when the texture has been loaded
  16154. * @param onError defines a callback triggered when an error occurred during the loading session
  16155. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16156. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16157. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16158. * @param mimeType defines an optional mime type information
  16159. */
  16160. 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);
  16161. /**
  16162. * Update the url (and optional buffer) of this texture if url was null during construction.
  16163. * @param url the url of the texture
  16164. * @param buffer the buffer of the texture (defaults to null)
  16165. * @param onLoad callback called when the texture is loaded (defaults to null)
  16166. */
  16167. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16168. /**
  16169. * Finish the loading sequence of a texture flagged as delayed load.
  16170. * @hidden
  16171. */
  16172. delayLoad(): void;
  16173. private _prepareRowForTextureGeneration;
  16174. /**
  16175. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16176. * @returns the transform matrix of the texture.
  16177. */
  16178. getTextureMatrix(uBase?: number): Matrix;
  16179. /**
  16180. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16181. * @returns The reflection texture transform
  16182. */
  16183. getReflectionTextureMatrix(): Matrix;
  16184. /**
  16185. * Clones the texture.
  16186. * @returns the cloned texture
  16187. */
  16188. clone(): Texture;
  16189. /**
  16190. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16191. * @returns The JSON representation of the texture
  16192. */
  16193. serialize(): any;
  16194. /**
  16195. * Get the current class name of the texture useful for serialization or dynamic coding.
  16196. * @returns "Texture"
  16197. */
  16198. getClassName(): string;
  16199. /**
  16200. * Dispose the texture and release its associated resources.
  16201. */
  16202. dispose(): void;
  16203. /**
  16204. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16205. * @param parsedTexture Define the JSON representation of the texture
  16206. * @param scene Define the scene the parsed texture should be instantiated in
  16207. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16208. * @returns The parsed texture if successful
  16209. */
  16210. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16211. /**
  16212. * Creates a texture from its base 64 representation.
  16213. * @param data Define the base64 payload without the data: prefix
  16214. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16215. * @param scene Define the scene the texture should belong to
  16216. * @param noMipmap Forces the texture to not create mip map information if true
  16217. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16218. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16219. * @param onLoad define a callback triggered when the texture has been loaded
  16220. * @param onError define a callback triggered when an error occurred during the loading session
  16221. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16222. * @returns the created texture
  16223. */
  16224. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16225. /**
  16226. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16227. * @param data Define the base64 payload without the data: prefix
  16228. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16229. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16230. * @param scene Define the scene the texture should belong to
  16231. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16232. * @param noMipmap Forces the texture to not create mip map information if true
  16233. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16234. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16235. * @param onLoad define a callback triggered when the texture has been loaded
  16236. * @param onError define a callback triggered when an error occurred during the loading session
  16237. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16238. * @returns the created texture
  16239. */
  16240. 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;
  16241. }
  16242. }
  16243. declare module BABYLON {
  16244. /**
  16245. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16246. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16247. */
  16248. export class PostProcessManager {
  16249. private _scene;
  16250. private _indexBuffer;
  16251. private _vertexBuffers;
  16252. /**
  16253. * Creates a new instance PostProcess
  16254. * @param scene The scene that the post process is associated with.
  16255. */
  16256. constructor(scene: Scene);
  16257. private _prepareBuffers;
  16258. private _buildIndexBuffer;
  16259. /**
  16260. * Rebuilds the vertex buffers of the manager.
  16261. * @hidden
  16262. */
  16263. _rebuild(): void;
  16264. /**
  16265. * Prepares a frame to be run through a post process.
  16266. * @param sourceTexture The input texture to the post procesess. (default: null)
  16267. * @param postProcesses An array of post processes to be run. (default: null)
  16268. * @returns True if the post processes were able to be run.
  16269. * @hidden
  16270. */
  16271. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16272. /**
  16273. * Manually render a set of post processes to a texture.
  16274. * @param postProcesses An array of post processes to be run.
  16275. * @param targetTexture The target texture to render to.
  16276. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16277. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16278. * @param lodLevel defines which lod of the texture to render to
  16279. */
  16280. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16281. /**
  16282. * Finalize the result of the output of the postprocesses.
  16283. * @param doNotPresent If true the result will not be displayed to the screen.
  16284. * @param targetTexture The target texture to render to.
  16285. * @param faceIndex The index of the face to bind the target texture to.
  16286. * @param postProcesses The array of post processes to render.
  16287. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16288. * @hidden
  16289. */
  16290. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16291. /**
  16292. * Disposes of the post process manager.
  16293. */
  16294. dispose(): void;
  16295. }
  16296. }
  16297. declare module BABYLON {
  16298. /** Interface used by value gradients (color, factor, ...) */
  16299. export interface IValueGradient {
  16300. /**
  16301. * Gets or sets the gradient value (between 0 and 1)
  16302. */
  16303. gradient: number;
  16304. }
  16305. /** Class used to store color4 gradient */
  16306. export class ColorGradient implements IValueGradient {
  16307. /**
  16308. * Gets or sets the gradient value (between 0 and 1)
  16309. */
  16310. gradient: number;
  16311. /**
  16312. * Gets or sets first associated color
  16313. */
  16314. color1: Color4;
  16315. /**
  16316. * Gets or sets second associated color
  16317. */
  16318. color2?: Color4;
  16319. /**
  16320. * Will get a color picked randomly between color1 and color2.
  16321. * If color2 is undefined then color1 will be used
  16322. * @param result defines the target Color4 to store the result in
  16323. */
  16324. getColorToRef(result: Color4): void;
  16325. }
  16326. /** Class used to store color 3 gradient */
  16327. export class Color3Gradient implements IValueGradient {
  16328. /**
  16329. * Gets or sets the gradient value (between 0 and 1)
  16330. */
  16331. gradient: number;
  16332. /**
  16333. * Gets or sets the associated color
  16334. */
  16335. color: Color3;
  16336. }
  16337. /** Class used to store factor gradient */
  16338. export class FactorGradient implements IValueGradient {
  16339. /**
  16340. * Gets or sets the gradient value (between 0 and 1)
  16341. */
  16342. gradient: number;
  16343. /**
  16344. * Gets or sets first associated factor
  16345. */
  16346. factor1: number;
  16347. /**
  16348. * Gets or sets second associated factor
  16349. */
  16350. factor2?: number;
  16351. /**
  16352. * Will get a number picked randomly between factor1 and factor2.
  16353. * If factor2 is undefined then factor1 will be used
  16354. * @returns the picked number
  16355. */
  16356. getFactor(): number;
  16357. }
  16358. /**
  16359. * Helper used to simplify some generic gradient tasks
  16360. */
  16361. export class GradientHelper {
  16362. /**
  16363. * Gets the current gradient from an array of IValueGradient
  16364. * @param ratio defines the current ratio to get
  16365. * @param gradients defines the array of IValueGradient
  16366. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16367. */
  16368. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16369. }
  16370. }
  16371. declare module BABYLON {
  16372. interface ThinEngine {
  16373. /**
  16374. * Creates a dynamic texture
  16375. * @param width defines the width of the texture
  16376. * @param height defines the height of the texture
  16377. * @param generateMipMaps defines if the engine should generate the mip levels
  16378. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16379. * @returns the dynamic texture inside an InternalTexture
  16380. */
  16381. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16382. /**
  16383. * Update the content of a dynamic texture
  16384. * @param texture defines the texture to update
  16385. * @param canvas defines the canvas containing the source
  16386. * @param invertY defines if data must be stored with Y axis inverted
  16387. * @param premulAlpha defines if alpha is stored as premultiplied
  16388. * @param format defines the format of the data
  16389. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16390. */
  16391. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16392. }
  16393. }
  16394. declare module BABYLON {
  16395. /**
  16396. * Helper class used to generate a canvas to manipulate images
  16397. */
  16398. export class CanvasGenerator {
  16399. /**
  16400. * Create a new canvas (or offscreen canvas depending on the context)
  16401. * @param width defines the expected width
  16402. * @param height defines the expected height
  16403. * @return a new canvas or offscreen canvas
  16404. */
  16405. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16406. }
  16407. }
  16408. declare module BABYLON {
  16409. /**
  16410. * A class extending Texture allowing drawing on a texture
  16411. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16412. */
  16413. export class DynamicTexture extends Texture {
  16414. private _generateMipMaps;
  16415. private _canvas;
  16416. private _context;
  16417. private _engine;
  16418. /**
  16419. * Creates a DynamicTexture
  16420. * @param name defines the name of the texture
  16421. * @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
  16422. * @param scene defines the scene where you want the texture
  16423. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16424. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16425. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16426. */
  16427. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16428. /**
  16429. * Get the current class name of the texture useful for serialization or dynamic coding.
  16430. * @returns "DynamicTexture"
  16431. */
  16432. getClassName(): string;
  16433. /**
  16434. * Gets the current state of canRescale
  16435. */
  16436. get canRescale(): boolean;
  16437. private _recreate;
  16438. /**
  16439. * Scales the texture
  16440. * @param ratio the scale factor to apply to both width and height
  16441. */
  16442. scale(ratio: number): void;
  16443. /**
  16444. * Resizes the texture
  16445. * @param width the new width
  16446. * @param height the new height
  16447. */
  16448. scaleTo(width: number, height: number): void;
  16449. /**
  16450. * Gets the context of the canvas used by the texture
  16451. * @returns the canvas context of the dynamic texture
  16452. */
  16453. getContext(): CanvasRenderingContext2D;
  16454. /**
  16455. * Clears the texture
  16456. */
  16457. clear(): void;
  16458. /**
  16459. * Updates the texture
  16460. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16461. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16462. */
  16463. update(invertY?: boolean, premulAlpha?: boolean): void;
  16464. /**
  16465. * Draws text onto the texture
  16466. * @param text defines the text to be drawn
  16467. * @param x defines the placement of the text from the left
  16468. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16469. * @param font defines the font to be used with font-style, font-size, font-name
  16470. * @param color defines the color used for the text
  16471. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16472. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16473. * @param update defines whether texture is immediately update (default is true)
  16474. */
  16475. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16476. /**
  16477. * Clones the texture
  16478. * @returns the clone of the texture.
  16479. */
  16480. clone(): DynamicTexture;
  16481. /**
  16482. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16483. * @returns a serialized dynamic texture object
  16484. */
  16485. serialize(): any;
  16486. /** @hidden */
  16487. _rebuild(): void;
  16488. }
  16489. }
  16490. declare module BABYLON {
  16491. interface AbstractScene {
  16492. /**
  16493. * The list of procedural textures added to the scene
  16494. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16495. */
  16496. proceduralTextures: Array<ProceduralTexture>;
  16497. }
  16498. /**
  16499. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16500. * in a given scene.
  16501. */
  16502. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16503. /**
  16504. * The component name helpfull to identify the component in the list of scene components.
  16505. */
  16506. readonly name: string;
  16507. /**
  16508. * The scene the component belongs to.
  16509. */
  16510. scene: Scene;
  16511. /**
  16512. * Creates a new instance of the component for the given scene
  16513. * @param scene Defines the scene to register the component in
  16514. */
  16515. constructor(scene: Scene);
  16516. /**
  16517. * Registers the component in a given scene
  16518. */
  16519. register(): void;
  16520. /**
  16521. * Rebuilds the elements related to this component in case of
  16522. * context lost for instance.
  16523. */
  16524. rebuild(): void;
  16525. /**
  16526. * Disposes the component and the associated ressources.
  16527. */
  16528. dispose(): void;
  16529. private _beforeClear;
  16530. }
  16531. }
  16532. declare module BABYLON {
  16533. interface ThinEngine {
  16534. /**
  16535. * Creates a new render target cube texture
  16536. * @param size defines the size of the texture
  16537. * @param options defines the options used to create the texture
  16538. * @returns a new render target cube texture stored in an InternalTexture
  16539. */
  16540. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16541. }
  16542. }
  16543. declare module BABYLON {
  16544. /** @hidden */
  16545. export var proceduralVertexShader: {
  16546. name: string;
  16547. shader: string;
  16548. };
  16549. }
  16550. declare module BABYLON {
  16551. /**
  16552. * 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.
  16553. * This is the base class of any Procedural texture and contains most of the shareable code.
  16554. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16555. */
  16556. export class ProceduralTexture extends Texture {
  16557. isCube: boolean;
  16558. /**
  16559. * Define if the texture is enabled or not (disabled texture will not render)
  16560. */
  16561. isEnabled: boolean;
  16562. /**
  16563. * Define if the texture must be cleared before rendering (default is true)
  16564. */
  16565. autoClear: boolean;
  16566. /**
  16567. * Callback called when the texture is generated
  16568. */
  16569. onGenerated: () => void;
  16570. /**
  16571. * Event raised when the texture is generated
  16572. */
  16573. onGeneratedObservable: Observable<ProceduralTexture>;
  16574. /** @hidden */
  16575. _generateMipMaps: boolean;
  16576. /** @hidden **/
  16577. _effect: Effect;
  16578. /** @hidden */
  16579. _textures: {
  16580. [key: string]: Texture;
  16581. };
  16582. private _size;
  16583. private _currentRefreshId;
  16584. private _frameId;
  16585. private _refreshRate;
  16586. private _vertexBuffers;
  16587. private _indexBuffer;
  16588. private _uniforms;
  16589. private _samplers;
  16590. private _fragment;
  16591. private _floats;
  16592. private _ints;
  16593. private _floatsArrays;
  16594. private _colors3;
  16595. private _colors4;
  16596. private _vectors2;
  16597. private _vectors3;
  16598. private _matrices;
  16599. private _fallbackTexture;
  16600. private _fallbackTextureUsed;
  16601. private _engine;
  16602. private _cachedDefines;
  16603. private _contentUpdateId;
  16604. private _contentData;
  16605. /**
  16606. * Instantiates a new procedural texture.
  16607. * 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.
  16608. * This is the base class of any Procedural texture and contains most of the shareable code.
  16609. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16610. * @param name Define the name of the texture
  16611. * @param size Define the size of the texture to create
  16612. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16613. * @param scene Define the scene the texture belongs to
  16614. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16615. * @param generateMipMaps Define if the texture should creates mip maps or not
  16616. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16617. */
  16618. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16619. /**
  16620. * The effect that is created when initializing the post process.
  16621. * @returns The created effect corresponding the the postprocess.
  16622. */
  16623. getEffect(): Effect;
  16624. /**
  16625. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16626. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16627. */
  16628. getContent(): Nullable<ArrayBufferView>;
  16629. private _createIndexBuffer;
  16630. /** @hidden */
  16631. _rebuild(): void;
  16632. /**
  16633. * Resets the texture in order to recreate its associated resources.
  16634. * This can be called in case of context loss
  16635. */
  16636. reset(): void;
  16637. protected _getDefines(): string;
  16638. /**
  16639. * Is the texture ready to be used ? (rendered at least once)
  16640. * @returns true if ready, otherwise, false.
  16641. */
  16642. isReady(): boolean;
  16643. /**
  16644. * Resets the refresh counter of the texture and start bak from scratch.
  16645. * Could be useful to regenerate the texture if it is setup to render only once.
  16646. */
  16647. resetRefreshCounter(): void;
  16648. /**
  16649. * Set the fragment shader to use in order to render the texture.
  16650. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16651. */
  16652. setFragment(fragment: any): void;
  16653. /**
  16654. * Define the refresh rate of the texture or the rendering frequency.
  16655. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16656. */
  16657. get refreshRate(): number;
  16658. set refreshRate(value: number);
  16659. /** @hidden */
  16660. _shouldRender(): boolean;
  16661. /**
  16662. * Get the size the texture is rendering at.
  16663. * @returns the size (texture is always squared)
  16664. */
  16665. getRenderSize(): number;
  16666. /**
  16667. * Resize the texture to new value.
  16668. * @param size Define the new size the texture should have
  16669. * @param generateMipMaps Define whether the new texture should create mip maps
  16670. */
  16671. resize(size: number, generateMipMaps: boolean): void;
  16672. private _checkUniform;
  16673. /**
  16674. * Set a texture in the shader program used to render.
  16675. * @param name Define the name of the uniform samplers as defined in the shader
  16676. * @param texture Define the texture to bind to this sampler
  16677. * @return the texture itself allowing "fluent" like uniform updates
  16678. */
  16679. setTexture(name: string, texture: Texture): ProceduralTexture;
  16680. /**
  16681. * Set a float in the shader.
  16682. * @param name Define the name of the uniform as defined in the shader
  16683. * @param value Define the value to give to the uniform
  16684. * @return the texture itself allowing "fluent" like uniform updates
  16685. */
  16686. setFloat(name: string, value: number): ProceduralTexture;
  16687. /**
  16688. * Set a int in the shader.
  16689. * @param name Define the name of the uniform as defined in the shader
  16690. * @param value Define the value to give to the uniform
  16691. * @return the texture itself allowing "fluent" like uniform updates
  16692. */
  16693. setInt(name: string, value: number): ProceduralTexture;
  16694. /**
  16695. * Set an array of floats in the shader.
  16696. * @param name Define the name of the uniform as defined in the shader
  16697. * @param value Define the value to give to the uniform
  16698. * @return the texture itself allowing "fluent" like uniform updates
  16699. */
  16700. setFloats(name: string, value: number[]): ProceduralTexture;
  16701. /**
  16702. * Set a vec3 in the shader from a Color3.
  16703. * @param name Define the name of the uniform as defined in the shader
  16704. * @param value Define the value to give to the uniform
  16705. * @return the texture itself allowing "fluent" like uniform updates
  16706. */
  16707. setColor3(name: string, value: Color3): ProceduralTexture;
  16708. /**
  16709. * Set a vec4 in the shader from a Color4.
  16710. * @param name Define the name of the uniform as defined in the shader
  16711. * @param value Define the value to give to the uniform
  16712. * @return the texture itself allowing "fluent" like uniform updates
  16713. */
  16714. setColor4(name: string, value: Color4): ProceduralTexture;
  16715. /**
  16716. * Set a vec2 in the shader from a Vector2.
  16717. * @param name Define the name of the uniform as defined in the shader
  16718. * @param value Define the value to give to the uniform
  16719. * @return the texture itself allowing "fluent" like uniform updates
  16720. */
  16721. setVector2(name: string, value: Vector2): ProceduralTexture;
  16722. /**
  16723. * Set a vec3 in the shader from a Vector3.
  16724. * @param name Define the name of the uniform as defined in the shader
  16725. * @param value Define the value to give to the uniform
  16726. * @return the texture itself allowing "fluent" like uniform updates
  16727. */
  16728. setVector3(name: string, value: Vector3): ProceduralTexture;
  16729. /**
  16730. * Set a mat4 in the shader from a MAtrix.
  16731. * @param name Define the name of the uniform as defined in the shader
  16732. * @param value Define the value to give to the uniform
  16733. * @return the texture itself allowing "fluent" like uniform updates
  16734. */
  16735. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16736. /**
  16737. * Render the texture to its associated render target.
  16738. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16739. */
  16740. render(useCameraPostProcess?: boolean): void;
  16741. /**
  16742. * Clone the texture.
  16743. * @returns the cloned texture
  16744. */
  16745. clone(): ProceduralTexture;
  16746. /**
  16747. * Dispose the texture and release its asoociated resources.
  16748. */
  16749. dispose(): void;
  16750. }
  16751. }
  16752. declare module BABYLON {
  16753. /**
  16754. * This represents the base class for particle system in Babylon.
  16755. * 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.
  16756. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16757. * @example https://doc.babylonjs.com/babylon101/particles
  16758. */
  16759. export class BaseParticleSystem {
  16760. /**
  16761. * Source color is added to the destination color without alpha affecting the result
  16762. */
  16763. static BLENDMODE_ONEONE: number;
  16764. /**
  16765. * Blend current color and particle color using particle’s alpha
  16766. */
  16767. static BLENDMODE_STANDARD: number;
  16768. /**
  16769. * Add current color and particle color multiplied by particle’s alpha
  16770. */
  16771. static BLENDMODE_ADD: number;
  16772. /**
  16773. * Multiply current color with particle color
  16774. */
  16775. static BLENDMODE_MULTIPLY: number;
  16776. /**
  16777. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16778. */
  16779. static BLENDMODE_MULTIPLYADD: number;
  16780. /**
  16781. * List of animations used by the particle system.
  16782. */
  16783. animations: Animation[];
  16784. /**
  16785. * The id of the Particle system.
  16786. */
  16787. id: string;
  16788. /**
  16789. * The friendly name of the Particle system.
  16790. */
  16791. name: string;
  16792. /**
  16793. * The rendering group used by the Particle system to chose when to render.
  16794. */
  16795. renderingGroupId: number;
  16796. /**
  16797. * The emitter represents the Mesh or position we are attaching the particle system to.
  16798. */
  16799. emitter: Nullable<AbstractMesh | Vector3>;
  16800. /**
  16801. * The maximum number of particles to emit per frame
  16802. */
  16803. emitRate: number;
  16804. /**
  16805. * If you want to launch only a few particles at once, that can be done, as well.
  16806. */
  16807. manualEmitCount: number;
  16808. /**
  16809. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16810. */
  16811. updateSpeed: number;
  16812. /**
  16813. * The amount of time the particle system is running (depends of the overall update speed).
  16814. */
  16815. targetStopDuration: number;
  16816. /**
  16817. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16818. */
  16819. disposeOnStop: boolean;
  16820. /**
  16821. * Minimum power of emitting particles.
  16822. */
  16823. minEmitPower: number;
  16824. /**
  16825. * Maximum power of emitting particles.
  16826. */
  16827. maxEmitPower: number;
  16828. /**
  16829. * Minimum life time of emitting particles.
  16830. */
  16831. minLifeTime: number;
  16832. /**
  16833. * Maximum life time of emitting particles.
  16834. */
  16835. maxLifeTime: number;
  16836. /**
  16837. * Minimum Size of emitting particles.
  16838. */
  16839. minSize: number;
  16840. /**
  16841. * Maximum Size of emitting particles.
  16842. */
  16843. maxSize: number;
  16844. /**
  16845. * Minimum scale of emitting particles on X axis.
  16846. */
  16847. minScaleX: number;
  16848. /**
  16849. * Maximum scale of emitting particles on X axis.
  16850. */
  16851. maxScaleX: number;
  16852. /**
  16853. * Minimum scale of emitting particles on Y axis.
  16854. */
  16855. minScaleY: number;
  16856. /**
  16857. * Maximum scale of emitting particles on Y axis.
  16858. */
  16859. maxScaleY: number;
  16860. /**
  16861. * Gets or sets the minimal initial rotation in radians.
  16862. */
  16863. minInitialRotation: number;
  16864. /**
  16865. * Gets or sets the maximal initial rotation in radians.
  16866. */
  16867. maxInitialRotation: number;
  16868. /**
  16869. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16870. */
  16871. minAngularSpeed: number;
  16872. /**
  16873. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16874. */
  16875. maxAngularSpeed: number;
  16876. /**
  16877. * The texture used to render each particle. (this can be a spritesheet)
  16878. */
  16879. particleTexture: Nullable<Texture>;
  16880. /**
  16881. * The layer mask we are rendering the particles through.
  16882. */
  16883. layerMask: number;
  16884. /**
  16885. * This can help using your own shader to render the particle system.
  16886. * The according effect will be created
  16887. */
  16888. customShader: any;
  16889. /**
  16890. * By default particle system starts as soon as they are created. This prevents the
  16891. * automatic start to happen and let you decide when to start emitting particles.
  16892. */
  16893. preventAutoStart: boolean;
  16894. private _noiseTexture;
  16895. /**
  16896. * Gets or sets a texture used to add random noise to particle positions
  16897. */
  16898. get noiseTexture(): Nullable<ProceduralTexture>;
  16899. set noiseTexture(value: Nullable<ProceduralTexture>);
  16900. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16901. noiseStrength: Vector3;
  16902. /**
  16903. * Callback triggered when the particle animation is ending.
  16904. */
  16905. onAnimationEnd: Nullable<() => void>;
  16906. /**
  16907. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16908. */
  16909. blendMode: number;
  16910. /**
  16911. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16912. * to override the particles.
  16913. */
  16914. forceDepthWrite: boolean;
  16915. /** 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 */
  16916. preWarmCycles: number;
  16917. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16918. preWarmStepOffset: number;
  16919. /**
  16920. * 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)
  16921. */
  16922. spriteCellChangeSpeed: number;
  16923. /**
  16924. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16925. */
  16926. startSpriteCellID: number;
  16927. /**
  16928. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16929. */
  16930. endSpriteCellID: number;
  16931. /**
  16932. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16933. */
  16934. spriteCellWidth: number;
  16935. /**
  16936. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16937. */
  16938. spriteCellHeight: number;
  16939. /**
  16940. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16941. */
  16942. spriteRandomStartCell: boolean;
  16943. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16944. translationPivot: Vector2;
  16945. /** @hidden */
  16946. protected _isAnimationSheetEnabled: boolean;
  16947. /**
  16948. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16949. */
  16950. beginAnimationOnStart: boolean;
  16951. /**
  16952. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16953. */
  16954. beginAnimationFrom: number;
  16955. /**
  16956. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16957. */
  16958. beginAnimationTo: number;
  16959. /**
  16960. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16961. */
  16962. beginAnimationLoop: boolean;
  16963. /**
  16964. * Gets or sets a world offset applied to all particles
  16965. */
  16966. worldOffset: Vector3;
  16967. /**
  16968. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16969. */
  16970. get isAnimationSheetEnabled(): boolean;
  16971. set isAnimationSheetEnabled(value: boolean);
  16972. /**
  16973. * Get hosting scene
  16974. * @returns the scene
  16975. */
  16976. getScene(): Scene;
  16977. /**
  16978. * You can use gravity if you want to give an orientation to your particles.
  16979. */
  16980. gravity: Vector3;
  16981. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16982. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16983. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16984. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16985. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16986. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16987. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16988. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16989. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16990. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16991. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16992. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16993. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16994. /**
  16995. * Defines the delay in milliseconds before starting the system (0 by default)
  16996. */
  16997. startDelay: number;
  16998. /**
  16999. * Gets the current list of drag gradients.
  17000. * You must use addDragGradient and removeDragGradient to udpate this list
  17001. * @returns the list of drag gradients
  17002. */
  17003. getDragGradients(): Nullable<Array<FactorGradient>>;
  17004. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17005. limitVelocityDamping: number;
  17006. /**
  17007. * Gets the current list of limit velocity gradients.
  17008. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17009. * @returns the list of limit velocity gradients
  17010. */
  17011. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17012. /**
  17013. * Gets the current list of color gradients.
  17014. * You must use addColorGradient and removeColorGradient to udpate this list
  17015. * @returns the list of color gradients
  17016. */
  17017. getColorGradients(): Nullable<Array<ColorGradient>>;
  17018. /**
  17019. * Gets the current list of size gradients.
  17020. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17021. * @returns the list of size gradients
  17022. */
  17023. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17024. /**
  17025. * Gets the current list of color remap gradients.
  17026. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17027. * @returns the list of color remap gradients
  17028. */
  17029. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17030. /**
  17031. * Gets the current list of alpha remap gradients.
  17032. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17033. * @returns the list of alpha remap gradients
  17034. */
  17035. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17036. /**
  17037. * Gets the current list of life time gradients.
  17038. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17039. * @returns the list of life time gradients
  17040. */
  17041. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17042. /**
  17043. * Gets the current list of angular speed gradients.
  17044. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17045. * @returns the list of angular speed gradients
  17046. */
  17047. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17048. /**
  17049. * Gets the current list of velocity gradients.
  17050. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17051. * @returns the list of velocity gradients
  17052. */
  17053. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17054. /**
  17055. * Gets the current list of start size gradients.
  17056. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17057. * @returns the list of start size gradients
  17058. */
  17059. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17060. /**
  17061. * Gets the current list of emit rate gradients.
  17062. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17063. * @returns the list of emit rate gradients
  17064. */
  17065. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17066. /**
  17067. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17068. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17069. */
  17070. get direction1(): Vector3;
  17071. set direction1(value: Vector3);
  17072. /**
  17073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17074. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17075. */
  17076. get direction2(): Vector3;
  17077. set direction2(value: Vector3);
  17078. /**
  17079. * 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.
  17080. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17081. */
  17082. get minEmitBox(): Vector3;
  17083. set minEmitBox(value: Vector3);
  17084. /**
  17085. * 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.
  17086. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17087. */
  17088. get maxEmitBox(): Vector3;
  17089. set maxEmitBox(value: Vector3);
  17090. /**
  17091. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17092. */
  17093. color1: Color4;
  17094. /**
  17095. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17096. */
  17097. color2: Color4;
  17098. /**
  17099. * Color the particle will have at the end of its lifetime
  17100. */
  17101. colorDead: Color4;
  17102. /**
  17103. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17104. */
  17105. textureMask: Color4;
  17106. /**
  17107. * The particle emitter type defines the emitter used by the particle system.
  17108. * It can be for example box, sphere, or cone...
  17109. */
  17110. particleEmitterType: IParticleEmitterType;
  17111. /** @hidden */
  17112. _isSubEmitter: boolean;
  17113. /**
  17114. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17115. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17116. */
  17117. billboardMode: number;
  17118. protected _isBillboardBased: boolean;
  17119. /**
  17120. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17121. */
  17122. get isBillboardBased(): boolean;
  17123. set isBillboardBased(value: boolean);
  17124. /**
  17125. * The scene the particle system belongs to.
  17126. */
  17127. protected _scene: Scene;
  17128. /**
  17129. * Local cache of defines for image processing.
  17130. */
  17131. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17132. /**
  17133. * Default configuration related to image processing available in the standard Material.
  17134. */
  17135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17136. /**
  17137. * Gets the image processing configuration used either in this material.
  17138. */
  17139. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17140. /**
  17141. * Sets the Default image processing configuration used either in the this material.
  17142. *
  17143. * If sets to null, the scene one is in use.
  17144. */
  17145. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17146. /**
  17147. * Attaches a new image processing configuration to the Standard Material.
  17148. * @param configuration
  17149. */
  17150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17151. /** @hidden */
  17152. protected _reset(): void;
  17153. /** @hidden */
  17154. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17155. /**
  17156. * Instantiates a particle system.
  17157. * 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.
  17158. * @param name The name of the particle system
  17159. */
  17160. constructor(name: string);
  17161. /**
  17162. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17165. * @returns the emitter
  17166. */
  17167. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17168. /**
  17169. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17170. * @param radius The radius of the hemisphere to emit from
  17171. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17172. * @returns the emitter
  17173. */
  17174. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17175. /**
  17176. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17177. * @param radius The radius of the sphere to emit from
  17178. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17179. * @returns the emitter
  17180. */
  17181. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17182. /**
  17183. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17184. * @param radius The radius of the sphere to emit from
  17185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17187. * @returns the emitter
  17188. */
  17189. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17190. /**
  17191. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17192. * @param radius The radius of the emission cylinder
  17193. * @param height The height of the emission cylinder
  17194. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17195. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17196. * @returns the emitter
  17197. */
  17198. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17199. /**
  17200. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17201. * @param radius The radius of the cylinder to emit from
  17202. * @param height The height of the emission cylinder
  17203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17204. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17205. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17206. * @returns the emitter
  17207. */
  17208. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17209. /**
  17210. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17211. * @param radius The radius of the cone to emit from
  17212. * @param angle The base angle of the cone
  17213. * @returns the emitter
  17214. */
  17215. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17216. /**
  17217. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17218. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17219. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17220. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17221. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17222. * @returns the emitter
  17223. */
  17224. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17225. }
  17226. }
  17227. declare module BABYLON {
  17228. /**
  17229. * Type of sub emitter
  17230. */
  17231. export enum SubEmitterType {
  17232. /**
  17233. * Attached to the particle over it's lifetime
  17234. */
  17235. ATTACHED = 0,
  17236. /**
  17237. * Created when the particle dies
  17238. */
  17239. END = 1
  17240. }
  17241. /**
  17242. * Sub emitter class used to emit particles from an existing particle
  17243. */
  17244. export class SubEmitter {
  17245. /**
  17246. * the particle system to be used by the sub emitter
  17247. */
  17248. particleSystem: ParticleSystem;
  17249. /**
  17250. * Type of the submitter (Default: END)
  17251. */
  17252. type: SubEmitterType;
  17253. /**
  17254. * 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)
  17255. * Note: This only is supported when using an emitter of type Mesh
  17256. */
  17257. inheritDirection: boolean;
  17258. /**
  17259. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17260. */
  17261. inheritedVelocityAmount: number;
  17262. /**
  17263. * Creates a sub emitter
  17264. * @param particleSystem the particle system to be used by the sub emitter
  17265. */
  17266. constructor(
  17267. /**
  17268. * the particle system to be used by the sub emitter
  17269. */
  17270. particleSystem: ParticleSystem);
  17271. /**
  17272. * Clones the sub emitter
  17273. * @returns the cloned sub emitter
  17274. */
  17275. clone(): SubEmitter;
  17276. /**
  17277. * Serialize current object to a JSON object
  17278. * @returns the serialized object
  17279. */
  17280. serialize(): any;
  17281. /** @hidden */
  17282. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17283. /**
  17284. * Creates a new SubEmitter from a serialized JSON version
  17285. * @param serializationObject defines the JSON object to read from
  17286. * @param scene defines the hosting scene
  17287. * @param rootUrl defines the rootUrl for data loading
  17288. * @returns a new SubEmitter
  17289. */
  17290. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17291. /** Release associated resources */
  17292. dispose(): void;
  17293. }
  17294. }
  17295. declare module BABYLON {
  17296. /** @hidden */
  17297. export var clipPlaneFragmentDeclaration: {
  17298. name: string;
  17299. shader: string;
  17300. };
  17301. }
  17302. declare module BABYLON {
  17303. /** @hidden */
  17304. export var imageProcessingDeclaration: {
  17305. name: string;
  17306. shader: string;
  17307. };
  17308. }
  17309. declare module BABYLON {
  17310. /** @hidden */
  17311. export var imageProcessingFunctions: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module BABYLON {
  17317. /** @hidden */
  17318. export var clipPlaneFragment: {
  17319. name: string;
  17320. shader: string;
  17321. };
  17322. }
  17323. declare module BABYLON {
  17324. /** @hidden */
  17325. export var particlesPixelShader: {
  17326. name: string;
  17327. shader: string;
  17328. };
  17329. }
  17330. declare module BABYLON {
  17331. /** @hidden */
  17332. export var clipPlaneVertexDeclaration: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module BABYLON {
  17338. /** @hidden */
  17339. export var clipPlaneVertex: {
  17340. name: string;
  17341. shader: string;
  17342. };
  17343. }
  17344. declare module BABYLON {
  17345. /** @hidden */
  17346. export var particlesVertexShader: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module BABYLON {
  17352. /**
  17353. * This represents a particle system in Babylon.
  17354. * 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.
  17355. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17356. * @example https://doc.babylonjs.com/babylon101/particles
  17357. */
  17358. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17359. /**
  17360. * Billboard mode will only apply to Y axis
  17361. */
  17362. static readonly BILLBOARDMODE_Y: number;
  17363. /**
  17364. * Billboard mode will apply to all axes
  17365. */
  17366. static readonly BILLBOARDMODE_ALL: number;
  17367. /**
  17368. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17369. */
  17370. static readonly BILLBOARDMODE_STRETCHED: number;
  17371. /**
  17372. * This function can be defined to provide custom update for active particles.
  17373. * This function will be called instead of regular update (age, position, color, etc.).
  17374. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17375. */
  17376. updateFunction: (particles: Particle[]) => void;
  17377. private _emitterWorldMatrix;
  17378. /**
  17379. * This function can be defined to specify initial direction for every new particle.
  17380. * It by default use the emitterType defined function
  17381. */
  17382. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17383. /**
  17384. * This function can be defined to specify initial position for every new particle.
  17385. * It by default use the emitterType defined function
  17386. */
  17387. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17388. /**
  17389. * @hidden
  17390. */
  17391. _inheritedVelocityOffset: Vector3;
  17392. /**
  17393. * An event triggered when the system is disposed
  17394. */
  17395. onDisposeObservable: Observable<ParticleSystem>;
  17396. private _onDisposeObserver;
  17397. /**
  17398. * Sets a callback that will be triggered when the system is disposed
  17399. */
  17400. set onDispose(callback: () => void);
  17401. private _particles;
  17402. private _epsilon;
  17403. private _capacity;
  17404. private _stockParticles;
  17405. private _newPartsExcess;
  17406. private _vertexData;
  17407. private _vertexBuffer;
  17408. private _vertexBuffers;
  17409. private _spriteBuffer;
  17410. private _indexBuffer;
  17411. private _effect;
  17412. private _customEffect;
  17413. private _cachedDefines;
  17414. private _scaledColorStep;
  17415. private _colorDiff;
  17416. private _scaledDirection;
  17417. private _scaledGravity;
  17418. private _currentRenderId;
  17419. private _alive;
  17420. private _useInstancing;
  17421. private _started;
  17422. private _stopped;
  17423. private _actualFrame;
  17424. private _scaledUpdateSpeed;
  17425. private _vertexBufferSize;
  17426. /** @hidden */
  17427. _currentEmitRateGradient: Nullable<FactorGradient>;
  17428. /** @hidden */
  17429. _currentEmitRate1: number;
  17430. /** @hidden */
  17431. _currentEmitRate2: number;
  17432. /** @hidden */
  17433. _currentStartSizeGradient: Nullable<FactorGradient>;
  17434. /** @hidden */
  17435. _currentStartSize1: number;
  17436. /** @hidden */
  17437. _currentStartSize2: number;
  17438. private readonly _rawTextureWidth;
  17439. private _rampGradientsTexture;
  17440. private _useRampGradients;
  17441. /** Gets or sets a boolean indicating that ramp gradients must be used
  17442. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17443. */
  17444. get useRampGradients(): boolean;
  17445. set useRampGradients(value: boolean);
  17446. /**
  17447. * 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.
  17448. * 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: [])
  17449. */
  17450. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17451. private _subEmitters;
  17452. /**
  17453. * @hidden
  17454. * If the particle systems emitter should be disposed when the particle system is disposed
  17455. */
  17456. _disposeEmitterOnDispose: boolean;
  17457. /**
  17458. * The current active Sub-systems, this property is used by the root particle system only.
  17459. */
  17460. activeSubSystems: Array<ParticleSystem>;
  17461. private _rootParticleSystem;
  17462. /**
  17463. * Gets the current list of active particles
  17464. */
  17465. get particles(): Particle[];
  17466. /**
  17467. * Returns the string "ParticleSystem"
  17468. * @returns a string containing the class name
  17469. */
  17470. getClassName(): string;
  17471. /**
  17472. * Instantiates a particle system.
  17473. * 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.
  17474. * @param name The name of the particle system
  17475. * @param capacity The max number of particles alive at the same time
  17476. * @param scene The scene the particle system belongs to
  17477. * @param customEffect a custom effect used to change the way particles are rendered by default
  17478. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17479. * @param epsilon Offset used to render the particles
  17480. */
  17481. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17482. private _addFactorGradient;
  17483. private _removeFactorGradient;
  17484. /**
  17485. * Adds a new life time gradient
  17486. * @param gradient defines the gradient to use (between 0 and 1)
  17487. * @param factor defines the life time factor to affect to the specified gradient
  17488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17489. * @returns the current particle system
  17490. */
  17491. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17492. /**
  17493. * Remove a specific life time gradient
  17494. * @param gradient defines the gradient to remove
  17495. * @returns the current particle system
  17496. */
  17497. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17498. /**
  17499. * Adds a new size gradient
  17500. * @param gradient defines the gradient to use (between 0 and 1)
  17501. * @param factor defines the size factor to affect to the specified gradient
  17502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17503. * @returns the current particle system
  17504. */
  17505. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17506. /**
  17507. * Remove a specific size gradient
  17508. * @param gradient defines the gradient to remove
  17509. * @returns the current particle system
  17510. */
  17511. removeSizeGradient(gradient: number): IParticleSystem;
  17512. /**
  17513. * Adds a new color remap gradient
  17514. * @param gradient defines the gradient to use (between 0 and 1)
  17515. * @param min defines the color remap minimal range
  17516. * @param max defines the color remap maximal range
  17517. * @returns the current particle system
  17518. */
  17519. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17520. /**
  17521. * Remove a specific color remap gradient
  17522. * @param gradient defines the gradient to remove
  17523. * @returns the current particle system
  17524. */
  17525. removeColorRemapGradient(gradient: number): IParticleSystem;
  17526. /**
  17527. * Adds a new alpha remap gradient
  17528. * @param gradient defines the gradient to use (between 0 and 1)
  17529. * @param min defines the alpha remap minimal range
  17530. * @param max defines the alpha remap maximal range
  17531. * @returns the current particle system
  17532. */
  17533. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17534. /**
  17535. * Remove a specific alpha remap gradient
  17536. * @param gradient defines the gradient to remove
  17537. * @returns the current particle system
  17538. */
  17539. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17540. /**
  17541. * Adds a new angular speed gradient
  17542. * @param gradient defines the gradient to use (between 0 and 1)
  17543. * @param factor defines the angular speed to affect to the specified gradient
  17544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17545. * @returns the current particle system
  17546. */
  17547. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17548. /**
  17549. * Remove a specific angular speed gradient
  17550. * @param gradient defines the gradient to remove
  17551. * @returns the current particle system
  17552. */
  17553. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17554. /**
  17555. * Adds a new velocity gradient
  17556. * @param gradient defines the gradient to use (between 0 and 1)
  17557. * @param factor defines the velocity to affect to the specified gradient
  17558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17559. * @returns the current particle system
  17560. */
  17561. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17562. /**
  17563. * Remove a specific velocity gradient
  17564. * @param gradient defines the gradient to remove
  17565. * @returns the current particle system
  17566. */
  17567. removeVelocityGradient(gradient: number): IParticleSystem;
  17568. /**
  17569. * Adds a new limit velocity gradient
  17570. * @param gradient defines the gradient to use (between 0 and 1)
  17571. * @param factor defines the limit velocity value to affect to the specified gradient
  17572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17573. * @returns the current particle system
  17574. */
  17575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17576. /**
  17577. * Remove a specific limit velocity gradient
  17578. * @param gradient defines the gradient to remove
  17579. * @returns the current particle system
  17580. */
  17581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17582. /**
  17583. * Adds a new drag gradient
  17584. * @param gradient defines the gradient to use (between 0 and 1)
  17585. * @param factor defines the drag value to affect to the specified gradient
  17586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17587. * @returns the current particle system
  17588. */
  17589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17590. /**
  17591. * Remove a specific drag gradient
  17592. * @param gradient defines the gradient to remove
  17593. * @returns the current particle system
  17594. */
  17595. removeDragGradient(gradient: number): IParticleSystem;
  17596. /**
  17597. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17598. * @param gradient defines the gradient to use (between 0 and 1)
  17599. * @param factor defines the emit rate value to affect to the specified gradient
  17600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17601. * @returns the current particle system
  17602. */
  17603. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17604. /**
  17605. * Remove a specific emit rate gradient
  17606. * @param gradient defines the gradient to remove
  17607. * @returns the current particle system
  17608. */
  17609. removeEmitRateGradient(gradient: number): IParticleSystem;
  17610. /**
  17611. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17612. * @param gradient defines the gradient to use (between 0 and 1)
  17613. * @param factor defines the start size value to affect to the specified gradient
  17614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17615. * @returns the current particle system
  17616. */
  17617. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17618. /**
  17619. * Remove a specific start size gradient
  17620. * @param gradient defines the gradient to remove
  17621. * @returns the current particle system
  17622. */
  17623. removeStartSizeGradient(gradient: number): IParticleSystem;
  17624. private _createRampGradientTexture;
  17625. /**
  17626. * Gets the current list of ramp gradients.
  17627. * You must use addRampGradient and removeRampGradient to udpate this list
  17628. * @returns the list of ramp gradients
  17629. */
  17630. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17631. /**
  17632. * Adds a new ramp gradient used to remap particle colors
  17633. * @param gradient defines the gradient to use (between 0 and 1)
  17634. * @param color defines the color to affect to the specified gradient
  17635. * @returns the current particle system
  17636. */
  17637. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17638. /**
  17639. * Remove a specific ramp gradient
  17640. * @param gradient defines the gradient to remove
  17641. * @returns the current particle system
  17642. */
  17643. removeRampGradient(gradient: number): ParticleSystem;
  17644. /**
  17645. * Adds a new color gradient
  17646. * @param gradient defines the gradient to use (between 0 and 1)
  17647. * @param color1 defines the color to affect to the specified gradient
  17648. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17649. * @returns this particle system
  17650. */
  17651. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17652. /**
  17653. * Remove a specific color gradient
  17654. * @param gradient defines the gradient to remove
  17655. * @returns this particle system
  17656. */
  17657. removeColorGradient(gradient: number): IParticleSystem;
  17658. private _fetchR;
  17659. protected _reset(): void;
  17660. private _resetEffect;
  17661. private _createVertexBuffers;
  17662. private _createIndexBuffer;
  17663. /**
  17664. * Gets the maximum number of particles active at the same time.
  17665. * @returns The max number of active particles.
  17666. */
  17667. getCapacity(): number;
  17668. /**
  17669. * Gets whether there are still active particles in the system.
  17670. * @returns True if it is alive, otherwise false.
  17671. */
  17672. isAlive(): boolean;
  17673. /**
  17674. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17675. * @returns True if it has been started, otherwise false.
  17676. */
  17677. isStarted(): boolean;
  17678. private _prepareSubEmitterInternalArray;
  17679. /**
  17680. * Starts the particle system and begins to emit
  17681. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17682. */
  17683. start(delay?: number): void;
  17684. /**
  17685. * Stops the particle system.
  17686. * @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.
  17687. */
  17688. stop(stopSubEmitters?: boolean): void;
  17689. /**
  17690. * Remove all active particles
  17691. */
  17692. reset(): void;
  17693. /**
  17694. * @hidden (for internal use only)
  17695. */
  17696. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17697. /**
  17698. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17699. * Its lifetime will start back at 0.
  17700. */
  17701. recycleParticle: (particle: Particle) => void;
  17702. private _stopSubEmitters;
  17703. private _createParticle;
  17704. private _removeFromRoot;
  17705. private _emitFromParticle;
  17706. private _update;
  17707. /** @hidden */
  17708. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17709. /** @hidden */
  17710. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17711. /** @hidden */
  17712. private _getEffect;
  17713. /**
  17714. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17715. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17716. */
  17717. animate(preWarmOnly?: boolean): void;
  17718. private _appendParticleVertices;
  17719. /**
  17720. * Rebuilds the particle system.
  17721. */
  17722. rebuild(): void;
  17723. /**
  17724. * Is this system ready to be used/rendered
  17725. * @return true if the system is ready
  17726. */
  17727. isReady(): boolean;
  17728. private _render;
  17729. /**
  17730. * Renders the particle system in its current state.
  17731. * @returns the current number of particles
  17732. */
  17733. render(): number;
  17734. /**
  17735. * Disposes the particle system and free the associated resources
  17736. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17737. */
  17738. dispose(disposeTexture?: boolean): void;
  17739. /**
  17740. * Clones the particle system.
  17741. * @param name The name of the cloned object
  17742. * @param newEmitter The new emitter to use
  17743. * @returns the cloned particle system
  17744. */
  17745. clone(name: string, newEmitter: any): ParticleSystem;
  17746. /**
  17747. * Serializes the particle system to a JSON object.
  17748. * @returns the JSON object
  17749. */
  17750. serialize(): any;
  17751. /** @hidden */
  17752. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17753. /** @hidden */
  17754. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17755. /**
  17756. * Parses a JSON object to create a particle system.
  17757. * @param parsedParticleSystem The JSON object to parse
  17758. * @param scene The scene to create the particle system in
  17759. * @param rootUrl The root url to use to load external dependencies like texture
  17760. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17761. * @returns the Parsed particle system
  17762. */
  17763. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17764. }
  17765. }
  17766. declare module BABYLON {
  17767. /**
  17768. * A particle represents one of the element emitted by a particle system.
  17769. * This is mainly define by its coordinates, direction, velocity and age.
  17770. */
  17771. export class Particle {
  17772. /**
  17773. * The particle system the particle belongs to.
  17774. */
  17775. particleSystem: ParticleSystem;
  17776. private static _Count;
  17777. /**
  17778. * Unique ID of the particle
  17779. */
  17780. id: number;
  17781. /**
  17782. * The world position of the particle in the scene.
  17783. */
  17784. position: Vector3;
  17785. /**
  17786. * The world direction of the particle in the scene.
  17787. */
  17788. direction: Vector3;
  17789. /**
  17790. * The color of the particle.
  17791. */
  17792. color: Color4;
  17793. /**
  17794. * The color change of the particle per step.
  17795. */
  17796. colorStep: Color4;
  17797. /**
  17798. * Defines how long will the life of the particle be.
  17799. */
  17800. lifeTime: number;
  17801. /**
  17802. * The current age of the particle.
  17803. */
  17804. age: number;
  17805. /**
  17806. * The current size of the particle.
  17807. */
  17808. size: number;
  17809. /**
  17810. * The current scale of the particle.
  17811. */
  17812. scale: Vector2;
  17813. /**
  17814. * The current angle of the particle.
  17815. */
  17816. angle: number;
  17817. /**
  17818. * Defines how fast is the angle changing.
  17819. */
  17820. angularSpeed: number;
  17821. /**
  17822. * Defines the cell index used by the particle to be rendered from a sprite.
  17823. */
  17824. cellIndex: number;
  17825. /**
  17826. * The information required to support color remapping
  17827. */
  17828. remapData: Vector4;
  17829. /** @hidden */
  17830. _randomCellOffset?: number;
  17831. /** @hidden */
  17832. _initialDirection: Nullable<Vector3>;
  17833. /** @hidden */
  17834. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17835. /** @hidden */
  17836. _initialStartSpriteCellID: number;
  17837. /** @hidden */
  17838. _initialEndSpriteCellID: number;
  17839. /** @hidden */
  17840. _currentColorGradient: Nullable<ColorGradient>;
  17841. /** @hidden */
  17842. _currentColor1: Color4;
  17843. /** @hidden */
  17844. _currentColor2: Color4;
  17845. /** @hidden */
  17846. _currentSizeGradient: Nullable<FactorGradient>;
  17847. /** @hidden */
  17848. _currentSize1: number;
  17849. /** @hidden */
  17850. _currentSize2: number;
  17851. /** @hidden */
  17852. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17853. /** @hidden */
  17854. _currentAngularSpeed1: number;
  17855. /** @hidden */
  17856. _currentAngularSpeed2: number;
  17857. /** @hidden */
  17858. _currentVelocityGradient: Nullable<FactorGradient>;
  17859. /** @hidden */
  17860. _currentVelocity1: number;
  17861. /** @hidden */
  17862. _currentVelocity2: number;
  17863. /** @hidden */
  17864. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17865. /** @hidden */
  17866. _currentLimitVelocity1: number;
  17867. /** @hidden */
  17868. _currentLimitVelocity2: number;
  17869. /** @hidden */
  17870. _currentDragGradient: Nullable<FactorGradient>;
  17871. /** @hidden */
  17872. _currentDrag1: number;
  17873. /** @hidden */
  17874. _currentDrag2: number;
  17875. /** @hidden */
  17876. _randomNoiseCoordinates1: Vector3;
  17877. /** @hidden */
  17878. _randomNoiseCoordinates2: Vector3;
  17879. /**
  17880. * Creates a new instance Particle
  17881. * @param particleSystem the particle system the particle belongs to
  17882. */
  17883. constructor(
  17884. /**
  17885. * The particle system the particle belongs to.
  17886. */
  17887. particleSystem: ParticleSystem);
  17888. private updateCellInfoFromSystem;
  17889. /**
  17890. * Defines how the sprite cell index is updated for the particle
  17891. */
  17892. updateCellIndex(): void;
  17893. /** @hidden */
  17894. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17895. /** @hidden */
  17896. _inheritParticleInfoToSubEmitters(): void;
  17897. /** @hidden */
  17898. _reset(): void;
  17899. /**
  17900. * Copy the properties of particle to another one.
  17901. * @param other the particle to copy the information to.
  17902. */
  17903. copyTo(other: Particle): void;
  17904. }
  17905. }
  17906. declare module BABYLON {
  17907. /**
  17908. * Particle emitter represents a volume emitting particles.
  17909. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17910. */
  17911. export interface IParticleEmitterType {
  17912. /**
  17913. * Called by the particle System when the direction is computed for the created particle.
  17914. * @param worldMatrix is the world matrix of the particle system
  17915. * @param directionToUpdate is the direction vector to update with the result
  17916. * @param particle is the particle we are computed the direction for
  17917. */
  17918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17919. /**
  17920. * Called by the particle System when the position is computed for the created particle.
  17921. * @param worldMatrix is the world matrix of the particle system
  17922. * @param positionToUpdate is the position vector to update with the result
  17923. * @param particle is the particle we are computed the position for
  17924. */
  17925. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17926. /**
  17927. * Clones the current emitter and returns a copy of it
  17928. * @returns the new emitter
  17929. */
  17930. clone(): IParticleEmitterType;
  17931. /**
  17932. * Called by the GPUParticleSystem to setup the update shader
  17933. * @param effect defines the update shader
  17934. */
  17935. applyToShader(effect: Effect): void;
  17936. /**
  17937. * Returns a string to use to update the GPU particles update shader
  17938. * @returns the effect defines string
  17939. */
  17940. getEffectDefines(): string;
  17941. /**
  17942. * Returns a string representing the class name
  17943. * @returns a string containing the class name
  17944. */
  17945. getClassName(): string;
  17946. /**
  17947. * Serializes the particle system to a JSON object.
  17948. * @returns the JSON object
  17949. */
  17950. serialize(): any;
  17951. /**
  17952. * Parse properties from a JSON object
  17953. * @param serializationObject defines the JSON object
  17954. */
  17955. parse(serializationObject: any): void;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /**
  17960. * Particle emitter emitting particles from the inside of a box.
  17961. * It emits the particles randomly between 2 given directions.
  17962. */
  17963. export class BoxParticleEmitter implements IParticleEmitterType {
  17964. /**
  17965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17966. */
  17967. direction1: Vector3;
  17968. /**
  17969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17970. */
  17971. direction2: Vector3;
  17972. /**
  17973. * 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.
  17974. */
  17975. minEmitBox: Vector3;
  17976. /**
  17977. * 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.
  17978. */
  17979. maxEmitBox: Vector3;
  17980. /**
  17981. * Creates a new instance BoxParticleEmitter
  17982. */
  17983. constructor();
  17984. /**
  17985. * Called by the particle System when the direction is computed for the created particle.
  17986. * @param worldMatrix is the world matrix of the particle system
  17987. * @param directionToUpdate is the direction vector to update with the result
  17988. * @param particle is the particle we are computed the direction for
  17989. */
  17990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17991. /**
  17992. * Called by the particle System when the position is computed for the created particle.
  17993. * @param worldMatrix is the world matrix of the particle system
  17994. * @param positionToUpdate is the position vector to update with the result
  17995. * @param particle is the particle we are computed the position for
  17996. */
  17997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17998. /**
  17999. * Clones the current emitter and returns a copy of it
  18000. * @returns the new emitter
  18001. */
  18002. clone(): BoxParticleEmitter;
  18003. /**
  18004. * Called by the GPUParticleSystem to setup the update shader
  18005. * @param effect defines the update shader
  18006. */
  18007. applyToShader(effect: Effect): void;
  18008. /**
  18009. * Returns a string to use to update the GPU particles update shader
  18010. * @returns a string containng the defines string
  18011. */
  18012. getEffectDefines(): string;
  18013. /**
  18014. * Returns the string "BoxParticleEmitter"
  18015. * @returns a string containing the class name
  18016. */
  18017. getClassName(): string;
  18018. /**
  18019. * Serializes the particle system to a JSON object.
  18020. * @returns the JSON object
  18021. */
  18022. serialize(): any;
  18023. /**
  18024. * Parse properties from a JSON object
  18025. * @param serializationObject defines the JSON object
  18026. */
  18027. parse(serializationObject: any): void;
  18028. }
  18029. }
  18030. declare module BABYLON {
  18031. /**
  18032. * Particle emitter emitting particles from the inside of a cone.
  18033. * It emits the particles alongside the cone volume from the base to the particle.
  18034. * The emission direction might be randomized.
  18035. */
  18036. export class ConeParticleEmitter implements IParticleEmitterType {
  18037. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18038. directionRandomizer: number;
  18039. private _radius;
  18040. private _angle;
  18041. private _height;
  18042. /**
  18043. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18044. */
  18045. radiusRange: number;
  18046. /**
  18047. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18048. */
  18049. heightRange: number;
  18050. /**
  18051. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18052. */
  18053. emitFromSpawnPointOnly: boolean;
  18054. /**
  18055. * Gets or sets the radius of the emission cone
  18056. */
  18057. get radius(): number;
  18058. set radius(value: number);
  18059. /**
  18060. * Gets or sets the angle of the emission cone
  18061. */
  18062. get angle(): number;
  18063. set angle(value: number);
  18064. private _buildHeight;
  18065. /**
  18066. * Creates a new instance ConeParticleEmitter
  18067. * @param radius the radius of the emission cone (1 by default)
  18068. * @param angle the cone base angle (PI by default)
  18069. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18070. */
  18071. constructor(radius?: number, angle?: number,
  18072. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18073. directionRandomizer?: number);
  18074. /**
  18075. * Called by the particle System when the direction is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param directionToUpdate is the direction vector to update with the result
  18078. * @param particle is the particle we are computed the direction for
  18079. */
  18080. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Called by the particle System when the position is computed for the created particle.
  18083. * @param worldMatrix is the world matrix of the particle system
  18084. * @param positionToUpdate is the position vector to update with the result
  18085. * @param particle is the particle we are computed the position for
  18086. */
  18087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18088. /**
  18089. * Clones the current emitter and returns a copy of it
  18090. * @returns the new emitter
  18091. */
  18092. clone(): ConeParticleEmitter;
  18093. /**
  18094. * Called by the GPUParticleSystem to setup the update shader
  18095. * @param effect defines the update shader
  18096. */
  18097. applyToShader(effect: Effect): void;
  18098. /**
  18099. * Returns a string to use to update the GPU particles update shader
  18100. * @returns a string containng the defines string
  18101. */
  18102. getEffectDefines(): string;
  18103. /**
  18104. * Returns the string "ConeParticleEmitter"
  18105. * @returns a string containing the class name
  18106. */
  18107. getClassName(): string;
  18108. /**
  18109. * Serializes the particle system to a JSON object.
  18110. * @returns the JSON object
  18111. */
  18112. serialize(): any;
  18113. /**
  18114. * Parse properties from a JSON object
  18115. * @param serializationObject defines the JSON object
  18116. */
  18117. parse(serializationObject: any): void;
  18118. }
  18119. }
  18120. declare module BABYLON {
  18121. /**
  18122. * Particle emitter emitting particles from the inside of a cylinder.
  18123. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18124. */
  18125. export class CylinderParticleEmitter implements IParticleEmitterType {
  18126. /**
  18127. * The radius of the emission cylinder.
  18128. */
  18129. radius: number;
  18130. /**
  18131. * The height of the emission cylinder.
  18132. */
  18133. height: number;
  18134. /**
  18135. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18136. */
  18137. radiusRange: number;
  18138. /**
  18139. * How much to randomize the particle direction [0-1].
  18140. */
  18141. directionRandomizer: number;
  18142. /**
  18143. * Creates a new instance CylinderParticleEmitter
  18144. * @param radius the radius of the emission cylinder (1 by default)
  18145. * @param height the height of the emission cylinder (1 by default)
  18146. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18147. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18148. */
  18149. constructor(
  18150. /**
  18151. * The radius of the emission cylinder.
  18152. */
  18153. radius?: number,
  18154. /**
  18155. * The height of the emission cylinder.
  18156. */
  18157. height?: number,
  18158. /**
  18159. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18160. */
  18161. radiusRange?: number,
  18162. /**
  18163. * How much to randomize the particle direction [0-1].
  18164. */
  18165. directionRandomizer?: number);
  18166. /**
  18167. * Called by the particle System when the direction is computed for the created particle.
  18168. * @param worldMatrix is the world matrix of the particle system
  18169. * @param directionToUpdate is the direction vector to update with the result
  18170. * @param particle is the particle we are computed the direction for
  18171. */
  18172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18173. /**
  18174. * Called by the particle System when the position is computed for the created particle.
  18175. * @param worldMatrix is the world matrix of the particle system
  18176. * @param positionToUpdate is the position vector to update with the result
  18177. * @param particle is the particle we are computed the position for
  18178. */
  18179. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18180. /**
  18181. * Clones the current emitter and returns a copy of it
  18182. * @returns the new emitter
  18183. */
  18184. clone(): CylinderParticleEmitter;
  18185. /**
  18186. * Called by the GPUParticleSystem to setup the update shader
  18187. * @param effect defines the update shader
  18188. */
  18189. applyToShader(effect: Effect): void;
  18190. /**
  18191. * Returns a string to use to update the GPU particles update shader
  18192. * @returns a string containng the defines string
  18193. */
  18194. getEffectDefines(): string;
  18195. /**
  18196. * Returns the string "CylinderParticleEmitter"
  18197. * @returns a string containing the class name
  18198. */
  18199. getClassName(): string;
  18200. /**
  18201. * Serializes the particle system to a JSON object.
  18202. * @returns the JSON object
  18203. */
  18204. serialize(): any;
  18205. /**
  18206. * Parse properties from a JSON object
  18207. * @param serializationObject defines the JSON object
  18208. */
  18209. parse(serializationObject: any): void;
  18210. }
  18211. /**
  18212. * Particle emitter emitting particles from the inside of a cylinder.
  18213. * It emits the particles randomly between two vectors.
  18214. */
  18215. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18216. /**
  18217. * The min limit of the emission direction.
  18218. */
  18219. direction1: Vector3;
  18220. /**
  18221. * The max limit of the emission direction.
  18222. */
  18223. direction2: Vector3;
  18224. /**
  18225. * Creates a new instance CylinderDirectedParticleEmitter
  18226. * @param radius the radius of the emission cylinder (1 by default)
  18227. * @param height the height of the emission cylinder (1 by default)
  18228. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18229. * @param direction1 the min limit of the emission direction (up vector by default)
  18230. * @param direction2 the max limit of the emission direction (up vector by default)
  18231. */
  18232. constructor(radius?: number, height?: number, radiusRange?: number,
  18233. /**
  18234. * The min limit of the emission direction.
  18235. */
  18236. direction1?: Vector3,
  18237. /**
  18238. * The max limit of the emission direction.
  18239. */
  18240. direction2?: Vector3);
  18241. /**
  18242. * Called by the particle System when the direction is computed for the created particle.
  18243. * @param worldMatrix is the world matrix of the particle system
  18244. * @param directionToUpdate is the direction vector to update with the result
  18245. * @param particle is the particle we are computed the direction for
  18246. */
  18247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18248. /**
  18249. * Clones the current emitter and returns a copy of it
  18250. * @returns the new emitter
  18251. */
  18252. clone(): CylinderDirectedParticleEmitter;
  18253. /**
  18254. * Called by the GPUParticleSystem to setup the update shader
  18255. * @param effect defines the update shader
  18256. */
  18257. applyToShader(effect: Effect): void;
  18258. /**
  18259. * Returns a string to use to update the GPU particles update shader
  18260. * @returns a string containng the defines string
  18261. */
  18262. getEffectDefines(): string;
  18263. /**
  18264. * Returns the string "CylinderDirectedParticleEmitter"
  18265. * @returns a string containing the class name
  18266. */
  18267. getClassName(): string;
  18268. /**
  18269. * Serializes the particle system to a JSON object.
  18270. * @returns the JSON object
  18271. */
  18272. serialize(): any;
  18273. /**
  18274. * Parse properties from a JSON object
  18275. * @param serializationObject defines the JSON object
  18276. */
  18277. parse(serializationObject: any): void;
  18278. }
  18279. }
  18280. declare module BABYLON {
  18281. /**
  18282. * Particle emitter emitting particles from the inside of a hemisphere.
  18283. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18284. */
  18285. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18286. /**
  18287. * The radius of the emission hemisphere.
  18288. */
  18289. radius: number;
  18290. /**
  18291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18292. */
  18293. radiusRange: number;
  18294. /**
  18295. * How much to randomize the particle direction [0-1].
  18296. */
  18297. directionRandomizer: number;
  18298. /**
  18299. * Creates a new instance HemisphericParticleEmitter
  18300. * @param radius the radius of the emission hemisphere (1 by default)
  18301. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18303. */
  18304. constructor(
  18305. /**
  18306. * The radius of the emission hemisphere.
  18307. */
  18308. radius?: number,
  18309. /**
  18310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18311. */
  18312. radiusRange?: number,
  18313. /**
  18314. * How much to randomize the particle direction [0-1].
  18315. */
  18316. directionRandomizer?: number);
  18317. /**
  18318. * Called by the particle System when the direction is computed for the created particle.
  18319. * @param worldMatrix is the world matrix of the particle system
  18320. * @param directionToUpdate is the direction vector to update with the result
  18321. * @param particle is the particle we are computed the direction for
  18322. */
  18323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18324. /**
  18325. * Called by the particle System when the position is computed for the created particle.
  18326. * @param worldMatrix is the world matrix of the particle system
  18327. * @param positionToUpdate is the position vector to update with the result
  18328. * @param particle is the particle we are computed the position for
  18329. */
  18330. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18331. /**
  18332. * Clones the current emitter and returns a copy of it
  18333. * @returns the new emitter
  18334. */
  18335. clone(): HemisphericParticleEmitter;
  18336. /**
  18337. * Called by the GPUParticleSystem to setup the update shader
  18338. * @param effect defines the update shader
  18339. */
  18340. applyToShader(effect: Effect): void;
  18341. /**
  18342. * Returns a string to use to update the GPU particles update shader
  18343. * @returns a string containng the defines string
  18344. */
  18345. getEffectDefines(): string;
  18346. /**
  18347. * Returns the string "HemisphericParticleEmitter"
  18348. * @returns a string containing the class name
  18349. */
  18350. getClassName(): string;
  18351. /**
  18352. * Serializes the particle system to a JSON object.
  18353. * @returns the JSON object
  18354. */
  18355. serialize(): any;
  18356. /**
  18357. * Parse properties from a JSON object
  18358. * @param serializationObject defines the JSON object
  18359. */
  18360. parse(serializationObject: any): void;
  18361. }
  18362. }
  18363. declare module BABYLON {
  18364. /**
  18365. * Particle emitter emitting particles from a point.
  18366. * It emits the particles randomly between 2 given directions.
  18367. */
  18368. export class PointParticleEmitter implements IParticleEmitterType {
  18369. /**
  18370. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18371. */
  18372. direction1: Vector3;
  18373. /**
  18374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18375. */
  18376. direction2: Vector3;
  18377. /**
  18378. * Creates a new instance PointParticleEmitter
  18379. */
  18380. constructor();
  18381. /**
  18382. * Called by the particle System when the direction is computed for the created particle.
  18383. * @param worldMatrix is the world matrix of the particle system
  18384. * @param directionToUpdate is the direction vector to update with the result
  18385. * @param particle is the particle we are computed the direction for
  18386. */
  18387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18388. /**
  18389. * Called by the particle System when the position is computed for the created particle.
  18390. * @param worldMatrix is the world matrix of the particle system
  18391. * @param positionToUpdate is the position vector to update with the result
  18392. * @param particle is the particle we are computed the position for
  18393. */
  18394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18395. /**
  18396. * Clones the current emitter and returns a copy of it
  18397. * @returns the new emitter
  18398. */
  18399. clone(): PointParticleEmitter;
  18400. /**
  18401. * Called by the GPUParticleSystem to setup the update shader
  18402. * @param effect defines the update shader
  18403. */
  18404. applyToShader(effect: Effect): void;
  18405. /**
  18406. * Returns a string to use to update the GPU particles update shader
  18407. * @returns a string containng the defines string
  18408. */
  18409. getEffectDefines(): string;
  18410. /**
  18411. * Returns the string "PointParticleEmitter"
  18412. * @returns a string containing the class name
  18413. */
  18414. getClassName(): string;
  18415. /**
  18416. * Serializes the particle system to a JSON object.
  18417. * @returns the JSON object
  18418. */
  18419. serialize(): any;
  18420. /**
  18421. * Parse properties from a JSON object
  18422. * @param serializationObject defines the JSON object
  18423. */
  18424. parse(serializationObject: any): void;
  18425. }
  18426. }
  18427. declare module BABYLON {
  18428. /**
  18429. * Particle emitter emitting particles from the inside of a sphere.
  18430. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18431. */
  18432. export class SphereParticleEmitter implements IParticleEmitterType {
  18433. /**
  18434. * The radius of the emission sphere.
  18435. */
  18436. radius: number;
  18437. /**
  18438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18439. */
  18440. radiusRange: number;
  18441. /**
  18442. * How much to randomize the particle direction [0-1].
  18443. */
  18444. directionRandomizer: number;
  18445. /**
  18446. * Creates a new instance SphereParticleEmitter
  18447. * @param radius the radius of the emission sphere (1 by default)
  18448. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18449. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18450. */
  18451. constructor(
  18452. /**
  18453. * The radius of the emission sphere.
  18454. */
  18455. radius?: number,
  18456. /**
  18457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18458. */
  18459. radiusRange?: number,
  18460. /**
  18461. * How much to randomize the particle direction [0-1].
  18462. */
  18463. directionRandomizer?: number);
  18464. /**
  18465. * Called by the particle System when the direction is computed for the created particle.
  18466. * @param worldMatrix is the world matrix of the particle system
  18467. * @param directionToUpdate is the direction vector to update with the result
  18468. * @param particle is the particle we are computed the direction for
  18469. */
  18470. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18471. /**
  18472. * Called by the particle System when the position is computed for the created particle.
  18473. * @param worldMatrix is the world matrix of the particle system
  18474. * @param positionToUpdate is the position vector to update with the result
  18475. * @param particle is the particle we are computed the position for
  18476. */
  18477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18478. /**
  18479. * Clones the current emitter and returns a copy of it
  18480. * @returns the new emitter
  18481. */
  18482. clone(): SphereParticleEmitter;
  18483. /**
  18484. * Called by the GPUParticleSystem to setup the update shader
  18485. * @param effect defines the update shader
  18486. */
  18487. applyToShader(effect: Effect): void;
  18488. /**
  18489. * Returns a string to use to update the GPU particles update shader
  18490. * @returns a string containng the defines string
  18491. */
  18492. getEffectDefines(): string;
  18493. /**
  18494. * Returns the string "SphereParticleEmitter"
  18495. * @returns a string containing the class name
  18496. */
  18497. getClassName(): string;
  18498. /**
  18499. * Serializes the particle system to a JSON object.
  18500. * @returns the JSON object
  18501. */
  18502. serialize(): any;
  18503. /**
  18504. * Parse properties from a JSON object
  18505. * @param serializationObject defines the JSON object
  18506. */
  18507. parse(serializationObject: any): void;
  18508. }
  18509. /**
  18510. * Particle emitter emitting particles from the inside of a sphere.
  18511. * It emits the particles randomly between two vectors.
  18512. */
  18513. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18514. /**
  18515. * The min limit of the emission direction.
  18516. */
  18517. direction1: Vector3;
  18518. /**
  18519. * The max limit of the emission direction.
  18520. */
  18521. direction2: Vector3;
  18522. /**
  18523. * Creates a new instance SphereDirectedParticleEmitter
  18524. * @param radius the radius of the emission sphere (1 by default)
  18525. * @param direction1 the min limit of the emission direction (up vector by default)
  18526. * @param direction2 the max limit of the emission direction (up vector by default)
  18527. */
  18528. constructor(radius?: number,
  18529. /**
  18530. * The min limit of the emission direction.
  18531. */
  18532. direction1?: Vector3,
  18533. /**
  18534. * The max limit of the emission direction.
  18535. */
  18536. direction2?: Vector3);
  18537. /**
  18538. * Called by the particle System when the direction is computed for the created particle.
  18539. * @param worldMatrix is the world matrix of the particle system
  18540. * @param directionToUpdate is the direction vector to update with the result
  18541. * @param particle is the particle we are computed the direction for
  18542. */
  18543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18544. /**
  18545. * Clones the current emitter and returns a copy of it
  18546. * @returns the new emitter
  18547. */
  18548. clone(): SphereDirectedParticleEmitter;
  18549. /**
  18550. * Called by the GPUParticleSystem to setup the update shader
  18551. * @param effect defines the update shader
  18552. */
  18553. applyToShader(effect: Effect): void;
  18554. /**
  18555. * Returns a string to use to update the GPU particles update shader
  18556. * @returns a string containng the defines string
  18557. */
  18558. getEffectDefines(): string;
  18559. /**
  18560. * Returns the string "SphereDirectedParticleEmitter"
  18561. * @returns a string containing the class name
  18562. */
  18563. getClassName(): string;
  18564. /**
  18565. * Serializes the particle system to a JSON object.
  18566. * @returns the JSON object
  18567. */
  18568. serialize(): any;
  18569. /**
  18570. * Parse properties from a JSON object
  18571. * @param serializationObject defines the JSON object
  18572. */
  18573. parse(serializationObject: any): void;
  18574. }
  18575. }
  18576. declare module BABYLON {
  18577. /**
  18578. * Particle emitter emitting particles from a custom list of positions.
  18579. */
  18580. export class CustomParticleEmitter implements IParticleEmitterType {
  18581. /**
  18582. * Gets or sets the position generator that will create the inital position of each particle.
  18583. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18584. */
  18585. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  18586. /**
  18587. * Gets or sets the destination generator that will create the final destination of each particle.
  18588. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18589. */
  18590. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  18591. /**
  18592. * Creates a new instance CustomParticleEmitter
  18593. */
  18594. constructor();
  18595. /**
  18596. * Called by the particle System when the direction is computed for the created particle.
  18597. * @param worldMatrix is the world matrix of the particle system
  18598. * @param directionToUpdate is the direction vector to update with the result
  18599. * @param particle is the particle we are computed the direction for
  18600. */
  18601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18602. /**
  18603. * Called by the particle System when the position is computed for the created particle.
  18604. * @param worldMatrix is the world matrix of the particle system
  18605. * @param positionToUpdate is the position vector to update with the result
  18606. * @param particle is the particle we are computed the position for
  18607. */
  18608. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18609. /**
  18610. * Clones the current emitter and returns a copy of it
  18611. * @returns the new emitter
  18612. */
  18613. clone(): CustomParticleEmitter;
  18614. /**
  18615. * Called by the GPUParticleSystem to setup the update shader
  18616. * @param effect defines the update shader
  18617. */
  18618. applyToShader(effect: Effect): void;
  18619. /**
  18620. * Returns a string to use to update the GPU particles update shader
  18621. * @returns a string containng the defines string
  18622. */
  18623. getEffectDefines(): string;
  18624. /**
  18625. * Returns the string "PointParticleEmitter"
  18626. * @returns a string containing the class name
  18627. */
  18628. getClassName(): string;
  18629. /**
  18630. * Serializes the particle system to a JSON object.
  18631. * @returns the JSON object
  18632. */
  18633. serialize(): any;
  18634. /**
  18635. * Parse properties from a JSON object
  18636. * @param serializationObject defines the JSON object
  18637. */
  18638. parse(serializationObject: any): void;
  18639. }
  18640. }
  18641. declare module BABYLON {
  18642. /**
  18643. * Interface representing a particle system in Babylon.js.
  18644. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18645. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18646. */
  18647. export interface IParticleSystem {
  18648. /**
  18649. * List of animations used by the particle system.
  18650. */
  18651. animations: Animation[];
  18652. /**
  18653. * The id of the Particle system.
  18654. */
  18655. id: string;
  18656. /**
  18657. * The name of the Particle system.
  18658. */
  18659. name: string;
  18660. /**
  18661. * The emitter represents the Mesh or position we are attaching the particle system to.
  18662. */
  18663. emitter: Nullable<AbstractMesh | Vector3>;
  18664. /**
  18665. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18666. */
  18667. isBillboardBased: boolean;
  18668. /**
  18669. * The rendering group used by the Particle system to chose when to render.
  18670. */
  18671. renderingGroupId: number;
  18672. /**
  18673. * The layer mask we are rendering the particles through.
  18674. */
  18675. layerMask: number;
  18676. /**
  18677. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18678. */
  18679. updateSpeed: number;
  18680. /**
  18681. * The amount of time the particle system is running (depends of the overall update speed).
  18682. */
  18683. targetStopDuration: number;
  18684. /**
  18685. * The texture used to render each particle. (this can be a spritesheet)
  18686. */
  18687. particleTexture: Nullable<Texture>;
  18688. /**
  18689. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18690. */
  18691. blendMode: number;
  18692. /**
  18693. * Minimum life time of emitting particles.
  18694. */
  18695. minLifeTime: number;
  18696. /**
  18697. * Maximum life time of emitting particles.
  18698. */
  18699. maxLifeTime: number;
  18700. /**
  18701. * Minimum Size of emitting particles.
  18702. */
  18703. minSize: number;
  18704. /**
  18705. * Maximum Size of emitting particles.
  18706. */
  18707. maxSize: number;
  18708. /**
  18709. * Minimum scale of emitting particles on X axis.
  18710. */
  18711. minScaleX: number;
  18712. /**
  18713. * Maximum scale of emitting particles on X axis.
  18714. */
  18715. maxScaleX: number;
  18716. /**
  18717. * Minimum scale of emitting particles on Y axis.
  18718. */
  18719. minScaleY: number;
  18720. /**
  18721. * Maximum scale of emitting particles on Y axis.
  18722. */
  18723. maxScaleY: number;
  18724. /**
  18725. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18726. */
  18727. color1: Color4;
  18728. /**
  18729. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18730. */
  18731. color2: Color4;
  18732. /**
  18733. * Color the particle will have at the end of its lifetime.
  18734. */
  18735. colorDead: Color4;
  18736. /**
  18737. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18738. */
  18739. emitRate: number;
  18740. /**
  18741. * You can use gravity if you want to give an orientation to your particles.
  18742. */
  18743. gravity: Vector3;
  18744. /**
  18745. * Minimum power of emitting particles.
  18746. */
  18747. minEmitPower: number;
  18748. /**
  18749. * Maximum power of emitting particles.
  18750. */
  18751. maxEmitPower: number;
  18752. /**
  18753. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18754. */
  18755. minAngularSpeed: number;
  18756. /**
  18757. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18758. */
  18759. maxAngularSpeed: number;
  18760. /**
  18761. * Gets or sets the minimal initial rotation in radians.
  18762. */
  18763. minInitialRotation: number;
  18764. /**
  18765. * Gets or sets the maximal initial rotation in radians.
  18766. */
  18767. maxInitialRotation: number;
  18768. /**
  18769. * The particle emitter type defines the emitter used by the particle system.
  18770. * It can be for example box, sphere, or cone...
  18771. */
  18772. particleEmitterType: Nullable<IParticleEmitterType>;
  18773. /**
  18774. * Defines the delay in milliseconds before starting the system (0 by default)
  18775. */
  18776. startDelay: number;
  18777. /**
  18778. * 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
  18779. */
  18780. preWarmCycles: number;
  18781. /**
  18782. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18783. */
  18784. preWarmStepOffset: number;
  18785. /**
  18786. * 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)
  18787. */
  18788. spriteCellChangeSpeed: number;
  18789. /**
  18790. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18791. */
  18792. startSpriteCellID: number;
  18793. /**
  18794. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18795. */
  18796. endSpriteCellID: number;
  18797. /**
  18798. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18799. */
  18800. spriteCellWidth: number;
  18801. /**
  18802. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18803. */
  18804. spriteCellHeight: number;
  18805. /**
  18806. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18807. */
  18808. spriteRandomStartCell: boolean;
  18809. /**
  18810. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18811. */
  18812. isAnimationSheetEnabled: boolean;
  18813. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18814. translationPivot: Vector2;
  18815. /**
  18816. * Gets or sets a texture used to add random noise to particle positions
  18817. */
  18818. noiseTexture: Nullable<BaseTexture>;
  18819. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18820. noiseStrength: Vector3;
  18821. /**
  18822. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18823. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18824. */
  18825. billboardMode: number;
  18826. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18827. limitVelocityDamping: number;
  18828. /**
  18829. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18830. */
  18831. beginAnimationOnStart: boolean;
  18832. /**
  18833. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18834. */
  18835. beginAnimationFrom: number;
  18836. /**
  18837. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18838. */
  18839. beginAnimationTo: number;
  18840. /**
  18841. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18842. */
  18843. beginAnimationLoop: boolean;
  18844. /**
  18845. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18846. */
  18847. disposeOnStop: boolean;
  18848. /**
  18849. * Gets the maximum number of particles active at the same time.
  18850. * @returns The max number of active particles.
  18851. */
  18852. getCapacity(): number;
  18853. /**
  18854. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18855. * @returns True if it has been started, otherwise false.
  18856. */
  18857. isStarted(): boolean;
  18858. /**
  18859. * Animates the particle system for this frame.
  18860. */
  18861. animate(): void;
  18862. /**
  18863. * Renders the particle system in its current state.
  18864. * @returns the current number of particles
  18865. */
  18866. render(): number;
  18867. /**
  18868. * Dispose the particle system and frees its associated resources.
  18869. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18870. */
  18871. dispose(disposeTexture?: boolean): void;
  18872. /**
  18873. * Clones the particle system.
  18874. * @param name The name of the cloned object
  18875. * @param newEmitter The new emitter to use
  18876. * @returns the cloned particle system
  18877. */
  18878. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18879. /**
  18880. * Serializes the particle system to a JSON object.
  18881. * @returns the JSON object
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Rebuild the particle system
  18886. */
  18887. rebuild(): void;
  18888. /**
  18889. * Starts the particle system and begins to emit
  18890. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18891. */
  18892. start(delay?: number): void;
  18893. /**
  18894. * Stops the particle system.
  18895. */
  18896. stop(): void;
  18897. /**
  18898. * Remove all active particles
  18899. */
  18900. reset(): void;
  18901. /**
  18902. * Is this system ready to be used/rendered
  18903. * @return true if the system is ready
  18904. */
  18905. isReady(): boolean;
  18906. /**
  18907. * Adds a new color gradient
  18908. * @param gradient defines the gradient to use (between 0 and 1)
  18909. * @param color1 defines the color to affect to the specified gradient
  18910. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18911. * @returns the current particle system
  18912. */
  18913. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18914. /**
  18915. * Remove a specific color gradient
  18916. * @param gradient defines the gradient to remove
  18917. * @returns the current particle system
  18918. */
  18919. removeColorGradient(gradient: number): IParticleSystem;
  18920. /**
  18921. * Adds a new size gradient
  18922. * @param gradient defines the gradient to use (between 0 and 1)
  18923. * @param factor defines the size factor to affect to the specified gradient
  18924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18925. * @returns the current particle system
  18926. */
  18927. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18928. /**
  18929. * Remove a specific size gradient
  18930. * @param gradient defines the gradient to remove
  18931. * @returns the current particle system
  18932. */
  18933. removeSizeGradient(gradient: number): IParticleSystem;
  18934. /**
  18935. * Gets the current list of color gradients.
  18936. * You must use addColorGradient and removeColorGradient to udpate this list
  18937. * @returns the list of color gradients
  18938. */
  18939. getColorGradients(): Nullable<Array<ColorGradient>>;
  18940. /**
  18941. * Gets the current list of size gradients.
  18942. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18943. * @returns the list of size gradients
  18944. */
  18945. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18946. /**
  18947. * Gets the current list of angular speed gradients.
  18948. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18949. * @returns the list of angular speed gradients
  18950. */
  18951. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18952. /**
  18953. * Adds a new angular speed gradient
  18954. * @param gradient defines the gradient to use (between 0 and 1)
  18955. * @param factor defines the angular speed to affect to the specified gradient
  18956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18957. * @returns the current particle system
  18958. */
  18959. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18960. /**
  18961. * Remove a specific angular speed gradient
  18962. * @param gradient defines the gradient to remove
  18963. * @returns the current particle system
  18964. */
  18965. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18966. /**
  18967. * Gets the current list of velocity gradients.
  18968. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18969. * @returns the list of velocity gradients
  18970. */
  18971. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18972. /**
  18973. * Adds a new velocity gradient
  18974. * @param gradient defines the gradient to use (between 0 and 1)
  18975. * @param factor defines the velocity to affect to the specified gradient
  18976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18977. * @returns the current particle system
  18978. */
  18979. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18980. /**
  18981. * Remove a specific velocity gradient
  18982. * @param gradient defines the gradient to remove
  18983. * @returns the current particle system
  18984. */
  18985. removeVelocityGradient(gradient: number): IParticleSystem;
  18986. /**
  18987. * Gets the current list of limit velocity gradients.
  18988. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18989. * @returns the list of limit velocity gradients
  18990. */
  18991. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18992. /**
  18993. * Adds a new limit velocity gradient
  18994. * @param gradient defines the gradient to use (between 0 and 1)
  18995. * @param factor defines the limit velocity to affect to the specified gradient
  18996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18997. * @returns the current particle system
  18998. */
  18999. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19000. /**
  19001. * Remove a specific limit velocity gradient
  19002. * @param gradient defines the gradient to remove
  19003. * @returns the current particle system
  19004. */
  19005. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19006. /**
  19007. * Adds a new drag gradient
  19008. * @param gradient defines the gradient to use (between 0 and 1)
  19009. * @param factor defines the drag to affect to the specified gradient
  19010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19011. * @returns the current particle system
  19012. */
  19013. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19014. /**
  19015. * Remove a specific drag gradient
  19016. * @param gradient defines the gradient to remove
  19017. * @returns the current particle system
  19018. */
  19019. removeDragGradient(gradient: number): IParticleSystem;
  19020. /**
  19021. * Gets the current list of drag gradients.
  19022. * You must use addDragGradient and removeDragGradient to udpate this list
  19023. * @returns the list of drag gradients
  19024. */
  19025. getDragGradients(): Nullable<Array<FactorGradient>>;
  19026. /**
  19027. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19028. * @param gradient defines the gradient to use (between 0 and 1)
  19029. * @param factor defines the emit rate to affect to the specified gradient
  19030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19031. * @returns the current particle system
  19032. */
  19033. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19034. /**
  19035. * Remove a specific emit rate gradient
  19036. * @param gradient defines the gradient to remove
  19037. * @returns the current particle system
  19038. */
  19039. removeEmitRateGradient(gradient: number): IParticleSystem;
  19040. /**
  19041. * Gets the current list of emit rate gradients.
  19042. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19043. * @returns the list of emit rate gradients
  19044. */
  19045. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19046. /**
  19047. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19048. * @param gradient defines the gradient to use (between 0 and 1)
  19049. * @param factor defines the start size to affect to the specified gradient
  19050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19051. * @returns the current particle system
  19052. */
  19053. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19054. /**
  19055. * Remove a specific start size gradient
  19056. * @param gradient defines the gradient to remove
  19057. * @returns the current particle system
  19058. */
  19059. removeStartSizeGradient(gradient: number): IParticleSystem;
  19060. /**
  19061. * Gets the current list of start size gradients.
  19062. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19063. * @returns the list of start size gradients
  19064. */
  19065. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19066. /**
  19067. * Adds a new life time gradient
  19068. * @param gradient defines the gradient to use (between 0 and 1)
  19069. * @param factor defines the life time factor to affect to the specified gradient
  19070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19071. * @returns the current particle system
  19072. */
  19073. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19074. /**
  19075. * Remove a specific life time gradient
  19076. * @param gradient defines the gradient to remove
  19077. * @returns the current particle system
  19078. */
  19079. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of life time gradients.
  19082. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19083. * @returns the list of life time gradients
  19084. */
  19085. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Gets the current list of color gradients.
  19088. * You must use addColorGradient and removeColorGradient to udpate this list
  19089. * @returns the list of color gradients
  19090. */
  19091. getColorGradients(): Nullable<Array<ColorGradient>>;
  19092. /**
  19093. * Adds a new ramp gradient used to remap particle colors
  19094. * @param gradient defines the gradient to use (between 0 and 1)
  19095. * @param color defines the color to affect to the specified gradient
  19096. * @returns the current particle system
  19097. */
  19098. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19099. /**
  19100. * Gets the current list of ramp gradients.
  19101. * You must use addRampGradient and removeRampGradient to udpate this list
  19102. * @returns the list of ramp gradients
  19103. */
  19104. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19105. /** Gets or sets a boolean indicating that ramp gradients must be used
  19106. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19107. */
  19108. useRampGradients: boolean;
  19109. /**
  19110. * Adds a new color remap gradient
  19111. * @param gradient defines the gradient to use (between 0 and 1)
  19112. * @param min defines the color remap minimal range
  19113. * @param max defines the color remap maximal range
  19114. * @returns the current particle system
  19115. */
  19116. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19117. /**
  19118. * Gets the current list of color remap gradients.
  19119. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19120. * @returns the list of color remap gradients
  19121. */
  19122. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19123. /**
  19124. * Adds a new alpha remap gradient
  19125. * @param gradient defines the gradient to use (between 0 and 1)
  19126. * @param min defines the alpha remap minimal range
  19127. * @param max defines the alpha remap maximal range
  19128. * @returns the current particle system
  19129. */
  19130. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19131. /**
  19132. * Gets the current list of alpha remap gradients.
  19133. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19134. * @returns the list of alpha remap gradients
  19135. */
  19136. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19137. /**
  19138. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19139. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19140. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19141. * @returns the emitter
  19142. */
  19143. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19144. /**
  19145. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19146. * @param radius The radius of the hemisphere to emit from
  19147. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19148. * @returns the emitter
  19149. */
  19150. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19151. /**
  19152. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19153. * @param radius The radius of the sphere to emit from
  19154. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19155. * @returns the emitter
  19156. */
  19157. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19158. /**
  19159. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19160. * @param radius The radius of the sphere to emit from
  19161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19163. * @returns the emitter
  19164. */
  19165. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19166. /**
  19167. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19168. * @param radius The radius of the emission cylinder
  19169. * @param height The height of the emission cylinder
  19170. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19171. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19172. * @returns the emitter
  19173. */
  19174. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19175. /**
  19176. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19177. * @param radius The radius of the cylinder to emit from
  19178. * @param height The height of the emission cylinder
  19179. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19182. * @returns the emitter
  19183. */
  19184. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19185. /**
  19186. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19187. * @param radius The radius of the cone to emit from
  19188. * @param angle The base angle of the cone
  19189. * @returns the emitter
  19190. */
  19191. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19192. /**
  19193. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19196. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19197. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19198. * @returns the emitter
  19199. */
  19200. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19201. /**
  19202. * Get hosting scene
  19203. * @returns the scene
  19204. */
  19205. getScene(): Scene;
  19206. }
  19207. }
  19208. declare module BABYLON {
  19209. /**
  19210. * Creates an instance based on a source mesh.
  19211. */
  19212. export class InstancedMesh extends AbstractMesh {
  19213. private _sourceMesh;
  19214. private _currentLOD;
  19215. /** @hidden */
  19216. _indexInSourceMeshInstanceArray: number;
  19217. constructor(name: string, source: Mesh);
  19218. /**
  19219. * Returns the string "InstancedMesh".
  19220. */
  19221. getClassName(): string;
  19222. /** Gets the list of lights affecting that mesh */
  19223. get lightSources(): Light[];
  19224. _resyncLightSources(): void;
  19225. _resyncLightSource(light: Light): void;
  19226. _removeLightSource(light: Light, dispose: boolean): void;
  19227. /**
  19228. * If the source mesh receives shadows
  19229. */
  19230. get receiveShadows(): boolean;
  19231. /**
  19232. * The material of the source mesh
  19233. */
  19234. get material(): Nullable<Material>;
  19235. /**
  19236. * Visibility of the source mesh
  19237. */
  19238. get visibility(): number;
  19239. /**
  19240. * Skeleton of the source mesh
  19241. */
  19242. get skeleton(): Nullable<Skeleton>;
  19243. /**
  19244. * Rendering ground id of the source mesh
  19245. */
  19246. get renderingGroupId(): number;
  19247. set renderingGroupId(value: number);
  19248. /**
  19249. * Returns the total number of vertices (integer).
  19250. */
  19251. getTotalVertices(): number;
  19252. /**
  19253. * Returns a positive integer : the total number of indices in this mesh geometry.
  19254. * @returns the numner of indices or zero if the mesh has no geometry.
  19255. */
  19256. getTotalIndices(): number;
  19257. /**
  19258. * The source mesh of the instance
  19259. */
  19260. get sourceMesh(): Mesh;
  19261. /**
  19262. * Is this node ready to be used/rendered
  19263. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19264. * @return {boolean} is it ready
  19265. */
  19266. isReady(completeCheck?: boolean): boolean;
  19267. /**
  19268. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19269. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19270. * @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.
  19271. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19272. */
  19273. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19274. /**
  19275. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19276. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19277. * The `data` are either a numeric array either a Float32Array.
  19278. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19279. * 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).
  19280. * Note that a new underlying VertexBuffer object is created each call.
  19281. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19282. *
  19283. * Possible `kind` values :
  19284. * - VertexBuffer.PositionKind
  19285. * - VertexBuffer.UVKind
  19286. * - VertexBuffer.UV2Kind
  19287. * - VertexBuffer.UV3Kind
  19288. * - VertexBuffer.UV4Kind
  19289. * - VertexBuffer.UV5Kind
  19290. * - VertexBuffer.UV6Kind
  19291. * - VertexBuffer.ColorKind
  19292. * - VertexBuffer.MatricesIndicesKind
  19293. * - VertexBuffer.MatricesIndicesExtraKind
  19294. * - VertexBuffer.MatricesWeightsKind
  19295. * - VertexBuffer.MatricesWeightsExtraKind
  19296. *
  19297. * Returns the Mesh.
  19298. */
  19299. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19300. /**
  19301. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19302. * If the mesh has no geometry, it is simply returned as it is.
  19303. * The `data` are either a numeric array either a Float32Array.
  19304. * No new underlying VertexBuffer object is created.
  19305. * 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.
  19306. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19307. *
  19308. * Possible `kind` values :
  19309. * - VertexBuffer.PositionKind
  19310. * - VertexBuffer.UVKind
  19311. * - VertexBuffer.UV2Kind
  19312. * - VertexBuffer.UV3Kind
  19313. * - VertexBuffer.UV4Kind
  19314. * - VertexBuffer.UV5Kind
  19315. * - VertexBuffer.UV6Kind
  19316. * - VertexBuffer.ColorKind
  19317. * - VertexBuffer.MatricesIndicesKind
  19318. * - VertexBuffer.MatricesIndicesExtraKind
  19319. * - VertexBuffer.MatricesWeightsKind
  19320. * - VertexBuffer.MatricesWeightsExtraKind
  19321. *
  19322. * Returns the Mesh.
  19323. */
  19324. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19325. /**
  19326. * Sets the mesh indices.
  19327. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19328. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19329. * This method creates a new index buffer each call.
  19330. * Returns the Mesh.
  19331. */
  19332. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19333. /**
  19334. * Boolean : True if the mesh owns the requested kind of data.
  19335. */
  19336. isVerticesDataPresent(kind: string): boolean;
  19337. /**
  19338. * Returns an array of indices (IndicesArray).
  19339. */
  19340. getIndices(): Nullable<IndicesArray>;
  19341. get _positions(): Nullable<Vector3[]>;
  19342. /**
  19343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19344. * This means the mesh underlying bounding box and sphere are recomputed.
  19345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19346. * @returns the current mesh
  19347. */
  19348. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19349. /** @hidden */
  19350. _preActivate(): InstancedMesh;
  19351. /** @hidden */
  19352. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19353. /** @hidden */
  19354. _postActivate(): void;
  19355. getWorldMatrix(): Matrix;
  19356. get isAnInstance(): boolean;
  19357. /**
  19358. * Returns the current associated LOD AbstractMesh.
  19359. */
  19360. getLOD(camera: Camera): AbstractMesh;
  19361. /** @hidden */
  19362. _syncSubMeshes(): InstancedMesh;
  19363. /** @hidden */
  19364. _generatePointsArray(): boolean;
  19365. /**
  19366. * Creates a new InstancedMesh from the current mesh.
  19367. * - name (string) : the cloned mesh name
  19368. * - newParent (optional Node) : the optional Node to parent the clone to.
  19369. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19370. *
  19371. * Returns the clone.
  19372. */
  19373. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19374. /**
  19375. * Disposes the InstancedMesh.
  19376. * Returns nothing.
  19377. */
  19378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19379. }
  19380. interface Mesh {
  19381. /**
  19382. * Register a custom buffer that will be instanced
  19383. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19384. * @param kind defines the buffer kind
  19385. * @param stride defines the stride in floats
  19386. */
  19387. registerInstancedBuffer(kind: string, stride: number): void;
  19388. /** @hidden */
  19389. _userInstancedBuffersStorage: {
  19390. data: {
  19391. [key: string]: Float32Array;
  19392. };
  19393. sizes: {
  19394. [key: string]: number;
  19395. };
  19396. vertexBuffers: {
  19397. [key: string]: Nullable<VertexBuffer>;
  19398. };
  19399. strides: {
  19400. [key: string]: number;
  19401. };
  19402. };
  19403. }
  19404. interface AbstractMesh {
  19405. /**
  19406. * Object used to store instanced buffers defined by user
  19407. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19408. */
  19409. instancedBuffers: {
  19410. [key: string]: any;
  19411. };
  19412. }
  19413. }
  19414. declare module BABYLON {
  19415. /**
  19416. * Defines the options associated with the creation of a shader material.
  19417. */
  19418. export interface IShaderMaterialOptions {
  19419. /**
  19420. * Does the material work in alpha blend mode
  19421. */
  19422. needAlphaBlending: boolean;
  19423. /**
  19424. * Does the material work in alpha test mode
  19425. */
  19426. needAlphaTesting: boolean;
  19427. /**
  19428. * The list of attribute names used in the shader
  19429. */
  19430. attributes: string[];
  19431. /**
  19432. * The list of unifrom names used in the shader
  19433. */
  19434. uniforms: string[];
  19435. /**
  19436. * The list of UBO names used in the shader
  19437. */
  19438. uniformBuffers: string[];
  19439. /**
  19440. * The list of sampler names used in the shader
  19441. */
  19442. samplers: string[];
  19443. /**
  19444. * The list of defines used in the shader
  19445. */
  19446. defines: string[];
  19447. }
  19448. /**
  19449. * 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.
  19450. *
  19451. * This returned material effects how the mesh will look based on the code in the shaders.
  19452. *
  19453. * @see http://doc.babylonjs.com/how_to/shader_material
  19454. */
  19455. export class ShaderMaterial extends Material {
  19456. private _shaderPath;
  19457. private _options;
  19458. private _textures;
  19459. private _textureArrays;
  19460. private _floats;
  19461. private _ints;
  19462. private _floatsArrays;
  19463. private _colors3;
  19464. private _colors3Arrays;
  19465. private _colors4;
  19466. private _colors4Arrays;
  19467. private _vectors2;
  19468. private _vectors3;
  19469. private _vectors4;
  19470. private _matrices;
  19471. private _matrixArrays;
  19472. private _matrices3x3;
  19473. private _matrices2x2;
  19474. private _vectors2Arrays;
  19475. private _vectors3Arrays;
  19476. private _vectors4Arrays;
  19477. private _cachedWorldViewMatrix;
  19478. private _cachedWorldViewProjectionMatrix;
  19479. private _renderId;
  19480. private _multiview;
  19481. /**
  19482. * Instantiate a new shader material.
  19483. * 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.
  19484. * This returned material effects how the mesh will look based on the code in the shaders.
  19485. * @see http://doc.babylonjs.com/how_to/shader_material
  19486. * @param name Define the name of the material in the scene
  19487. * @param scene Define the scene the material belongs to
  19488. * @param shaderPath Defines the route to the shader code in one of three ways:
  19489. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19490. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19491. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19492. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19493. * @param options Define the options used to create the shader
  19494. */
  19495. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19496. /**
  19497. * Gets the shader path used to define the shader code
  19498. * It can be modified to trigger a new compilation
  19499. */
  19500. get shaderPath(): any;
  19501. /**
  19502. * Sets the shader path used to define the shader code
  19503. * It can be modified to trigger a new compilation
  19504. */
  19505. set shaderPath(shaderPath: any);
  19506. /**
  19507. * Gets the options used to compile the shader.
  19508. * They can be modified to trigger a new compilation
  19509. */
  19510. get options(): IShaderMaterialOptions;
  19511. /**
  19512. * Gets the current class name of the material e.g. "ShaderMaterial"
  19513. * Mainly use in serialization.
  19514. * @returns the class name
  19515. */
  19516. getClassName(): string;
  19517. /**
  19518. * Specifies if the material will require alpha blending
  19519. * @returns a boolean specifying if alpha blending is needed
  19520. */
  19521. needAlphaBlending(): boolean;
  19522. /**
  19523. * Specifies if this material should be rendered in alpha test mode
  19524. * @returns a boolean specifying if an alpha test is needed.
  19525. */
  19526. needAlphaTesting(): boolean;
  19527. private _checkUniform;
  19528. /**
  19529. * Set a texture in the shader.
  19530. * @param name Define the name of the uniform samplers as defined in the shader
  19531. * @param texture Define the texture to bind to this sampler
  19532. * @return the material itself allowing "fluent" like uniform updates
  19533. */
  19534. setTexture(name: string, texture: Texture): ShaderMaterial;
  19535. /**
  19536. * Set a texture array in the shader.
  19537. * @param name Define the name of the uniform sampler array as defined in the shader
  19538. * @param textures Define the list of textures to bind to this sampler
  19539. * @return the material itself allowing "fluent" like uniform updates
  19540. */
  19541. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19542. /**
  19543. * Set a float in the shader.
  19544. * @param name Define the name of the uniform as defined in the shader
  19545. * @param value Define the value to give to the uniform
  19546. * @return the material itself allowing "fluent" like uniform updates
  19547. */
  19548. setFloat(name: string, value: number): ShaderMaterial;
  19549. /**
  19550. * Set a int in the shader.
  19551. * @param name Define the name of the uniform as defined in the shader
  19552. * @param value Define the value to give to the uniform
  19553. * @return the material itself allowing "fluent" like uniform updates
  19554. */
  19555. setInt(name: string, value: number): ShaderMaterial;
  19556. /**
  19557. * Set an array of floats in the shader.
  19558. * @param name Define the name of the uniform as defined in the shader
  19559. * @param value Define the value to give to the uniform
  19560. * @return the material itself allowing "fluent" like uniform updates
  19561. */
  19562. setFloats(name: string, value: number[]): ShaderMaterial;
  19563. /**
  19564. * Set a vec3 in the shader from a Color3.
  19565. * @param name Define the name of the uniform as defined in the shader
  19566. * @param value Define the value to give to the uniform
  19567. * @return the material itself allowing "fluent" like uniform updates
  19568. */
  19569. setColor3(name: string, value: Color3): ShaderMaterial;
  19570. /**
  19571. * Set a vec3 array in the shader from a Color3 array.
  19572. * @param name Define the name of the uniform as defined in the shader
  19573. * @param value Define the value to give to the uniform
  19574. * @return the material itself allowing "fluent" like uniform updates
  19575. */
  19576. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19577. /**
  19578. * Set a vec4 in the shader from a Color4.
  19579. * @param name Define the name of the uniform as defined in the shader
  19580. * @param value Define the value to give to the uniform
  19581. * @return the material itself allowing "fluent" like uniform updates
  19582. */
  19583. setColor4(name: string, value: Color4): ShaderMaterial;
  19584. /**
  19585. * Set a vec4 array in the shader from a Color4 array.
  19586. * @param name Define the name of the uniform as defined in the shader
  19587. * @param value Define the value to give to the uniform
  19588. * @return the material itself allowing "fluent" like uniform updates
  19589. */
  19590. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19591. /**
  19592. * Set a vec2 in the shader from a Vector2.
  19593. * @param name Define the name of the uniform as defined in the shader
  19594. * @param value Define the value to give to the uniform
  19595. * @return the material itself allowing "fluent" like uniform updates
  19596. */
  19597. setVector2(name: string, value: Vector2): ShaderMaterial;
  19598. /**
  19599. * Set a vec3 in the shader from a Vector3.
  19600. * @param name Define the name of the uniform as defined in the shader
  19601. * @param value Define the value to give to the uniform
  19602. * @return the material itself allowing "fluent" like uniform updates
  19603. */
  19604. setVector3(name: string, value: Vector3): ShaderMaterial;
  19605. /**
  19606. * Set a vec4 in the shader from a Vector4.
  19607. * @param name Define the name of the uniform as defined in the shader
  19608. * @param value Define the value to give to the uniform
  19609. * @return the material itself allowing "fluent" like uniform updates
  19610. */
  19611. setVector4(name: string, value: Vector4): ShaderMaterial;
  19612. /**
  19613. * Set a mat4 in the shader from a Matrix.
  19614. * @param name Define the name of the uniform as defined in the shader
  19615. * @param value Define the value to give to the uniform
  19616. * @return the material itself allowing "fluent" like uniform updates
  19617. */
  19618. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19619. /**
  19620. * Set a float32Array in the shader from a matrix array.
  19621. * @param name Define the name of the uniform as defined in the shader
  19622. * @param value Define the value to give to the uniform
  19623. * @return the material itself allowing "fluent" like uniform updates
  19624. */
  19625. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19626. /**
  19627. * Set a mat3 in the shader from a Float32Array.
  19628. * @param name Define the name of the uniform as defined in the shader
  19629. * @param value Define the value to give to the uniform
  19630. * @return the material itself allowing "fluent" like uniform updates
  19631. */
  19632. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19633. /**
  19634. * Set a mat2 in the shader from a Float32Array.
  19635. * @param name Define the name of the uniform as defined in the shader
  19636. * @param value Define the value to give to the uniform
  19637. * @return the material itself allowing "fluent" like uniform updates
  19638. */
  19639. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19640. /**
  19641. * Set a vec2 array in the shader from a number array.
  19642. * @param name Define the name of the uniform as defined in the shader
  19643. * @param value Define the value to give to the uniform
  19644. * @return the material itself allowing "fluent" like uniform updates
  19645. */
  19646. setArray2(name: string, value: number[]): ShaderMaterial;
  19647. /**
  19648. * Set a vec3 array in the shader from a number array.
  19649. * @param name Define the name of the uniform as defined in the shader
  19650. * @param value Define the value to give to the uniform
  19651. * @return the material itself allowing "fluent" like uniform updates
  19652. */
  19653. setArray3(name: string, value: number[]): ShaderMaterial;
  19654. /**
  19655. * Set a vec4 array in the shader from a number array.
  19656. * @param name Define the name of the uniform as defined in the shader
  19657. * @param value Define the value to give to the uniform
  19658. * @return the material itself allowing "fluent" like uniform updates
  19659. */
  19660. setArray4(name: string, value: number[]): ShaderMaterial;
  19661. private _checkCache;
  19662. /**
  19663. * Specifies that the submesh is ready to be used
  19664. * @param mesh defines the mesh to check
  19665. * @param subMesh defines which submesh to check
  19666. * @param useInstances specifies that instances should be used
  19667. * @returns a boolean indicating that the submesh is ready or not
  19668. */
  19669. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19670. /**
  19671. * Checks if the material is ready to render the requested mesh
  19672. * @param mesh Define the mesh to render
  19673. * @param useInstances Define whether or not the material is used with instances
  19674. * @returns true if ready, otherwise false
  19675. */
  19676. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19677. /**
  19678. * Binds the world matrix to the material
  19679. * @param world defines the world transformation matrix
  19680. */
  19681. bindOnlyWorldMatrix(world: Matrix): void;
  19682. /**
  19683. * Binds the material to the mesh
  19684. * @param world defines the world transformation matrix
  19685. * @param mesh defines the mesh to bind the material to
  19686. */
  19687. bind(world: Matrix, mesh?: Mesh): void;
  19688. /**
  19689. * Gets the active textures from the material
  19690. * @returns an array of textures
  19691. */
  19692. getActiveTextures(): BaseTexture[];
  19693. /**
  19694. * Specifies if the material uses a texture
  19695. * @param texture defines the texture to check against the material
  19696. * @returns a boolean specifying if the material uses the texture
  19697. */
  19698. hasTexture(texture: BaseTexture): boolean;
  19699. /**
  19700. * Makes a duplicate of the material, and gives it a new name
  19701. * @param name defines the new name for the duplicated material
  19702. * @returns the cloned material
  19703. */
  19704. clone(name: string): ShaderMaterial;
  19705. /**
  19706. * Disposes the material
  19707. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19708. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19709. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19710. */
  19711. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19712. /**
  19713. * Serializes this material in a JSON representation
  19714. * @returns the serialized material object
  19715. */
  19716. serialize(): any;
  19717. /**
  19718. * Creates a shader material from parsed shader material data
  19719. * @param source defines the JSON represnetation of the material
  19720. * @param scene defines the hosting scene
  19721. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19722. * @returns a new material
  19723. */
  19724. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19725. }
  19726. }
  19727. declare module BABYLON {
  19728. /** @hidden */
  19729. export var colorPixelShader: {
  19730. name: string;
  19731. shader: string;
  19732. };
  19733. }
  19734. declare module BABYLON {
  19735. /** @hidden */
  19736. export var colorVertexShader: {
  19737. name: string;
  19738. shader: string;
  19739. };
  19740. }
  19741. declare module BABYLON {
  19742. /**
  19743. * Line mesh
  19744. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19745. */
  19746. export class LinesMesh extends Mesh {
  19747. /**
  19748. * If vertex color should be applied to the mesh
  19749. */
  19750. readonly useVertexColor?: boolean | undefined;
  19751. /**
  19752. * If vertex alpha should be applied to the mesh
  19753. */
  19754. readonly useVertexAlpha?: boolean | undefined;
  19755. /**
  19756. * Color of the line (Default: White)
  19757. */
  19758. color: Color3;
  19759. /**
  19760. * Alpha of the line (Default: 1)
  19761. */
  19762. alpha: number;
  19763. /**
  19764. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19765. * This margin is expressed in world space coordinates, so its value may vary.
  19766. * Default value is 0.1
  19767. */
  19768. intersectionThreshold: number;
  19769. private _colorShader;
  19770. private color4;
  19771. /**
  19772. * Creates a new LinesMesh
  19773. * @param name defines the name
  19774. * @param scene defines the hosting scene
  19775. * @param parent defines the parent mesh if any
  19776. * @param source defines the optional source LinesMesh used to clone data from
  19777. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19778. * When false, achieved by calling a clone(), also passing False.
  19779. * This will make creation of children, recursive.
  19780. * @param useVertexColor defines if this LinesMesh supports vertex color
  19781. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19782. */
  19783. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19784. /**
  19785. * If vertex color should be applied to the mesh
  19786. */
  19787. useVertexColor?: boolean | undefined,
  19788. /**
  19789. * If vertex alpha should be applied to the mesh
  19790. */
  19791. useVertexAlpha?: boolean | undefined);
  19792. private _addClipPlaneDefine;
  19793. private _removeClipPlaneDefine;
  19794. isReady(): boolean;
  19795. /**
  19796. * Returns the string "LineMesh"
  19797. */
  19798. getClassName(): string;
  19799. /**
  19800. * @hidden
  19801. */
  19802. get material(): Material;
  19803. /**
  19804. * @hidden
  19805. */
  19806. set material(value: Material);
  19807. /**
  19808. * @hidden
  19809. */
  19810. get checkCollisions(): boolean;
  19811. /** @hidden */
  19812. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19813. /** @hidden */
  19814. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19815. /**
  19816. * Disposes of the line mesh
  19817. * @param doNotRecurse If children should be disposed
  19818. */
  19819. dispose(doNotRecurse?: boolean): void;
  19820. /**
  19821. * Returns a new LineMesh object cloned from the current one.
  19822. */
  19823. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  19824. /**
  19825. * Creates a new InstancedLinesMesh object from the mesh model.
  19826. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19827. * @param name defines the name of the new instance
  19828. * @returns a new InstancedLinesMesh
  19829. */
  19830. createInstance(name: string): InstancedLinesMesh;
  19831. }
  19832. /**
  19833. * Creates an instance based on a source LinesMesh
  19834. */
  19835. export class InstancedLinesMesh extends InstancedMesh {
  19836. /**
  19837. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19838. * This margin is expressed in world space coordinates, so its value may vary.
  19839. * Initilized with the intersectionThreshold value of the source LinesMesh
  19840. */
  19841. intersectionThreshold: number;
  19842. constructor(name: string, source: LinesMesh);
  19843. /**
  19844. * Returns the string "InstancedLinesMesh".
  19845. */
  19846. getClassName(): string;
  19847. }
  19848. }
  19849. declare module BABYLON {
  19850. /** @hidden */
  19851. export var linePixelShader: {
  19852. name: string;
  19853. shader: string;
  19854. };
  19855. }
  19856. declare module BABYLON {
  19857. /** @hidden */
  19858. export var lineVertexShader: {
  19859. name: string;
  19860. shader: string;
  19861. };
  19862. }
  19863. declare module BABYLON {
  19864. interface AbstractMesh {
  19865. /**
  19866. * Gets the edgesRenderer associated with the mesh
  19867. */
  19868. edgesRenderer: Nullable<EdgesRenderer>;
  19869. }
  19870. interface LinesMesh {
  19871. /**
  19872. * Enables the edge rendering mode on the mesh.
  19873. * This mode makes the mesh edges visible
  19874. * @param epsilon defines the maximal distance between two angles to detect a face
  19875. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19876. * @returns the currentAbstractMesh
  19877. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19878. */
  19879. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19880. }
  19881. interface InstancedLinesMesh {
  19882. /**
  19883. * Enables the edge rendering mode on the mesh.
  19884. * This mode makes the mesh edges visible
  19885. * @param epsilon defines the maximal distance between two angles to detect a face
  19886. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19887. * @returns the current InstancedLinesMesh
  19888. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19889. */
  19890. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19891. }
  19892. /**
  19893. * Defines the minimum contract an Edges renderer should follow.
  19894. */
  19895. export interface IEdgesRenderer extends IDisposable {
  19896. /**
  19897. * Gets or sets a boolean indicating if the edgesRenderer is active
  19898. */
  19899. isEnabled: boolean;
  19900. /**
  19901. * Renders the edges of the attached mesh,
  19902. */
  19903. render(): void;
  19904. /**
  19905. * Checks wether or not the edges renderer is ready to render.
  19906. * @return true if ready, otherwise false.
  19907. */
  19908. isReady(): boolean;
  19909. }
  19910. /**
  19911. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19912. */
  19913. export class EdgesRenderer implements IEdgesRenderer {
  19914. /**
  19915. * Define the size of the edges with an orthographic camera
  19916. */
  19917. edgesWidthScalerForOrthographic: number;
  19918. /**
  19919. * Define the size of the edges with a perspective camera
  19920. */
  19921. edgesWidthScalerForPerspective: number;
  19922. protected _source: AbstractMesh;
  19923. protected _linesPositions: number[];
  19924. protected _linesNormals: number[];
  19925. protected _linesIndices: number[];
  19926. protected _epsilon: number;
  19927. protected _indicesCount: number;
  19928. protected _lineShader: ShaderMaterial;
  19929. protected _ib: DataBuffer;
  19930. protected _buffers: {
  19931. [key: string]: Nullable<VertexBuffer>;
  19932. };
  19933. protected _checkVerticesInsteadOfIndices: boolean;
  19934. private _meshRebuildObserver;
  19935. private _meshDisposeObserver;
  19936. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19937. isEnabled: boolean;
  19938. /**
  19939. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19940. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19941. * @param source Mesh used to create edges
  19942. * @param epsilon sum of angles in adjacency to check for edge
  19943. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19944. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19945. */
  19946. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19947. protected _prepareRessources(): void;
  19948. /** @hidden */
  19949. _rebuild(): void;
  19950. /**
  19951. * Releases the required resources for the edges renderer
  19952. */
  19953. dispose(): void;
  19954. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19955. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19956. /**
  19957. * Checks if the pair of p0 and p1 is en edge
  19958. * @param faceIndex
  19959. * @param edge
  19960. * @param faceNormals
  19961. * @param p0
  19962. * @param p1
  19963. * @private
  19964. */
  19965. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19966. /**
  19967. * push line into the position, normal and index buffer
  19968. * @protected
  19969. */
  19970. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19971. /**
  19972. * Generates lines edges from adjacencjes
  19973. * @private
  19974. */
  19975. _generateEdgesLines(): void;
  19976. /**
  19977. * Checks wether or not the edges renderer is ready to render.
  19978. * @return true if ready, otherwise false.
  19979. */
  19980. isReady(): boolean;
  19981. /**
  19982. * Renders the edges of the attached mesh,
  19983. */
  19984. render(): void;
  19985. }
  19986. /**
  19987. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19988. */
  19989. export class LineEdgesRenderer extends EdgesRenderer {
  19990. /**
  19991. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19992. * @param source LineMesh used to generate edges
  19993. * @param epsilon not important (specified angle for edge detection)
  19994. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19995. */
  19996. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19997. /**
  19998. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19999. */
  20000. _generateEdgesLines(): void;
  20001. }
  20002. }
  20003. declare module BABYLON {
  20004. /**
  20005. * This represents the object necessary to create a rendering group.
  20006. * This is exclusively used and created by the rendering manager.
  20007. * To modify the behavior, you use the available helpers in your scene or meshes.
  20008. * @hidden
  20009. */
  20010. export class RenderingGroup {
  20011. index: number;
  20012. private static _zeroVector;
  20013. private _scene;
  20014. private _opaqueSubMeshes;
  20015. private _transparentSubMeshes;
  20016. private _alphaTestSubMeshes;
  20017. private _depthOnlySubMeshes;
  20018. private _particleSystems;
  20019. private _spriteManagers;
  20020. private _opaqueSortCompareFn;
  20021. private _alphaTestSortCompareFn;
  20022. private _transparentSortCompareFn;
  20023. private _renderOpaque;
  20024. private _renderAlphaTest;
  20025. private _renderTransparent;
  20026. /** @hidden */
  20027. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20028. onBeforeTransparentRendering: () => void;
  20029. /**
  20030. * Set the opaque sort comparison function.
  20031. * If null the sub meshes will be render in the order they were created
  20032. */
  20033. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20034. /**
  20035. * Set the alpha test sort comparison function.
  20036. * If null the sub meshes will be render in the order they were created
  20037. */
  20038. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20039. /**
  20040. * Set the transparent sort comparison function.
  20041. * If null the sub meshes will be render in the order they were created
  20042. */
  20043. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20044. /**
  20045. * Creates a new rendering group.
  20046. * @param index The rendering group index
  20047. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20048. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20049. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20050. */
  20051. 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>);
  20052. /**
  20053. * Render all the sub meshes contained in the group.
  20054. * @param customRenderFunction Used to override the default render behaviour of the group.
  20055. * @returns true if rendered some submeshes.
  20056. */
  20057. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20058. /**
  20059. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20060. * @param subMeshes The submeshes to render
  20061. */
  20062. private renderOpaqueSorted;
  20063. /**
  20064. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20065. * @param subMeshes The submeshes to render
  20066. */
  20067. private renderAlphaTestSorted;
  20068. /**
  20069. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20070. * @param subMeshes The submeshes to render
  20071. */
  20072. private renderTransparentSorted;
  20073. /**
  20074. * Renders the submeshes in a specified order.
  20075. * @param subMeshes The submeshes to sort before render
  20076. * @param sortCompareFn The comparison function use to sort
  20077. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20078. * @param transparent Specifies to activate blending if true
  20079. */
  20080. private static renderSorted;
  20081. /**
  20082. * Renders the submeshes in the order they were dispatched (no sort applied).
  20083. * @param subMeshes The submeshes to render
  20084. */
  20085. private static renderUnsorted;
  20086. /**
  20087. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20088. * are rendered back to front if in the same alpha index.
  20089. *
  20090. * @param a The first submesh
  20091. * @param b The second submesh
  20092. * @returns The result of the comparison
  20093. */
  20094. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20095. /**
  20096. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20097. * are rendered back to front.
  20098. *
  20099. * @param a The first submesh
  20100. * @param b The second submesh
  20101. * @returns The result of the comparison
  20102. */
  20103. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20104. /**
  20105. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20106. * are rendered front to back (prevent overdraw).
  20107. *
  20108. * @param a The first submesh
  20109. * @param b The second submesh
  20110. * @returns The result of the comparison
  20111. */
  20112. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20113. /**
  20114. * Resets the different lists of submeshes to prepare a new frame.
  20115. */
  20116. prepare(): void;
  20117. dispose(): void;
  20118. /**
  20119. * Inserts the submesh in its correct queue depending on its material.
  20120. * @param subMesh The submesh to dispatch
  20121. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20122. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20123. */
  20124. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20125. dispatchSprites(spriteManager: ISpriteManager): void;
  20126. dispatchParticles(particleSystem: IParticleSystem): void;
  20127. private _renderParticles;
  20128. private _renderSprites;
  20129. }
  20130. }
  20131. declare module BABYLON {
  20132. /**
  20133. * Interface describing the different options available in the rendering manager
  20134. * regarding Auto Clear between groups.
  20135. */
  20136. export interface IRenderingManagerAutoClearSetup {
  20137. /**
  20138. * Defines whether or not autoclear is enable.
  20139. */
  20140. autoClear: boolean;
  20141. /**
  20142. * Defines whether or not to autoclear the depth buffer.
  20143. */
  20144. depth: boolean;
  20145. /**
  20146. * Defines whether or not to autoclear the stencil buffer.
  20147. */
  20148. stencil: boolean;
  20149. }
  20150. /**
  20151. * This class is used by the onRenderingGroupObservable
  20152. */
  20153. export class RenderingGroupInfo {
  20154. /**
  20155. * The Scene that being rendered
  20156. */
  20157. scene: Scene;
  20158. /**
  20159. * The camera currently used for the rendering pass
  20160. */
  20161. camera: Nullable<Camera>;
  20162. /**
  20163. * The ID of the renderingGroup being processed
  20164. */
  20165. renderingGroupId: number;
  20166. }
  20167. /**
  20168. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20169. * It is enable to manage the different groups as well as the different necessary sort functions.
  20170. * This should not be used directly aside of the few static configurations
  20171. */
  20172. export class RenderingManager {
  20173. /**
  20174. * The max id used for rendering groups (not included)
  20175. */
  20176. static MAX_RENDERINGGROUPS: number;
  20177. /**
  20178. * The min id used for rendering groups (included)
  20179. */
  20180. static MIN_RENDERINGGROUPS: number;
  20181. /**
  20182. * Used to globally prevent autoclearing scenes.
  20183. */
  20184. static AUTOCLEAR: boolean;
  20185. /**
  20186. * @hidden
  20187. */
  20188. _useSceneAutoClearSetup: boolean;
  20189. private _scene;
  20190. private _renderingGroups;
  20191. private _depthStencilBufferAlreadyCleaned;
  20192. private _autoClearDepthStencil;
  20193. private _customOpaqueSortCompareFn;
  20194. private _customAlphaTestSortCompareFn;
  20195. private _customTransparentSortCompareFn;
  20196. private _renderingGroupInfo;
  20197. /**
  20198. * Instantiates a new rendering group for a particular scene
  20199. * @param scene Defines the scene the groups belongs to
  20200. */
  20201. constructor(scene: Scene);
  20202. private _clearDepthStencilBuffer;
  20203. /**
  20204. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20205. * @hidden
  20206. */
  20207. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20208. /**
  20209. * Resets the different information of the group to prepare a new frame
  20210. * @hidden
  20211. */
  20212. reset(): void;
  20213. /**
  20214. * Dispose and release the group and its associated resources.
  20215. * @hidden
  20216. */
  20217. dispose(): void;
  20218. /**
  20219. * Clear the info related to rendering groups preventing retention points during dispose.
  20220. */
  20221. freeRenderingGroups(): void;
  20222. private _prepareRenderingGroup;
  20223. /**
  20224. * Add a sprite manager to the rendering manager in order to render it this frame.
  20225. * @param spriteManager Define the sprite manager to render
  20226. */
  20227. dispatchSprites(spriteManager: ISpriteManager): void;
  20228. /**
  20229. * Add a particle system to the rendering manager in order to render it this frame.
  20230. * @param particleSystem Define the particle system to render
  20231. */
  20232. dispatchParticles(particleSystem: IParticleSystem): void;
  20233. /**
  20234. * Add a submesh to the manager in order to render it this frame
  20235. * @param subMesh The submesh to dispatch
  20236. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20237. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20238. */
  20239. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20240. /**
  20241. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20242. * This allowed control for front to back rendering or reversly depending of the special needs.
  20243. *
  20244. * @param renderingGroupId The rendering group id corresponding to its index
  20245. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20246. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20247. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20248. */
  20249. 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;
  20250. /**
  20251. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20252. *
  20253. * @param renderingGroupId The rendering group id corresponding to its index
  20254. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20255. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20256. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20257. */
  20258. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20259. /**
  20260. * Gets the current auto clear configuration for one rendering group of the rendering
  20261. * manager.
  20262. * @param index the rendering group index to get the information for
  20263. * @returns The auto clear setup for the requested rendering group
  20264. */
  20265. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20266. }
  20267. }
  20268. declare module BABYLON {
  20269. /**
  20270. * This Helps creating a texture that will be created from a camera in your scene.
  20271. * It is basically a dynamic texture that could be used to create special effects for instance.
  20272. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20273. */
  20274. export class RenderTargetTexture extends Texture {
  20275. isCube: boolean;
  20276. /**
  20277. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20278. */
  20279. static readonly REFRESHRATE_RENDER_ONCE: number;
  20280. /**
  20281. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20282. */
  20283. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20284. /**
  20285. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20286. * the central point of your effect and can save a lot of performances.
  20287. */
  20288. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20289. /**
  20290. * Use this predicate to dynamically define the list of mesh you want to render.
  20291. * If set, the renderList property will be overwritten.
  20292. */
  20293. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20294. private _renderList;
  20295. /**
  20296. * Use this list to define the list of mesh you want to render.
  20297. */
  20298. get renderList(): Nullable<Array<AbstractMesh>>;
  20299. set renderList(value: Nullable<Array<AbstractMesh>>);
  20300. /**
  20301. * Use this function to overload the renderList array at rendering time.
  20302. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20303. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20304. * the cube (if the RTT is a cube, else layerOrFace=0).
  20305. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20306. */
  20307. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20308. private _hookArray;
  20309. /**
  20310. * Define if particles should be rendered in your texture.
  20311. */
  20312. renderParticles: boolean;
  20313. /**
  20314. * Define if sprites should be rendered in your texture.
  20315. */
  20316. renderSprites: boolean;
  20317. /**
  20318. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20319. */
  20320. coordinatesMode: number;
  20321. /**
  20322. * Define the camera used to render the texture.
  20323. */
  20324. activeCamera: Nullable<Camera>;
  20325. /**
  20326. * Override the render function of the texture with your own one.
  20327. */
  20328. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20329. /**
  20330. * Define if camera post processes should be use while rendering the texture.
  20331. */
  20332. useCameraPostProcesses: boolean;
  20333. /**
  20334. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20335. */
  20336. ignoreCameraViewport: boolean;
  20337. private _postProcessManager;
  20338. private _postProcesses;
  20339. private _resizeObserver;
  20340. /**
  20341. * An event triggered when the texture is unbind.
  20342. */
  20343. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20344. /**
  20345. * An event triggered when the texture is unbind.
  20346. */
  20347. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20348. private _onAfterUnbindObserver;
  20349. /**
  20350. * Set a after unbind callback in the texture.
  20351. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20352. */
  20353. set onAfterUnbind(callback: () => void);
  20354. /**
  20355. * An event triggered before rendering the texture
  20356. */
  20357. onBeforeRenderObservable: Observable<number>;
  20358. private _onBeforeRenderObserver;
  20359. /**
  20360. * Set a before render callback in the texture.
  20361. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20362. */
  20363. set onBeforeRender(callback: (faceIndex: number) => void);
  20364. /**
  20365. * An event triggered after rendering the texture
  20366. */
  20367. onAfterRenderObservable: Observable<number>;
  20368. private _onAfterRenderObserver;
  20369. /**
  20370. * Set a after render callback in the texture.
  20371. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20372. */
  20373. set onAfterRender(callback: (faceIndex: number) => void);
  20374. /**
  20375. * An event triggered after the texture clear
  20376. */
  20377. onClearObservable: Observable<Engine>;
  20378. private _onClearObserver;
  20379. /**
  20380. * Set a clear callback in the texture.
  20381. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20382. */
  20383. set onClear(callback: (Engine: Engine) => void);
  20384. /**
  20385. * An event triggered when the texture is resized.
  20386. */
  20387. onResizeObservable: Observable<RenderTargetTexture>;
  20388. /**
  20389. * Define the clear color of the Render Target if it should be different from the scene.
  20390. */
  20391. clearColor: Color4;
  20392. protected _size: number | {
  20393. width: number;
  20394. height: number;
  20395. layers?: number;
  20396. };
  20397. protected _initialSizeParameter: number | {
  20398. width: number;
  20399. height: number;
  20400. } | {
  20401. ratio: number;
  20402. };
  20403. protected _sizeRatio: Nullable<number>;
  20404. /** @hidden */
  20405. _generateMipMaps: boolean;
  20406. protected _renderingManager: RenderingManager;
  20407. /** @hidden */
  20408. _waitingRenderList: string[];
  20409. protected _doNotChangeAspectRatio: boolean;
  20410. protected _currentRefreshId: number;
  20411. protected _refreshRate: number;
  20412. protected _textureMatrix: Matrix;
  20413. protected _samples: number;
  20414. protected _renderTargetOptions: RenderTargetCreationOptions;
  20415. /**
  20416. * Gets render target creation options that were used.
  20417. */
  20418. get renderTargetOptions(): RenderTargetCreationOptions;
  20419. protected _engine: Engine;
  20420. protected _onRatioRescale(): void;
  20421. /**
  20422. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20423. * It must define where the camera used to render the texture is set
  20424. */
  20425. boundingBoxPosition: Vector3;
  20426. private _boundingBoxSize;
  20427. /**
  20428. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20429. * When defined, the cubemap will switch to local mode
  20430. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20431. * @example https://www.babylonjs-playground.com/#RNASML
  20432. */
  20433. set boundingBoxSize(value: Vector3);
  20434. get boundingBoxSize(): Vector3;
  20435. /**
  20436. * In case the RTT has been created with a depth texture, get the associated
  20437. * depth texture.
  20438. * Otherwise, return null.
  20439. */
  20440. get depthStencilTexture(): Nullable<InternalTexture>;
  20441. /**
  20442. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20443. * or used a shadow, depth texture...
  20444. * @param name The friendly name of the texture
  20445. * @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)
  20446. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20447. * @param generateMipMaps True if mip maps need to be generated after render.
  20448. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20449. * @param type The type of the buffer in the RTT (int, half float, float...)
  20450. * @param isCube True if a cube texture needs to be created
  20451. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20452. * @param generateDepthBuffer True to generate a depth buffer
  20453. * @param generateStencilBuffer True to generate a stencil buffer
  20454. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20455. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20456. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20457. */
  20458. constructor(name: string, size: number | {
  20459. width: number;
  20460. height: number;
  20461. layers?: number;
  20462. } | {
  20463. ratio: number;
  20464. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20465. /**
  20466. * Creates a depth stencil texture.
  20467. * This is only available in WebGL 2 or with the depth texture extension available.
  20468. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20469. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20470. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20471. */
  20472. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20473. private _processSizeParameter;
  20474. /**
  20475. * Define the number of samples to use in case of MSAA.
  20476. * It defaults to one meaning no MSAA has been enabled.
  20477. */
  20478. get samples(): number;
  20479. set samples(value: number);
  20480. /**
  20481. * Resets the refresh counter of the texture and start bak from scratch.
  20482. * Could be useful to regenerate the texture if it is setup to render only once.
  20483. */
  20484. resetRefreshCounter(): void;
  20485. /**
  20486. * Define the refresh rate of the texture or the rendering frequency.
  20487. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20488. */
  20489. get refreshRate(): number;
  20490. set refreshRate(value: number);
  20491. /**
  20492. * Adds a post process to the render target rendering passes.
  20493. * @param postProcess define the post process to add
  20494. */
  20495. addPostProcess(postProcess: PostProcess): void;
  20496. /**
  20497. * Clear all the post processes attached to the render target
  20498. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20499. */
  20500. clearPostProcesses(dispose?: boolean): void;
  20501. /**
  20502. * Remove one of the post process from the list of attached post processes to the texture
  20503. * @param postProcess define the post process to remove from the list
  20504. */
  20505. removePostProcess(postProcess: PostProcess): void;
  20506. /** @hidden */
  20507. _shouldRender(): boolean;
  20508. /**
  20509. * Gets the actual render size of the texture.
  20510. * @returns the width of the render size
  20511. */
  20512. getRenderSize(): number;
  20513. /**
  20514. * Gets the actual render width of the texture.
  20515. * @returns the width of the render size
  20516. */
  20517. getRenderWidth(): number;
  20518. /**
  20519. * Gets the actual render height of the texture.
  20520. * @returns the height of the render size
  20521. */
  20522. getRenderHeight(): number;
  20523. /**
  20524. * Gets the actual number of layers of the texture.
  20525. * @returns the number of layers
  20526. */
  20527. getRenderLayers(): number;
  20528. /**
  20529. * Get if the texture can be rescaled or not.
  20530. */
  20531. get canRescale(): boolean;
  20532. /**
  20533. * Resize the texture using a ratio.
  20534. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20535. */
  20536. scale(ratio: number): void;
  20537. /**
  20538. * Get the texture reflection matrix used to rotate/transform the reflection.
  20539. * @returns the reflection matrix
  20540. */
  20541. getReflectionTextureMatrix(): Matrix;
  20542. /**
  20543. * Resize the texture to a new desired size.
  20544. * Be carrefull as it will recreate all the data in the new texture.
  20545. * @param size Define the new size. It can be:
  20546. * - a number for squared texture,
  20547. * - an object containing { width: number, height: number }
  20548. * - or an object containing a ratio { ratio: number }
  20549. */
  20550. resize(size: number | {
  20551. width: number;
  20552. height: number;
  20553. } | {
  20554. ratio: number;
  20555. }): void;
  20556. private _defaultRenderListPrepared;
  20557. /**
  20558. * Renders all the objects from the render list into the texture.
  20559. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20560. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20561. */
  20562. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20563. private _bestReflectionRenderTargetDimension;
  20564. private _prepareRenderingManager;
  20565. /**
  20566. * @hidden
  20567. * @param faceIndex face index to bind to if this is a cubetexture
  20568. * @param layer defines the index of the texture to bind in the array
  20569. */
  20570. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20571. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20572. private renderToTarget;
  20573. /**
  20574. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20575. * This allowed control for front to back rendering or reversly depending of the special needs.
  20576. *
  20577. * @param renderingGroupId The rendering group id corresponding to its index
  20578. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20579. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20580. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20581. */
  20582. 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;
  20583. /**
  20584. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20585. *
  20586. * @param renderingGroupId The rendering group id corresponding to its index
  20587. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20588. */
  20589. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20590. /**
  20591. * Clones the texture.
  20592. * @returns the cloned texture
  20593. */
  20594. clone(): RenderTargetTexture;
  20595. /**
  20596. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20597. * @returns The JSON representation of the texture
  20598. */
  20599. serialize(): any;
  20600. /**
  20601. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20602. */
  20603. disposeFramebufferObjects(): void;
  20604. /**
  20605. * Dispose the texture and release its associated resources.
  20606. */
  20607. dispose(): void;
  20608. /** @hidden */
  20609. _rebuild(): void;
  20610. /**
  20611. * Clear the info related to rendering groups preventing retention point in material dispose.
  20612. */
  20613. freeRenderingGroups(): void;
  20614. /**
  20615. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20616. * @returns the view count
  20617. */
  20618. getViewCount(): number;
  20619. }
  20620. }
  20621. declare module BABYLON {
  20622. /**
  20623. * Options for compiling materials.
  20624. */
  20625. export interface IMaterialCompilationOptions {
  20626. /**
  20627. * Defines whether clip planes are enabled.
  20628. */
  20629. clipPlane: boolean;
  20630. /**
  20631. * Defines whether instances are enabled.
  20632. */
  20633. useInstances: boolean;
  20634. }
  20635. /**
  20636. * Base class for the main features of a material in Babylon.js
  20637. */
  20638. export class Material implements IAnimatable {
  20639. /**
  20640. * Returns the triangle fill mode
  20641. */
  20642. static readonly TriangleFillMode: number;
  20643. /**
  20644. * Returns the wireframe mode
  20645. */
  20646. static readonly WireFrameFillMode: number;
  20647. /**
  20648. * Returns the point fill mode
  20649. */
  20650. static readonly PointFillMode: number;
  20651. /**
  20652. * Returns the point list draw mode
  20653. */
  20654. static readonly PointListDrawMode: number;
  20655. /**
  20656. * Returns the line list draw mode
  20657. */
  20658. static readonly LineListDrawMode: number;
  20659. /**
  20660. * Returns the line loop draw mode
  20661. */
  20662. static readonly LineLoopDrawMode: number;
  20663. /**
  20664. * Returns the line strip draw mode
  20665. */
  20666. static readonly LineStripDrawMode: number;
  20667. /**
  20668. * Returns the triangle strip draw mode
  20669. */
  20670. static readonly TriangleStripDrawMode: number;
  20671. /**
  20672. * Returns the triangle fan draw mode
  20673. */
  20674. static readonly TriangleFanDrawMode: number;
  20675. /**
  20676. * Stores the clock-wise side orientation
  20677. */
  20678. static readonly ClockWiseSideOrientation: number;
  20679. /**
  20680. * Stores the counter clock-wise side orientation
  20681. */
  20682. static readonly CounterClockWiseSideOrientation: number;
  20683. /**
  20684. * The dirty texture flag value
  20685. */
  20686. static readonly TextureDirtyFlag: number;
  20687. /**
  20688. * The dirty light flag value
  20689. */
  20690. static readonly LightDirtyFlag: number;
  20691. /**
  20692. * The dirty fresnel flag value
  20693. */
  20694. static readonly FresnelDirtyFlag: number;
  20695. /**
  20696. * The dirty attribute flag value
  20697. */
  20698. static readonly AttributesDirtyFlag: number;
  20699. /**
  20700. * The dirty misc flag value
  20701. */
  20702. static readonly MiscDirtyFlag: number;
  20703. /**
  20704. * The all dirty flag value
  20705. */
  20706. static readonly AllDirtyFlag: number;
  20707. /**
  20708. * The ID of the material
  20709. */
  20710. id: string;
  20711. /**
  20712. * Gets or sets the unique id of the material
  20713. */
  20714. uniqueId: number;
  20715. /**
  20716. * The name of the material
  20717. */
  20718. name: string;
  20719. /**
  20720. * Gets or sets user defined metadata
  20721. */
  20722. metadata: any;
  20723. /**
  20724. * For internal use only. Please do not use.
  20725. */
  20726. reservedDataStore: any;
  20727. /**
  20728. * Specifies if the ready state should be checked on each call
  20729. */
  20730. checkReadyOnEveryCall: boolean;
  20731. /**
  20732. * Specifies if the ready state should be checked once
  20733. */
  20734. checkReadyOnlyOnce: boolean;
  20735. /**
  20736. * The state of the material
  20737. */
  20738. state: string;
  20739. /**
  20740. * The alpha value of the material
  20741. */
  20742. protected _alpha: number;
  20743. /**
  20744. * List of inspectable custom properties (used by the Inspector)
  20745. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20746. */
  20747. inspectableCustomProperties: IInspectable[];
  20748. /**
  20749. * Sets the alpha value of the material
  20750. */
  20751. set alpha(value: number);
  20752. /**
  20753. * Gets the alpha value of the material
  20754. */
  20755. get alpha(): number;
  20756. /**
  20757. * Specifies if back face culling is enabled
  20758. */
  20759. protected _backFaceCulling: boolean;
  20760. /**
  20761. * Sets the back-face culling state
  20762. */
  20763. set backFaceCulling(value: boolean);
  20764. /**
  20765. * Gets the back-face culling state
  20766. */
  20767. get backFaceCulling(): boolean;
  20768. /**
  20769. * Stores the value for side orientation
  20770. */
  20771. sideOrientation: number;
  20772. /**
  20773. * Callback triggered when the material is compiled
  20774. */
  20775. onCompiled: Nullable<(effect: Effect) => void>;
  20776. /**
  20777. * Callback triggered when an error occurs
  20778. */
  20779. onError: Nullable<(effect: Effect, errors: string) => void>;
  20780. /**
  20781. * Callback triggered to get the render target textures
  20782. */
  20783. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20784. /**
  20785. * Gets a boolean indicating that current material needs to register RTT
  20786. */
  20787. get hasRenderTargetTextures(): boolean;
  20788. /**
  20789. * Specifies if the material should be serialized
  20790. */
  20791. doNotSerialize: boolean;
  20792. /**
  20793. * @hidden
  20794. */
  20795. _storeEffectOnSubMeshes: boolean;
  20796. /**
  20797. * Stores the animations for the material
  20798. */
  20799. animations: Nullable<Array<Animation>>;
  20800. /**
  20801. * An event triggered when the material is disposed
  20802. */
  20803. onDisposeObservable: Observable<Material>;
  20804. /**
  20805. * An observer which watches for dispose events
  20806. */
  20807. private _onDisposeObserver;
  20808. private _onUnBindObservable;
  20809. /**
  20810. * Called during a dispose event
  20811. */
  20812. set onDispose(callback: () => void);
  20813. private _onBindObservable;
  20814. /**
  20815. * An event triggered when the material is bound
  20816. */
  20817. get onBindObservable(): Observable<AbstractMesh>;
  20818. /**
  20819. * An observer which watches for bind events
  20820. */
  20821. private _onBindObserver;
  20822. /**
  20823. * Called during a bind event
  20824. */
  20825. set onBind(callback: (Mesh: AbstractMesh) => void);
  20826. /**
  20827. * An event triggered when the material is unbound
  20828. */
  20829. get onUnBindObservable(): Observable<Material>;
  20830. /**
  20831. * Stores the value of the alpha mode
  20832. */
  20833. private _alphaMode;
  20834. /**
  20835. * Sets the value of the alpha mode.
  20836. *
  20837. * | Value | Type | Description |
  20838. * | --- | --- | --- |
  20839. * | 0 | ALPHA_DISABLE | |
  20840. * | 1 | ALPHA_ADD | |
  20841. * | 2 | ALPHA_COMBINE | |
  20842. * | 3 | ALPHA_SUBTRACT | |
  20843. * | 4 | ALPHA_MULTIPLY | |
  20844. * | 5 | ALPHA_MAXIMIZED | |
  20845. * | 6 | ALPHA_ONEONE | |
  20846. * | 7 | ALPHA_PREMULTIPLIED | |
  20847. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20848. * | 9 | ALPHA_INTERPOLATE | |
  20849. * | 10 | ALPHA_SCREENMODE | |
  20850. *
  20851. */
  20852. set alphaMode(value: number);
  20853. /**
  20854. * Gets the value of the alpha mode
  20855. */
  20856. get alphaMode(): number;
  20857. /**
  20858. * Stores the state of the need depth pre-pass value
  20859. */
  20860. private _needDepthPrePass;
  20861. /**
  20862. * Sets the need depth pre-pass value
  20863. */
  20864. set needDepthPrePass(value: boolean);
  20865. /**
  20866. * Gets the depth pre-pass value
  20867. */
  20868. get needDepthPrePass(): boolean;
  20869. /**
  20870. * Specifies if depth writing should be disabled
  20871. */
  20872. disableDepthWrite: boolean;
  20873. /**
  20874. * Specifies if depth writing should be forced
  20875. */
  20876. forceDepthWrite: boolean;
  20877. /**
  20878. * Specifies the depth function that should be used. 0 means the default engine function
  20879. */
  20880. depthFunction: number;
  20881. /**
  20882. * Specifies if there should be a separate pass for culling
  20883. */
  20884. separateCullingPass: boolean;
  20885. /**
  20886. * Stores the state specifing if fog should be enabled
  20887. */
  20888. private _fogEnabled;
  20889. /**
  20890. * Sets the state for enabling fog
  20891. */
  20892. set fogEnabled(value: boolean);
  20893. /**
  20894. * Gets the value of the fog enabled state
  20895. */
  20896. get fogEnabled(): boolean;
  20897. /**
  20898. * Stores the size of points
  20899. */
  20900. pointSize: number;
  20901. /**
  20902. * Stores the z offset value
  20903. */
  20904. zOffset: number;
  20905. /**
  20906. * Gets a value specifying if wireframe mode is enabled
  20907. */
  20908. get wireframe(): boolean;
  20909. /**
  20910. * Sets the state of wireframe mode
  20911. */
  20912. set wireframe(value: boolean);
  20913. /**
  20914. * Gets the value specifying if point clouds are enabled
  20915. */
  20916. get pointsCloud(): boolean;
  20917. /**
  20918. * Sets the state of point cloud mode
  20919. */
  20920. set pointsCloud(value: boolean);
  20921. /**
  20922. * Gets the material fill mode
  20923. */
  20924. get fillMode(): number;
  20925. /**
  20926. * Sets the material fill mode
  20927. */
  20928. set fillMode(value: number);
  20929. /**
  20930. * @hidden
  20931. * Stores the effects for the material
  20932. */
  20933. _effect: Nullable<Effect>;
  20934. /**
  20935. * Specifies if uniform buffers should be used
  20936. */
  20937. private _useUBO;
  20938. /**
  20939. * Stores a reference to the scene
  20940. */
  20941. private _scene;
  20942. /**
  20943. * Stores the fill mode state
  20944. */
  20945. private _fillMode;
  20946. /**
  20947. * Specifies if the depth write state should be cached
  20948. */
  20949. private _cachedDepthWriteState;
  20950. /**
  20951. * Specifies if the depth function state should be cached
  20952. */
  20953. private _cachedDepthFunctionState;
  20954. /**
  20955. * Stores the uniform buffer
  20956. */
  20957. protected _uniformBuffer: UniformBuffer;
  20958. /** @hidden */
  20959. _indexInSceneMaterialArray: number;
  20960. /** @hidden */
  20961. meshMap: Nullable<{
  20962. [id: string]: AbstractMesh | undefined;
  20963. }>;
  20964. /**
  20965. * Creates a material instance
  20966. * @param name defines the name of the material
  20967. * @param scene defines the scene to reference
  20968. * @param doNotAdd specifies if the material should be added to the scene
  20969. */
  20970. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20971. /**
  20972. * Returns a string representation of the current material
  20973. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20974. * @returns a string with material information
  20975. */
  20976. toString(fullDetails?: boolean): string;
  20977. /**
  20978. * Gets the class name of the material
  20979. * @returns a string with the class name of the material
  20980. */
  20981. getClassName(): string;
  20982. /**
  20983. * Specifies if updates for the material been locked
  20984. */
  20985. get isFrozen(): boolean;
  20986. /**
  20987. * Locks updates for the material
  20988. */
  20989. freeze(): void;
  20990. /**
  20991. * Unlocks updates for the material
  20992. */
  20993. unfreeze(): void;
  20994. /**
  20995. * Specifies if the material is ready to be used
  20996. * @param mesh defines the mesh to check
  20997. * @param useInstances specifies if instances should be used
  20998. * @returns a boolean indicating if the material is ready to be used
  20999. */
  21000. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21001. /**
  21002. * Specifies that the submesh is ready to be used
  21003. * @param mesh defines the mesh to check
  21004. * @param subMesh defines which submesh to check
  21005. * @param useInstances specifies that instances should be used
  21006. * @returns a boolean indicating that the submesh is ready or not
  21007. */
  21008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21009. /**
  21010. * Returns the material effect
  21011. * @returns the effect associated with the material
  21012. */
  21013. getEffect(): Nullable<Effect>;
  21014. /**
  21015. * Returns the current scene
  21016. * @returns a Scene
  21017. */
  21018. getScene(): Scene;
  21019. /**
  21020. * Specifies if the material will require alpha blending
  21021. * @returns a boolean specifying if alpha blending is needed
  21022. */
  21023. needAlphaBlending(): boolean;
  21024. /**
  21025. * Specifies if the mesh will require alpha blending
  21026. * @param mesh defines the mesh to check
  21027. * @returns a boolean specifying if alpha blending is needed for the mesh
  21028. */
  21029. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21030. /**
  21031. * Specifies if this material should be rendered in alpha test mode
  21032. * @returns a boolean specifying if an alpha test is needed.
  21033. */
  21034. needAlphaTesting(): boolean;
  21035. /**
  21036. * Gets the texture used for the alpha test
  21037. * @returns the texture to use for alpha testing
  21038. */
  21039. getAlphaTestTexture(): Nullable<BaseTexture>;
  21040. /**
  21041. * Marks the material to indicate that it needs to be re-calculated
  21042. */
  21043. markDirty(): void;
  21044. /** @hidden */
  21045. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21046. /**
  21047. * Binds the material to the mesh
  21048. * @param world defines the world transformation matrix
  21049. * @param mesh defines the mesh to bind the material to
  21050. */
  21051. bind(world: Matrix, mesh?: Mesh): void;
  21052. /**
  21053. * Binds the submesh to the material
  21054. * @param world defines the world transformation matrix
  21055. * @param mesh defines the mesh containing the submesh
  21056. * @param subMesh defines the submesh to bind the material to
  21057. */
  21058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21059. /**
  21060. * Binds the world matrix to the material
  21061. * @param world defines the world transformation matrix
  21062. */
  21063. bindOnlyWorldMatrix(world: Matrix): void;
  21064. /**
  21065. * Binds the scene's uniform buffer to the effect.
  21066. * @param effect defines the effect to bind to the scene uniform buffer
  21067. * @param sceneUbo defines the uniform buffer storing scene data
  21068. */
  21069. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21070. /**
  21071. * Binds the view matrix to the effect
  21072. * @param effect defines the effect to bind the view matrix to
  21073. */
  21074. bindView(effect: Effect): void;
  21075. /**
  21076. * Binds the view projection matrix to the effect
  21077. * @param effect defines the effect to bind the view projection matrix to
  21078. */
  21079. bindViewProjection(effect: Effect): void;
  21080. /**
  21081. * Specifies if material alpha testing should be turned on for the mesh
  21082. * @param mesh defines the mesh to check
  21083. */
  21084. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21085. /**
  21086. * Processes to execute after binding the material to a mesh
  21087. * @param mesh defines the rendered mesh
  21088. */
  21089. protected _afterBind(mesh?: Mesh): void;
  21090. /**
  21091. * Unbinds the material from the mesh
  21092. */
  21093. unbind(): void;
  21094. /**
  21095. * Gets the active textures from the material
  21096. * @returns an array of textures
  21097. */
  21098. getActiveTextures(): BaseTexture[];
  21099. /**
  21100. * Specifies if the material uses a texture
  21101. * @param texture defines the texture to check against the material
  21102. * @returns a boolean specifying if the material uses the texture
  21103. */
  21104. hasTexture(texture: BaseTexture): boolean;
  21105. /**
  21106. * Makes a duplicate of the material, and gives it a new name
  21107. * @param name defines the new name for the duplicated material
  21108. * @returns the cloned material
  21109. */
  21110. clone(name: string): Nullable<Material>;
  21111. /**
  21112. * Gets the meshes bound to the material
  21113. * @returns an array of meshes bound to the material
  21114. */
  21115. getBindedMeshes(): AbstractMesh[];
  21116. /**
  21117. * Force shader compilation
  21118. * @param mesh defines the mesh associated with this material
  21119. * @param onCompiled defines a function to execute once the material is compiled
  21120. * @param options defines the options to configure the compilation
  21121. * @param onError defines a function to execute if the material fails compiling
  21122. */
  21123. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21124. /**
  21125. * Force shader compilation
  21126. * @param mesh defines the mesh that will use this material
  21127. * @param options defines additional options for compiling the shaders
  21128. * @returns a promise that resolves when the compilation completes
  21129. */
  21130. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21131. private static readonly _AllDirtyCallBack;
  21132. private static readonly _ImageProcessingDirtyCallBack;
  21133. private static readonly _TextureDirtyCallBack;
  21134. private static readonly _FresnelDirtyCallBack;
  21135. private static readonly _MiscDirtyCallBack;
  21136. private static readonly _LightsDirtyCallBack;
  21137. private static readonly _AttributeDirtyCallBack;
  21138. private static _FresnelAndMiscDirtyCallBack;
  21139. private static _TextureAndMiscDirtyCallBack;
  21140. private static readonly _DirtyCallbackArray;
  21141. private static readonly _RunDirtyCallBacks;
  21142. /**
  21143. * Marks a define in the material to indicate that it needs to be re-computed
  21144. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21145. */
  21146. markAsDirty(flag: number): void;
  21147. /**
  21148. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21149. * @param func defines a function which checks material defines against the submeshes
  21150. */
  21151. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21152. /**
  21153. * Indicates that we need to re-calculated for all submeshes
  21154. */
  21155. protected _markAllSubMeshesAsAllDirty(): void;
  21156. /**
  21157. * Indicates that image processing needs to be re-calculated for all submeshes
  21158. */
  21159. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21160. /**
  21161. * Indicates that textures need to be re-calculated for all submeshes
  21162. */
  21163. protected _markAllSubMeshesAsTexturesDirty(): void;
  21164. /**
  21165. * Indicates that fresnel needs to be re-calculated for all submeshes
  21166. */
  21167. protected _markAllSubMeshesAsFresnelDirty(): void;
  21168. /**
  21169. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21170. */
  21171. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21172. /**
  21173. * Indicates that lights need to be re-calculated for all submeshes
  21174. */
  21175. protected _markAllSubMeshesAsLightsDirty(): void;
  21176. /**
  21177. * Indicates that attributes need to be re-calculated for all submeshes
  21178. */
  21179. protected _markAllSubMeshesAsAttributesDirty(): void;
  21180. /**
  21181. * Indicates that misc needs to be re-calculated for all submeshes
  21182. */
  21183. protected _markAllSubMeshesAsMiscDirty(): void;
  21184. /**
  21185. * Indicates that textures and misc need to be re-calculated for all submeshes
  21186. */
  21187. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21188. /**
  21189. * Disposes the material
  21190. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21191. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21192. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21193. */
  21194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21195. /** @hidden */
  21196. private releaseVertexArrayObject;
  21197. /**
  21198. * Serializes this material
  21199. * @returns the serialized material object
  21200. */
  21201. serialize(): any;
  21202. /**
  21203. * Creates a material from parsed material data
  21204. * @param parsedMaterial defines parsed material data
  21205. * @param scene defines the hosting scene
  21206. * @param rootUrl defines the root URL to use to load textures
  21207. * @returns a new material
  21208. */
  21209. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21210. }
  21211. }
  21212. declare module BABYLON {
  21213. /**
  21214. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21215. * separate meshes. This can be use to improve performances.
  21216. * @see http://doc.babylonjs.com/how_to/multi_materials
  21217. */
  21218. export class MultiMaterial extends Material {
  21219. private _subMaterials;
  21220. /**
  21221. * Gets or Sets the list of Materials used within the multi material.
  21222. * They need to be ordered according to the submeshes order in the associated mesh
  21223. */
  21224. get subMaterials(): Nullable<Material>[];
  21225. set subMaterials(value: Nullable<Material>[]);
  21226. /**
  21227. * Function used to align with Node.getChildren()
  21228. * @returns the list of Materials used within the multi material
  21229. */
  21230. getChildren(): Nullable<Material>[];
  21231. /**
  21232. * Instantiates a new Multi Material
  21233. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21234. * separate meshes. This can be use to improve performances.
  21235. * @see http://doc.babylonjs.com/how_to/multi_materials
  21236. * @param name Define the name in the scene
  21237. * @param scene Define the scene the material belongs to
  21238. */
  21239. constructor(name: string, scene: Scene);
  21240. private _hookArray;
  21241. /**
  21242. * Get one of the submaterial by its index in the submaterials array
  21243. * @param index The index to look the sub material at
  21244. * @returns The Material if the index has been defined
  21245. */
  21246. getSubMaterial(index: number): Nullable<Material>;
  21247. /**
  21248. * Get the list of active textures for the whole sub materials list.
  21249. * @returns All the textures that will be used during the rendering
  21250. */
  21251. getActiveTextures(): BaseTexture[];
  21252. /**
  21253. * Gets the current class name of the material e.g. "MultiMaterial"
  21254. * Mainly use in serialization.
  21255. * @returns the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Checks if the material is ready to render the requested sub mesh
  21260. * @param mesh Define the mesh the submesh belongs to
  21261. * @param subMesh Define the sub mesh to look readyness for
  21262. * @param useInstances Define whether or not the material is used with instances
  21263. * @returns true if ready, otherwise false
  21264. */
  21265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21266. /**
  21267. * Clones the current material and its related sub materials
  21268. * @param name Define the name of the newly cloned material
  21269. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21270. * @returns the cloned material
  21271. */
  21272. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21273. /**
  21274. * Serializes the materials into a JSON representation.
  21275. * @returns the JSON representation
  21276. */
  21277. serialize(): any;
  21278. /**
  21279. * Dispose the material and release its associated resources
  21280. * @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)
  21281. * @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)
  21282. * @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)
  21283. */
  21284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21285. /**
  21286. * Creates a MultiMaterial from parsed MultiMaterial data.
  21287. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21288. * @param scene defines the hosting scene
  21289. * @returns a new MultiMaterial
  21290. */
  21291. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21292. }
  21293. }
  21294. declare module BABYLON {
  21295. /**
  21296. * Base class for submeshes
  21297. */
  21298. export class BaseSubMesh {
  21299. /** @hidden */
  21300. _materialDefines: Nullable<MaterialDefines>;
  21301. /** @hidden */
  21302. _materialEffect: Nullable<Effect>;
  21303. /**
  21304. * Gets material defines used by the effect associated to the sub mesh
  21305. */
  21306. get materialDefines(): Nullable<MaterialDefines>;
  21307. /**
  21308. * Sets material defines used by the effect associated to the sub mesh
  21309. */
  21310. set materialDefines(defines: Nullable<MaterialDefines>);
  21311. /**
  21312. * Gets associated effect
  21313. */
  21314. get effect(): Nullable<Effect>;
  21315. /**
  21316. * Sets associated effect (effect used to render this submesh)
  21317. * @param effect defines the effect to associate with
  21318. * @param defines defines the set of defines used to compile this effect
  21319. */
  21320. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21321. }
  21322. /**
  21323. * Defines a subdivision inside a mesh
  21324. */
  21325. export class SubMesh extends BaseSubMesh implements ICullable {
  21326. /** the material index to use */
  21327. materialIndex: number;
  21328. /** vertex index start */
  21329. verticesStart: number;
  21330. /** vertices count */
  21331. verticesCount: number;
  21332. /** index start */
  21333. indexStart: number;
  21334. /** indices count */
  21335. indexCount: number;
  21336. /** @hidden */
  21337. _linesIndexCount: number;
  21338. private _mesh;
  21339. private _renderingMesh;
  21340. private _boundingInfo;
  21341. private _linesIndexBuffer;
  21342. /** @hidden */
  21343. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21344. /** @hidden */
  21345. _trianglePlanes: Plane[];
  21346. /** @hidden */
  21347. _lastColliderTransformMatrix: Nullable<Matrix>;
  21348. /** @hidden */
  21349. _renderId: number;
  21350. /** @hidden */
  21351. _alphaIndex: number;
  21352. /** @hidden */
  21353. _distanceToCamera: number;
  21354. /** @hidden */
  21355. _id: number;
  21356. private _currentMaterial;
  21357. /**
  21358. * Add a new submesh to a mesh
  21359. * @param materialIndex defines the material index to use
  21360. * @param verticesStart defines vertex index start
  21361. * @param verticesCount defines vertices count
  21362. * @param indexStart defines index start
  21363. * @param indexCount defines indices count
  21364. * @param mesh defines the parent mesh
  21365. * @param renderingMesh defines an optional rendering mesh
  21366. * @param createBoundingBox defines if bounding box should be created for this submesh
  21367. * @returns the new submesh
  21368. */
  21369. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21370. /**
  21371. * Creates a new submesh
  21372. * @param materialIndex defines the material index to use
  21373. * @param verticesStart defines vertex index start
  21374. * @param verticesCount defines vertices count
  21375. * @param indexStart defines index start
  21376. * @param indexCount defines indices count
  21377. * @param mesh defines the parent mesh
  21378. * @param renderingMesh defines an optional rendering mesh
  21379. * @param createBoundingBox defines if bounding box should be created for this submesh
  21380. */
  21381. constructor(
  21382. /** the material index to use */
  21383. materialIndex: number,
  21384. /** vertex index start */
  21385. verticesStart: number,
  21386. /** vertices count */
  21387. verticesCount: number,
  21388. /** index start */
  21389. indexStart: number,
  21390. /** indices count */
  21391. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21392. /**
  21393. * Returns true if this submesh covers the entire parent mesh
  21394. * @ignorenaming
  21395. */
  21396. get IsGlobal(): boolean;
  21397. /**
  21398. * Returns the submesh BoudingInfo object
  21399. * @returns current bounding info (or mesh's one if the submesh is global)
  21400. */
  21401. getBoundingInfo(): BoundingInfo;
  21402. /**
  21403. * Sets the submesh BoundingInfo
  21404. * @param boundingInfo defines the new bounding info to use
  21405. * @returns the SubMesh
  21406. */
  21407. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21408. /**
  21409. * Returns the mesh of the current submesh
  21410. * @return the parent mesh
  21411. */
  21412. getMesh(): AbstractMesh;
  21413. /**
  21414. * Returns the rendering mesh of the submesh
  21415. * @returns the rendering mesh (could be different from parent mesh)
  21416. */
  21417. getRenderingMesh(): Mesh;
  21418. /**
  21419. * Returns the submesh material
  21420. * @returns null or the current material
  21421. */
  21422. getMaterial(): Nullable<Material>;
  21423. /**
  21424. * Sets a new updated BoundingInfo object to the submesh
  21425. * @param data defines an optional position array to use to determine the bounding info
  21426. * @returns the SubMesh
  21427. */
  21428. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21429. /** @hidden */
  21430. _checkCollision(collider: Collider): boolean;
  21431. /**
  21432. * Updates the submesh BoundingInfo
  21433. * @param world defines the world matrix to use to update the bounding info
  21434. * @returns the submesh
  21435. */
  21436. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21437. /**
  21438. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21439. * @param frustumPlanes defines the frustum planes
  21440. * @returns true if the submesh is intersecting with the frustum
  21441. */
  21442. isInFrustum(frustumPlanes: Plane[]): boolean;
  21443. /**
  21444. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21445. * @param frustumPlanes defines the frustum planes
  21446. * @returns true if the submesh is inside the frustum
  21447. */
  21448. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21449. /**
  21450. * Renders the submesh
  21451. * @param enableAlphaMode defines if alpha needs to be used
  21452. * @returns the submesh
  21453. */
  21454. render(enableAlphaMode: boolean): SubMesh;
  21455. /**
  21456. * @hidden
  21457. */
  21458. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21459. /**
  21460. * Checks if the submesh intersects with a ray
  21461. * @param ray defines the ray to test
  21462. * @returns true is the passed ray intersects the submesh bounding box
  21463. */
  21464. canIntersects(ray: Ray): boolean;
  21465. /**
  21466. * Intersects current submesh with a ray
  21467. * @param ray defines the ray to test
  21468. * @param positions defines mesh's positions array
  21469. * @param indices defines mesh's indices array
  21470. * @param fastCheck defines if only bounding info should be used
  21471. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21472. * @returns intersection info or null if no intersection
  21473. */
  21474. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21475. /** @hidden */
  21476. private _intersectLines;
  21477. /** @hidden */
  21478. private _intersectUnIndexedLines;
  21479. /** @hidden */
  21480. private _intersectTriangles;
  21481. /** @hidden */
  21482. private _intersectUnIndexedTriangles;
  21483. /** @hidden */
  21484. _rebuild(): void;
  21485. /**
  21486. * Creates a new submesh from the passed mesh
  21487. * @param newMesh defines the new hosting mesh
  21488. * @param newRenderingMesh defines an optional rendering mesh
  21489. * @returns the new submesh
  21490. */
  21491. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21492. /**
  21493. * Release associated resources
  21494. */
  21495. dispose(): void;
  21496. /**
  21497. * Gets the class name
  21498. * @returns the string "SubMesh".
  21499. */
  21500. getClassName(): string;
  21501. /**
  21502. * Creates a new submesh from indices data
  21503. * @param materialIndex the index of the main mesh material
  21504. * @param startIndex the index where to start the copy in the mesh indices array
  21505. * @param indexCount the number of indices to copy then from the startIndex
  21506. * @param mesh the main mesh to create the submesh from
  21507. * @param renderingMesh the optional rendering mesh
  21508. * @returns a new submesh
  21509. */
  21510. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21511. }
  21512. }
  21513. declare module BABYLON {
  21514. /**
  21515. * Class used to represent data loading progression
  21516. */
  21517. export class SceneLoaderFlags {
  21518. private static _ForceFullSceneLoadingForIncremental;
  21519. private static _ShowLoadingScreen;
  21520. private static _CleanBoneMatrixWeights;
  21521. private static _loggingLevel;
  21522. /**
  21523. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21524. */
  21525. static get ForceFullSceneLoadingForIncremental(): boolean;
  21526. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21527. /**
  21528. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21529. */
  21530. static get ShowLoadingScreen(): boolean;
  21531. static set ShowLoadingScreen(value: boolean);
  21532. /**
  21533. * Defines the current logging level (while loading the scene)
  21534. * @ignorenaming
  21535. */
  21536. static get loggingLevel(): number;
  21537. static set loggingLevel(value: number);
  21538. /**
  21539. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21540. */
  21541. static get CleanBoneMatrixWeights(): boolean;
  21542. static set CleanBoneMatrixWeights(value: boolean);
  21543. }
  21544. }
  21545. declare module BABYLON {
  21546. /**
  21547. * Class used to store geometry data (vertex buffers + index buffer)
  21548. */
  21549. export class Geometry implements IGetSetVerticesData {
  21550. /**
  21551. * Gets or sets the ID of the geometry
  21552. */
  21553. id: string;
  21554. /**
  21555. * Gets or sets the unique ID of the geometry
  21556. */
  21557. uniqueId: number;
  21558. /**
  21559. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21560. */
  21561. delayLoadState: number;
  21562. /**
  21563. * Gets the file containing the data to load when running in delay load state
  21564. */
  21565. delayLoadingFile: Nullable<string>;
  21566. /**
  21567. * Callback called when the geometry is updated
  21568. */
  21569. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21570. private _scene;
  21571. private _engine;
  21572. private _meshes;
  21573. private _totalVertices;
  21574. /** @hidden */
  21575. _indices: IndicesArray;
  21576. /** @hidden */
  21577. _vertexBuffers: {
  21578. [key: string]: VertexBuffer;
  21579. };
  21580. private _isDisposed;
  21581. private _extend;
  21582. private _boundingBias;
  21583. /** @hidden */
  21584. _delayInfo: Array<string>;
  21585. private _indexBuffer;
  21586. private _indexBufferIsUpdatable;
  21587. /** @hidden */
  21588. _boundingInfo: Nullable<BoundingInfo>;
  21589. /** @hidden */
  21590. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21591. /** @hidden */
  21592. _softwareSkinningFrameId: number;
  21593. private _vertexArrayObjects;
  21594. private _updatable;
  21595. /** @hidden */
  21596. _positions: Nullable<Vector3[]>;
  21597. /**
  21598. * 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
  21599. */
  21600. get boundingBias(): Vector2;
  21601. /**
  21602. * 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
  21603. */
  21604. set boundingBias(value: Vector2);
  21605. /**
  21606. * Static function used to attach a new empty geometry to a mesh
  21607. * @param mesh defines the mesh to attach the geometry to
  21608. * @returns the new Geometry
  21609. */
  21610. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21611. /**
  21612. * Creates a new geometry
  21613. * @param id defines the unique ID
  21614. * @param scene defines the hosting scene
  21615. * @param vertexData defines the VertexData used to get geometry data
  21616. * @param updatable defines if geometry must be updatable (false by default)
  21617. * @param mesh defines the mesh that will be associated with the geometry
  21618. */
  21619. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21620. /**
  21621. * Gets the current extend of the geometry
  21622. */
  21623. get extend(): {
  21624. minimum: Vector3;
  21625. maximum: Vector3;
  21626. };
  21627. /**
  21628. * Gets the hosting scene
  21629. * @returns the hosting Scene
  21630. */
  21631. getScene(): Scene;
  21632. /**
  21633. * Gets the hosting engine
  21634. * @returns the hosting Engine
  21635. */
  21636. getEngine(): Engine;
  21637. /**
  21638. * Defines if the geometry is ready to use
  21639. * @returns true if the geometry is ready to be used
  21640. */
  21641. isReady(): boolean;
  21642. /**
  21643. * Gets a value indicating that the geometry should not be serialized
  21644. */
  21645. get doNotSerialize(): boolean;
  21646. /** @hidden */
  21647. _rebuild(): void;
  21648. /**
  21649. * Affects all geometry data in one call
  21650. * @param vertexData defines the geometry data
  21651. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21652. */
  21653. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21654. /**
  21655. * Set specific vertex data
  21656. * @param kind defines the data kind (Position, normal, etc...)
  21657. * @param data defines the vertex data to use
  21658. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21659. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21660. */
  21661. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21662. /**
  21663. * Removes a specific vertex data
  21664. * @param kind defines the data kind (Position, normal, etc...)
  21665. */
  21666. removeVerticesData(kind: string): void;
  21667. /**
  21668. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21669. * @param buffer defines the vertex buffer to use
  21670. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21671. */
  21672. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21673. /**
  21674. * Update a specific vertex buffer
  21675. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21676. * It will do nothing if the buffer is not updatable
  21677. * @param kind defines the data kind (Position, normal, etc...)
  21678. * @param data defines the data to use
  21679. * @param offset defines the offset in the target buffer where to store the data
  21680. * @param useBytes set to true if the offset is in bytes
  21681. */
  21682. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21683. /**
  21684. * Update a specific vertex buffer
  21685. * This function will create a new buffer if the current one is not updatable
  21686. * @param kind defines the data kind (Position, normal, etc...)
  21687. * @param data defines the data to use
  21688. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21689. */
  21690. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21691. private _updateBoundingInfo;
  21692. /** @hidden */
  21693. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21694. /**
  21695. * Gets total number of vertices
  21696. * @returns the total number of vertices
  21697. */
  21698. getTotalVertices(): number;
  21699. /**
  21700. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21701. * @param kind defines the data kind (Position, normal, etc...)
  21702. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21703. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21704. * @returns a float array containing vertex data
  21705. */
  21706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21707. /**
  21708. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21709. * @param kind defines the data kind (Position, normal, etc...)
  21710. * @returns true if the vertex buffer with the specified kind is updatable
  21711. */
  21712. isVertexBufferUpdatable(kind: string): boolean;
  21713. /**
  21714. * Gets a specific vertex buffer
  21715. * @param kind defines the data kind (Position, normal, etc...)
  21716. * @returns a VertexBuffer
  21717. */
  21718. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21719. /**
  21720. * Returns all vertex buffers
  21721. * @return an object holding all vertex buffers indexed by kind
  21722. */
  21723. getVertexBuffers(): Nullable<{
  21724. [key: string]: VertexBuffer;
  21725. }>;
  21726. /**
  21727. * Gets a boolean indicating if specific vertex buffer is present
  21728. * @param kind defines the data kind (Position, normal, etc...)
  21729. * @returns true if data is present
  21730. */
  21731. isVerticesDataPresent(kind: string): boolean;
  21732. /**
  21733. * Gets a list of all attached data kinds (Position, normal, etc...)
  21734. * @returns a list of string containing all kinds
  21735. */
  21736. getVerticesDataKinds(): string[];
  21737. /**
  21738. * Update index buffer
  21739. * @param indices defines the indices to store in the index buffer
  21740. * @param offset defines the offset in the target buffer where to store the data
  21741. * @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)
  21742. */
  21743. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21744. /**
  21745. * Creates a new index buffer
  21746. * @param indices defines the indices to store in the index buffer
  21747. * @param totalVertices defines the total number of vertices (could be null)
  21748. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21749. */
  21750. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21751. /**
  21752. * Return the total number of indices
  21753. * @returns the total number of indices
  21754. */
  21755. getTotalIndices(): number;
  21756. /**
  21757. * Gets the index buffer array
  21758. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21760. * @returns the index buffer array
  21761. */
  21762. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21763. /**
  21764. * Gets the index buffer
  21765. * @return the index buffer
  21766. */
  21767. getIndexBuffer(): Nullable<DataBuffer>;
  21768. /** @hidden */
  21769. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21770. /**
  21771. * Release the associated resources for a specific mesh
  21772. * @param mesh defines the source mesh
  21773. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21774. */
  21775. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21776. /**
  21777. * Apply current geometry to a given mesh
  21778. * @param mesh defines the mesh to apply geometry to
  21779. */
  21780. applyToMesh(mesh: Mesh): void;
  21781. private _updateExtend;
  21782. private _applyToMesh;
  21783. private notifyUpdate;
  21784. /**
  21785. * Load the geometry if it was flagged as delay loaded
  21786. * @param scene defines the hosting scene
  21787. * @param onLoaded defines a callback called when the geometry is loaded
  21788. */
  21789. load(scene: Scene, onLoaded?: () => void): void;
  21790. private _queueLoad;
  21791. /**
  21792. * Invert the geometry to move from a right handed system to a left handed one.
  21793. */
  21794. toLeftHanded(): void;
  21795. /** @hidden */
  21796. _resetPointsArrayCache(): void;
  21797. /** @hidden */
  21798. _generatePointsArray(): boolean;
  21799. /**
  21800. * Gets a value indicating if the geometry is disposed
  21801. * @returns true if the geometry was disposed
  21802. */
  21803. isDisposed(): boolean;
  21804. private _disposeVertexArrayObjects;
  21805. /**
  21806. * Free all associated resources
  21807. */
  21808. dispose(): void;
  21809. /**
  21810. * Clone the current geometry into a new geometry
  21811. * @param id defines the unique ID of the new geometry
  21812. * @returns a new geometry object
  21813. */
  21814. copy(id: string): Geometry;
  21815. /**
  21816. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21817. * @return a JSON representation of the current geometry data (without the vertices data)
  21818. */
  21819. serialize(): any;
  21820. private toNumberArray;
  21821. /**
  21822. * Serialize all vertices data into a JSON oject
  21823. * @returns a JSON representation of the current geometry data
  21824. */
  21825. serializeVerticeData(): any;
  21826. /**
  21827. * Extracts a clone of a mesh geometry
  21828. * @param mesh defines the source mesh
  21829. * @param id defines the unique ID of the new geometry object
  21830. * @returns the new geometry object
  21831. */
  21832. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21833. /**
  21834. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21835. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21836. * Be aware Math.random() could cause collisions, but:
  21837. * "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"
  21838. * @returns a string containing a new GUID
  21839. */
  21840. static RandomId(): string;
  21841. /** @hidden */
  21842. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21843. private static _CleanMatricesWeights;
  21844. /**
  21845. * Create a new geometry from persisted data (Using .babylon file format)
  21846. * @param parsedVertexData defines the persisted data
  21847. * @param scene defines the hosting scene
  21848. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21849. * @returns the new geometry object
  21850. */
  21851. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21852. }
  21853. }
  21854. declare module BABYLON {
  21855. /**
  21856. * Define an interface for all classes that will get and set the data on vertices
  21857. */
  21858. export interface IGetSetVerticesData {
  21859. /**
  21860. * Gets a boolean indicating if specific vertex data is present
  21861. * @param kind defines the vertex data kind to use
  21862. * @returns true is data kind is present
  21863. */
  21864. isVerticesDataPresent(kind: string): boolean;
  21865. /**
  21866. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21869. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21870. * @returns a float array containing vertex data
  21871. */
  21872. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21873. /**
  21874. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21875. * @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.
  21876. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21877. * @returns the indices array or an empty array if the mesh has no geometry
  21878. */
  21879. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21880. /**
  21881. * Set specific vertex data
  21882. * @param kind defines the data kind (Position, normal, etc...)
  21883. * @param data defines the vertex data to use
  21884. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21885. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21886. */
  21887. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21888. /**
  21889. * Update a specific associated vertex buffer
  21890. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21891. * - VertexBuffer.PositionKind
  21892. * - VertexBuffer.UVKind
  21893. * - VertexBuffer.UV2Kind
  21894. * - VertexBuffer.UV3Kind
  21895. * - VertexBuffer.UV4Kind
  21896. * - VertexBuffer.UV5Kind
  21897. * - VertexBuffer.UV6Kind
  21898. * - VertexBuffer.ColorKind
  21899. * - VertexBuffer.MatricesIndicesKind
  21900. * - VertexBuffer.MatricesIndicesExtraKind
  21901. * - VertexBuffer.MatricesWeightsKind
  21902. * - VertexBuffer.MatricesWeightsExtraKind
  21903. * @param data defines the data source
  21904. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21905. * @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)
  21906. */
  21907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21908. /**
  21909. * Creates a new index buffer
  21910. * @param indices defines the indices to store in the index buffer
  21911. * @param totalVertices defines the total number of vertices (could be null)
  21912. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21913. */
  21914. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21915. }
  21916. /**
  21917. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21918. */
  21919. export class VertexData {
  21920. /**
  21921. * Mesh side orientation : usually the external or front surface
  21922. */
  21923. static readonly FRONTSIDE: number;
  21924. /**
  21925. * Mesh side orientation : usually the internal or back surface
  21926. */
  21927. static readonly BACKSIDE: number;
  21928. /**
  21929. * Mesh side orientation : both internal and external or front and back surfaces
  21930. */
  21931. static readonly DOUBLESIDE: number;
  21932. /**
  21933. * Mesh side orientation : by default, `FRONTSIDE`
  21934. */
  21935. static readonly DEFAULTSIDE: number;
  21936. /**
  21937. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21938. */
  21939. positions: Nullable<FloatArray>;
  21940. /**
  21941. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21942. */
  21943. normals: Nullable<FloatArray>;
  21944. /**
  21945. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21946. */
  21947. tangents: Nullable<FloatArray>;
  21948. /**
  21949. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21950. */
  21951. uvs: Nullable<FloatArray>;
  21952. /**
  21953. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21954. */
  21955. uvs2: Nullable<FloatArray>;
  21956. /**
  21957. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21958. */
  21959. uvs3: Nullable<FloatArray>;
  21960. /**
  21961. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21962. */
  21963. uvs4: Nullable<FloatArray>;
  21964. /**
  21965. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21966. */
  21967. uvs5: Nullable<FloatArray>;
  21968. /**
  21969. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21970. */
  21971. uvs6: Nullable<FloatArray>;
  21972. /**
  21973. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21974. */
  21975. colors: Nullable<FloatArray>;
  21976. /**
  21977. * 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).
  21978. */
  21979. matricesIndices: Nullable<FloatArray>;
  21980. /**
  21981. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21982. */
  21983. matricesWeights: Nullable<FloatArray>;
  21984. /**
  21985. * An array extending the number of possible indices
  21986. */
  21987. matricesIndicesExtra: Nullable<FloatArray>;
  21988. /**
  21989. * An array extending the number of possible weights when the number of indices is extended
  21990. */
  21991. matricesWeightsExtra: Nullable<FloatArray>;
  21992. /**
  21993. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21994. */
  21995. indices: Nullable<IndicesArray>;
  21996. /**
  21997. * Uses the passed data array to set the set the values for the specified kind of data
  21998. * @param data a linear array of floating numbers
  21999. * @param kind the type of data that is being set, eg positions, colors etc
  22000. */
  22001. set(data: FloatArray, kind: string): void;
  22002. /**
  22003. * Associates the vertexData to the passed Mesh.
  22004. * Sets it as updatable or not (default `false`)
  22005. * @param mesh the mesh the vertexData is applied to
  22006. * @param updatable when used and having the value true allows new data to update the vertexData
  22007. * @returns the VertexData
  22008. */
  22009. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22010. /**
  22011. * Associates the vertexData to the passed Geometry.
  22012. * Sets it as updatable or not (default `false`)
  22013. * @param geometry the geometry the vertexData is applied to
  22014. * @param updatable when used and having the value true allows new data to update the vertexData
  22015. * @returns VertexData
  22016. */
  22017. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22018. /**
  22019. * Updates the associated mesh
  22020. * @param mesh the mesh to be updated
  22021. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22022. * @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
  22023. * @returns VertexData
  22024. */
  22025. updateMesh(mesh: Mesh): VertexData;
  22026. /**
  22027. * Updates the associated geometry
  22028. * @param geometry the geometry to be updated
  22029. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22030. * @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
  22031. * @returns VertexData.
  22032. */
  22033. updateGeometry(geometry: Geometry): VertexData;
  22034. private _applyTo;
  22035. private _update;
  22036. /**
  22037. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22038. * @param matrix the transforming matrix
  22039. * @returns the VertexData
  22040. */
  22041. transform(matrix: Matrix): VertexData;
  22042. /**
  22043. * Merges the passed VertexData into the current one
  22044. * @param other the VertexData to be merged into the current one
  22045. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22046. * @returns the modified VertexData
  22047. */
  22048. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22049. private _mergeElement;
  22050. private _validate;
  22051. /**
  22052. * Serializes the VertexData
  22053. * @returns a serialized object
  22054. */
  22055. serialize(): any;
  22056. /**
  22057. * Extracts the vertexData from a mesh
  22058. * @param mesh the mesh from which to extract the VertexData
  22059. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22060. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22061. * @returns the object VertexData associated to the passed mesh
  22062. */
  22063. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22064. /**
  22065. * Extracts the vertexData from the geometry
  22066. * @param geometry the geometry from which to extract the VertexData
  22067. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22068. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22069. * @returns the object VertexData associated to the passed mesh
  22070. */
  22071. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22072. private static _ExtractFrom;
  22073. /**
  22074. * Creates the VertexData for a Ribbon
  22075. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22076. * * pathArray array of paths, each of which an array of successive Vector3
  22077. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22078. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22079. * * 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
  22080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22081. * * 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)
  22082. * * 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)
  22083. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22084. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22085. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22086. * @returns the VertexData of the ribbon
  22087. */
  22088. static CreateRibbon(options: {
  22089. pathArray: Vector3[][];
  22090. closeArray?: boolean;
  22091. closePath?: boolean;
  22092. offset?: number;
  22093. sideOrientation?: number;
  22094. frontUVs?: Vector4;
  22095. backUVs?: Vector4;
  22096. invertUV?: boolean;
  22097. uvs?: Vector2[];
  22098. colors?: Color4[];
  22099. }): VertexData;
  22100. /**
  22101. * Creates the VertexData for a box
  22102. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22103. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22104. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22105. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22106. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22107. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22108. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22110. * * 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)
  22111. * * 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)
  22112. * @returns the VertexData of the box
  22113. */
  22114. static CreateBox(options: {
  22115. size?: number;
  22116. width?: number;
  22117. height?: number;
  22118. depth?: number;
  22119. faceUV?: Vector4[];
  22120. faceColors?: Color4[];
  22121. sideOrientation?: number;
  22122. frontUVs?: Vector4;
  22123. backUVs?: Vector4;
  22124. }): VertexData;
  22125. /**
  22126. * Creates the VertexData for a tiled box
  22127. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22128. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22129. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22130. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22131. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22132. * @returns the VertexData of the box
  22133. */
  22134. static CreateTiledBox(options: {
  22135. pattern?: number;
  22136. width?: number;
  22137. height?: number;
  22138. depth?: number;
  22139. tileSize?: number;
  22140. tileWidth?: number;
  22141. tileHeight?: number;
  22142. alignHorizontal?: number;
  22143. alignVertical?: number;
  22144. faceUV?: Vector4[];
  22145. faceColors?: Color4[];
  22146. sideOrientation?: number;
  22147. }): VertexData;
  22148. /**
  22149. * Creates the VertexData for a tiled plane
  22150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22151. * * pattern a limited pattern arrangement depending on the number
  22152. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22153. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22154. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22156. * * 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)
  22157. * * 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)
  22158. * @returns the VertexData of the tiled plane
  22159. */
  22160. static CreateTiledPlane(options: {
  22161. pattern?: number;
  22162. tileSize?: number;
  22163. tileWidth?: number;
  22164. tileHeight?: number;
  22165. size?: number;
  22166. width?: number;
  22167. height?: number;
  22168. alignHorizontal?: number;
  22169. alignVertical?: number;
  22170. sideOrientation?: number;
  22171. frontUVs?: Vector4;
  22172. backUVs?: Vector4;
  22173. }): VertexData;
  22174. /**
  22175. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22176. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22177. * * segments sets the number of horizontal strips optional, default 32
  22178. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22179. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22180. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22181. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22182. * * 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
  22183. * * 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
  22184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22185. * * 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)
  22186. * * 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)
  22187. * @returns the VertexData of the ellipsoid
  22188. */
  22189. static CreateSphere(options: {
  22190. segments?: number;
  22191. diameter?: number;
  22192. diameterX?: number;
  22193. diameterY?: number;
  22194. diameterZ?: number;
  22195. arc?: number;
  22196. slice?: number;
  22197. sideOrientation?: number;
  22198. frontUVs?: Vector4;
  22199. backUVs?: Vector4;
  22200. }): VertexData;
  22201. /**
  22202. * Creates the VertexData for a cylinder, cone or prism
  22203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22204. * * height sets the height (y direction) of the cylinder, optional, default 2
  22205. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22206. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22207. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22208. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22209. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22210. * * 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
  22211. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22212. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22213. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22214. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22216. * * 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)
  22217. * * 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)
  22218. * @returns the VertexData of the cylinder, cone or prism
  22219. */
  22220. static CreateCylinder(options: {
  22221. height?: number;
  22222. diameterTop?: number;
  22223. diameterBottom?: number;
  22224. diameter?: number;
  22225. tessellation?: number;
  22226. subdivisions?: number;
  22227. arc?: number;
  22228. faceColors?: Color4[];
  22229. faceUV?: Vector4[];
  22230. hasRings?: boolean;
  22231. enclose?: boolean;
  22232. sideOrientation?: number;
  22233. frontUVs?: Vector4;
  22234. backUVs?: Vector4;
  22235. }): VertexData;
  22236. /**
  22237. * Creates the VertexData for a torus
  22238. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22239. * * diameter the diameter of the torus, optional default 1
  22240. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22241. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22243. * * 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)
  22244. * * 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)
  22245. * @returns the VertexData of the torus
  22246. */
  22247. static CreateTorus(options: {
  22248. diameter?: number;
  22249. thickness?: number;
  22250. tessellation?: number;
  22251. sideOrientation?: number;
  22252. frontUVs?: Vector4;
  22253. backUVs?: Vector4;
  22254. }): VertexData;
  22255. /**
  22256. * Creates the VertexData of the LineSystem
  22257. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22258. * - lines an array of lines, each line being an array of successive Vector3
  22259. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22260. * @returns the VertexData of the LineSystem
  22261. */
  22262. static CreateLineSystem(options: {
  22263. lines: Vector3[][];
  22264. colors?: Nullable<Color4[][]>;
  22265. }): VertexData;
  22266. /**
  22267. * Create the VertexData for a DashedLines
  22268. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22269. * - points an array successive Vector3
  22270. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22271. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22272. * - dashNb the intended total number of dashes, optional, default 200
  22273. * @returns the VertexData for the DashedLines
  22274. */
  22275. static CreateDashedLines(options: {
  22276. points: Vector3[];
  22277. dashSize?: number;
  22278. gapSize?: number;
  22279. dashNb?: number;
  22280. }): VertexData;
  22281. /**
  22282. * Creates the VertexData for a Ground
  22283. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22284. * - width the width (x direction) of the ground, optional, default 1
  22285. * - height the height (z direction) of the ground, optional, default 1
  22286. * - subdivisions the number of subdivisions per side, optional, default 1
  22287. * @returns the VertexData of the Ground
  22288. */
  22289. static CreateGround(options: {
  22290. width?: number;
  22291. height?: number;
  22292. subdivisions?: number;
  22293. subdivisionsX?: number;
  22294. subdivisionsY?: number;
  22295. }): VertexData;
  22296. /**
  22297. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22298. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22299. * * xmin the ground minimum X coordinate, optional, default -1
  22300. * * zmin the ground minimum Z coordinate, optional, default -1
  22301. * * xmax the ground maximum X coordinate, optional, default 1
  22302. * * zmax the ground maximum Z coordinate, optional, default 1
  22303. * * 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}
  22304. * * 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}
  22305. * @returns the VertexData of the TiledGround
  22306. */
  22307. static CreateTiledGround(options: {
  22308. xmin: number;
  22309. zmin: number;
  22310. xmax: number;
  22311. zmax: number;
  22312. subdivisions?: {
  22313. w: number;
  22314. h: number;
  22315. };
  22316. precision?: {
  22317. w: number;
  22318. h: number;
  22319. };
  22320. }): VertexData;
  22321. /**
  22322. * Creates the VertexData of the Ground designed from a heightmap
  22323. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22324. * * width the width (x direction) of the ground
  22325. * * height the height (z direction) of the ground
  22326. * * subdivisions the number of subdivisions per side
  22327. * * minHeight the minimum altitude on the ground, optional, default 0
  22328. * * maxHeight the maximum altitude on the ground, optional default 1
  22329. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22330. * * buffer the array holding the image color data
  22331. * * bufferWidth the width of image
  22332. * * bufferHeight the height of image
  22333. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22334. * @returns the VertexData of the Ground designed from a heightmap
  22335. */
  22336. static CreateGroundFromHeightMap(options: {
  22337. width: number;
  22338. height: number;
  22339. subdivisions: number;
  22340. minHeight: number;
  22341. maxHeight: number;
  22342. colorFilter: Color3;
  22343. buffer: Uint8Array;
  22344. bufferWidth: number;
  22345. bufferHeight: number;
  22346. alphaFilter: number;
  22347. }): VertexData;
  22348. /**
  22349. * Creates the VertexData for a Plane
  22350. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22351. * * size sets the width and height of the plane to the value of size, optional default 1
  22352. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22353. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * 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)
  22356. * * 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)
  22357. * @returns the VertexData of the box
  22358. */
  22359. static CreatePlane(options: {
  22360. size?: number;
  22361. width?: number;
  22362. height?: number;
  22363. sideOrientation?: number;
  22364. frontUVs?: Vector4;
  22365. backUVs?: Vector4;
  22366. }): VertexData;
  22367. /**
  22368. * Creates the VertexData of the Disc or regular Polygon
  22369. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22370. * * radius the radius of the disc, optional default 0.5
  22371. * * tessellation the number of polygon sides, optional, default 64
  22372. * * 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
  22373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22374. * * 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)
  22375. * * 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)
  22376. * @returns the VertexData of the box
  22377. */
  22378. static CreateDisc(options: {
  22379. radius?: number;
  22380. tessellation?: number;
  22381. arc?: number;
  22382. sideOrientation?: number;
  22383. frontUVs?: Vector4;
  22384. backUVs?: Vector4;
  22385. }): VertexData;
  22386. /**
  22387. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22388. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22389. * @param polygon a mesh built from polygonTriangulation.build()
  22390. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22391. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22392. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22393. * @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)
  22394. * @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)
  22395. * @returns the VertexData of the Polygon
  22396. */
  22397. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22398. /**
  22399. * Creates the VertexData of the IcoSphere
  22400. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22401. * * radius the radius of the IcoSphere, optional default 1
  22402. * * radiusX allows stretching in the x direction, optional, default radius
  22403. * * radiusY allows stretching in the y direction, optional, default radius
  22404. * * radiusZ allows stretching in the z direction, optional, default radius
  22405. * * flat when true creates a flat shaded mesh, optional, default true
  22406. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22408. * * 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)
  22409. * * 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)
  22410. * @returns the VertexData of the IcoSphere
  22411. */
  22412. static CreateIcoSphere(options: {
  22413. radius?: number;
  22414. radiusX?: number;
  22415. radiusY?: number;
  22416. radiusZ?: number;
  22417. flat?: boolean;
  22418. subdivisions?: number;
  22419. sideOrientation?: number;
  22420. frontUVs?: Vector4;
  22421. backUVs?: Vector4;
  22422. }): VertexData;
  22423. /**
  22424. * Creates the VertexData for a Polyhedron
  22425. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22426. * * type provided types are:
  22427. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22428. * * 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)
  22429. * * size the size of the IcoSphere, optional default 1
  22430. * * sizeX allows stretching in the x direction, optional, default size
  22431. * * sizeY allows stretching in the y direction, optional, default size
  22432. * * sizeZ allows stretching in the z direction, optional, default size
  22433. * * 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
  22434. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22435. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22436. * * flat when true creates a flat shaded mesh, optional, default true
  22437. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22439. * * 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)
  22440. * * 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)
  22441. * @returns the VertexData of the Polyhedron
  22442. */
  22443. static CreatePolyhedron(options: {
  22444. type?: number;
  22445. size?: number;
  22446. sizeX?: number;
  22447. sizeY?: number;
  22448. sizeZ?: number;
  22449. custom?: any;
  22450. faceUV?: Vector4[];
  22451. faceColors?: Color4[];
  22452. flat?: boolean;
  22453. sideOrientation?: number;
  22454. frontUVs?: Vector4;
  22455. backUVs?: Vector4;
  22456. }): VertexData;
  22457. /**
  22458. * Creates the VertexData for a TorusKnot
  22459. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22460. * * radius the radius of the torus knot, optional, default 2
  22461. * * tube the thickness of the tube, optional, default 0.5
  22462. * * radialSegments the number of sides on each tube segments, optional, default 32
  22463. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22464. * * p the number of windings around the z axis, optional, default 2
  22465. * * q the number of windings around the x axis, optional, default 3
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * 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)
  22468. * * 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)
  22469. * @returns the VertexData of the Torus Knot
  22470. */
  22471. static CreateTorusKnot(options: {
  22472. radius?: number;
  22473. tube?: number;
  22474. radialSegments?: number;
  22475. tubularSegments?: number;
  22476. p?: number;
  22477. q?: number;
  22478. sideOrientation?: number;
  22479. frontUVs?: Vector4;
  22480. backUVs?: Vector4;
  22481. }): VertexData;
  22482. /**
  22483. * Compute normals for given positions and indices
  22484. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22485. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22486. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22487. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22488. * * facetNormals : optional array of facet normals (vector3)
  22489. * * facetPositions : optional array of facet positions (vector3)
  22490. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22491. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22492. * * bInfo : optional bounding info, required for facetPartitioning computation
  22493. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22494. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22495. * * useRightHandedSystem: optional boolean to for right handed system computation
  22496. * * depthSort : optional boolean to enable the facet depth sort computation
  22497. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22498. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22499. */
  22500. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22501. facetNormals?: any;
  22502. facetPositions?: any;
  22503. facetPartitioning?: any;
  22504. ratio?: number;
  22505. bInfo?: any;
  22506. bbSize?: Vector3;
  22507. subDiv?: any;
  22508. useRightHandedSystem?: boolean;
  22509. depthSort?: boolean;
  22510. distanceTo?: Vector3;
  22511. depthSortedFacets?: any;
  22512. }): void;
  22513. /** @hidden */
  22514. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22515. /**
  22516. * Applies VertexData created from the imported parameters to the geometry
  22517. * @param parsedVertexData the parsed data from an imported file
  22518. * @param geometry the geometry to apply the VertexData to
  22519. */
  22520. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22521. }
  22522. }
  22523. declare module BABYLON {
  22524. /**
  22525. * Defines a target to use with MorphTargetManager
  22526. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22527. */
  22528. export class MorphTarget implements IAnimatable {
  22529. /** defines the name of the target */
  22530. name: string;
  22531. /**
  22532. * Gets or sets the list of animations
  22533. */
  22534. animations: Animation[];
  22535. private _scene;
  22536. private _positions;
  22537. private _normals;
  22538. private _tangents;
  22539. private _uvs;
  22540. private _influence;
  22541. private _uniqueId;
  22542. /**
  22543. * Observable raised when the influence changes
  22544. */
  22545. onInfluenceChanged: Observable<boolean>;
  22546. /** @hidden */
  22547. _onDataLayoutChanged: Observable<void>;
  22548. /**
  22549. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22550. */
  22551. get influence(): number;
  22552. set influence(influence: number);
  22553. /**
  22554. * Gets or sets the id of the morph Target
  22555. */
  22556. id: string;
  22557. private _animationPropertiesOverride;
  22558. /**
  22559. * Gets or sets the animation properties override
  22560. */
  22561. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22562. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22563. /**
  22564. * Creates a new MorphTarget
  22565. * @param name defines the name of the target
  22566. * @param influence defines the influence to use
  22567. * @param scene defines the scene the morphtarget belongs to
  22568. */
  22569. constructor(
  22570. /** defines the name of the target */
  22571. name: string, influence?: number, scene?: Nullable<Scene>);
  22572. /**
  22573. * Gets the unique ID of this manager
  22574. */
  22575. get uniqueId(): number;
  22576. /**
  22577. * Gets a boolean defining if the target contains position data
  22578. */
  22579. get hasPositions(): boolean;
  22580. /**
  22581. * Gets a boolean defining if the target contains normal data
  22582. */
  22583. get hasNormals(): boolean;
  22584. /**
  22585. * Gets a boolean defining if the target contains tangent data
  22586. */
  22587. get hasTangents(): boolean;
  22588. /**
  22589. * Gets a boolean defining if the target contains texture coordinates data
  22590. */
  22591. get hasUVs(): boolean;
  22592. /**
  22593. * Affects position data to this target
  22594. * @param data defines the position data to use
  22595. */
  22596. setPositions(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the position data stored in this target
  22599. * @returns a FloatArray containing the position data (or null if not present)
  22600. */
  22601. getPositions(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects normal data to this target
  22604. * @param data defines the normal data to use
  22605. */
  22606. setNormals(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the normal data stored in this target
  22609. * @returns a FloatArray containing the normal data (or null if not present)
  22610. */
  22611. getNormals(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects tangent data to this target
  22614. * @param data defines the tangent data to use
  22615. */
  22616. setTangents(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the tangent data stored in this target
  22619. * @returns a FloatArray containing the tangent data (or null if not present)
  22620. */
  22621. getTangents(): Nullable<FloatArray>;
  22622. /**
  22623. * Affects texture coordinates data to this target
  22624. * @param data defines the texture coordinates data to use
  22625. */
  22626. setUVs(data: Nullable<FloatArray>): void;
  22627. /**
  22628. * Gets the texture coordinates data stored in this target
  22629. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22630. */
  22631. getUVs(): Nullable<FloatArray>;
  22632. /**
  22633. * Clone the current target
  22634. * @returns a new MorphTarget
  22635. */
  22636. clone(): MorphTarget;
  22637. /**
  22638. * Serializes the current target into a Serialization object
  22639. * @returns the serialized object
  22640. */
  22641. serialize(): any;
  22642. /**
  22643. * Returns the string "MorphTarget"
  22644. * @returns "MorphTarget"
  22645. */
  22646. getClassName(): string;
  22647. /**
  22648. * Creates a new target from serialized data
  22649. * @param serializationObject defines the serialized data to use
  22650. * @returns a new MorphTarget
  22651. */
  22652. static Parse(serializationObject: any): MorphTarget;
  22653. /**
  22654. * Creates a MorphTarget from mesh data
  22655. * @param mesh defines the source mesh
  22656. * @param name defines the name to use for the new target
  22657. * @param influence defines the influence to attach to the target
  22658. * @returns a new MorphTarget
  22659. */
  22660. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22661. }
  22662. }
  22663. declare module BABYLON {
  22664. /**
  22665. * This class is used to deform meshes using morphing between different targets
  22666. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22667. */
  22668. export class MorphTargetManager {
  22669. private _targets;
  22670. private _targetInfluenceChangedObservers;
  22671. private _targetDataLayoutChangedObservers;
  22672. private _activeTargets;
  22673. private _scene;
  22674. private _influences;
  22675. private _supportsNormals;
  22676. private _supportsTangents;
  22677. private _supportsUVs;
  22678. private _vertexCount;
  22679. private _uniqueId;
  22680. private _tempInfluences;
  22681. /**
  22682. * Gets or sets a boolean indicating if normals must be morphed
  22683. */
  22684. enableNormalMorphing: boolean;
  22685. /**
  22686. * Gets or sets a boolean indicating if tangents must be morphed
  22687. */
  22688. enableTangentMorphing: boolean;
  22689. /**
  22690. * Gets or sets a boolean indicating if UV must be morphed
  22691. */
  22692. enableUVMorphing: boolean;
  22693. /**
  22694. * Creates a new MorphTargetManager
  22695. * @param scene defines the current scene
  22696. */
  22697. constructor(scene?: Nullable<Scene>);
  22698. /**
  22699. * Gets the unique ID of this manager
  22700. */
  22701. get uniqueId(): number;
  22702. /**
  22703. * Gets the number of vertices handled by this manager
  22704. */
  22705. get vertexCount(): number;
  22706. /**
  22707. * Gets a boolean indicating if this manager supports morphing of normals
  22708. */
  22709. get supportsNormals(): boolean;
  22710. /**
  22711. * Gets a boolean indicating if this manager supports morphing of tangents
  22712. */
  22713. get supportsTangents(): boolean;
  22714. /**
  22715. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22716. */
  22717. get supportsUVs(): boolean;
  22718. /**
  22719. * Gets the number of targets stored in this manager
  22720. */
  22721. get numTargets(): number;
  22722. /**
  22723. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22724. */
  22725. get numInfluencers(): number;
  22726. /**
  22727. * Gets the list of influences (one per target)
  22728. */
  22729. get influences(): Float32Array;
  22730. /**
  22731. * Gets the active target at specified index. An active target is a target with an influence > 0
  22732. * @param index defines the index to check
  22733. * @returns the requested target
  22734. */
  22735. getActiveTarget(index: number): MorphTarget;
  22736. /**
  22737. * Gets the target at specified index
  22738. * @param index defines the index to check
  22739. * @returns the requested target
  22740. */
  22741. getTarget(index: number): MorphTarget;
  22742. /**
  22743. * Add a new target to this manager
  22744. * @param target defines the target to add
  22745. */
  22746. addTarget(target: MorphTarget): void;
  22747. /**
  22748. * Removes a target from the manager
  22749. * @param target defines the target to remove
  22750. */
  22751. removeTarget(target: MorphTarget): void;
  22752. /**
  22753. * Clone the current manager
  22754. * @returns a new MorphTargetManager
  22755. */
  22756. clone(): MorphTargetManager;
  22757. /**
  22758. * Serializes the current manager into a Serialization object
  22759. * @returns the serialized object
  22760. */
  22761. serialize(): any;
  22762. private _syncActiveTargets;
  22763. /**
  22764. * Syncrhonize the targets with all the meshes using this morph target manager
  22765. */
  22766. synchronize(): void;
  22767. /**
  22768. * Creates a new MorphTargetManager from serialized data
  22769. * @param serializationObject defines the serialized data
  22770. * @param scene defines the hosting scene
  22771. * @returns the new MorphTargetManager
  22772. */
  22773. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22774. }
  22775. }
  22776. declare module BABYLON {
  22777. /**
  22778. * Class used to represent a specific level of detail of a mesh
  22779. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22780. */
  22781. export class MeshLODLevel {
  22782. /** Defines the distance where this level should start being displayed */
  22783. distance: number;
  22784. /** Defines the mesh to use to render this level */
  22785. mesh: Nullable<Mesh>;
  22786. /**
  22787. * Creates a new LOD level
  22788. * @param distance defines the distance where this level should star being displayed
  22789. * @param mesh defines the mesh to use to render this level
  22790. */
  22791. constructor(
  22792. /** Defines the distance where this level should start being displayed */
  22793. distance: number,
  22794. /** Defines the mesh to use to render this level */
  22795. mesh: Nullable<Mesh>);
  22796. }
  22797. }
  22798. declare module BABYLON {
  22799. /**
  22800. * Mesh representing the gorund
  22801. */
  22802. export class GroundMesh extends Mesh {
  22803. /** If octree should be generated */
  22804. generateOctree: boolean;
  22805. private _heightQuads;
  22806. /** @hidden */
  22807. _subdivisionsX: number;
  22808. /** @hidden */
  22809. _subdivisionsY: number;
  22810. /** @hidden */
  22811. _width: number;
  22812. /** @hidden */
  22813. _height: number;
  22814. /** @hidden */
  22815. _minX: number;
  22816. /** @hidden */
  22817. _maxX: number;
  22818. /** @hidden */
  22819. _minZ: number;
  22820. /** @hidden */
  22821. _maxZ: number;
  22822. constructor(name: string, scene: Scene);
  22823. /**
  22824. * "GroundMesh"
  22825. * @returns "GroundMesh"
  22826. */
  22827. getClassName(): string;
  22828. /**
  22829. * The minimum of x and y subdivisions
  22830. */
  22831. get subdivisions(): number;
  22832. /**
  22833. * X subdivisions
  22834. */
  22835. get subdivisionsX(): number;
  22836. /**
  22837. * Y subdivisions
  22838. */
  22839. get subdivisionsY(): number;
  22840. /**
  22841. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22842. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22843. * @param chunksCount the number of subdivisions for x and y
  22844. * @param octreeBlocksSize (Default: 32)
  22845. */
  22846. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22847. /**
  22848. * Returns a height (y) value in the Worl system :
  22849. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22850. * @param x x coordinate
  22851. * @param z z coordinate
  22852. * @returns the ground y position if (x, z) are outside the ground surface.
  22853. */
  22854. getHeightAtCoordinates(x: number, z: number): number;
  22855. /**
  22856. * Returns a normalized vector (Vector3) orthogonal to the ground
  22857. * at the ground coordinates (x, z) expressed in the World system.
  22858. * @param x x coordinate
  22859. * @param z z coordinate
  22860. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22861. */
  22862. getNormalAtCoordinates(x: number, z: number): Vector3;
  22863. /**
  22864. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22865. * at the ground coordinates (x, z) expressed in the World system.
  22866. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22867. * @param x x coordinate
  22868. * @param z z coordinate
  22869. * @param ref vector to store the result
  22870. * @returns the GroundMesh.
  22871. */
  22872. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22873. /**
  22874. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22875. * if the ground has been updated.
  22876. * This can be used in the render loop.
  22877. * @returns the GroundMesh.
  22878. */
  22879. updateCoordinateHeights(): GroundMesh;
  22880. private _getFacetAt;
  22881. private _initHeightQuads;
  22882. private _computeHeightQuads;
  22883. /**
  22884. * Serializes this ground mesh
  22885. * @param serializationObject object to write serialization to
  22886. */
  22887. serialize(serializationObject: any): void;
  22888. /**
  22889. * Parses a serialized ground mesh
  22890. * @param parsedMesh the serialized mesh
  22891. * @param scene the scene to create the ground mesh in
  22892. * @returns the created ground mesh
  22893. */
  22894. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * Interface for Physics-Joint data
  22900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22901. */
  22902. export interface PhysicsJointData {
  22903. /**
  22904. * The main pivot of the joint
  22905. */
  22906. mainPivot?: Vector3;
  22907. /**
  22908. * The connected pivot of the joint
  22909. */
  22910. connectedPivot?: Vector3;
  22911. /**
  22912. * The main axis of the joint
  22913. */
  22914. mainAxis?: Vector3;
  22915. /**
  22916. * The connected axis of the joint
  22917. */
  22918. connectedAxis?: Vector3;
  22919. /**
  22920. * The collision of the joint
  22921. */
  22922. collision?: boolean;
  22923. /**
  22924. * Native Oimo/Cannon/Energy data
  22925. */
  22926. nativeParams?: any;
  22927. }
  22928. /**
  22929. * This is a holder class for the physics joint created by the physics plugin
  22930. * It holds a set of functions to control the underlying joint
  22931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22932. */
  22933. export class PhysicsJoint {
  22934. /**
  22935. * The type of the physics joint
  22936. */
  22937. type: number;
  22938. /**
  22939. * The data for the physics joint
  22940. */
  22941. jointData: PhysicsJointData;
  22942. private _physicsJoint;
  22943. protected _physicsPlugin: IPhysicsEnginePlugin;
  22944. /**
  22945. * Initializes the physics joint
  22946. * @param type The type of the physics joint
  22947. * @param jointData The data for the physics joint
  22948. */
  22949. constructor(
  22950. /**
  22951. * The type of the physics joint
  22952. */
  22953. type: number,
  22954. /**
  22955. * The data for the physics joint
  22956. */
  22957. jointData: PhysicsJointData);
  22958. /**
  22959. * Gets the physics joint
  22960. */
  22961. get physicsJoint(): any;
  22962. /**
  22963. * Sets the physics joint
  22964. */
  22965. set physicsJoint(newJoint: any);
  22966. /**
  22967. * Sets the physics plugin
  22968. */
  22969. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22970. /**
  22971. * Execute a function that is physics-plugin specific.
  22972. * @param {Function} func the function that will be executed.
  22973. * It accepts two parameters: the physics world and the physics joint
  22974. */
  22975. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22976. /**
  22977. * Distance-Joint type
  22978. */
  22979. static DistanceJoint: number;
  22980. /**
  22981. * Hinge-Joint type
  22982. */
  22983. static HingeJoint: number;
  22984. /**
  22985. * Ball-and-Socket joint type
  22986. */
  22987. static BallAndSocketJoint: number;
  22988. /**
  22989. * Wheel-Joint type
  22990. */
  22991. static WheelJoint: number;
  22992. /**
  22993. * Slider-Joint type
  22994. */
  22995. static SliderJoint: number;
  22996. /**
  22997. * Prismatic-Joint type
  22998. */
  22999. static PrismaticJoint: number;
  23000. /**
  23001. * Universal-Joint type
  23002. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23003. */
  23004. static UniversalJoint: number;
  23005. /**
  23006. * Hinge-Joint 2 type
  23007. */
  23008. static Hinge2Joint: number;
  23009. /**
  23010. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23011. */
  23012. static PointToPointJoint: number;
  23013. /**
  23014. * Spring-Joint type
  23015. */
  23016. static SpringJoint: number;
  23017. /**
  23018. * Lock-Joint type
  23019. */
  23020. static LockJoint: number;
  23021. }
  23022. /**
  23023. * A class representing a physics distance joint
  23024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23025. */
  23026. export class DistanceJoint extends PhysicsJoint {
  23027. /**
  23028. *
  23029. * @param jointData The data for the Distance-Joint
  23030. */
  23031. constructor(jointData: DistanceJointData);
  23032. /**
  23033. * Update the predefined distance.
  23034. * @param maxDistance The maximum preferred distance
  23035. * @param minDistance The minimum preferred distance
  23036. */
  23037. updateDistance(maxDistance: number, minDistance?: number): void;
  23038. }
  23039. /**
  23040. * Represents a Motor-Enabled Joint
  23041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23042. */
  23043. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23044. /**
  23045. * Initializes the Motor-Enabled Joint
  23046. * @param type The type of the joint
  23047. * @param jointData The physica joint data for the joint
  23048. */
  23049. constructor(type: number, jointData: PhysicsJointData);
  23050. /**
  23051. * Set the motor values.
  23052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23053. * @param force the force to apply
  23054. * @param maxForce max force for this motor.
  23055. */
  23056. setMotor(force?: number, maxForce?: number): void;
  23057. /**
  23058. * Set the motor's limits.
  23059. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23060. * @param upperLimit The upper limit of the motor
  23061. * @param lowerLimit The lower limit of the motor
  23062. */
  23063. setLimit(upperLimit: number, lowerLimit?: number): void;
  23064. }
  23065. /**
  23066. * This class represents a single physics Hinge-Joint
  23067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23068. */
  23069. export class HingeJoint extends MotorEnabledJoint {
  23070. /**
  23071. * Initializes the Hinge-Joint
  23072. * @param jointData The joint data for the Hinge-Joint
  23073. */
  23074. constructor(jointData: PhysicsJointData);
  23075. /**
  23076. * Set the motor values.
  23077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23078. * @param {number} force the force to apply
  23079. * @param {number} maxForce max force for this motor.
  23080. */
  23081. setMotor(force?: number, maxForce?: number): void;
  23082. /**
  23083. * Set the motor's limits.
  23084. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23085. * @param upperLimit The upper limit of the motor
  23086. * @param lowerLimit The lower limit of the motor
  23087. */
  23088. setLimit(upperLimit: number, lowerLimit?: number): void;
  23089. }
  23090. /**
  23091. * This class represents a dual hinge physics joint (same as wheel joint)
  23092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23093. */
  23094. export class Hinge2Joint extends MotorEnabledJoint {
  23095. /**
  23096. * Initializes the Hinge2-Joint
  23097. * @param jointData The joint data for the Hinge2-Joint
  23098. */
  23099. constructor(jointData: PhysicsJointData);
  23100. /**
  23101. * Set the motor values.
  23102. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23103. * @param {number} targetSpeed the speed the motor is to reach
  23104. * @param {number} maxForce max force for this motor.
  23105. * @param {motorIndex} the motor's index, 0 or 1.
  23106. */
  23107. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23108. /**
  23109. * Set the motor limits.
  23110. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23111. * @param {number} upperLimit the upper limit
  23112. * @param {number} lowerLimit lower limit
  23113. * @param {motorIndex} the motor's index, 0 or 1.
  23114. */
  23115. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23116. }
  23117. /**
  23118. * Interface for a motor enabled joint
  23119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23120. */
  23121. export interface IMotorEnabledJoint {
  23122. /**
  23123. * Physics joint
  23124. */
  23125. physicsJoint: any;
  23126. /**
  23127. * Sets the motor of the motor-enabled joint
  23128. * @param force The force of the motor
  23129. * @param maxForce The maximum force of the motor
  23130. * @param motorIndex The index of the motor
  23131. */
  23132. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23133. /**
  23134. * Sets the limit of the motor
  23135. * @param upperLimit The upper limit of the motor
  23136. * @param lowerLimit The lower limit of the motor
  23137. * @param motorIndex The index of the motor
  23138. */
  23139. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23140. }
  23141. /**
  23142. * Joint data for a Distance-Joint
  23143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23144. */
  23145. export interface DistanceJointData extends PhysicsJointData {
  23146. /**
  23147. * Max distance the 2 joint objects can be apart
  23148. */
  23149. maxDistance: number;
  23150. }
  23151. /**
  23152. * Joint data from a spring joint
  23153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23154. */
  23155. export interface SpringJointData extends PhysicsJointData {
  23156. /**
  23157. * Length of the spring
  23158. */
  23159. length: number;
  23160. /**
  23161. * Stiffness of the spring
  23162. */
  23163. stiffness: number;
  23164. /**
  23165. * Damping of the spring
  23166. */
  23167. damping: number;
  23168. /** this callback will be called when applying the force to the impostors. */
  23169. forceApplicationCallback: () => void;
  23170. }
  23171. }
  23172. declare module BABYLON {
  23173. /**
  23174. * Holds the data for the raycast result
  23175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23176. */
  23177. export class PhysicsRaycastResult {
  23178. private _hasHit;
  23179. private _hitDistance;
  23180. private _hitNormalWorld;
  23181. private _hitPointWorld;
  23182. private _rayFromWorld;
  23183. private _rayToWorld;
  23184. /**
  23185. * Gets if there was a hit
  23186. */
  23187. get hasHit(): boolean;
  23188. /**
  23189. * Gets the distance from the hit
  23190. */
  23191. get hitDistance(): number;
  23192. /**
  23193. * Gets the hit normal/direction in the world
  23194. */
  23195. get hitNormalWorld(): Vector3;
  23196. /**
  23197. * Gets the hit point in the world
  23198. */
  23199. get hitPointWorld(): Vector3;
  23200. /**
  23201. * Gets the ray "start point" of the ray in the world
  23202. */
  23203. get rayFromWorld(): Vector3;
  23204. /**
  23205. * Gets the ray "end point" of the ray in the world
  23206. */
  23207. get rayToWorld(): Vector3;
  23208. /**
  23209. * Sets the hit data (normal & point in world space)
  23210. * @param hitNormalWorld defines the normal in world space
  23211. * @param hitPointWorld defines the point in world space
  23212. */
  23213. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23214. /**
  23215. * Sets the distance from the start point to the hit point
  23216. * @param distance
  23217. */
  23218. setHitDistance(distance: number): void;
  23219. /**
  23220. * Calculates the distance manually
  23221. */
  23222. calculateHitDistance(): void;
  23223. /**
  23224. * Resets all the values to default
  23225. * @param from The from point on world space
  23226. * @param to The to point on world space
  23227. */
  23228. reset(from?: Vector3, to?: Vector3): void;
  23229. }
  23230. /**
  23231. * Interface for the size containing width and height
  23232. */
  23233. interface IXYZ {
  23234. /**
  23235. * X
  23236. */
  23237. x: number;
  23238. /**
  23239. * Y
  23240. */
  23241. y: number;
  23242. /**
  23243. * Z
  23244. */
  23245. z: number;
  23246. }
  23247. }
  23248. declare module BABYLON {
  23249. /**
  23250. * Interface used to describe a physics joint
  23251. */
  23252. export interface PhysicsImpostorJoint {
  23253. /** Defines the main impostor to which the joint is linked */
  23254. mainImpostor: PhysicsImpostor;
  23255. /** Defines the impostor that is connected to the main impostor using this joint */
  23256. connectedImpostor: PhysicsImpostor;
  23257. /** Defines the joint itself */
  23258. joint: PhysicsJoint;
  23259. }
  23260. /** @hidden */
  23261. export interface IPhysicsEnginePlugin {
  23262. world: any;
  23263. name: string;
  23264. setGravity(gravity: Vector3): void;
  23265. setTimeStep(timeStep: number): void;
  23266. getTimeStep(): number;
  23267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23271. removePhysicsBody(impostor: PhysicsImpostor): void;
  23272. generateJoint(joint: PhysicsImpostorJoint): void;
  23273. removeJoint(joint: PhysicsImpostorJoint): void;
  23274. isSupported(): boolean;
  23275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23282. getBodyMass(impostor: PhysicsImpostor): number;
  23283. getBodyFriction(impostor: PhysicsImpostor): number;
  23284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23285. getBodyRestitution(impostor: PhysicsImpostor): number;
  23286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23287. getBodyPressure?(impostor: PhysicsImpostor): number;
  23288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23297. sleepBody(impostor: PhysicsImpostor): void;
  23298. wakeUpBody(impostor: PhysicsImpostor): void;
  23299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23303. getRadius(impostor: PhysicsImpostor): number;
  23304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23306. dispose(): void;
  23307. }
  23308. /**
  23309. * Interface used to define a physics engine
  23310. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23311. */
  23312. export interface IPhysicsEngine {
  23313. /**
  23314. * Gets the gravity vector used by the simulation
  23315. */
  23316. gravity: Vector3;
  23317. /**
  23318. * Sets the gravity vector used by the simulation
  23319. * @param gravity defines the gravity vector to use
  23320. */
  23321. setGravity(gravity: Vector3): void;
  23322. /**
  23323. * Set the time step of the physics engine.
  23324. * Default is 1/60.
  23325. * To slow it down, enter 1/600 for example.
  23326. * To speed it up, 1/30
  23327. * @param newTimeStep the new timestep to apply to this world.
  23328. */
  23329. setTimeStep(newTimeStep: number): void;
  23330. /**
  23331. * Get the time step of the physics engine.
  23332. * @returns the current time step
  23333. */
  23334. getTimeStep(): number;
  23335. /**
  23336. * Set the sub time step of the physics engine.
  23337. * Default is 0 meaning there is no sub steps
  23338. * To increase physics resolution precision, set a small value (like 1 ms)
  23339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23340. */
  23341. setSubTimeStep(subTimeStep: number): void;
  23342. /**
  23343. * Get the sub time step of the physics engine.
  23344. * @returns the current sub time step
  23345. */
  23346. getSubTimeStep(): number;
  23347. /**
  23348. * Release all resources
  23349. */
  23350. dispose(): void;
  23351. /**
  23352. * Gets the name of the current physics plugin
  23353. * @returns the name of the plugin
  23354. */
  23355. getPhysicsPluginName(): string;
  23356. /**
  23357. * Adding a new impostor for the impostor tracking.
  23358. * This will be done by the impostor itself.
  23359. * @param impostor the impostor to add
  23360. */
  23361. addImpostor(impostor: PhysicsImpostor): void;
  23362. /**
  23363. * Remove an impostor from the engine.
  23364. * This impostor and its mesh will not longer be updated by the physics engine.
  23365. * @param impostor the impostor to remove
  23366. */
  23367. removeImpostor(impostor: PhysicsImpostor): void;
  23368. /**
  23369. * Add a joint to the physics engine
  23370. * @param mainImpostor defines the main impostor to which the joint is added.
  23371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23372. * @param joint defines the joint that will connect both impostors.
  23373. */
  23374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23375. /**
  23376. * Removes a joint from the simulation
  23377. * @param mainImpostor defines the impostor used with the joint
  23378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23379. * @param joint defines the joint to remove
  23380. */
  23381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23382. /**
  23383. * Gets the current plugin used to run the simulation
  23384. * @returns current plugin
  23385. */
  23386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23387. /**
  23388. * Gets the list of physic impostors
  23389. * @returns an array of PhysicsImpostor
  23390. */
  23391. getImpostors(): Array<PhysicsImpostor>;
  23392. /**
  23393. * Gets the impostor for a physics enabled object
  23394. * @param object defines the object impersonated by the impostor
  23395. * @returns the PhysicsImpostor or null if not found
  23396. */
  23397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23398. /**
  23399. * Gets the impostor for a physics body object
  23400. * @param body defines physics body used by the impostor
  23401. * @returns the PhysicsImpostor or null if not found
  23402. */
  23403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23404. /**
  23405. * Does a raycast in the physics world
  23406. * @param from when should the ray start?
  23407. * @param to when should the ray end?
  23408. * @returns PhysicsRaycastResult
  23409. */
  23410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23411. /**
  23412. * Called by the scene. No need to call it.
  23413. * @param delta defines the timespam between frames
  23414. */
  23415. _step(delta: number): void;
  23416. }
  23417. }
  23418. declare module BABYLON {
  23419. /**
  23420. * The interface for the physics imposter parameters
  23421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23422. */
  23423. export interface PhysicsImpostorParameters {
  23424. /**
  23425. * The mass of the physics imposter
  23426. */
  23427. mass: number;
  23428. /**
  23429. * The friction of the physics imposter
  23430. */
  23431. friction?: number;
  23432. /**
  23433. * The coefficient of restitution of the physics imposter
  23434. */
  23435. restitution?: number;
  23436. /**
  23437. * The native options of the physics imposter
  23438. */
  23439. nativeOptions?: any;
  23440. /**
  23441. * Specifies if the parent should be ignored
  23442. */
  23443. ignoreParent?: boolean;
  23444. /**
  23445. * Specifies if bi-directional transformations should be disabled
  23446. */
  23447. disableBidirectionalTransformation?: boolean;
  23448. /**
  23449. * The pressure inside the physics imposter, soft object only
  23450. */
  23451. pressure?: number;
  23452. /**
  23453. * The stiffness the physics imposter, soft object only
  23454. */
  23455. stiffness?: number;
  23456. /**
  23457. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23458. */
  23459. velocityIterations?: number;
  23460. /**
  23461. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23462. */
  23463. positionIterations?: number;
  23464. /**
  23465. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23466. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23467. * Add to fix multiple points
  23468. */
  23469. fixedPoints?: number;
  23470. /**
  23471. * The collision margin around a soft object
  23472. */
  23473. margin?: number;
  23474. /**
  23475. * The collision margin around a soft object
  23476. */
  23477. damping?: number;
  23478. /**
  23479. * The path for a rope based on an extrusion
  23480. */
  23481. path?: any;
  23482. /**
  23483. * The shape of an extrusion used for a rope based on an extrusion
  23484. */
  23485. shape?: any;
  23486. }
  23487. /**
  23488. * Interface for a physics-enabled object
  23489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23490. */
  23491. export interface IPhysicsEnabledObject {
  23492. /**
  23493. * The position of the physics-enabled object
  23494. */
  23495. position: Vector3;
  23496. /**
  23497. * The rotation of the physics-enabled object
  23498. */
  23499. rotationQuaternion: Nullable<Quaternion>;
  23500. /**
  23501. * The scale of the physics-enabled object
  23502. */
  23503. scaling: Vector3;
  23504. /**
  23505. * The rotation of the physics-enabled object
  23506. */
  23507. rotation?: Vector3;
  23508. /**
  23509. * The parent of the physics-enabled object
  23510. */
  23511. parent?: any;
  23512. /**
  23513. * The bounding info of the physics-enabled object
  23514. * @returns The bounding info of the physics-enabled object
  23515. */
  23516. getBoundingInfo(): BoundingInfo;
  23517. /**
  23518. * Computes the world matrix
  23519. * @param force Specifies if the world matrix should be computed by force
  23520. * @returns A world matrix
  23521. */
  23522. computeWorldMatrix(force: boolean): Matrix;
  23523. /**
  23524. * Gets the world matrix
  23525. * @returns A world matrix
  23526. */
  23527. getWorldMatrix?(): Matrix;
  23528. /**
  23529. * Gets the child meshes
  23530. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23531. * @returns An array of abstract meshes
  23532. */
  23533. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23534. /**
  23535. * Gets the vertex data
  23536. * @param kind The type of vertex data
  23537. * @returns A nullable array of numbers, or a float32 array
  23538. */
  23539. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23540. /**
  23541. * Gets the indices from the mesh
  23542. * @returns A nullable array of index arrays
  23543. */
  23544. getIndices?(): Nullable<IndicesArray>;
  23545. /**
  23546. * Gets the scene from the mesh
  23547. * @returns the indices array or null
  23548. */
  23549. getScene?(): Scene;
  23550. /**
  23551. * Gets the absolute position from the mesh
  23552. * @returns the absolute position
  23553. */
  23554. getAbsolutePosition(): Vector3;
  23555. /**
  23556. * Gets the absolute pivot point from the mesh
  23557. * @returns the absolute pivot point
  23558. */
  23559. getAbsolutePivotPoint(): Vector3;
  23560. /**
  23561. * Rotates the mesh
  23562. * @param axis The axis of rotation
  23563. * @param amount The amount of rotation
  23564. * @param space The space of the rotation
  23565. * @returns The rotation transform node
  23566. */
  23567. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23568. /**
  23569. * Translates the mesh
  23570. * @param axis The axis of translation
  23571. * @param distance The distance of translation
  23572. * @param space The space of the translation
  23573. * @returns The transform node
  23574. */
  23575. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23576. /**
  23577. * Sets the absolute position of the mesh
  23578. * @param absolutePosition The absolute position of the mesh
  23579. * @returns The transform node
  23580. */
  23581. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23582. /**
  23583. * Gets the class name of the mesh
  23584. * @returns The class name
  23585. */
  23586. getClassName(): string;
  23587. }
  23588. /**
  23589. * Represents a physics imposter
  23590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23591. */
  23592. export class PhysicsImpostor {
  23593. /**
  23594. * The physics-enabled object used as the physics imposter
  23595. */
  23596. object: IPhysicsEnabledObject;
  23597. /**
  23598. * The type of the physics imposter
  23599. */
  23600. type: number;
  23601. private _options;
  23602. private _scene?;
  23603. /**
  23604. * The default object size of the imposter
  23605. */
  23606. static DEFAULT_OBJECT_SIZE: Vector3;
  23607. /**
  23608. * The identity quaternion of the imposter
  23609. */
  23610. static IDENTITY_QUATERNION: Quaternion;
  23611. /** @hidden */
  23612. _pluginData: any;
  23613. private _physicsEngine;
  23614. private _physicsBody;
  23615. private _bodyUpdateRequired;
  23616. private _onBeforePhysicsStepCallbacks;
  23617. private _onAfterPhysicsStepCallbacks;
  23618. /** @hidden */
  23619. _onPhysicsCollideCallbacks: Array<{
  23620. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23621. otherImpostors: Array<PhysicsImpostor>;
  23622. }>;
  23623. private _deltaPosition;
  23624. private _deltaRotation;
  23625. private _deltaRotationConjugated;
  23626. /** @hidden */
  23627. _isFromLine: boolean;
  23628. private _parent;
  23629. private _isDisposed;
  23630. private static _tmpVecs;
  23631. private static _tmpQuat;
  23632. /**
  23633. * Specifies if the physics imposter is disposed
  23634. */
  23635. get isDisposed(): boolean;
  23636. /**
  23637. * Gets the mass of the physics imposter
  23638. */
  23639. get mass(): number;
  23640. set mass(value: number);
  23641. /**
  23642. * Gets the coefficient of friction
  23643. */
  23644. get friction(): number;
  23645. /**
  23646. * Sets the coefficient of friction
  23647. */
  23648. set friction(value: number);
  23649. /**
  23650. * Gets the coefficient of restitution
  23651. */
  23652. get restitution(): number;
  23653. /**
  23654. * Sets the coefficient of restitution
  23655. */
  23656. set restitution(value: number);
  23657. /**
  23658. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23659. */
  23660. get pressure(): number;
  23661. /**
  23662. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23663. */
  23664. set pressure(value: number);
  23665. /**
  23666. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23667. */
  23668. get stiffness(): number;
  23669. /**
  23670. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23671. */
  23672. set stiffness(value: number);
  23673. /**
  23674. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23675. */
  23676. get velocityIterations(): number;
  23677. /**
  23678. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23679. */
  23680. set velocityIterations(value: number);
  23681. /**
  23682. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23683. */
  23684. get positionIterations(): number;
  23685. /**
  23686. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23687. */
  23688. set positionIterations(value: number);
  23689. /**
  23690. * The unique id of the physics imposter
  23691. * set by the physics engine when adding this impostor to the array
  23692. */
  23693. uniqueId: number;
  23694. /**
  23695. * @hidden
  23696. */
  23697. soft: boolean;
  23698. /**
  23699. * @hidden
  23700. */
  23701. segments: number;
  23702. private _joints;
  23703. /**
  23704. * Initializes the physics imposter
  23705. * @param object The physics-enabled object used as the physics imposter
  23706. * @param type The type of the physics imposter
  23707. * @param _options The options for the physics imposter
  23708. * @param _scene The Babylon scene
  23709. */
  23710. constructor(
  23711. /**
  23712. * The physics-enabled object used as the physics imposter
  23713. */
  23714. object: IPhysicsEnabledObject,
  23715. /**
  23716. * The type of the physics imposter
  23717. */
  23718. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23719. /**
  23720. * This function will completly initialize this impostor.
  23721. * It will create a new body - but only if this mesh has no parent.
  23722. * If it has, this impostor will not be used other than to define the impostor
  23723. * of the child mesh.
  23724. * @hidden
  23725. */
  23726. _init(): void;
  23727. private _getPhysicsParent;
  23728. /**
  23729. * Should a new body be generated.
  23730. * @returns boolean specifying if body initialization is required
  23731. */
  23732. isBodyInitRequired(): boolean;
  23733. /**
  23734. * Sets the updated scaling
  23735. * @param updated Specifies if the scaling is updated
  23736. */
  23737. setScalingUpdated(): void;
  23738. /**
  23739. * Force a regeneration of this or the parent's impostor's body.
  23740. * Use under cautious - This will remove all joints already implemented.
  23741. */
  23742. forceUpdate(): void;
  23743. /**
  23744. * Gets the body that holds this impostor. Either its own, or its parent.
  23745. */
  23746. get physicsBody(): any;
  23747. /**
  23748. * Get the parent of the physics imposter
  23749. * @returns Physics imposter or null
  23750. */
  23751. get parent(): Nullable<PhysicsImpostor>;
  23752. /**
  23753. * Sets the parent of the physics imposter
  23754. */
  23755. set parent(value: Nullable<PhysicsImpostor>);
  23756. /**
  23757. * Set the physics body. Used mainly by the physics engine/plugin
  23758. */
  23759. set physicsBody(physicsBody: any);
  23760. /**
  23761. * Resets the update flags
  23762. */
  23763. resetUpdateFlags(): void;
  23764. /**
  23765. * Gets the object extend size
  23766. * @returns the object extend size
  23767. */
  23768. getObjectExtendSize(): Vector3;
  23769. /**
  23770. * Gets the object center
  23771. * @returns The object center
  23772. */
  23773. getObjectCenter(): Vector3;
  23774. /**
  23775. * Get a specific parameter from the options parameters
  23776. * @param paramName The object parameter name
  23777. * @returns The object parameter
  23778. */
  23779. getParam(paramName: string): any;
  23780. /**
  23781. * Sets a specific parameter in the options given to the physics plugin
  23782. * @param paramName The parameter name
  23783. * @param value The value of the parameter
  23784. */
  23785. setParam(paramName: string, value: number): void;
  23786. /**
  23787. * Specifically change the body's mass option. Won't recreate the physics body object
  23788. * @param mass The mass of the physics imposter
  23789. */
  23790. setMass(mass: number): void;
  23791. /**
  23792. * Gets the linear velocity
  23793. * @returns linear velocity or null
  23794. */
  23795. getLinearVelocity(): Nullable<Vector3>;
  23796. /**
  23797. * Sets the linear velocity
  23798. * @param velocity linear velocity or null
  23799. */
  23800. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23801. /**
  23802. * Gets the angular velocity
  23803. * @returns angular velocity or null
  23804. */
  23805. getAngularVelocity(): Nullable<Vector3>;
  23806. /**
  23807. * Sets the angular velocity
  23808. * @param velocity The velocity or null
  23809. */
  23810. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23811. /**
  23812. * Execute a function with the physics plugin native code
  23813. * Provide a function the will have two variables - the world object and the physics body object
  23814. * @param func The function to execute with the physics plugin native code
  23815. */
  23816. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23817. /**
  23818. * Register a function that will be executed before the physics world is stepping forward
  23819. * @param func The function to execute before the physics world is stepped forward
  23820. */
  23821. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23822. /**
  23823. * Unregister a function that will be executed before the physics world is stepping forward
  23824. * @param func The function to execute before the physics world is stepped forward
  23825. */
  23826. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23827. /**
  23828. * Register a function that will be executed after the physics step
  23829. * @param func The function to execute after physics step
  23830. */
  23831. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23832. /**
  23833. * Unregisters a function that will be executed after the physics step
  23834. * @param func The function to execute after physics step
  23835. */
  23836. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23837. /**
  23838. * register a function that will be executed when this impostor collides against a different body
  23839. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23840. * @param func Callback that is executed on collision
  23841. */
  23842. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23843. /**
  23844. * Unregisters the physics imposter on contact
  23845. * @param collideAgainst The physics object to collide against
  23846. * @param func Callback to execute on collision
  23847. */
  23848. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23849. private _tmpQuat;
  23850. private _tmpQuat2;
  23851. /**
  23852. * Get the parent rotation
  23853. * @returns The parent rotation
  23854. */
  23855. getParentsRotation(): Quaternion;
  23856. /**
  23857. * this function is executed by the physics engine.
  23858. */
  23859. beforeStep: () => void;
  23860. /**
  23861. * this function is executed by the physics engine
  23862. */
  23863. afterStep: () => void;
  23864. /**
  23865. * Legacy collision detection event support
  23866. */
  23867. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23868. /**
  23869. * event and body object due to cannon's event-based architecture.
  23870. */
  23871. onCollide: (e: {
  23872. body: any;
  23873. }) => void;
  23874. /**
  23875. * Apply a force
  23876. * @param force The force to apply
  23877. * @param contactPoint The contact point for the force
  23878. * @returns The physics imposter
  23879. */
  23880. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23881. /**
  23882. * Apply an impulse
  23883. * @param force The impulse force
  23884. * @param contactPoint The contact point for the impulse force
  23885. * @returns The physics imposter
  23886. */
  23887. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23888. /**
  23889. * A help function to create a joint
  23890. * @param otherImpostor A physics imposter used to create a joint
  23891. * @param jointType The type of joint
  23892. * @param jointData The data for the joint
  23893. * @returns The physics imposter
  23894. */
  23895. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23896. /**
  23897. * Add a joint to this impostor with a different impostor
  23898. * @param otherImpostor A physics imposter used to add a joint
  23899. * @param joint The joint to add
  23900. * @returns The physics imposter
  23901. */
  23902. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23903. /**
  23904. * Add an anchor to a cloth impostor
  23905. * @param otherImpostor rigid impostor to anchor to
  23906. * @param width ratio across width from 0 to 1
  23907. * @param height ratio up height from 0 to 1
  23908. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23909. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23910. * @returns impostor the soft imposter
  23911. */
  23912. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23913. /**
  23914. * Add a hook to a rope impostor
  23915. * @param otherImpostor rigid impostor to anchor to
  23916. * @param length ratio across rope from 0 to 1
  23917. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23919. * @returns impostor the rope imposter
  23920. */
  23921. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23922. /**
  23923. * Will keep this body still, in a sleep mode.
  23924. * @returns the physics imposter
  23925. */
  23926. sleep(): PhysicsImpostor;
  23927. /**
  23928. * Wake the body up.
  23929. * @returns The physics imposter
  23930. */
  23931. wakeUp(): PhysicsImpostor;
  23932. /**
  23933. * Clones the physics imposter
  23934. * @param newObject The physics imposter clones to this physics-enabled object
  23935. * @returns A nullable physics imposter
  23936. */
  23937. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23938. /**
  23939. * Disposes the physics imposter
  23940. */
  23941. dispose(): void;
  23942. /**
  23943. * Sets the delta position
  23944. * @param position The delta position amount
  23945. */
  23946. setDeltaPosition(position: Vector3): void;
  23947. /**
  23948. * Sets the delta rotation
  23949. * @param rotation The delta rotation amount
  23950. */
  23951. setDeltaRotation(rotation: Quaternion): void;
  23952. /**
  23953. * Gets the box size of the physics imposter and stores the result in the input parameter
  23954. * @param result Stores the box size
  23955. * @returns The physics imposter
  23956. */
  23957. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23958. /**
  23959. * Gets the radius of the physics imposter
  23960. * @returns Radius of the physics imposter
  23961. */
  23962. getRadius(): number;
  23963. /**
  23964. * Sync a bone with this impostor
  23965. * @param bone The bone to sync to the impostor.
  23966. * @param boneMesh The mesh that the bone is influencing.
  23967. * @param jointPivot The pivot of the joint / bone in local space.
  23968. * @param distToJoint Optional distance from the impostor to the joint.
  23969. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23970. */
  23971. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23972. /**
  23973. * Sync impostor to a bone
  23974. * @param bone The bone that the impostor will be synced to.
  23975. * @param boneMesh The mesh that the bone is influencing.
  23976. * @param jointPivot The pivot of the joint / bone in local space.
  23977. * @param distToJoint Optional distance from the impostor to the joint.
  23978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23979. * @param boneAxis Optional vector3 axis the bone is aligned with
  23980. */
  23981. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23982. /**
  23983. * No-Imposter type
  23984. */
  23985. static NoImpostor: number;
  23986. /**
  23987. * Sphere-Imposter type
  23988. */
  23989. static SphereImpostor: number;
  23990. /**
  23991. * Box-Imposter type
  23992. */
  23993. static BoxImpostor: number;
  23994. /**
  23995. * Plane-Imposter type
  23996. */
  23997. static PlaneImpostor: number;
  23998. /**
  23999. * Mesh-imposter type
  24000. */
  24001. static MeshImpostor: number;
  24002. /**
  24003. * Capsule-Impostor type (Ammo.js plugin only)
  24004. */
  24005. static CapsuleImpostor: number;
  24006. /**
  24007. * Cylinder-Imposter type
  24008. */
  24009. static CylinderImpostor: number;
  24010. /**
  24011. * Particle-Imposter type
  24012. */
  24013. static ParticleImpostor: number;
  24014. /**
  24015. * Heightmap-Imposter type
  24016. */
  24017. static HeightmapImpostor: number;
  24018. /**
  24019. * ConvexHull-Impostor type (Ammo.js plugin only)
  24020. */
  24021. static ConvexHullImpostor: number;
  24022. /**
  24023. * Custom-Imposter type (Ammo.js plugin only)
  24024. */
  24025. static CustomImpostor: number;
  24026. /**
  24027. * Rope-Imposter type
  24028. */
  24029. static RopeImpostor: number;
  24030. /**
  24031. * Cloth-Imposter type
  24032. */
  24033. static ClothImpostor: number;
  24034. /**
  24035. * Softbody-Imposter type
  24036. */
  24037. static SoftbodyImpostor: number;
  24038. }
  24039. }
  24040. declare module BABYLON {
  24041. /**
  24042. * @hidden
  24043. **/
  24044. export class _CreationDataStorage {
  24045. closePath?: boolean;
  24046. closeArray?: boolean;
  24047. idx: number[];
  24048. dashSize: number;
  24049. gapSize: number;
  24050. path3D: Path3D;
  24051. pathArray: Vector3[][];
  24052. arc: number;
  24053. radius: number;
  24054. cap: number;
  24055. tessellation: number;
  24056. }
  24057. /**
  24058. * @hidden
  24059. **/
  24060. class _InstanceDataStorage {
  24061. visibleInstances: any;
  24062. batchCache: _InstancesBatch;
  24063. instancesBufferSize: number;
  24064. instancesBuffer: Nullable<Buffer>;
  24065. instancesData: Float32Array;
  24066. overridenInstanceCount: number;
  24067. isFrozen: boolean;
  24068. previousBatch: Nullable<_InstancesBatch>;
  24069. hardwareInstancedRendering: boolean;
  24070. sideOrientation: number;
  24071. manualUpdate: boolean;
  24072. }
  24073. /**
  24074. * @hidden
  24075. **/
  24076. export class _InstancesBatch {
  24077. mustReturn: boolean;
  24078. visibleInstances: Nullable<InstancedMesh[]>[];
  24079. renderSelf: boolean[];
  24080. hardwareInstancedRendering: boolean[];
  24081. }
  24082. /**
  24083. * Class used to represent renderable models
  24084. */
  24085. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24086. /**
  24087. * Mesh side orientation : usually the external or front surface
  24088. */
  24089. static readonly FRONTSIDE: number;
  24090. /**
  24091. * Mesh side orientation : usually the internal or back surface
  24092. */
  24093. static readonly BACKSIDE: number;
  24094. /**
  24095. * Mesh side orientation : both internal and external or front and back surfaces
  24096. */
  24097. static readonly DOUBLESIDE: number;
  24098. /**
  24099. * Mesh side orientation : by default, `FRONTSIDE`
  24100. */
  24101. static readonly DEFAULTSIDE: number;
  24102. /**
  24103. * Mesh cap setting : no cap
  24104. */
  24105. static readonly NO_CAP: number;
  24106. /**
  24107. * Mesh cap setting : one cap at the beginning of the mesh
  24108. */
  24109. static readonly CAP_START: number;
  24110. /**
  24111. * Mesh cap setting : one cap at the end of the mesh
  24112. */
  24113. static readonly CAP_END: number;
  24114. /**
  24115. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24116. */
  24117. static readonly CAP_ALL: number;
  24118. /**
  24119. * Mesh pattern setting : no flip or rotate
  24120. */
  24121. static readonly NO_FLIP: number;
  24122. /**
  24123. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24124. */
  24125. static readonly FLIP_TILE: number;
  24126. /**
  24127. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24128. */
  24129. static readonly ROTATE_TILE: number;
  24130. /**
  24131. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24132. */
  24133. static readonly FLIP_ROW: number;
  24134. /**
  24135. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24136. */
  24137. static readonly ROTATE_ROW: number;
  24138. /**
  24139. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24140. */
  24141. static readonly FLIP_N_ROTATE_TILE: number;
  24142. /**
  24143. * Mesh pattern setting : rotate pattern and rotate
  24144. */
  24145. static readonly FLIP_N_ROTATE_ROW: number;
  24146. /**
  24147. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24148. */
  24149. static readonly CENTER: number;
  24150. /**
  24151. * Mesh tile positioning : part tiles on left
  24152. */
  24153. static readonly LEFT: number;
  24154. /**
  24155. * Mesh tile positioning : part tiles on right
  24156. */
  24157. static readonly RIGHT: number;
  24158. /**
  24159. * Mesh tile positioning : part tiles on top
  24160. */
  24161. static readonly TOP: number;
  24162. /**
  24163. * Mesh tile positioning : part tiles on bottom
  24164. */
  24165. static readonly BOTTOM: number;
  24166. /**
  24167. * Gets the default side orientation.
  24168. * @param orientation the orientation to value to attempt to get
  24169. * @returns the default orientation
  24170. * @hidden
  24171. */
  24172. static _GetDefaultSideOrientation(orientation?: number): number;
  24173. private _internalMeshDataInfo;
  24174. /**
  24175. * An event triggered before rendering the mesh
  24176. */
  24177. get onBeforeRenderObservable(): Observable<Mesh>;
  24178. /**
  24179. * An event triggered before binding the mesh
  24180. */
  24181. get onBeforeBindObservable(): Observable<Mesh>;
  24182. /**
  24183. * An event triggered after rendering the mesh
  24184. */
  24185. get onAfterRenderObservable(): Observable<Mesh>;
  24186. /**
  24187. * An event triggered before drawing the mesh
  24188. */
  24189. get onBeforeDrawObservable(): Observable<Mesh>;
  24190. private _onBeforeDrawObserver;
  24191. /**
  24192. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24193. */
  24194. set onBeforeDraw(callback: () => void);
  24195. get hasInstances(): boolean;
  24196. /**
  24197. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24198. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24199. */
  24200. delayLoadState: number;
  24201. /**
  24202. * Gets the list of instances created from this mesh
  24203. * it is not supposed to be modified manually.
  24204. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24206. */
  24207. instances: InstancedMesh[];
  24208. /**
  24209. * Gets the file containing delay loading data for this mesh
  24210. */
  24211. delayLoadingFile: string;
  24212. /** @hidden */
  24213. _binaryInfo: any;
  24214. /**
  24215. * User defined function used to change how LOD level selection is done
  24216. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24217. */
  24218. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24219. /**
  24220. * Gets or sets the morph target manager
  24221. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24222. */
  24223. get morphTargetManager(): Nullable<MorphTargetManager>;
  24224. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24225. /** @hidden */
  24226. _creationDataStorage: Nullable<_CreationDataStorage>;
  24227. /** @hidden */
  24228. _geometry: Nullable<Geometry>;
  24229. /** @hidden */
  24230. _delayInfo: Array<string>;
  24231. /** @hidden */
  24232. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24233. /** @hidden */
  24234. _instanceDataStorage: _InstanceDataStorage;
  24235. private _effectiveMaterial;
  24236. /** @hidden */
  24237. _shouldGenerateFlatShading: boolean;
  24238. /** @hidden */
  24239. _originalBuilderSideOrientation: number;
  24240. /**
  24241. * Use this property to change the original side orientation defined at construction time
  24242. */
  24243. overrideMaterialSideOrientation: Nullable<number>;
  24244. /**
  24245. * Gets the source mesh (the one used to clone this one from)
  24246. */
  24247. get source(): Nullable<Mesh>;
  24248. /**
  24249. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24250. */
  24251. get isUnIndexed(): boolean;
  24252. set isUnIndexed(value: boolean);
  24253. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24254. get worldMatrixInstancedBuffer(): Float32Array;
  24255. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24256. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24257. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24258. /**
  24259. * @constructor
  24260. * @param name The value used by scene.getMeshByName() to do a lookup.
  24261. * @param scene The scene to add this mesh to.
  24262. * @param parent The parent of this mesh, if it has one
  24263. * @param source An optional Mesh from which geometry is shared, cloned.
  24264. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24265. * When false, achieved by calling a clone(), also passing False.
  24266. * This will make creation of children, recursive.
  24267. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24268. */
  24269. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24270. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24271. doNotInstantiate: boolean;
  24272. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24273. /**
  24274. * Gets the class name
  24275. * @returns the string "Mesh".
  24276. */
  24277. getClassName(): string;
  24278. /** @hidden */
  24279. get _isMesh(): boolean;
  24280. /**
  24281. * Returns a description of this mesh
  24282. * @param fullDetails define if full details about this mesh must be used
  24283. * @returns a descriptive string representing this mesh
  24284. */
  24285. toString(fullDetails?: boolean): string;
  24286. /** @hidden */
  24287. _unBindEffect(): void;
  24288. /**
  24289. * Gets a boolean indicating if this mesh has LOD
  24290. */
  24291. get hasLODLevels(): boolean;
  24292. /**
  24293. * Gets the list of MeshLODLevel associated with the current mesh
  24294. * @returns an array of MeshLODLevel
  24295. */
  24296. getLODLevels(): MeshLODLevel[];
  24297. private _sortLODLevels;
  24298. /**
  24299. * Add a mesh as LOD level triggered at the given distance.
  24300. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24301. * @param distance The distance from the center of the object to show this level
  24302. * @param mesh The mesh to be added as LOD level (can be null)
  24303. * @return This mesh (for chaining)
  24304. */
  24305. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24306. /**
  24307. * Returns the LOD level mesh at the passed distance or null if not found.
  24308. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24309. * @param distance The distance from the center of the object to show this level
  24310. * @returns a Mesh or `null`
  24311. */
  24312. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24313. /**
  24314. * Remove a mesh from the LOD array
  24315. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24316. * @param mesh defines the mesh to be removed
  24317. * @return This mesh (for chaining)
  24318. */
  24319. removeLODLevel(mesh: Mesh): Mesh;
  24320. /**
  24321. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24322. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24323. * @param camera defines the camera to use to compute distance
  24324. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24325. * @return This mesh (for chaining)
  24326. */
  24327. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24328. /**
  24329. * Gets the mesh internal Geometry object
  24330. */
  24331. get geometry(): Nullable<Geometry>;
  24332. /**
  24333. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24334. * @returns the total number of vertices
  24335. */
  24336. getTotalVertices(): number;
  24337. /**
  24338. * Returns the content of an associated vertex buffer
  24339. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24340. * - VertexBuffer.PositionKind
  24341. * - VertexBuffer.UVKind
  24342. * - VertexBuffer.UV2Kind
  24343. * - VertexBuffer.UV3Kind
  24344. * - VertexBuffer.UV4Kind
  24345. * - VertexBuffer.UV5Kind
  24346. * - VertexBuffer.UV6Kind
  24347. * - VertexBuffer.ColorKind
  24348. * - VertexBuffer.MatricesIndicesKind
  24349. * - VertexBuffer.MatricesIndicesExtraKind
  24350. * - VertexBuffer.MatricesWeightsKind
  24351. * - VertexBuffer.MatricesWeightsExtraKind
  24352. * @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
  24353. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24354. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24355. */
  24356. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24357. /**
  24358. * Returns the mesh VertexBuffer object from the requested `kind`
  24359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24360. * - VertexBuffer.PositionKind
  24361. * - VertexBuffer.NormalKind
  24362. * - VertexBuffer.UVKind
  24363. * - VertexBuffer.UV2Kind
  24364. * - VertexBuffer.UV3Kind
  24365. * - VertexBuffer.UV4Kind
  24366. * - VertexBuffer.UV5Kind
  24367. * - VertexBuffer.UV6Kind
  24368. * - VertexBuffer.ColorKind
  24369. * - VertexBuffer.MatricesIndicesKind
  24370. * - VertexBuffer.MatricesIndicesExtraKind
  24371. * - VertexBuffer.MatricesWeightsKind
  24372. * - VertexBuffer.MatricesWeightsExtraKind
  24373. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24374. */
  24375. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24376. /**
  24377. * Tests if a specific vertex buffer is associated with this mesh
  24378. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24379. * - VertexBuffer.PositionKind
  24380. * - VertexBuffer.NormalKind
  24381. * - VertexBuffer.UVKind
  24382. * - VertexBuffer.UV2Kind
  24383. * - VertexBuffer.UV3Kind
  24384. * - VertexBuffer.UV4Kind
  24385. * - VertexBuffer.UV5Kind
  24386. * - VertexBuffer.UV6Kind
  24387. * - VertexBuffer.ColorKind
  24388. * - VertexBuffer.MatricesIndicesKind
  24389. * - VertexBuffer.MatricesIndicesExtraKind
  24390. * - VertexBuffer.MatricesWeightsKind
  24391. * - VertexBuffer.MatricesWeightsExtraKind
  24392. * @returns a boolean
  24393. */
  24394. isVerticesDataPresent(kind: string): boolean;
  24395. /**
  24396. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24397. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24398. * - VertexBuffer.PositionKind
  24399. * - VertexBuffer.UVKind
  24400. * - VertexBuffer.UV2Kind
  24401. * - VertexBuffer.UV3Kind
  24402. * - VertexBuffer.UV4Kind
  24403. * - VertexBuffer.UV5Kind
  24404. * - VertexBuffer.UV6Kind
  24405. * - VertexBuffer.ColorKind
  24406. * - VertexBuffer.MatricesIndicesKind
  24407. * - VertexBuffer.MatricesIndicesExtraKind
  24408. * - VertexBuffer.MatricesWeightsKind
  24409. * - VertexBuffer.MatricesWeightsExtraKind
  24410. * @returns a boolean
  24411. */
  24412. isVertexBufferUpdatable(kind: string): boolean;
  24413. /**
  24414. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24415. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24416. * - VertexBuffer.PositionKind
  24417. * - VertexBuffer.NormalKind
  24418. * - VertexBuffer.UVKind
  24419. * - VertexBuffer.UV2Kind
  24420. * - VertexBuffer.UV3Kind
  24421. * - VertexBuffer.UV4Kind
  24422. * - VertexBuffer.UV5Kind
  24423. * - VertexBuffer.UV6Kind
  24424. * - VertexBuffer.ColorKind
  24425. * - VertexBuffer.MatricesIndicesKind
  24426. * - VertexBuffer.MatricesIndicesExtraKind
  24427. * - VertexBuffer.MatricesWeightsKind
  24428. * - VertexBuffer.MatricesWeightsExtraKind
  24429. * @returns an array of strings
  24430. */
  24431. getVerticesDataKinds(): string[];
  24432. /**
  24433. * Returns a positive integer : the total number of indices in this mesh geometry.
  24434. * @returns the numner of indices or zero if the mesh has no geometry.
  24435. */
  24436. getTotalIndices(): number;
  24437. /**
  24438. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24439. * @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.
  24440. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24441. * @returns the indices array or an empty array if the mesh has no geometry
  24442. */
  24443. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24444. get isBlocked(): boolean;
  24445. /**
  24446. * Determine if the current mesh is ready to be rendered
  24447. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24448. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24449. * @returns true if all associated assets are ready (material, textures, shaders)
  24450. */
  24451. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24452. /**
  24453. * 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.
  24454. */
  24455. get areNormalsFrozen(): boolean;
  24456. /**
  24457. * 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.
  24458. * @returns the current mesh
  24459. */
  24460. freezeNormals(): Mesh;
  24461. /**
  24462. * 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
  24463. * @returns the current mesh
  24464. */
  24465. unfreezeNormals(): Mesh;
  24466. /**
  24467. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24468. */
  24469. set overridenInstanceCount(count: number);
  24470. /** @hidden */
  24471. _preActivate(): Mesh;
  24472. /** @hidden */
  24473. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24474. /** @hidden */
  24475. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24476. /**
  24477. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24478. * This means the mesh underlying bounding box and sphere are recomputed.
  24479. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24480. * @returns the current mesh
  24481. */
  24482. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24483. /** @hidden */
  24484. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24485. /**
  24486. * This function will subdivide the mesh into multiple submeshes
  24487. * @param count defines the expected number of submeshes
  24488. */
  24489. subdivide(count: number): void;
  24490. /**
  24491. * Copy a FloatArray into a specific associated vertex buffer
  24492. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24493. * - VertexBuffer.PositionKind
  24494. * - VertexBuffer.UVKind
  24495. * - VertexBuffer.UV2Kind
  24496. * - VertexBuffer.UV3Kind
  24497. * - VertexBuffer.UV4Kind
  24498. * - VertexBuffer.UV5Kind
  24499. * - VertexBuffer.UV6Kind
  24500. * - VertexBuffer.ColorKind
  24501. * - VertexBuffer.MatricesIndicesKind
  24502. * - VertexBuffer.MatricesIndicesExtraKind
  24503. * - VertexBuffer.MatricesWeightsKind
  24504. * - VertexBuffer.MatricesWeightsExtraKind
  24505. * @param data defines the data source
  24506. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24507. * @param stride defines the data stride size (can be null)
  24508. * @returns the current mesh
  24509. */
  24510. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24511. /**
  24512. * Delete a vertex buffer associated with this mesh
  24513. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24514. * - VertexBuffer.PositionKind
  24515. * - VertexBuffer.UVKind
  24516. * - VertexBuffer.UV2Kind
  24517. * - VertexBuffer.UV3Kind
  24518. * - VertexBuffer.UV4Kind
  24519. * - VertexBuffer.UV5Kind
  24520. * - VertexBuffer.UV6Kind
  24521. * - VertexBuffer.ColorKind
  24522. * - VertexBuffer.MatricesIndicesKind
  24523. * - VertexBuffer.MatricesIndicesExtraKind
  24524. * - VertexBuffer.MatricesWeightsKind
  24525. * - VertexBuffer.MatricesWeightsExtraKind
  24526. */
  24527. removeVerticesData(kind: string): void;
  24528. /**
  24529. * Flags an associated vertex buffer as updatable
  24530. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24531. * - VertexBuffer.PositionKind
  24532. * - VertexBuffer.UVKind
  24533. * - VertexBuffer.UV2Kind
  24534. * - VertexBuffer.UV3Kind
  24535. * - VertexBuffer.UV4Kind
  24536. * - VertexBuffer.UV5Kind
  24537. * - VertexBuffer.UV6Kind
  24538. * - VertexBuffer.ColorKind
  24539. * - VertexBuffer.MatricesIndicesKind
  24540. * - VertexBuffer.MatricesIndicesExtraKind
  24541. * - VertexBuffer.MatricesWeightsKind
  24542. * - VertexBuffer.MatricesWeightsExtraKind
  24543. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24544. */
  24545. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24546. /**
  24547. * Sets the mesh global Vertex Buffer
  24548. * @param buffer defines the buffer to use
  24549. * @returns the current mesh
  24550. */
  24551. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24552. /**
  24553. * Update a specific associated vertex buffer
  24554. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24555. * - VertexBuffer.PositionKind
  24556. * - VertexBuffer.UVKind
  24557. * - VertexBuffer.UV2Kind
  24558. * - VertexBuffer.UV3Kind
  24559. * - VertexBuffer.UV4Kind
  24560. * - VertexBuffer.UV5Kind
  24561. * - VertexBuffer.UV6Kind
  24562. * - VertexBuffer.ColorKind
  24563. * - VertexBuffer.MatricesIndicesKind
  24564. * - VertexBuffer.MatricesIndicesExtraKind
  24565. * - VertexBuffer.MatricesWeightsKind
  24566. * - VertexBuffer.MatricesWeightsExtraKind
  24567. * @param data defines the data source
  24568. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24569. * @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)
  24570. * @returns the current mesh
  24571. */
  24572. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24573. /**
  24574. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24575. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24576. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24577. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24578. * @returns the current mesh
  24579. */
  24580. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24581. /**
  24582. * Creates a un-shared specific occurence of the geometry for the mesh.
  24583. * @returns the current mesh
  24584. */
  24585. makeGeometryUnique(): Mesh;
  24586. /**
  24587. * Set the index buffer of this mesh
  24588. * @param indices defines the source data
  24589. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24590. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24591. * @returns the current mesh
  24592. */
  24593. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24594. /**
  24595. * Update the current index buffer
  24596. * @param indices defines the source data
  24597. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24598. * @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)
  24599. * @returns the current mesh
  24600. */
  24601. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24602. /**
  24603. * Invert the geometry to move from a right handed system to a left handed one.
  24604. * @returns the current mesh
  24605. */
  24606. toLeftHanded(): Mesh;
  24607. /** @hidden */
  24608. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24609. /** @hidden */
  24610. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24611. /**
  24612. * Registers for this mesh a javascript function called just before the rendering process
  24613. * @param func defines the function to call before rendering this mesh
  24614. * @returns the current mesh
  24615. */
  24616. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24617. /**
  24618. * Disposes a previously registered javascript function called before the rendering
  24619. * @param func defines the function to remove
  24620. * @returns the current mesh
  24621. */
  24622. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24623. /**
  24624. * Registers for this mesh a javascript function called just after the rendering is complete
  24625. * @param func defines the function to call after rendering this mesh
  24626. * @returns the current mesh
  24627. */
  24628. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24629. /**
  24630. * Disposes a previously registered javascript function called after the rendering.
  24631. * @param func defines the function to remove
  24632. * @returns the current mesh
  24633. */
  24634. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24635. /** @hidden */
  24636. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24637. /** @hidden */
  24638. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24639. /** @hidden */
  24640. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24641. /** @hidden */
  24642. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24643. /** @hidden */
  24644. _rebuild(): void;
  24645. /** @hidden */
  24646. _freeze(): void;
  24647. /** @hidden */
  24648. _unFreeze(): void;
  24649. /**
  24650. * 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
  24651. * @param subMesh defines the subMesh to render
  24652. * @param enableAlphaMode defines if alpha mode can be changed
  24653. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24654. * @returns the current mesh
  24655. */
  24656. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24657. private _onBeforeDraw;
  24658. /**
  24659. * Renormalize the mesh and patch it up if there are no weights
  24660. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24661. * However in the case of zero weights then we set just a single influence to 1.
  24662. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24663. */
  24664. cleanMatrixWeights(): void;
  24665. private normalizeSkinFourWeights;
  24666. private normalizeSkinWeightsAndExtra;
  24667. /**
  24668. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24669. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24670. * the user know there was an issue with importing the mesh
  24671. * @returns a validation object with skinned, valid and report string
  24672. */
  24673. validateSkinning(): {
  24674. skinned: boolean;
  24675. valid: boolean;
  24676. report: string;
  24677. };
  24678. /** @hidden */
  24679. _checkDelayState(): Mesh;
  24680. private _queueLoad;
  24681. /**
  24682. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24683. * A mesh is in the frustum if its bounding box intersects the frustum
  24684. * @param frustumPlanes defines the frustum to test
  24685. * @returns true if the mesh is in the frustum planes
  24686. */
  24687. isInFrustum(frustumPlanes: Plane[]): boolean;
  24688. /**
  24689. * Sets the mesh material by the material or multiMaterial `id` property
  24690. * @param id is a string identifying the material or the multiMaterial
  24691. * @returns the current mesh
  24692. */
  24693. setMaterialByID(id: string): Mesh;
  24694. /**
  24695. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24696. * @returns an array of IAnimatable
  24697. */
  24698. getAnimatables(): IAnimatable[];
  24699. /**
  24700. * Modifies the mesh geometry according to the passed transformation matrix.
  24701. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24702. * The mesh normals are modified using the same transformation.
  24703. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24704. * @param transform defines the transform matrix to use
  24705. * @see http://doc.babylonjs.com/resources/baking_transformations
  24706. * @returns the current mesh
  24707. */
  24708. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24709. /**
  24710. * Modifies the mesh geometry according to its own current World Matrix.
  24711. * The mesh World Matrix is then reset.
  24712. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24713. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24714. * @see http://doc.babylonjs.com/resources/baking_transformations
  24715. * @returns the current mesh
  24716. */
  24717. bakeCurrentTransformIntoVertices(): Mesh;
  24718. /** @hidden */
  24719. get _positions(): Nullable<Vector3[]>;
  24720. /** @hidden */
  24721. _resetPointsArrayCache(): Mesh;
  24722. /** @hidden */
  24723. _generatePointsArray(): boolean;
  24724. /**
  24725. * Returns a new Mesh object generated from the current mesh properties.
  24726. * This method must not get confused with createInstance()
  24727. * @param name is a string, the name given to the new mesh
  24728. * @param newParent can be any Node object (default `null`)
  24729. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24730. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24731. * @returns a new mesh
  24732. */
  24733. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24734. /**
  24735. * Releases resources associated with this mesh.
  24736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24738. */
  24739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24740. /** @hidden */
  24741. _disposeInstanceSpecificData(): void;
  24742. /**
  24743. * Modifies the mesh geometry according to a displacement map.
  24744. * 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.
  24745. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24746. * @param url is a string, the URL from the image file is to be downloaded.
  24747. * @param minHeight is the lower limit of the displacement.
  24748. * @param maxHeight is the upper limit of the displacement.
  24749. * @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.
  24750. * @param uvOffset is an optional vector2 used to offset UV.
  24751. * @param uvScale is an optional vector2 used to scale UV.
  24752. * @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.
  24753. * @returns the Mesh.
  24754. */
  24755. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24756. /**
  24757. * Modifies the mesh geometry according to a displacementMap buffer.
  24758. * 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.
  24759. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24760. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24761. * @param heightMapWidth is the width of the buffer image.
  24762. * @param heightMapHeight is the height of the buffer image.
  24763. * @param minHeight is the lower limit of the displacement.
  24764. * @param maxHeight is the upper limit of the displacement.
  24765. * @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.
  24766. * @param uvOffset is an optional vector2 used to offset UV.
  24767. * @param uvScale is an optional vector2 used to scale UV.
  24768. * @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.
  24769. * @returns the Mesh.
  24770. */
  24771. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24772. /**
  24773. * Modify the mesh to get a flat shading rendering.
  24774. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24775. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24776. * @returns current mesh
  24777. */
  24778. convertToFlatShadedMesh(): Mesh;
  24779. /**
  24780. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24781. * In other words, more vertices, no more indices and a single bigger VBO.
  24782. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24783. * @returns current mesh
  24784. */
  24785. convertToUnIndexedMesh(): Mesh;
  24786. /**
  24787. * Inverses facet orientations.
  24788. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24789. * @param flipNormals will also inverts the normals
  24790. * @returns current mesh
  24791. */
  24792. flipFaces(flipNormals?: boolean): Mesh;
  24793. /**
  24794. * Increase the number of facets and hence vertices in a mesh
  24795. * Vertex normals are interpolated from existing vertex normals
  24796. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24797. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24798. */
  24799. increaseVertices(numberPerEdge: number): void;
  24800. /**
  24801. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24802. * This will undo any application of covertToFlatShadedMesh
  24803. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24804. */
  24805. forceSharedVertices(): void;
  24806. /** @hidden */
  24807. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24808. /** @hidden */
  24809. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24810. /**
  24811. * Creates a new InstancedMesh object from the mesh model.
  24812. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24813. * @param name defines the name of the new instance
  24814. * @returns a new InstancedMesh
  24815. */
  24816. createInstance(name: string): InstancedMesh;
  24817. /**
  24818. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24819. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24820. * @returns the current mesh
  24821. */
  24822. synchronizeInstances(): Mesh;
  24823. /**
  24824. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24825. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24826. * This should be used together with the simplification to avoid disappearing triangles.
  24827. * @param successCallback an optional success callback to be called after the optimization finished.
  24828. * @returns the current mesh
  24829. */
  24830. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24831. /**
  24832. * Serialize current mesh
  24833. * @param serializationObject defines the object which will receive the serialization data
  24834. */
  24835. serialize(serializationObject: any): void;
  24836. /** @hidden */
  24837. _syncGeometryWithMorphTargetManager(): void;
  24838. /** @hidden */
  24839. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24840. /**
  24841. * Returns a new Mesh object parsed from the source provided.
  24842. * @param parsedMesh is the source
  24843. * @param scene defines the hosting scene
  24844. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24845. * @returns a new Mesh
  24846. */
  24847. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24848. /**
  24849. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24850. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24851. * @param name defines the name of the mesh to create
  24852. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24853. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24854. * @param closePath creates a seam between the first and the last points of each path of the path array
  24855. * @param offset is taken in account only if the `pathArray` is containing a single path
  24856. * @param scene defines the hosting scene
  24857. * @param updatable defines if the mesh must be flagged as updatable
  24858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24859. * @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)
  24860. * @returns a new Mesh
  24861. */
  24862. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24863. /**
  24864. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24865. * @param name defines the name of the mesh to create
  24866. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24867. * @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
  24868. * @param scene defines the hosting scene
  24869. * @param updatable defines if the mesh must be flagged as updatable
  24870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24871. * @returns a new Mesh
  24872. */
  24873. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24874. /**
  24875. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24876. * @param name defines the name of the mesh to create
  24877. * @param size sets the size (float) of each box side (default 1)
  24878. * @param scene defines the hosting scene
  24879. * @param updatable defines if the mesh must be flagged as updatable
  24880. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24881. * @returns a new Mesh
  24882. */
  24883. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24884. /**
  24885. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24886. * @param name defines the name of the mesh to create
  24887. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24888. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24895. /**
  24896. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24899. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24900. * @param scene defines the hosting scene
  24901. * @returns a new Mesh
  24902. */
  24903. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24904. /**
  24905. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24906. * @param name defines the name of the mesh to create
  24907. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24908. * @param diameterTop set the top cap diameter (floats, default 1)
  24909. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24910. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24911. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24912. * @param scene defines the hosting scene
  24913. * @param updatable defines if the mesh must be flagged as updatable
  24914. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24915. * @returns a new Mesh
  24916. */
  24917. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24918. /**
  24919. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24920. * @param name defines the name of the mesh to create
  24921. * @param diameter sets the diameter size (float) of the torus (default 1)
  24922. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24923. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24924. * @param scene defines the hosting scene
  24925. * @param updatable defines if the mesh must be flagged as updatable
  24926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24927. * @returns a new Mesh
  24928. */
  24929. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24930. /**
  24931. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24932. * @param name defines the name of the mesh to create
  24933. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24934. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24935. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24936. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24937. * @param p the number of windings on X axis (positive integers, default 2)
  24938. * @param q the number of windings on Y axis (positive integers, default 3)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24945. /**
  24946. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24947. * @param name defines the name of the mesh to create
  24948. * @param points is an array successive Vector3
  24949. * @param scene defines the hosting scene
  24950. * @param updatable defines if the mesh must be flagged as updatable
  24951. * @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).
  24952. * @returns a new Mesh
  24953. */
  24954. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24955. /**
  24956. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24957. * @param name defines the name of the mesh to create
  24958. * @param points is an array successive Vector3
  24959. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24960. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24961. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24962. * @param scene defines the hosting scene
  24963. * @param updatable defines if the mesh must be flagged as updatable
  24964. * @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)
  24965. * @returns a new Mesh
  24966. */
  24967. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24968. /**
  24969. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24970. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24971. * 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.
  24972. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24973. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24974. * Remember you can only change the shape positions, not their number when updating a polygon.
  24975. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24976. * @param name defines the name of the mesh to create
  24977. * @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
  24978. * @param scene defines the hosting scene
  24979. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24980. * @param updatable defines if the mesh must be flagged as updatable
  24981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24982. * @param earcutInjection can be used to inject your own earcut reference
  24983. * @returns a new Mesh
  24984. */
  24985. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24986. /**
  24987. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24988. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24989. * @param name defines the name of the mesh to create
  24990. * @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
  24991. * @param depth defines the height of extrusion
  24992. * @param scene defines the hosting scene
  24993. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24994. * @param updatable defines if the mesh must be flagged as updatable
  24995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24996. * @param earcutInjection can be used to inject your own earcut reference
  24997. * @returns a new Mesh
  24998. */
  24999. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25000. /**
  25001. * Creates an extruded shape mesh.
  25002. * 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
  25003. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25004. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25005. * @param name defines the name of the mesh to create
  25006. * @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
  25007. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25008. * @param scale is the value to scale the shape
  25009. * @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
  25010. * @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
  25011. * @param scene defines the hosting scene
  25012. * @param updatable defines if the mesh must be flagged as updatable
  25013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25014. * @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)
  25015. * @returns a new Mesh
  25016. */
  25017. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25018. /**
  25019. * Creates an custom extruded shape mesh.
  25020. * The custom extrusion is a parametric shape.
  25021. * It has no predefined shape. Its final shape will depend on the input parameters.
  25022. * Please consider using the same method from the MeshBuilder class instead
  25023. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25024. * @param name defines the name of the mesh to create
  25025. * @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
  25026. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25027. * @param scaleFunction is a custom Javascript function called on each path point
  25028. * @param rotationFunction is a custom Javascript function called on each path point
  25029. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25030. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25031. * @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
  25032. * @param scene defines the hosting scene
  25033. * @param updatable defines if the mesh must be flagged as updatable
  25034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25035. * @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)
  25036. * @returns a new Mesh
  25037. */
  25038. 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;
  25039. /**
  25040. * Creates lathe mesh.
  25041. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25042. * Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @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
  25045. * @param radius is the radius value of the lathe
  25046. * @param tessellation is the side number of the lathe.
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25050. * @returns a new Mesh
  25051. */
  25052. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25053. /**
  25054. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25057. * @param scene defines the hosting scene
  25058. * @param updatable defines if the mesh must be flagged as updatable
  25059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25060. * @returns a new Mesh
  25061. */
  25062. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25063. /**
  25064. * Creates a ground mesh.
  25065. * Please consider using the same method from the MeshBuilder class instead
  25066. * @param name defines the name of the mesh to create
  25067. * @param width set the width of the ground
  25068. * @param height set the height of the ground
  25069. * @param subdivisions sets the number of subdivisions per side
  25070. * @param scene defines the hosting scene
  25071. * @param updatable defines if the mesh must be flagged as updatable
  25072. * @returns a new Mesh
  25073. */
  25074. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25075. /**
  25076. * Creates a tiled ground mesh.
  25077. * Please consider using the same method from the MeshBuilder class instead
  25078. * @param name defines the name of the mesh to create
  25079. * @param xmin set the ground minimum X coordinate
  25080. * @param zmin set the ground minimum Y coordinate
  25081. * @param xmax set the ground maximum X coordinate
  25082. * @param zmax set the ground maximum Z coordinate
  25083. * @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
  25084. * @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
  25085. * @param scene defines the hosting scene
  25086. * @param updatable defines if the mesh must be flagged as updatable
  25087. * @returns a new Mesh
  25088. */
  25089. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25090. w: number;
  25091. h: number;
  25092. }, precision: {
  25093. w: number;
  25094. h: number;
  25095. }, scene: Scene, updatable?: boolean): Mesh;
  25096. /**
  25097. * Creates a ground mesh from a height map.
  25098. * Please consider using the same method from the MeshBuilder class instead
  25099. * @see http://doc.babylonjs.com/babylon101/height_map
  25100. * @param name defines the name of the mesh to create
  25101. * @param url sets the URL of the height map image resource
  25102. * @param width set the ground width size
  25103. * @param height set the ground height size
  25104. * @param subdivisions sets the number of subdivision per side
  25105. * @param minHeight is the minimum altitude on the ground
  25106. * @param maxHeight is the maximum altitude on the ground
  25107. * @param scene defines the hosting scene
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25110. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25111. * @returns a new Mesh
  25112. */
  25113. 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;
  25114. /**
  25115. * Creates a tube mesh.
  25116. * The tube is a parametric shape.
  25117. * It has no predefined shape. Its final shape will depend on the input parameters.
  25118. * Please consider using the same method from the MeshBuilder class instead
  25119. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25120. * @param name defines the name of the mesh to create
  25121. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25122. * @param radius sets the tube radius size
  25123. * @param tessellation is the number of sides on the tubular surface
  25124. * @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
  25125. * @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
  25126. * @param scene defines the hosting scene
  25127. * @param updatable defines if the mesh must be flagged as updatable
  25128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25129. * @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)
  25130. * @returns a new Mesh
  25131. */
  25132. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25133. (i: number, distance: number): number;
  25134. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25135. /**
  25136. * Creates a polyhedron mesh.
  25137. * Please consider using the same method from the MeshBuilder class instead.
  25138. * * 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
  25139. * * The parameter `size` (positive float, default 1) sets the polygon size
  25140. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25141. * * 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`
  25142. * * 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
  25143. * * 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)`)
  25144. * * 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
  25145. * * 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
  25146. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25147. * * 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
  25148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25149. * @param name defines the name of the mesh to create
  25150. * @param options defines the options used to create the mesh
  25151. * @param scene defines the hosting scene
  25152. * @returns a new Mesh
  25153. */
  25154. static CreatePolyhedron(name: string, options: {
  25155. type?: number;
  25156. size?: number;
  25157. sizeX?: number;
  25158. sizeY?: number;
  25159. sizeZ?: number;
  25160. custom?: any;
  25161. faceUV?: Vector4[];
  25162. faceColors?: Color4[];
  25163. updatable?: boolean;
  25164. sideOrientation?: number;
  25165. }, scene: Scene): Mesh;
  25166. /**
  25167. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25168. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25169. * * 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`)
  25170. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25171. * * 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
  25172. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25173. * * 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
  25174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25175. * @param name defines the name of the mesh
  25176. * @param options defines the options used to create the mesh
  25177. * @param scene defines the hosting scene
  25178. * @returns a new Mesh
  25179. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25180. */
  25181. static CreateIcoSphere(name: string, options: {
  25182. radius?: number;
  25183. flat?: boolean;
  25184. subdivisions?: number;
  25185. sideOrientation?: number;
  25186. updatable?: boolean;
  25187. }, scene: Scene): Mesh;
  25188. /**
  25189. * Creates a decal mesh.
  25190. * Please consider using the same method from the MeshBuilder class instead.
  25191. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25192. * @param name defines the name of the mesh
  25193. * @param sourceMesh defines the mesh receiving the decal
  25194. * @param position sets the position of the decal in world coordinates
  25195. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25196. * @param size sets the decal scaling
  25197. * @param angle sets the angle to rotate the decal
  25198. * @returns a new Mesh
  25199. */
  25200. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25201. /**
  25202. * Prepare internal position array for software CPU skinning
  25203. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25204. */
  25205. setPositionsForCPUSkinning(): Float32Array;
  25206. /**
  25207. * Prepare internal normal array for software CPU skinning
  25208. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25209. */
  25210. setNormalsForCPUSkinning(): Float32Array;
  25211. /**
  25212. * Updates the vertex buffer by applying transformation from the bones
  25213. * @param skeleton defines the skeleton to apply to current mesh
  25214. * @returns the current mesh
  25215. */
  25216. applySkeleton(skeleton: Skeleton): Mesh;
  25217. /**
  25218. * 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
  25219. * @param meshes defines the list of meshes to scan
  25220. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25221. */
  25222. static MinMax(meshes: AbstractMesh[]): {
  25223. min: Vector3;
  25224. max: Vector3;
  25225. };
  25226. /**
  25227. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25228. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25229. * @returns a vector3
  25230. */
  25231. static Center(meshesOrMinMaxVector: {
  25232. min: Vector3;
  25233. max: Vector3;
  25234. } | AbstractMesh[]): Vector3;
  25235. /**
  25236. * Merge the array of meshes into a single mesh for performance reasons.
  25237. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25238. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25239. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25240. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25241. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25242. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25243. * @returns a new mesh
  25244. */
  25245. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25246. /** @hidden */
  25247. addInstance(instance: InstancedMesh): void;
  25248. /** @hidden */
  25249. removeInstance(instance: InstancedMesh): void;
  25250. }
  25251. }
  25252. declare module BABYLON {
  25253. /**
  25254. * This is the base class of all the camera used in the application.
  25255. * @see http://doc.babylonjs.com/features/cameras
  25256. */
  25257. export class Camera extends Node {
  25258. /** @hidden */
  25259. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25260. /**
  25261. * This is the default projection mode used by the cameras.
  25262. * It helps recreating a feeling of perspective and better appreciate depth.
  25263. * This is the best way to simulate real life cameras.
  25264. */
  25265. static readonly PERSPECTIVE_CAMERA: number;
  25266. /**
  25267. * This helps creating camera with an orthographic mode.
  25268. * 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.
  25269. */
  25270. static readonly ORTHOGRAPHIC_CAMERA: number;
  25271. /**
  25272. * This is the default FOV mode for perspective cameras.
  25273. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25274. */
  25275. static readonly FOVMODE_VERTICAL_FIXED: number;
  25276. /**
  25277. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25278. */
  25279. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25280. /**
  25281. * This specifies ther is no need for a camera rig.
  25282. * Basically only one eye is rendered corresponding to the camera.
  25283. */
  25284. static readonly RIG_MODE_NONE: number;
  25285. /**
  25286. * Simulates a camera Rig with one blue eye and one red eye.
  25287. * This can be use with 3d blue and red glasses.
  25288. */
  25289. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25290. /**
  25291. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25292. */
  25293. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25294. /**
  25295. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25296. */
  25297. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25298. /**
  25299. * Defines that both eyes of the camera will be rendered over under each other.
  25300. */
  25301. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25302. /**
  25303. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25304. */
  25305. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25306. /**
  25307. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25308. */
  25309. static readonly RIG_MODE_VR: number;
  25310. /**
  25311. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25312. */
  25313. static readonly RIG_MODE_WEBVR: number;
  25314. /**
  25315. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25316. */
  25317. static readonly RIG_MODE_CUSTOM: number;
  25318. /**
  25319. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25320. */
  25321. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25322. /**
  25323. * Define the input manager associated with the camera.
  25324. */
  25325. inputs: CameraInputsManager<Camera>;
  25326. /** @hidden */
  25327. _position: Vector3;
  25328. /**
  25329. * Define the current local position of the camera in the scene
  25330. */
  25331. get position(): Vector3;
  25332. set position(newPosition: Vector3);
  25333. /**
  25334. * The vector the camera should consider as up.
  25335. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25336. */
  25337. upVector: Vector3;
  25338. /**
  25339. * Define the current limit on the left side for an orthographic camera
  25340. * In scene unit
  25341. */
  25342. orthoLeft: Nullable<number>;
  25343. /**
  25344. * Define the current limit on the right side for an orthographic camera
  25345. * In scene unit
  25346. */
  25347. orthoRight: Nullable<number>;
  25348. /**
  25349. * Define the current limit on the bottom side for an orthographic camera
  25350. * In scene unit
  25351. */
  25352. orthoBottom: Nullable<number>;
  25353. /**
  25354. * Define the current limit on the top side for an orthographic camera
  25355. * In scene unit
  25356. */
  25357. orthoTop: Nullable<number>;
  25358. /**
  25359. * Field Of View is set in Radians. (default is 0.8)
  25360. */
  25361. fov: number;
  25362. /**
  25363. * Define the minimum distance the camera can see from.
  25364. * This is important to note that the depth buffer are not infinite and the closer it starts
  25365. * the more your scene might encounter depth fighting issue.
  25366. */
  25367. minZ: number;
  25368. /**
  25369. * Define the maximum distance the camera can see to.
  25370. * This is important to note that the depth buffer are not infinite and the further it end
  25371. * the more your scene might encounter depth fighting issue.
  25372. */
  25373. maxZ: number;
  25374. /**
  25375. * Define the default inertia of the camera.
  25376. * This helps giving a smooth feeling to the camera movement.
  25377. */
  25378. inertia: number;
  25379. /**
  25380. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25381. */
  25382. mode: number;
  25383. /**
  25384. * Define wether the camera is intermediate.
  25385. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25386. */
  25387. isIntermediate: boolean;
  25388. /**
  25389. * Define the viewport of the camera.
  25390. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25391. */
  25392. viewport: Viewport;
  25393. /**
  25394. * Restricts the camera to viewing objects with the same layerMask.
  25395. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25396. */
  25397. layerMask: number;
  25398. /**
  25399. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25400. */
  25401. fovMode: number;
  25402. /**
  25403. * Rig mode of the camera.
  25404. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25405. * This is normally controlled byt the camera themselves as internal use.
  25406. */
  25407. cameraRigMode: number;
  25408. /**
  25409. * Defines the distance between both "eyes" in case of a RIG
  25410. */
  25411. interaxialDistance: number;
  25412. /**
  25413. * Defines if stereoscopic rendering is done side by side or over under.
  25414. */
  25415. isStereoscopicSideBySide: boolean;
  25416. /**
  25417. * 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
  25418. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25419. * else in the scene. (Eg. security camera)
  25420. *
  25421. * 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)
  25422. */
  25423. customRenderTargets: RenderTargetTexture[];
  25424. /**
  25425. * When set, the camera will render to this render target instead of the default canvas
  25426. *
  25427. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25428. */
  25429. outputRenderTarget: Nullable<RenderTargetTexture>;
  25430. /**
  25431. * Observable triggered when the camera view matrix has changed.
  25432. */
  25433. onViewMatrixChangedObservable: Observable<Camera>;
  25434. /**
  25435. * Observable triggered when the camera Projection matrix has changed.
  25436. */
  25437. onProjectionMatrixChangedObservable: Observable<Camera>;
  25438. /**
  25439. * Observable triggered when the inputs have been processed.
  25440. */
  25441. onAfterCheckInputsObservable: Observable<Camera>;
  25442. /**
  25443. * Observable triggered when reset has been called and applied to the camera.
  25444. */
  25445. onRestoreStateObservable: Observable<Camera>;
  25446. /** @hidden */
  25447. _cameraRigParams: any;
  25448. /** @hidden */
  25449. _rigCameras: Camera[];
  25450. /** @hidden */
  25451. _rigPostProcess: Nullable<PostProcess>;
  25452. protected _webvrViewMatrix: Matrix;
  25453. /** @hidden */
  25454. _skipRendering: boolean;
  25455. /** @hidden */
  25456. _projectionMatrix: Matrix;
  25457. /** @hidden */
  25458. _postProcesses: Nullable<PostProcess>[];
  25459. /** @hidden */
  25460. _activeMeshes: SmartArray<AbstractMesh>;
  25461. protected _globalPosition: Vector3;
  25462. /** @hidden */
  25463. _computedViewMatrix: Matrix;
  25464. private _doNotComputeProjectionMatrix;
  25465. private _transformMatrix;
  25466. private _frustumPlanes;
  25467. private _refreshFrustumPlanes;
  25468. private _storedFov;
  25469. private _stateStored;
  25470. /**
  25471. * Instantiates a new camera object.
  25472. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25473. * @see http://doc.babylonjs.com/features/cameras
  25474. * @param name Defines the name of the camera in the scene
  25475. * @param position Defines the position of the camera
  25476. * @param scene Defines the scene the camera belongs too
  25477. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25478. */
  25479. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25480. /**
  25481. * Store current camera state (fov, position, etc..)
  25482. * @returns the camera
  25483. */
  25484. storeState(): Camera;
  25485. /**
  25486. * Restores the camera state values if it has been stored. You must call storeState() first
  25487. */
  25488. protected _restoreStateValues(): boolean;
  25489. /**
  25490. * Restored camera state. You must call storeState() first.
  25491. * @returns true if restored and false otherwise
  25492. */
  25493. restoreState(): boolean;
  25494. /**
  25495. * Gets the class name of the camera.
  25496. * @returns the class name
  25497. */
  25498. getClassName(): string;
  25499. /** @hidden */
  25500. readonly _isCamera: boolean;
  25501. /**
  25502. * Gets a string representation of the camera useful for debug purpose.
  25503. * @param fullDetails Defines that a more verboe level of logging is required
  25504. * @returns the string representation
  25505. */
  25506. toString(fullDetails?: boolean): string;
  25507. /**
  25508. * Gets the current world space position of the camera.
  25509. */
  25510. get globalPosition(): Vector3;
  25511. /**
  25512. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25513. * @returns the active meshe list
  25514. */
  25515. getActiveMeshes(): SmartArray<AbstractMesh>;
  25516. /**
  25517. * Check wether a mesh is part of the current active mesh list of the camera
  25518. * @param mesh Defines the mesh to check
  25519. * @returns true if active, false otherwise
  25520. */
  25521. isActiveMesh(mesh: Mesh): boolean;
  25522. /**
  25523. * Is this camera ready to be used/rendered
  25524. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25525. * @return true if the camera is ready
  25526. */
  25527. isReady(completeCheck?: boolean): boolean;
  25528. /** @hidden */
  25529. _initCache(): void;
  25530. /** @hidden */
  25531. _updateCache(ignoreParentClass?: boolean): void;
  25532. /** @hidden */
  25533. _isSynchronized(): boolean;
  25534. /** @hidden */
  25535. _isSynchronizedViewMatrix(): boolean;
  25536. /** @hidden */
  25537. _isSynchronizedProjectionMatrix(): boolean;
  25538. /**
  25539. * Attach the input controls to a specific dom element to get the input from.
  25540. * @param element Defines the element the controls should be listened from
  25541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25542. */
  25543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25544. /**
  25545. * Detach the current controls from the specified dom element.
  25546. * @param element Defines the element to stop listening the inputs from
  25547. */
  25548. detachControl(element: HTMLElement): void;
  25549. /**
  25550. * Update the camera state according to the different inputs gathered during the frame.
  25551. */
  25552. update(): void;
  25553. /** @hidden */
  25554. _checkInputs(): void;
  25555. /** @hidden */
  25556. get rigCameras(): Camera[];
  25557. /**
  25558. * Gets the post process used by the rig cameras
  25559. */
  25560. get rigPostProcess(): Nullable<PostProcess>;
  25561. /**
  25562. * Internal, gets the first post proces.
  25563. * @returns the first post process to be run on this camera.
  25564. */
  25565. _getFirstPostProcess(): Nullable<PostProcess>;
  25566. private _cascadePostProcessesToRigCams;
  25567. /**
  25568. * Attach a post process to the camera.
  25569. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25570. * @param postProcess The post process to attach to the camera
  25571. * @param insertAt The position of the post process in case several of them are in use in the scene
  25572. * @returns the position the post process has been inserted at
  25573. */
  25574. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25575. /**
  25576. * Detach a post process to the camera.
  25577. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25578. * @param postProcess The post process to detach from the camera
  25579. */
  25580. detachPostProcess(postProcess: PostProcess): void;
  25581. /**
  25582. * Gets the current world matrix of the camera
  25583. */
  25584. getWorldMatrix(): Matrix;
  25585. /** @hidden */
  25586. _getViewMatrix(): Matrix;
  25587. /**
  25588. * Gets the current view matrix of the camera.
  25589. * @param force forces the camera to recompute the matrix without looking at the cached state
  25590. * @returns the view matrix
  25591. */
  25592. getViewMatrix(force?: boolean): Matrix;
  25593. /**
  25594. * Freeze the projection matrix.
  25595. * It will prevent the cache check of the camera projection compute and can speed up perf
  25596. * if no parameter of the camera are meant to change
  25597. * @param projection Defines manually a projection if necessary
  25598. */
  25599. freezeProjectionMatrix(projection?: Matrix): void;
  25600. /**
  25601. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25602. */
  25603. unfreezeProjectionMatrix(): void;
  25604. /**
  25605. * Gets the current projection matrix of the camera.
  25606. * @param force forces the camera to recompute the matrix without looking at the cached state
  25607. * @returns the projection matrix
  25608. */
  25609. getProjectionMatrix(force?: boolean): Matrix;
  25610. /**
  25611. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25612. * @returns a Matrix
  25613. */
  25614. getTransformationMatrix(): Matrix;
  25615. private _updateFrustumPlanes;
  25616. /**
  25617. * Checks if a cullable object (mesh...) is in the camera frustum
  25618. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25619. * @param target The object to check
  25620. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25621. * @returns true if the object is in frustum otherwise false
  25622. */
  25623. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25624. /**
  25625. * Checks if a cullable object (mesh...) is in the camera frustum
  25626. * Unlike isInFrustum this cheks the full bounding box
  25627. * @param target The object to check
  25628. * @returns true if the object is in frustum otherwise false
  25629. */
  25630. isCompletelyInFrustum(target: ICullable): boolean;
  25631. /**
  25632. * Gets a ray in the forward direction from the camera.
  25633. * @param length Defines the length of the ray to create
  25634. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25635. * @param origin Defines the start point of the ray which defaults to the camera position
  25636. * @returns the forward ray
  25637. */
  25638. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25639. /**
  25640. * Releases resources associated with this node.
  25641. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25642. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25643. */
  25644. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25645. /** @hidden */
  25646. _isLeftCamera: boolean;
  25647. /**
  25648. * Gets the left camera of a rig setup in case of Rigged Camera
  25649. */
  25650. get isLeftCamera(): boolean;
  25651. /** @hidden */
  25652. _isRightCamera: boolean;
  25653. /**
  25654. * Gets the right camera of a rig setup in case of Rigged Camera
  25655. */
  25656. get isRightCamera(): boolean;
  25657. /**
  25658. * Gets the left camera of a rig setup in case of Rigged Camera
  25659. */
  25660. get leftCamera(): Nullable<FreeCamera>;
  25661. /**
  25662. * Gets the right camera of a rig setup in case of Rigged Camera
  25663. */
  25664. get rightCamera(): Nullable<FreeCamera>;
  25665. /**
  25666. * Gets the left camera target of a rig setup in case of Rigged Camera
  25667. * @returns the target position
  25668. */
  25669. getLeftTarget(): Nullable<Vector3>;
  25670. /**
  25671. * Gets the right camera target of a rig setup in case of Rigged Camera
  25672. * @returns the target position
  25673. */
  25674. getRightTarget(): Nullable<Vector3>;
  25675. /**
  25676. * @hidden
  25677. */
  25678. setCameraRigMode(mode: number, rigParams: any): void;
  25679. /** @hidden */
  25680. static _setStereoscopicRigMode(camera: Camera): void;
  25681. /** @hidden */
  25682. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25683. /** @hidden */
  25684. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25685. /** @hidden */
  25686. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25687. /** @hidden */
  25688. _getVRProjectionMatrix(): Matrix;
  25689. protected _updateCameraRotationMatrix(): void;
  25690. protected _updateWebVRCameraRotationMatrix(): void;
  25691. /**
  25692. * This function MUST be overwritten by the different WebVR cameras available.
  25693. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25694. * @hidden
  25695. */
  25696. _getWebVRProjectionMatrix(): Matrix;
  25697. /**
  25698. * This function MUST be overwritten by the different WebVR cameras available.
  25699. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25700. * @hidden
  25701. */
  25702. _getWebVRViewMatrix(): Matrix;
  25703. /** @hidden */
  25704. setCameraRigParameter(name: string, value: any): void;
  25705. /**
  25706. * needs to be overridden by children so sub has required properties to be copied
  25707. * @hidden
  25708. */
  25709. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25710. /**
  25711. * May need to be overridden by children
  25712. * @hidden
  25713. */
  25714. _updateRigCameras(): void;
  25715. /** @hidden */
  25716. _setupInputs(): void;
  25717. /**
  25718. * Serialiaze the camera setup to a json represention
  25719. * @returns the JSON representation
  25720. */
  25721. serialize(): any;
  25722. /**
  25723. * Clones the current camera.
  25724. * @param name The cloned camera name
  25725. * @returns the cloned camera
  25726. */
  25727. clone(name: string): Camera;
  25728. /**
  25729. * Gets the direction of the camera relative to a given local axis.
  25730. * @param localAxis Defines the reference axis to provide a relative direction.
  25731. * @return the direction
  25732. */
  25733. getDirection(localAxis: Vector3): Vector3;
  25734. /**
  25735. * Returns the current camera absolute rotation
  25736. */
  25737. get absoluteRotation(): Quaternion;
  25738. /**
  25739. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25740. * @param localAxis Defines the reference axis to provide a relative direction.
  25741. * @param result Defines the vector to store the result in
  25742. */
  25743. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25744. /**
  25745. * Gets a camera constructor for a given camera type
  25746. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25747. * @param name The name of the camera the result will be able to instantiate
  25748. * @param scene The scene the result will construct the camera in
  25749. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25750. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25751. * @returns a factory method to construc the camera
  25752. */
  25753. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25754. /**
  25755. * Compute the world matrix of the camera.
  25756. * @returns the camera world matrix
  25757. */
  25758. computeWorldMatrix(): Matrix;
  25759. /**
  25760. * Parse a JSON and creates the camera from the parsed information
  25761. * @param parsedCamera The JSON to parse
  25762. * @param scene The scene to instantiate the camera in
  25763. * @returns the newly constructed camera
  25764. */
  25765. static Parse(parsedCamera: any, scene: Scene): Camera;
  25766. }
  25767. }
  25768. declare module BABYLON {
  25769. /**
  25770. * Class containing static functions to help procedurally build meshes
  25771. */
  25772. export class DiscBuilder {
  25773. /**
  25774. * Creates a plane polygonal mesh. By default, this is a disc
  25775. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25776. * * 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
  25777. * * 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
  25778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25779. * * 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
  25780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25781. * @param name defines the name of the mesh
  25782. * @param options defines the options used to create the mesh
  25783. * @param scene defines the hosting scene
  25784. * @returns the plane polygonal mesh
  25785. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25786. */
  25787. static CreateDisc(name: string, options: {
  25788. radius?: number;
  25789. tessellation?: number;
  25790. arc?: number;
  25791. updatable?: boolean;
  25792. sideOrientation?: number;
  25793. frontUVs?: Vector4;
  25794. backUVs?: Vector4;
  25795. }, scene?: Nullable<Scene>): Mesh;
  25796. }
  25797. }
  25798. declare module BABYLON {
  25799. /**
  25800. * This represents all the required information to add a fresnel effect on a material:
  25801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25802. */
  25803. export class FresnelParameters {
  25804. private _isEnabled;
  25805. /**
  25806. * Define if the fresnel effect is enable or not.
  25807. */
  25808. get isEnabled(): boolean;
  25809. set isEnabled(value: boolean);
  25810. /**
  25811. * Define the color used on edges (grazing angle)
  25812. */
  25813. leftColor: Color3;
  25814. /**
  25815. * Define the color used on center
  25816. */
  25817. rightColor: Color3;
  25818. /**
  25819. * Define bias applied to computed fresnel term
  25820. */
  25821. bias: number;
  25822. /**
  25823. * Defined the power exponent applied to fresnel term
  25824. */
  25825. power: number;
  25826. /**
  25827. * Clones the current fresnel and its valuues
  25828. * @returns a clone fresnel configuration
  25829. */
  25830. clone(): FresnelParameters;
  25831. /**
  25832. * Serializes the current fresnel parameters to a JSON representation.
  25833. * @return the JSON serialization
  25834. */
  25835. serialize(): any;
  25836. /**
  25837. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25838. * @param parsedFresnelParameters Define the JSON representation
  25839. * @returns the parsed parameters
  25840. */
  25841. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25842. }
  25843. }
  25844. declare module BABYLON {
  25845. /**
  25846. * Base class of materials working in push mode in babylon JS
  25847. * @hidden
  25848. */
  25849. export class PushMaterial extends Material {
  25850. protected _activeEffect: Effect;
  25851. protected _normalMatrix: Matrix;
  25852. /**
  25853. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25854. * This means that the material can keep using a previous shader while a new one is being compiled.
  25855. * This is mostly used when shader parallel compilation is supported (true by default)
  25856. */
  25857. allowShaderHotSwapping: boolean;
  25858. constructor(name: string, scene: Scene);
  25859. getEffect(): Effect;
  25860. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25861. /**
  25862. * Binds the given world matrix to the active effect
  25863. *
  25864. * @param world the matrix to bind
  25865. */
  25866. bindOnlyWorldMatrix(world: Matrix): void;
  25867. /**
  25868. * Binds the given normal matrix to the active effect
  25869. *
  25870. * @param normalMatrix the matrix to bind
  25871. */
  25872. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25873. bind(world: Matrix, mesh?: Mesh): void;
  25874. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25875. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25876. }
  25877. }
  25878. declare module BABYLON {
  25879. /**
  25880. * This groups all the flags used to control the materials channel.
  25881. */
  25882. export class MaterialFlags {
  25883. private static _DiffuseTextureEnabled;
  25884. /**
  25885. * Are diffuse textures enabled in the application.
  25886. */
  25887. static get DiffuseTextureEnabled(): boolean;
  25888. static set DiffuseTextureEnabled(value: boolean);
  25889. private static _AmbientTextureEnabled;
  25890. /**
  25891. * Are ambient textures enabled in the application.
  25892. */
  25893. static get AmbientTextureEnabled(): boolean;
  25894. static set AmbientTextureEnabled(value: boolean);
  25895. private static _OpacityTextureEnabled;
  25896. /**
  25897. * Are opacity textures enabled in the application.
  25898. */
  25899. static get OpacityTextureEnabled(): boolean;
  25900. static set OpacityTextureEnabled(value: boolean);
  25901. private static _ReflectionTextureEnabled;
  25902. /**
  25903. * Are reflection textures enabled in the application.
  25904. */
  25905. static get ReflectionTextureEnabled(): boolean;
  25906. static set ReflectionTextureEnabled(value: boolean);
  25907. private static _EmissiveTextureEnabled;
  25908. /**
  25909. * Are emissive textures enabled in the application.
  25910. */
  25911. static get EmissiveTextureEnabled(): boolean;
  25912. static set EmissiveTextureEnabled(value: boolean);
  25913. private static _SpecularTextureEnabled;
  25914. /**
  25915. * Are specular textures enabled in the application.
  25916. */
  25917. static get SpecularTextureEnabled(): boolean;
  25918. static set SpecularTextureEnabled(value: boolean);
  25919. private static _BumpTextureEnabled;
  25920. /**
  25921. * Are bump textures enabled in the application.
  25922. */
  25923. static get BumpTextureEnabled(): boolean;
  25924. static set BumpTextureEnabled(value: boolean);
  25925. private static _LightmapTextureEnabled;
  25926. /**
  25927. * Are lightmap textures enabled in the application.
  25928. */
  25929. static get LightmapTextureEnabled(): boolean;
  25930. static set LightmapTextureEnabled(value: boolean);
  25931. private static _RefractionTextureEnabled;
  25932. /**
  25933. * Are refraction textures enabled in the application.
  25934. */
  25935. static get RefractionTextureEnabled(): boolean;
  25936. static set RefractionTextureEnabled(value: boolean);
  25937. private static _ColorGradingTextureEnabled;
  25938. /**
  25939. * Are color grading textures enabled in the application.
  25940. */
  25941. static get ColorGradingTextureEnabled(): boolean;
  25942. static set ColorGradingTextureEnabled(value: boolean);
  25943. private static _FresnelEnabled;
  25944. /**
  25945. * Are fresnels enabled in the application.
  25946. */
  25947. static get FresnelEnabled(): boolean;
  25948. static set FresnelEnabled(value: boolean);
  25949. private static _ClearCoatTextureEnabled;
  25950. /**
  25951. * Are clear coat textures enabled in the application.
  25952. */
  25953. static get ClearCoatTextureEnabled(): boolean;
  25954. static set ClearCoatTextureEnabled(value: boolean);
  25955. private static _ClearCoatBumpTextureEnabled;
  25956. /**
  25957. * Are clear coat bump textures enabled in the application.
  25958. */
  25959. static get ClearCoatBumpTextureEnabled(): boolean;
  25960. static set ClearCoatBumpTextureEnabled(value: boolean);
  25961. private static _ClearCoatTintTextureEnabled;
  25962. /**
  25963. * Are clear coat tint textures enabled in the application.
  25964. */
  25965. static get ClearCoatTintTextureEnabled(): boolean;
  25966. static set ClearCoatTintTextureEnabled(value: boolean);
  25967. private static _SheenTextureEnabled;
  25968. /**
  25969. * Are sheen textures enabled in the application.
  25970. */
  25971. static get SheenTextureEnabled(): boolean;
  25972. static set SheenTextureEnabled(value: boolean);
  25973. private static _AnisotropicTextureEnabled;
  25974. /**
  25975. * Are anisotropic textures enabled in the application.
  25976. */
  25977. static get AnisotropicTextureEnabled(): boolean;
  25978. static set AnisotropicTextureEnabled(value: boolean);
  25979. private static _ThicknessTextureEnabled;
  25980. /**
  25981. * Are thickness textures enabled in the application.
  25982. */
  25983. static get ThicknessTextureEnabled(): boolean;
  25984. static set ThicknessTextureEnabled(value: boolean);
  25985. }
  25986. }
  25987. declare module BABYLON {
  25988. /** @hidden */
  25989. export var defaultFragmentDeclaration: {
  25990. name: string;
  25991. shader: string;
  25992. };
  25993. }
  25994. declare module BABYLON {
  25995. /** @hidden */
  25996. export var defaultUboDeclaration: {
  25997. name: string;
  25998. shader: string;
  25999. };
  26000. }
  26001. declare module BABYLON {
  26002. /** @hidden */
  26003. export var lightFragmentDeclaration: {
  26004. name: string;
  26005. shader: string;
  26006. };
  26007. }
  26008. declare module BABYLON {
  26009. /** @hidden */
  26010. export var lightUboDeclaration: {
  26011. name: string;
  26012. shader: string;
  26013. };
  26014. }
  26015. declare module BABYLON {
  26016. /** @hidden */
  26017. export var lightsFragmentFunctions: {
  26018. name: string;
  26019. shader: string;
  26020. };
  26021. }
  26022. declare module BABYLON {
  26023. /** @hidden */
  26024. export var shadowsFragmentFunctions: {
  26025. name: string;
  26026. shader: string;
  26027. };
  26028. }
  26029. declare module BABYLON {
  26030. /** @hidden */
  26031. export var fresnelFunction: {
  26032. name: string;
  26033. shader: string;
  26034. };
  26035. }
  26036. declare module BABYLON {
  26037. /** @hidden */
  26038. export var reflectionFunction: {
  26039. name: string;
  26040. shader: string;
  26041. };
  26042. }
  26043. declare module BABYLON {
  26044. /** @hidden */
  26045. export var bumpFragmentFunctions: {
  26046. name: string;
  26047. shader: string;
  26048. };
  26049. }
  26050. declare module BABYLON {
  26051. /** @hidden */
  26052. export var logDepthDeclaration: {
  26053. name: string;
  26054. shader: string;
  26055. };
  26056. }
  26057. declare module BABYLON {
  26058. /** @hidden */
  26059. export var bumpFragment: {
  26060. name: string;
  26061. shader: string;
  26062. };
  26063. }
  26064. declare module BABYLON {
  26065. /** @hidden */
  26066. export var depthPrePass: {
  26067. name: string;
  26068. shader: string;
  26069. };
  26070. }
  26071. declare module BABYLON {
  26072. /** @hidden */
  26073. export var lightFragment: {
  26074. name: string;
  26075. shader: string;
  26076. };
  26077. }
  26078. declare module BABYLON {
  26079. /** @hidden */
  26080. export var logDepthFragment: {
  26081. name: string;
  26082. shader: string;
  26083. };
  26084. }
  26085. declare module BABYLON {
  26086. /** @hidden */
  26087. export var defaultPixelShader: {
  26088. name: string;
  26089. shader: string;
  26090. };
  26091. }
  26092. declare module BABYLON {
  26093. /** @hidden */
  26094. export var defaultVertexDeclaration: {
  26095. name: string;
  26096. shader: string;
  26097. };
  26098. }
  26099. declare module BABYLON {
  26100. /** @hidden */
  26101. export var bumpVertexDeclaration: {
  26102. name: string;
  26103. shader: string;
  26104. };
  26105. }
  26106. declare module BABYLON {
  26107. /** @hidden */
  26108. export var bumpVertex: {
  26109. name: string;
  26110. shader: string;
  26111. };
  26112. }
  26113. declare module BABYLON {
  26114. /** @hidden */
  26115. export var fogVertex: {
  26116. name: string;
  26117. shader: string;
  26118. };
  26119. }
  26120. declare module BABYLON {
  26121. /** @hidden */
  26122. export var shadowsVertex: {
  26123. name: string;
  26124. shader: string;
  26125. };
  26126. }
  26127. declare module BABYLON {
  26128. /** @hidden */
  26129. export var pointCloudVertex: {
  26130. name: string;
  26131. shader: string;
  26132. };
  26133. }
  26134. declare module BABYLON {
  26135. /** @hidden */
  26136. export var logDepthVertex: {
  26137. name: string;
  26138. shader: string;
  26139. };
  26140. }
  26141. declare module BABYLON {
  26142. /** @hidden */
  26143. export var defaultVertexShader: {
  26144. name: string;
  26145. shader: string;
  26146. };
  26147. }
  26148. declare module BABYLON {
  26149. /** @hidden */
  26150. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26151. MAINUV1: boolean;
  26152. MAINUV2: boolean;
  26153. DIFFUSE: boolean;
  26154. DIFFUSEDIRECTUV: number;
  26155. AMBIENT: boolean;
  26156. AMBIENTDIRECTUV: number;
  26157. OPACITY: boolean;
  26158. OPACITYDIRECTUV: number;
  26159. OPACITYRGB: boolean;
  26160. REFLECTION: boolean;
  26161. EMISSIVE: boolean;
  26162. EMISSIVEDIRECTUV: number;
  26163. SPECULAR: boolean;
  26164. SPECULARDIRECTUV: number;
  26165. BUMP: boolean;
  26166. BUMPDIRECTUV: number;
  26167. PARALLAX: boolean;
  26168. PARALLAXOCCLUSION: boolean;
  26169. SPECULAROVERALPHA: boolean;
  26170. CLIPPLANE: boolean;
  26171. CLIPPLANE2: boolean;
  26172. CLIPPLANE3: boolean;
  26173. CLIPPLANE4: boolean;
  26174. CLIPPLANE5: boolean;
  26175. CLIPPLANE6: boolean;
  26176. ALPHATEST: boolean;
  26177. DEPTHPREPASS: boolean;
  26178. ALPHAFROMDIFFUSE: boolean;
  26179. POINTSIZE: boolean;
  26180. FOG: boolean;
  26181. SPECULARTERM: boolean;
  26182. DIFFUSEFRESNEL: boolean;
  26183. OPACITYFRESNEL: boolean;
  26184. REFLECTIONFRESNEL: boolean;
  26185. REFRACTIONFRESNEL: boolean;
  26186. EMISSIVEFRESNEL: boolean;
  26187. FRESNEL: boolean;
  26188. NORMAL: boolean;
  26189. UV1: boolean;
  26190. UV2: boolean;
  26191. VERTEXCOLOR: boolean;
  26192. VERTEXALPHA: boolean;
  26193. NUM_BONE_INFLUENCERS: number;
  26194. BonesPerMesh: number;
  26195. BONETEXTURE: boolean;
  26196. INSTANCES: boolean;
  26197. GLOSSINESS: boolean;
  26198. ROUGHNESS: boolean;
  26199. EMISSIVEASILLUMINATION: boolean;
  26200. LINKEMISSIVEWITHDIFFUSE: boolean;
  26201. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26202. LIGHTMAP: boolean;
  26203. LIGHTMAPDIRECTUV: number;
  26204. OBJECTSPACE_NORMALMAP: boolean;
  26205. USELIGHTMAPASSHADOWMAP: boolean;
  26206. REFLECTIONMAP_3D: boolean;
  26207. REFLECTIONMAP_SPHERICAL: boolean;
  26208. REFLECTIONMAP_PLANAR: boolean;
  26209. REFLECTIONMAP_CUBIC: boolean;
  26210. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26211. REFLECTIONMAP_PROJECTION: boolean;
  26212. REFLECTIONMAP_SKYBOX: boolean;
  26213. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26214. REFLECTIONMAP_EXPLICIT: boolean;
  26215. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26216. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26217. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26218. INVERTCUBICMAP: boolean;
  26219. LOGARITHMICDEPTH: boolean;
  26220. REFRACTION: boolean;
  26221. REFRACTIONMAP_3D: boolean;
  26222. REFLECTIONOVERALPHA: boolean;
  26223. TWOSIDEDLIGHTING: boolean;
  26224. SHADOWFLOAT: boolean;
  26225. MORPHTARGETS: boolean;
  26226. MORPHTARGETS_NORMAL: boolean;
  26227. MORPHTARGETS_TANGENT: boolean;
  26228. MORPHTARGETS_UV: boolean;
  26229. NUM_MORPH_INFLUENCERS: number;
  26230. NONUNIFORMSCALING: boolean;
  26231. PREMULTIPLYALPHA: boolean;
  26232. IMAGEPROCESSING: boolean;
  26233. VIGNETTE: boolean;
  26234. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26235. VIGNETTEBLENDMODEOPAQUE: boolean;
  26236. TONEMAPPING: boolean;
  26237. TONEMAPPING_ACES: boolean;
  26238. CONTRAST: boolean;
  26239. COLORCURVES: boolean;
  26240. COLORGRADING: boolean;
  26241. COLORGRADING3D: boolean;
  26242. SAMPLER3DGREENDEPTH: boolean;
  26243. SAMPLER3DBGRMAP: boolean;
  26244. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26245. MULTIVIEW: boolean;
  26246. /**
  26247. * If the reflection texture on this material is in linear color space
  26248. * @hidden
  26249. */
  26250. IS_REFLECTION_LINEAR: boolean;
  26251. /**
  26252. * If the refraction texture on this material is in linear color space
  26253. * @hidden
  26254. */
  26255. IS_REFRACTION_LINEAR: boolean;
  26256. EXPOSURE: boolean;
  26257. constructor();
  26258. setReflectionMode(modeToEnable: string): void;
  26259. }
  26260. /**
  26261. * This is the default material used in Babylon. It is the best trade off between quality
  26262. * and performances.
  26263. * @see http://doc.babylonjs.com/babylon101/materials
  26264. */
  26265. export class StandardMaterial extends PushMaterial {
  26266. private _diffuseTexture;
  26267. /**
  26268. * The basic texture of the material as viewed under a light.
  26269. */
  26270. diffuseTexture: Nullable<BaseTexture>;
  26271. private _ambientTexture;
  26272. /**
  26273. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26274. */
  26275. ambientTexture: Nullable<BaseTexture>;
  26276. private _opacityTexture;
  26277. /**
  26278. * Define the transparency of the material from a texture.
  26279. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26280. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26281. */
  26282. opacityTexture: Nullable<BaseTexture>;
  26283. private _reflectionTexture;
  26284. /**
  26285. * Define the texture used to display the reflection.
  26286. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26287. */
  26288. reflectionTexture: Nullable<BaseTexture>;
  26289. private _emissiveTexture;
  26290. /**
  26291. * Define texture of the material as if self lit.
  26292. * This will be mixed in the final result even in the absence of light.
  26293. */
  26294. emissiveTexture: Nullable<BaseTexture>;
  26295. private _specularTexture;
  26296. /**
  26297. * Define how the color and intensity of the highlight given by the light in the material.
  26298. */
  26299. specularTexture: Nullable<BaseTexture>;
  26300. private _bumpTexture;
  26301. /**
  26302. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26303. * 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.
  26304. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26305. */
  26306. bumpTexture: Nullable<BaseTexture>;
  26307. private _lightmapTexture;
  26308. /**
  26309. * Complex lighting can be computationally expensive to compute at runtime.
  26310. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26311. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26312. */
  26313. lightmapTexture: Nullable<BaseTexture>;
  26314. private _refractionTexture;
  26315. /**
  26316. * Define the texture used to display the refraction.
  26317. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26318. */
  26319. refractionTexture: Nullable<BaseTexture>;
  26320. /**
  26321. * The color of the material lit by the environmental background lighting.
  26322. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26323. */
  26324. ambientColor: Color3;
  26325. /**
  26326. * The basic color of the material as viewed under a light.
  26327. */
  26328. diffuseColor: Color3;
  26329. /**
  26330. * Define how the color and intensity of the highlight given by the light in the material.
  26331. */
  26332. specularColor: Color3;
  26333. /**
  26334. * Define the color of the material as if self lit.
  26335. * This will be mixed in the final result even in the absence of light.
  26336. */
  26337. emissiveColor: Color3;
  26338. /**
  26339. * Defines how sharp are the highlights in the material.
  26340. * The bigger the value the sharper giving a more glossy feeling to the result.
  26341. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26342. */
  26343. specularPower: number;
  26344. private _useAlphaFromDiffuseTexture;
  26345. /**
  26346. * Does the transparency come from the diffuse texture alpha channel.
  26347. */
  26348. useAlphaFromDiffuseTexture: boolean;
  26349. private _useEmissiveAsIllumination;
  26350. /**
  26351. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26352. */
  26353. useEmissiveAsIllumination: boolean;
  26354. private _linkEmissiveWithDiffuse;
  26355. /**
  26356. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26357. * the emissive level when the final color is close to one.
  26358. */
  26359. linkEmissiveWithDiffuse: boolean;
  26360. private _useSpecularOverAlpha;
  26361. /**
  26362. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26363. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26364. */
  26365. useSpecularOverAlpha: boolean;
  26366. private _useReflectionOverAlpha;
  26367. /**
  26368. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26369. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26370. */
  26371. useReflectionOverAlpha: boolean;
  26372. private _disableLighting;
  26373. /**
  26374. * Does lights from the scene impacts this material.
  26375. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26376. */
  26377. disableLighting: boolean;
  26378. private _useObjectSpaceNormalMap;
  26379. /**
  26380. * Allows using an object space normal map (instead of tangent space).
  26381. */
  26382. useObjectSpaceNormalMap: boolean;
  26383. private _useParallax;
  26384. /**
  26385. * Is parallax enabled or not.
  26386. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26387. */
  26388. useParallax: boolean;
  26389. private _useParallaxOcclusion;
  26390. /**
  26391. * Is parallax occlusion enabled or not.
  26392. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26393. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26394. */
  26395. useParallaxOcclusion: boolean;
  26396. /**
  26397. * 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.
  26398. */
  26399. parallaxScaleBias: number;
  26400. private _roughness;
  26401. /**
  26402. * Helps to define how blurry the reflections should appears in the material.
  26403. */
  26404. roughness: number;
  26405. /**
  26406. * In case of refraction, define the value of the index of refraction.
  26407. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26408. */
  26409. indexOfRefraction: number;
  26410. /**
  26411. * Invert the refraction texture alongside the y axis.
  26412. * It can be useful with procedural textures or probe for instance.
  26413. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26414. */
  26415. invertRefractionY: boolean;
  26416. /**
  26417. * Defines the alpha limits in alpha test mode.
  26418. */
  26419. alphaCutOff: number;
  26420. private _useLightmapAsShadowmap;
  26421. /**
  26422. * In case of light mapping, define whether the map contains light or shadow informations.
  26423. */
  26424. useLightmapAsShadowmap: boolean;
  26425. private _diffuseFresnelParameters;
  26426. /**
  26427. * Define the diffuse fresnel parameters of the material.
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26429. */
  26430. diffuseFresnelParameters: FresnelParameters;
  26431. private _opacityFresnelParameters;
  26432. /**
  26433. * Define the opacity fresnel parameters of the material.
  26434. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26435. */
  26436. opacityFresnelParameters: FresnelParameters;
  26437. private _reflectionFresnelParameters;
  26438. /**
  26439. * Define the reflection fresnel parameters of the material.
  26440. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26441. */
  26442. reflectionFresnelParameters: FresnelParameters;
  26443. private _refractionFresnelParameters;
  26444. /**
  26445. * Define the refraction fresnel parameters of the material.
  26446. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26447. */
  26448. refractionFresnelParameters: FresnelParameters;
  26449. private _emissiveFresnelParameters;
  26450. /**
  26451. * Define the emissive fresnel parameters of the material.
  26452. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26453. */
  26454. emissiveFresnelParameters: FresnelParameters;
  26455. private _useReflectionFresnelFromSpecular;
  26456. /**
  26457. * If true automatically deducts the fresnels values from the material specularity.
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26459. */
  26460. useReflectionFresnelFromSpecular: boolean;
  26461. private _useGlossinessFromSpecularMapAlpha;
  26462. /**
  26463. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26464. */
  26465. useGlossinessFromSpecularMapAlpha: boolean;
  26466. private _maxSimultaneousLights;
  26467. /**
  26468. * Defines the maximum number of lights that can be used in the material
  26469. */
  26470. maxSimultaneousLights: number;
  26471. private _invertNormalMapX;
  26472. /**
  26473. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26474. */
  26475. invertNormalMapX: boolean;
  26476. private _invertNormalMapY;
  26477. /**
  26478. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26479. */
  26480. invertNormalMapY: boolean;
  26481. private _twoSidedLighting;
  26482. /**
  26483. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26484. */
  26485. twoSidedLighting: boolean;
  26486. /**
  26487. * Default configuration related to image processing available in the standard Material.
  26488. */
  26489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26490. /**
  26491. * Gets the image processing configuration used either in this material.
  26492. */
  26493. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26494. /**
  26495. * Sets the Default image processing configuration used either in the this material.
  26496. *
  26497. * If sets to null, the scene one is in use.
  26498. */
  26499. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26500. /**
  26501. * Keep track of the image processing observer to allow dispose and replace.
  26502. */
  26503. private _imageProcessingObserver;
  26504. /**
  26505. * Attaches a new image processing configuration to the Standard Material.
  26506. * @param configuration
  26507. */
  26508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26509. /**
  26510. * Gets wether the color curves effect is enabled.
  26511. */
  26512. get cameraColorCurvesEnabled(): boolean;
  26513. /**
  26514. * Sets wether the color curves effect is enabled.
  26515. */
  26516. set cameraColorCurvesEnabled(value: boolean);
  26517. /**
  26518. * Gets wether the color grading effect is enabled.
  26519. */
  26520. get cameraColorGradingEnabled(): boolean;
  26521. /**
  26522. * Gets wether the color grading effect is enabled.
  26523. */
  26524. set cameraColorGradingEnabled(value: boolean);
  26525. /**
  26526. * Gets wether tonemapping is enabled or not.
  26527. */
  26528. get cameraToneMappingEnabled(): boolean;
  26529. /**
  26530. * Sets wether tonemapping is enabled or not
  26531. */
  26532. set cameraToneMappingEnabled(value: boolean);
  26533. /**
  26534. * The camera exposure used on this material.
  26535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26536. * This corresponds to a photographic exposure.
  26537. */
  26538. get cameraExposure(): number;
  26539. /**
  26540. * The camera exposure used on this material.
  26541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26542. * This corresponds to a photographic exposure.
  26543. */
  26544. set cameraExposure(value: number);
  26545. /**
  26546. * Gets The camera contrast used on this material.
  26547. */
  26548. get cameraContrast(): number;
  26549. /**
  26550. * Sets The camera contrast used on this material.
  26551. */
  26552. set cameraContrast(value: number);
  26553. /**
  26554. * Gets the Color Grading 2D Lookup Texture.
  26555. */
  26556. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26557. /**
  26558. * Sets the Color Grading 2D Lookup Texture.
  26559. */
  26560. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26561. /**
  26562. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26563. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26564. * 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;
  26565. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26566. */
  26567. get cameraColorCurves(): Nullable<ColorCurves>;
  26568. /**
  26569. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26570. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26571. * 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;
  26572. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26573. */
  26574. set cameraColorCurves(value: Nullable<ColorCurves>);
  26575. /**
  26576. * Custom callback helping to override the default shader used in the material.
  26577. */
  26578. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26579. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26580. protected _worldViewProjectionMatrix: Matrix;
  26581. protected _globalAmbientColor: Color3;
  26582. protected _useLogarithmicDepth: boolean;
  26583. protected _rebuildInParallel: boolean;
  26584. /**
  26585. * Instantiates a new standard material.
  26586. * This is the default material used in Babylon. It is the best trade off between quality
  26587. * and performances.
  26588. * @see http://doc.babylonjs.com/babylon101/materials
  26589. * @param name Define the name of the material in the scene
  26590. * @param scene Define the scene the material belong to
  26591. */
  26592. constructor(name: string, scene: Scene);
  26593. /**
  26594. * Gets a boolean indicating that current material needs to register RTT
  26595. */
  26596. get hasRenderTargetTextures(): boolean;
  26597. /**
  26598. * Gets the current class name of the material e.g. "StandardMaterial"
  26599. * Mainly use in serialization.
  26600. * @returns the class name
  26601. */
  26602. getClassName(): string;
  26603. /**
  26604. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26605. * You can try switching to logarithmic depth.
  26606. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26607. */
  26608. get useLogarithmicDepth(): boolean;
  26609. set useLogarithmicDepth(value: boolean);
  26610. /**
  26611. * Specifies if the material will require alpha blending
  26612. * @returns a boolean specifying if alpha blending is needed
  26613. */
  26614. needAlphaBlending(): boolean;
  26615. /**
  26616. * Specifies if this material should be rendered in alpha test mode
  26617. * @returns a boolean specifying if an alpha test is needed.
  26618. */
  26619. needAlphaTesting(): boolean;
  26620. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26621. /**
  26622. * Get the texture used for alpha test purpose.
  26623. * @returns the diffuse texture in case of the standard material.
  26624. */
  26625. getAlphaTestTexture(): Nullable<BaseTexture>;
  26626. /**
  26627. * Get if the submesh is ready to be used and all its information available.
  26628. * Child classes can use it to update shaders
  26629. * @param mesh defines the mesh to check
  26630. * @param subMesh defines which submesh to check
  26631. * @param useInstances specifies that instances should be used
  26632. * @returns a boolean indicating that the submesh is ready or not
  26633. */
  26634. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26635. /**
  26636. * Builds the material UBO layouts.
  26637. * Used internally during the effect preparation.
  26638. */
  26639. buildUniformLayout(): void;
  26640. /**
  26641. * Unbinds the material from the mesh
  26642. */
  26643. unbind(): void;
  26644. /**
  26645. * Binds the submesh to this material by preparing the effect and shader to draw
  26646. * @param world defines the world transformation matrix
  26647. * @param mesh defines the mesh containing the submesh
  26648. * @param subMesh defines the submesh to bind the material to
  26649. */
  26650. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26651. /**
  26652. * Get the list of animatables in the material.
  26653. * @returns the list of animatables object used in the material
  26654. */
  26655. getAnimatables(): IAnimatable[];
  26656. /**
  26657. * Gets the active textures from the material
  26658. * @returns an array of textures
  26659. */
  26660. getActiveTextures(): BaseTexture[];
  26661. /**
  26662. * Specifies if the material uses a texture
  26663. * @param texture defines the texture to check against the material
  26664. * @returns a boolean specifying if the material uses the texture
  26665. */
  26666. hasTexture(texture: BaseTexture): boolean;
  26667. /**
  26668. * Disposes the material
  26669. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26670. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26671. */
  26672. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26673. /**
  26674. * Makes a duplicate of the material, and gives it a new name
  26675. * @param name defines the new name for the duplicated material
  26676. * @returns the cloned material
  26677. */
  26678. clone(name: string): StandardMaterial;
  26679. /**
  26680. * Serializes this material in a JSON representation
  26681. * @returns the serialized material object
  26682. */
  26683. serialize(): any;
  26684. /**
  26685. * Creates a standard material from parsed material data
  26686. * @param source defines the JSON representation of the material
  26687. * @param scene defines the hosting scene
  26688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26689. * @returns a new standard material
  26690. */
  26691. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26692. /**
  26693. * Are diffuse textures enabled in the application.
  26694. */
  26695. static get DiffuseTextureEnabled(): boolean;
  26696. static set DiffuseTextureEnabled(value: boolean);
  26697. /**
  26698. * Are ambient textures enabled in the application.
  26699. */
  26700. static get AmbientTextureEnabled(): boolean;
  26701. static set AmbientTextureEnabled(value: boolean);
  26702. /**
  26703. * Are opacity textures enabled in the application.
  26704. */
  26705. static get OpacityTextureEnabled(): boolean;
  26706. static set OpacityTextureEnabled(value: boolean);
  26707. /**
  26708. * Are reflection textures enabled in the application.
  26709. */
  26710. static get ReflectionTextureEnabled(): boolean;
  26711. static set ReflectionTextureEnabled(value: boolean);
  26712. /**
  26713. * Are emissive textures enabled in the application.
  26714. */
  26715. static get EmissiveTextureEnabled(): boolean;
  26716. static set EmissiveTextureEnabled(value: boolean);
  26717. /**
  26718. * Are specular textures enabled in the application.
  26719. */
  26720. static get SpecularTextureEnabled(): boolean;
  26721. static set SpecularTextureEnabled(value: boolean);
  26722. /**
  26723. * Are bump textures enabled in the application.
  26724. */
  26725. static get BumpTextureEnabled(): boolean;
  26726. static set BumpTextureEnabled(value: boolean);
  26727. /**
  26728. * Are lightmap textures enabled in the application.
  26729. */
  26730. static get LightmapTextureEnabled(): boolean;
  26731. static set LightmapTextureEnabled(value: boolean);
  26732. /**
  26733. * Are refraction textures enabled in the application.
  26734. */
  26735. static get RefractionTextureEnabled(): boolean;
  26736. static set RefractionTextureEnabled(value: boolean);
  26737. /**
  26738. * Are color grading textures enabled in the application.
  26739. */
  26740. static get ColorGradingTextureEnabled(): boolean;
  26741. static set ColorGradingTextureEnabled(value: boolean);
  26742. /**
  26743. * Are fresnels enabled in the application.
  26744. */
  26745. static get FresnelEnabled(): boolean;
  26746. static set FresnelEnabled(value: boolean);
  26747. }
  26748. }
  26749. declare module BABYLON {
  26750. /**
  26751. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26752. *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.
  26753. * The SPS is also a particle system. It provides some methods to manage the particles.
  26754. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26755. *
  26756. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26757. */
  26758. export class SolidParticleSystem implements IDisposable {
  26759. /**
  26760. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26761. * Example : var p = SPS.particles[i];
  26762. */
  26763. particles: SolidParticle[];
  26764. /**
  26765. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26766. */
  26767. nbParticles: number;
  26768. /**
  26769. * If the particles must ever face the camera (default false). Useful for planar particles.
  26770. */
  26771. billboard: boolean;
  26772. /**
  26773. * Recompute normals when adding a shape
  26774. */
  26775. recomputeNormals: boolean;
  26776. /**
  26777. * This a counter ofr your own usage. It's not set by any SPS functions.
  26778. */
  26779. counter: number;
  26780. /**
  26781. * The SPS name. This name is also given to the underlying mesh.
  26782. */
  26783. name: string;
  26784. /**
  26785. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26786. */
  26787. mesh: Mesh;
  26788. /**
  26789. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26790. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26791. */
  26792. vars: any;
  26793. /**
  26794. * This array is populated when the SPS is set as 'pickable'.
  26795. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26796. * Each element of this array is an object `{idx: int, faceId: int}`.
  26797. * `idx` is the picked particle index in the `SPS.particles` array
  26798. * `faceId` is the picked face index counted within this particle.
  26799. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26800. */
  26801. pickedParticles: {
  26802. idx: number;
  26803. faceId: number;
  26804. }[];
  26805. /**
  26806. * This array is populated when `enableDepthSort` is set to true.
  26807. * Each element of this array is an instance of the class DepthSortedParticle.
  26808. */
  26809. depthSortedParticles: DepthSortedParticle[];
  26810. /**
  26811. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26812. * @hidden
  26813. */
  26814. _bSphereOnly: boolean;
  26815. /**
  26816. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26817. * @hidden
  26818. */
  26819. _bSphereRadiusFactor: number;
  26820. private _scene;
  26821. private _positions;
  26822. private _indices;
  26823. private _normals;
  26824. private _colors;
  26825. private _uvs;
  26826. private _indices32;
  26827. private _positions32;
  26828. private _normals32;
  26829. private _fixedNormal32;
  26830. private _colors32;
  26831. private _uvs32;
  26832. private _index;
  26833. private _updatable;
  26834. private _pickable;
  26835. private _isVisibilityBoxLocked;
  26836. private _alwaysVisible;
  26837. private _depthSort;
  26838. private _expandable;
  26839. private _shapeCounter;
  26840. private _copy;
  26841. private _color;
  26842. private _computeParticleColor;
  26843. private _computeParticleTexture;
  26844. private _computeParticleRotation;
  26845. private _computeParticleVertex;
  26846. private _computeBoundingBox;
  26847. private _depthSortParticles;
  26848. private _camera;
  26849. private _mustUnrotateFixedNormals;
  26850. private _particlesIntersect;
  26851. private _needs32Bits;
  26852. private _isNotBuilt;
  26853. private _lastParticleId;
  26854. private _idxOfId;
  26855. private _multimaterialEnabled;
  26856. private _useModelMaterial;
  26857. private _indicesByMaterial;
  26858. private _materialIndexes;
  26859. private _depthSortFunction;
  26860. private _materialSortFunction;
  26861. private _materials;
  26862. private _multimaterial;
  26863. private _materialIndexesById;
  26864. private _defaultMaterial;
  26865. private _autoUpdateSubMeshes;
  26866. /**
  26867. * Creates a SPS (Solid Particle System) object.
  26868. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26869. * @param scene (Scene) is the scene in which the SPS is added.
  26870. * @param options defines the options of the sps e.g.
  26871. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26872. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26873. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26874. * * 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.
  26875. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26876. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26877. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26878. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26879. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26880. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26881. */
  26882. constructor(name: string, scene: Scene, options?: {
  26883. updatable?: boolean;
  26884. isPickable?: boolean;
  26885. enableDepthSort?: boolean;
  26886. particleIntersection?: boolean;
  26887. boundingSphereOnly?: boolean;
  26888. bSphereRadiusFactor?: number;
  26889. expandable?: boolean;
  26890. useModelMaterial?: boolean;
  26891. enableMultiMaterial?: boolean;
  26892. });
  26893. /**
  26894. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26895. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26896. * @returns the created mesh
  26897. */
  26898. buildMesh(): Mesh;
  26899. /**
  26900. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26901. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26902. * Thus the particles generated from `digest()` have their property `position` set yet.
  26903. * @param mesh ( Mesh ) is the mesh to be digested
  26904. * @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
  26905. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26906. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26907. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26908. * @returns the current SPS
  26909. */
  26910. digest(mesh: Mesh, options?: {
  26911. facetNb?: number;
  26912. number?: number;
  26913. delta?: number;
  26914. storage?: [];
  26915. }): SolidParticleSystem;
  26916. /**
  26917. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26918. * @hidden
  26919. */
  26920. private _unrotateFixedNormals;
  26921. /**
  26922. * Resets the temporary working copy particle
  26923. * @hidden
  26924. */
  26925. private _resetCopy;
  26926. /**
  26927. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26928. * @param p the current index in the positions array to be updated
  26929. * @param ind the current index in the indices array
  26930. * @param shape a Vector3 array, the shape geometry
  26931. * @param positions the positions array to be updated
  26932. * @param meshInd the shape indices array
  26933. * @param indices the indices array to be updated
  26934. * @param meshUV the shape uv array
  26935. * @param uvs the uv array to be updated
  26936. * @param meshCol the shape color array
  26937. * @param colors the color array to be updated
  26938. * @param meshNor the shape normals array
  26939. * @param normals the normals array to be updated
  26940. * @param idx the particle index
  26941. * @param idxInShape the particle index in its shape
  26942. * @param options the addShape() method passed options
  26943. * @model the particle model
  26944. * @hidden
  26945. */
  26946. private _meshBuilder;
  26947. /**
  26948. * Returns a shape Vector3 array from positions float array
  26949. * @param positions float array
  26950. * @returns a vector3 array
  26951. * @hidden
  26952. */
  26953. private _posToShape;
  26954. /**
  26955. * Returns a shapeUV array from a float uvs (array deep copy)
  26956. * @param uvs as a float array
  26957. * @returns a shapeUV array
  26958. * @hidden
  26959. */
  26960. private _uvsToShapeUV;
  26961. /**
  26962. * Adds a new particle object in the particles array
  26963. * @param idx particle index in particles array
  26964. * @param id particle id
  26965. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26966. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26967. * @param model particle ModelShape object
  26968. * @param shapeId model shape identifier
  26969. * @param idxInShape index of the particle in the current model
  26970. * @param bInfo model bounding info object
  26971. * @param storage target storage array, if any
  26972. * @hidden
  26973. */
  26974. private _addParticle;
  26975. /**
  26976. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26977. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26978. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26979. * @param nb (positive integer) the number of particles to be created from this model
  26980. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26981. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26982. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26983. * @returns the number of shapes in the system
  26984. */
  26985. addShape(mesh: Mesh, nb: number, options?: {
  26986. positionFunction?: any;
  26987. vertexFunction?: any;
  26988. storage?: [];
  26989. }): number;
  26990. /**
  26991. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26992. * @hidden
  26993. */
  26994. private _rebuildParticle;
  26995. /**
  26996. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26997. * @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.
  26998. * @returns the SPS.
  26999. */
  27000. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27001. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27002. * Returns an array with the removed particles.
  27003. * 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.
  27004. * The SPS can't be empty so at least one particle needs to remain in place.
  27005. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27006. * @param start index of the first particle to remove
  27007. * @param end index of the last particle to remove (included)
  27008. * @returns an array populated with the removed particles
  27009. */
  27010. removeParticles(start: number, end: number): SolidParticle[];
  27011. /**
  27012. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27013. * @param solidParticleArray an array populated with Solid Particles objects
  27014. * @returns the SPS
  27015. */
  27016. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27017. /**
  27018. * Creates a new particle and modifies the SPS mesh geometry :
  27019. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27020. * - calls _addParticle() to populate the particle array
  27021. * factorized code from addShape() and insertParticlesFromArray()
  27022. * @param idx particle index in the particles array
  27023. * @param i particle index in its shape
  27024. * @param modelShape particle ModelShape object
  27025. * @param shape shape vertex array
  27026. * @param meshInd shape indices array
  27027. * @param meshUV shape uv array
  27028. * @param meshCol shape color array
  27029. * @param meshNor shape normals array
  27030. * @param bbInfo shape bounding info
  27031. * @param storage target particle storage
  27032. * @options addShape() passed options
  27033. * @hidden
  27034. */
  27035. private _insertNewParticle;
  27036. /**
  27037. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27038. * This method calls `updateParticle()` for each particle of the SPS.
  27039. * For an animated SPS, it is usually called within the render loop.
  27040. * 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.
  27041. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27042. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27043. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27044. * @returns the SPS.
  27045. */
  27046. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27047. /**
  27048. * Disposes the SPS.
  27049. */
  27050. dispose(): void;
  27051. /**
  27052. * Returns a SolidParticle object from its identifier : particle.id
  27053. * @param id (integer) the particle Id
  27054. * @returns the searched particle or null if not found in the SPS.
  27055. */
  27056. getParticleById(id: number): Nullable<SolidParticle>;
  27057. /**
  27058. * Returns a new array populated with the particles having the passed shapeId.
  27059. * @param shapeId (integer) the shape identifier
  27060. * @returns a new solid particle array
  27061. */
  27062. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27063. /**
  27064. * Populates the passed array "ref" with the particles having the passed shapeId.
  27065. * @param shapeId the shape identifier
  27066. * @returns the SPS
  27067. * @param ref
  27068. */
  27069. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27070. /**
  27071. * Computes the required SubMeshes according the materials assigned to the particles.
  27072. * @returns the solid particle system.
  27073. * Does nothing if called before the SPS mesh is built.
  27074. */
  27075. computeSubMeshes(): SolidParticleSystem;
  27076. /**
  27077. * Sorts the solid particles by material when MultiMaterial is enabled.
  27078. * Updates the indices32 array.
  27079. * Updates the indicesByMaterial array.
  27080. * Updates the mesh indices array.
  27081. * @returns the SPS
  27082. * @hidden
  27083. */
  27084. private _sortParticlesByMaterial;
  27085. /**
  27086. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27087. * @hidden
  27088. */
  27089. private _setMaterialIndexesById;
  27090. /**
  27091. * Returns an array with unique values of Materials from the passed array
  27092. * @param array the material array to be checked and filtered
  27093. * @hidden
  27094. */
  27095. private _filterUniqueMaterialId;
  27096. /**
  27097. * Sets a new Standard Material as _defaultMaterial if not already set.
  27098. * @hidden
  27099. */
  27100. private _setDefaultMaterial;
  27101. /**
  27102. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27103. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27104. * @returns the SPS.
  27105. */
  27106. refreshVisibleSize(): SolidParticleSystem;
  27107. /**
  27108. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27109. * @param size the size (float) of the visibility box
  27110. * note : this doesn't lock the SPS mesh bounding box.
  27111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27112. */
  27113. setVisibilityBox(size: number): void;
  27114. /**
  27115. * Gets whether the SPS as always visible or not
  27116. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27117. */
  27118. get isAlwaysVisible(): boolean;
  27119. /**
  27120. * Sets the SPS as always visible or not
  27121. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27122. */
  27123. set isAlwaysVisible(val: boolean);
  27124. /**
  27125. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27126. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27127. */
  27128. set isVisibilityBoxLocked(val: boolean);
  27129. /**
  27130. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27131. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27132. */
  27133. get isVisibilityBoxLocked(): boolean;
  27134. /**
  27135. * Tells to `setParticles()` to compute the particle rotations or not.
  27136. * Default value : true. The SPS is faster when it's set to false.
  27137. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27138. */
  27139. set computeParticleRotation(val: boolean);
  27140. /**
  27141. * Tells to `setParticles()` to compute the particle colors or not.
  27142. * Default value : true. The SPS is faster when it's set to false.
  27143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27144. */
  27145. set computeParticleColor(val: boolean);
  27146. set computeParticleTexture(val: boolean);
  27147. /**
  27148. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27149. * Default value : false. The SPS is faster when it's set to false.
  27150. * Note : the particle custom vertex positions aren't stored values.
  27151. */
  27152. set computeParticleVertex(val: boolean);
  27153. /**
  27154. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27155. */
  27156. set computeBoundingBox(val: boolean);
  27157. /**
  27158. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27159. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27160. * Default : `true`
  27161. */
  27162. set depthSortParticles(val: boolean);
  27163. /**
  27164. * Gets if `setParticles()` computes the particle rotations or not.
  27165. * Default value : true. The SPS is faster when it's set to false.
  27166. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27167. */
  27168. get computeParticleRotation(): boolean;
  27169. /**
  27170. * Gets if `setParticles()` computes the particle colors or not.
  27171. * Default value : true. The SPS is faster when it's set to false.
  27172. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27173. */
  27174. get computeParticleColor(): boolean;
  27175. /**
  27176. * Gets if `setParticles()` computes the particle textures or not.
  27177. * Default value : true. The SPS is faster when it's set to false.
  27178. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27179. */
  27180. get computeParticleTexture(): boolean;
  27181. /**
  27182. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27183. * Default value : false. The SPS is faster when it's set to false.
  27184. * Note : the particle custom vertex positions aren't stored values.
  27185. */
  27186. get computeParticleVertex(): boolean;
  27187. /**
  27188. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27189. */
  27190. get computeBoundingBox(): boolean;
  27191. /**
  27192. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27193. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27194. * Default : `true`
  27195. */
  27196. get depthSortParticles(): boolean;
  27197. /**
  27198. * Gets if the SPS is created as expandable at construction time.
  27199. * Default : `false`
  27200. */
  27201. get expandable(): boolean;
  27202. /**
  27203. * Gets if the SPS supports the Multi Materials
  27204. */
  27205. get multimaterialEnabled(): boolean;
  27206. /**
  27207. * Gets if the SPS uses the model materials for its own multimaterial.
  27208. */
  27209. get useModelMaterial(): boolean;
  27210. /**
  27211. * The SPS used material array.
  27212. */
  27213. get materials(): Material[];
  27214. /**
  27215. * Sets the SPS MultiMaterial from the passed materials.
  27216. * Note : the passed array is internally copied and not used then by reference.
  27217. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27218. */
  27219. setMultiMaterial(materials: Material[]): void;
  27220. /**
  27221. * The SPS computed multimaterial object
  27222. */
  27223. get multimaterial(): MultiMaterial;
  27224. set multimaterial(mm: MultiMaterial);
  27225. /**
  27226. * If the subMeshes must be updated on the next call to setParticles()
  27227. */
  27228. get autoUpdateSubMeshes(): boolean;
  27229. set autoUpdateSubMeshes(val: boolean);
  27230. /**
  27231. * This function does nothing. It may be overwritten to set all the particle first values.
  27232. * The SPS doesn't call this function, you may have to call it by your own.
  27233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27234. */
  27235. initParticles(): void;
  27236. /**
  27237. * This function does nothing. It may be overwritten to recycle a particle.
  27238. * The SPS doesn't call this function, you may have to call it by your own.
  27239. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27240. * @param particle The particle to recycle
  27241. * @returns the recycled particle
  27242. */
  27243. recycleParticle(particle: SolidParticle): SolidParticle;
  27244. /**
  27245. * Updates a particle : this function should be overwritten by the user.
  27246. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27247. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27248. * @example : just set a particle position or velocity and recycle conditions
  27249. * @param particle The particle to update
  27250. * @returns the updated particle
  27251. */
  27252. updateParticle(particle: SolidParticle): SolidParticle;
  27253. /**
  27254. * Updates a vertex of a particle : it can be overwritten by the user.
  27255. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27256. * @param particle the current particle
  27257. * @param vertex the current index of the current particle
  27258. * @param pt the index of the current vertex in the particle shape
  27259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27260. * @example : just set a vertex particle position
  27261. * @returns the updated vertex
  27262. */
  27263. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27264. /**
  27265. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27266. * This does nothing and may be overwritten by the user.
  27267. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27268. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27269. * @param update the boolean update value actually passed to setParticles()
  27270. */
  27271. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27272. /**
  27273. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27274. * This will be passed three parameters.
  27275. * This does nothing and may be overwritten by the user.
  27276. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27277. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27278. * @param update the boolean update value actually passed to setParticles()
  27279. */
  27280. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27281. }
  27282. }
  27283. declare module BABYLON {
  27284. /**
  27285. * Represents one particle of a solid particle system.
  27286. */
  27287. export class SolidParticle {
  27288. /**
  27289. * particle global index
  27290. */
  27291. idx: number;
  27292. /**
  27293. * particle identifier
  27294. */
  27295. id: number;
  27296. /**
  27297. * The color of the particle
  27298. */
  27299. color: Nullable<Color4>;
  27300. /**
  27301. * The world space position of the particle.
  27302. */
  27303. position: Vector3;
  27304. /**
  27305. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27306. */
  27307. rotation: Vector3;
  27308. /**
  27309. * The world space rotation quaternion of the particle.
  27310. */
  27311. rotationQuaternion: Nullable<Quaternion>;
  27312. /**
  27313. * The scaling of the particle.
  27314. */
  27315. scaling: Vector3;
  27316. /**
  27317. * The uvs of the particle.
  27318. */
  27319. uvs: Vector4;
  27320. /**
  27321. * The current speed of the particle.
  27322. */
  27323. velocity: Vector3;
  27324. /**
  27325. * The pivot point in the particle local space.
  27326. */
  27327. pivot: Vector3;
  27328. /**
  27329. * Must the particle be translated from its pivot point in its local space ?
  27330. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27331. * Default : false
  27332. */
  27333. translateFromPivot: boolean;
  27334. /**
  27335. * Is the particle active or not ?
  27336. */
  27337. alive: boolean;
  27338. /**
  27339. * Is the particle visible or not ?
  27340. */
  27341. isVisible: boolean;
  27342. /**
  27343. * Index of this particle in the global "positions" array (Internal use)
  27344. * @hidden
  27345. */
  27346. _pos: number;
  27347. /**
  27348. * @hidden Index of this particle in the global "indices" array (Internal use)
  27349. */
  27350. _ind: number;
  27351. /**
  27352. * @hidden ModelShape of this particle (Internal use)
  27353. */
  27354. _model: ModelShape;
  27355. /**
  27356. * ModelShape id of this particle
  27357. */
  27358. shapeId: number;
  27359. /**
  27360. * Index of the particle in its shape id
  27361. */
  27362. idxInShape: number;
  27363. /**
  27364. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27365. */
  27366. _modelBoundingInfo: BoundingInfo;
  27367. /**
  27368. * @hidden Particle BoundingInfo object (Internal use)
  27369. */
  27370. _boundingInfo: BoundingInfo;
  27371. /**
  27372. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27373. */
  27374. _sps: SolidParticleSystem;
  27375. /**
  27376. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27377. */
  27378. _stillInvisible: boolean;
  27379. /**
  27380. * @hidden Last computed particle rotation matrix
  27381. */
  27382. _rotationMatrix: number[];
  27383. /**
  27384. * Parent particle Id, if any.
  27385. * Default null.
  27386. */
  27387. parentId: Nullable<number>;
  27388. /**
  27389. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27390. */
  27391. materialIndex: Nullable<number>;
  27392. /**
  27393. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27394. * The possible values are :
  27395. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27396. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27397. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27398. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27399. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27400. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27401. * */
  27402. cullingStrategy: number;
  27403. /**
  27404. * @hidden Internal global position in the SPS.
  27405. */
  27406. _globalPosition: Vector3;
  27407. /**
  27408. * Creates a Solid Particle object.
  27409. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27410. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27411. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27412. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27413. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27414. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27415. * @param shapeId (integer) is the model shape identifier in the SPS.
  27416. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27417. * @param sps defines the sps it is associated to
  27418. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27419. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27420. */
  27421. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27422. /**
  27423. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27424. * @param target the particle target
  27425. * @returns the current particle
  27426. */
  27427. copyToRef(target: SolidParticle): SolidParticle;
  27428. /**
  27429. * Legacy support, changed scale to scaling
  27430. */
  27431. get scale(): Vector3;
  27432. /**
  27433. * Legacy support, changed scale to scaling
  27434. */
  27435. set scale(scale: Vector3);
  27436. /**
  27437. * Legacy support, changed quaternion to rotationQuaternion
  27438. */
  27439. get quaternion(): Nullable<Quaternion>;
  27440. /**
  27441. * Legacy support, changed quaternion to rotationQuaternion
  27442. */
  27443. set quaternion(q: Nullable<Quaternion>);
  27444. /**
  27445. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27446. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27447. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27448. * @returns true if it intersects
  27449. */
  27450. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27451. /**
  27452. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27453. * A particle is in the frustum if its bounding box intersects the frustum
  27454. * @param frustumPlanes defines the frustum to test
  27455. * @returns true if the particle is in the frustum planes
  27456. */
  27457. isInFrustum(frustumPlanes: Plane[]): boolean;
  27458. /**
  27459. * get the rotation matrix of the particle
  27460. * @hidden
  27461. */
  27462. getRotationMatrix(m: Matrix): void;
  27463. }
  27464. /**
  27465. * Represents the shape of the model used by one particle of a solid particle system.
  27466. * SPS internal tool, don't use it manually.
  27467. */
  27468. export class ModelShape {
  27469. /**
  27470. * The shape id
  27471. * @hidden
  27472. */
  27473. shapeID: number;
  27474. /**
  27475. * flat array of model positions (internal use)
  27476. * @hidden
  27477. */
  27478. _shape: Vector3[];
  27479. /**
  27480. * flat array of model UVs (internal use)
  27481. * @hidden
  27482. */
  27483. _shapeUV: number[];
  27484. /**
  27485. * color array of the model
  27486. * @hidden
  27487. */
  27488. _shapeColors: number[];
  27489. /**
  27490. * indices array of the model
  27491. * @hidden
  27492. */
  27493. _indices: number[];
  27494. /**
  27495. * normals array of the model
  27496. * @hidden
  27497. */
  27498. _normals: number[];
  27499. /**
  27500. * length of the shape in the model indices array (internal use)
  27501. * @hidden
  27502. */
  27503. _indicesLength: number;
  27504. /**
  27505. * Custom position function (internal use)
  27506. * @hidden
  27507. */
  27508. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27509. /**
  27510. * Custom vertex function (internal use)
  27511. * @hidden
  27512. */
  27513. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27514. /**
  27515. * Model material (internal use)
  27516. * @hidden
  27517. */
  27518. _material: Nullable<Material>;
  27519. /**
  27520. * 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.
  27521. * SPS internal tool, don't use it manually.
  27522. * @hidden
  27523. */
  27524. 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>);
  27525. }
  27526. /**
  27527. * Represents a Depth Sorted Particle in the solid particle system.
  27528. * @hidden
  27529. */
  27530. export class DepthSortedParticle {
  27531. /**
  27532. * Index of the particle in the "indices" array
  27533. */
  27534. ind: number;
  27535. /**
  27536. * Length of the particle shape in the "indices" array
  27537. */
  27538. indicesLength: number;
  27539. /**
  27540. * Squared distance from the particle to the camera
  27541. */
  27542. sqDistance: number;
  27543. /**
  27544. * Material index when used with MultiMaterials
  27545. */
  27546. materialIndex: number;
  27547. /**
  27548. * Creates a new sorted particle
  27549. * @param materialIndex
  27550. */
  27551. constructor(ind: number, indLength: number, materialIndex: number);
  27552. }
  27553. }
  27554. declare module BABYLON {
  27555. /**
  27556. * @hidden
  27557. */
  27558. export class _MeshCollisionData {
  27559. _checkCollisions: boolean;
  27560. _collisionMask: number;
  27561. _collisionGroup: number;
  27562. _collider: Nullable<Collider>;
  27563. _oldPositionForCollisions: Vector3;
  27564. _diffPositionForCollisions: Vector3;
  27565. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27566. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27567. }
  27568. }
  27569. declare module BABYLON {
  27570. /** @hidden */
  27571. class _FacetDataStorage {
  27572. facetPositions: Vector3[];
  27573. facetNormals: Vector3[];
  27574. facetPartitioning: number[][];
  27575. facetNb: number;
  27576. partitioningSubdivisions: number;
  27577. partitioningBBoxRatio: number;
  27578. facetDataEnabled: boolean;
  27579. facetParameters: any;
  27580. bbSize: Vector3;
  27581. subDiv: {
  27582. max: number;
  27583. X: number;
  27584. Y: number;
  27585. Z: number;
  27586. };
  27587. facetDepthSort: boolean;
  27588. facetDepthSortEnabled: boolean;
  27589. depthSortedIndices: IndicesArray;
  27590. depthSortedFacets: {
  27591. ind: number;
  27592. sqDistance: number;
  27593. }[];
  27594. facetDepthSortFunction: (f1: {
  27595. ind: number;
  27596. sqDistance: number;
  27597. }, f2: {
  27598. ind: number;
  27599. sqDistance: number;
  27600. }) => number;
  27601. facetDepthSortFrom: Vector3;
  27602. facetDepthSortOrigin: Vector3;
  27603. invertedMatrix: Matrix;
  27604. }
  27605. /**
  27606. * @hidden
  27607. **/
  27608. class _InternalAbstractMeshDataInfo {
  27609. _hasVertexAlpha: boolean;
  27610. _useVertexColors: boolean;
  27611. _numBoneInfluencers: number;
  27612. _applyFog: boolean;
  27613. _receiveShadows: boolean;
  27614. _facetData: _FacetDataStorage;
  27615. _visibility: number;
  27616. _skeleton: Nullable<Skeleton>;
  27617. _layerMask: number;
  27618. _computeBonesUsingShaders: boolean;
  27619. _isActive: boolean;
  27620. _onlyForInstances: boolean;
  27621. _isActiveIntermediate: boolean;
  27622. _onlyForInstancesIntermediate: boolean;
  27623. _actAsRegularMesh: boolean;
  27624. }
  27625. /**
  27626. * Class used to store all common mesh properties
  27627. */
  27628. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27629. /** No occlusion */
  27630. static OCCLUSION_TYPE_NONE: number;
  27631. /** Occlusion set to optimisitic */
  27632. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27633. /** Occlusion set to strict */
  27634. static OCCLUSION_TYPE_STRICT: number;
  27635. /** Use an accurante occlusion algorithm */
  27636. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27637. /** Use a conservative occlusion algorithm */
  27638. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27639. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27640. * Test order :
  27641. * Is the bounding sphere outside the frustum ?
  27642. * If not, are the bounding box vertices outside the frustum ?
  27643. * It not, then the cullable object is in the frustum.
  27644. */
  27645. static readonly CULLINGSTRATEGY_STANDARD: number;
  27646. /** Culling strategy : Bounding Sphere Only.
  27647. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27648. * It's also less accurate than the standard because some not visible objects can still be selected.
  27649. * Test : is the bounding sphere outside the frustum ?
  27650. * If not, then the cullable object is in the frustum.
  27651. */
  27652. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27653. /** Culling strategy : Optimistic Inclusion.
  27654. * This in an inclusion test first, then the standard exclusion test.
  27655. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27656. * 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.
  27657. * Anyway, it's as accurate as the standard strategy.
  27658. * Test :
  27659. * Is the cullable object bounding sphere center in the frustum ?
  27660. * If not, apply the default culling strategy.
  27661. */
  27662. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27663. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27664. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27665. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27666. * 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.
  27667. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27668. * Test :
  27669. * Is the cullable object bounding sphere center in the frustum ?
  27670. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27671. */
  27672. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27673. /**
  27674. * No billboard
  27675. */
  27676. static get BILLBOARDMODE_NONE(): number;
  27677. /** Billboard on X axis */
  27678. static get BILLBOARDMODE_X(): number;
  27679. /** Billboard on Y axis */
  27680. static get BILLBOARDMODE_Y(): number;
  27681. /** Billboard on Z axis */
  27682. static get BILLBOARDMODE_Z(): number;
  27683. /** Billboard on all axes */
  27684. static get BILLBOARDMODE_ALL(): number;
  27685. /** Billboard on using position instead of orientation */
  27686. static get BILLBOARDMODE_USE_POSITION(): number;
  27687. /** @hidden */
  27688. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27689. /**
  27690. * The culling strategy to use to check whether the mesh must be rendered or not.
  27691. * This value can be changed at any time and will be used on the next render mesh selection.
  27692. * The possible values are :
  27693. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27694. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27695. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27696. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27697. * Please read each static variable documentation to get details about the culling process.
  27698. * */
  27699. cullingStrategy: number;
  27700. /**
  27701. * Gets the number of facets in the mesh
  27702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27703. */
  27704. get facetNb(): number;
  27705. /**
  27706. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27708. */
  27709. get partitioningSubdivisions(): number;
  27710. set partitioningSubdivisions(nb: number);
  27711. /**
  27712. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27713. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27715. */
  27716. get partitioningBBoxRatio(): number;
  27717. set partitioningBBoxRatio(ratio: number);
  27718. /**
  27719. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27720. * Works only for updatable meshes.
  27721. * Doesn't work with multi-materials
  27722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27723. */
  27724. get mustDepthSortFacets(): boolean;
  27725. set mustDepthSortFacets(sort: boolean);
  27726. /**
  27727. * The location (Vector3) where the facet depth sort must be computed from.
  27728. * By default, the active camera position.
  27729. * Used only when facet depth sort is enabled
  27730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27731. */
  27732. get facetDepthSortFrom(): Vector3;
  27733. set facetDepthSortFrom(location: Vector3);
  27734. /**
  27735. * gets a boolean indicating if facetData is enabled
  27736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27737. */
  27738. get isFacetDataEnabled(): boolean;
  27739. /** @hidden */
  27740. _updateNonUniformScalingState(value: boolean): boolean;
  27741. /**
  27742. * An event triggered when this mesh collides with another one
  27743. */
  27744. onCollideObservable: Observable<AbstractMesh>;
  27745. /** Set a function to call when this mesh collides with another one */
  27746. set onCollide(callback: () => void);
  27747. /**
  27748. * An event triggered when the collision's position changes
  27749. */
  27750. onCollisionPositionChangeObservable: Observable<Vector3>;
  27751. /** Set a function to call when the collision's position changes */
  27752. set onCollisionPositionChange(callback: () => void);
  27753. /**
  27754. * An event triggered when material is changed
  27755. */
  27756. onMaterialChangedObservable: Observable<AbstractMesh>;
  27757. /**
  27758. * Gets or sets the orientation for POV movement & rotation
  27759. */
  27760. definedFacingForward: boolean;
  27761. /** @hidden */
  27762. _occlusionQuery: Nullable<WebGLQuery>;
  27763. /** @hidden */
  27764. _renderingGroup: Nullable<RenderingGroup>;
  27765. /**
  27766. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27767. */
  27768. get visibility(): number;
  27769. /**
  27770. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27771. */
  27772. set visibility(value: number);
  27773. /** Gets or sets the alpha index used to sort transparent meshes
  27774. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27775. */
  27776. alphaIndex: number;
  27777. /**
  27778. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27779. */
  27780. isVisible: boolean;
  27781. /**
  27782. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27783. */
  27784. isPickable: boolean;
  27785. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27786. showSubMeshesBoundingBox: boolean;
  27787. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27788. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27789. */
  27790. isBlocker: boolean;
  27791. /**
  27792. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27793. */
  27794. enablePointerMoveEvents: boolean;
  27795. /**
  27796. * Specifies the rendering group id for this mesh (0 by default)
  27797. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27798. */
  27799. renderingGroupId: number;
  27800. private _material;
  27801. /** Gets or sets current material */
  27802. get material(): Nullable<Material>;
  27803. set material(value: Nullable<Material>);
  27804. /**
  27805. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27806. * @see http://doc.babylonjs.com/babylon101/shadows
  27807. */
  27808. get receiveShadows(): boolean;
  27809. set receiveShadows(value: boolean);
  27810. /** Defines color to use when rendering outline */
  27811. outlineColor: Color3;
  27812. /** Define width to use when rendering outline */
  27813. outlineWidth: number;
  27814. /** Defines color to use when rendering overlay */
  27815. overlayColor: Color3;
  27816. /** Defines alpha to use when rendering overlay */
  27817. overlayAlpha: number;
  27818. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27819. get hasVertexAlpha(): boolean;
  27820. set hasVertexAlpha(value: boolean);
  27821. /** 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) */
  27822. get useVertexColors(): boolean;
  27823. set useVertexColors(value: boolean);
  27824. /**
  27825. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27826. */
  27827. get computeBonesUsingShaders(): boolean;
  27828. set computeBonesUsingShaders(value: boolean);
  27829. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27830. get numBoneInfluencers(): number;
  27831. set numBoneInfluencers(value: number);
  27832. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27833. get applyFog(): boolean;
  27834. set applyFog(value: boolean);
  27835. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27836. useOctreeForRenderingSelection: boolean;
  27837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27838. useOctreeForPicking: boolean;
  27839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27840. useOctreeForCollisions: boolean;
  27841. /**
  27842. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27843. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27844. */
  27845. get layerMask(): number;
  27846. set layerMask(value: number);
  27847. /**
  27848. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27849. */
  27850. alwaysSelectAsActiveMesh: boolean;
  27851. /**
  27852. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27853. */
  27854. doNotSyncBoundingInfo: boolean;
  27855. /**
  27856. * Gets or sets the current action manager
  27857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27858. */
  27859. actionManager: Nullable<AbstractActionManager>;
  27860. private _meshCollisionData;
  27861. /**
  27862. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27863. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27864. */
  27865. ellipsoid: Vector3;
  27866. /**
  27867. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27869. */
  27870. ellipsoidOffset: Vector3;
  27871. /**
  27872. * Gets or sets a collision mask used to mask collisions (default is -1).
  27873. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27874. */
  27875. get collisionMask(): number;
  27876. set collisionMask(mask: number);
  27877. /**
  27878. * Gets or sets the current collision group mask (-1 by default).
  27879. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27880. */
  27881. get collisionGroup(): number;
  27882. set collisionGroup(mask: number);
  27883. /**
  27884. * Defines edge width used when edgesRenderer is enabled
  27885. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27886. */
  27887. edgesWidth: number;
  27888. /**
  27889. * Defines edge color used when edgesRenderer is enabled
  27890. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27891. */
  27892. edgesColor: Color4;
  27893. /** @hidden */
  27894. _edgesRenderer: Nullable<IEdgesRenderer>;
  27895. /** @hidden */
  27896. _masterMesh: Nullable<AbstractMesh>;
  27897. /** @hidden */
  27898. _boundingInfo: Nullable<BoundingInfo>;
  27899. /** @hidden */
  27900. _renderId: number;
  27901. /**
  27902. * Gets or sets the list of subMeshes
  27903. * @see http://doc.babylonjs.com/how_to/multi_materials
  27904. */
  27905. subMeshes: SubMesh[];
  27906. /** @hidden */
  27907. _intersectionsInProgress: AbstractMesh[];
  27908. /** @hidden */
  27909. _unIndexed: boolean;
  27910. /** @hidden */
  27911. _lightSources: Light[];
  27912. /** Gets the list of lights affecting that mesh */
  27913. get lightSources(): Light[];
  27914. /** @hidden */
  27915. get _positions(): Nullable<Vector3[]>;
  27916. /** @hidden */
  27917. _waitingData: {
  27918. lods: Nullable<any>;
  27919. actions: Nullable<any>;
  27920. freezeWorldMatrix: Nullable<boolean>;
  27921. };
  27922. /** @hidden */
  27923. _bonesTransformMatrices: Nullable<Float32Array>;
  27924. /** @hidden */
  27925. _transformMatrixTexture: Nullable<RawTexture>;
  27926. /**
  27927. * Gets or sets a skeleton to apply skining transformations
  27928. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27929. */
  27930. set skeleton(value: Nullable<Skeleton>);
  27931. get skeleton(): Nullable<Skeleton>;
  27932. /**
  27933. * An event triggered when the mesh is rebuilt.
  27934. */
  27935. onRebuildObservable: Observable<AbstractMesh>;
  27936. /**
  27937. * Creates a new AbstractMesh
  27938. * @param name defines the name of the mesh
  27939. * @param scene defines the hosting scene
  27940. */
  27941. constructor(name: string, scene?: Nullable<Scene>);
  27942. /**
  27943. * Returns the string "AbstractMesh"
  27944. * @returns "AbstractMesh"
  27945. */
  27946. getClassName(): string;
  27947. /**
  27948. * Gets a string representation of the current mesh
  27949. * @param fullDetails defines a boolean indicating if full details must be included
  27950. * @returns a string representation of the current mesh
  27951. */
  27952. toString(fullDetails?: boolean): string;
  27953. /**
  27954. * @hidden
  27955. */
  27956. protected _getEffectiveParent(): Nullable<Node>;
  27957. /** @hidden */
  27958. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27959. /** @hidden */
  27960. _rebuild(): void;
  27961. /** @hidden */
  27962. _resyncLightSources(): void;
  27963. /** @hidden */
  27964. _resyncLightSource(light: Light): void;
  27965. /** @hidden */
  27966. _unBindEffect(): void;
  27967. /** @hidden */
  27968. _removeLightSource(light: Light, dispose: boolean): void;
  27969. private _markSubMeshesAsDirty;
  27970. /** @hidden */
  27971. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27972. /** @hidden */
  27973. _markSubMeshesAsAttributesDirty(): void;
  27974. /** @hidden */
  27975. _markSubMeshesAsMiscDirty(): void;
  27976. /**
  27977. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27978. */
  27979. get scaling(): Vector3;
  27980. set scaling(newScaling: Vector3);
  27981. /**
  27982. * Returns true if the mesh is blocked. Implemented by child classes
  27983. */
  27984. get isBlocked(): boolean;
  27985. /**
  27986. * Returns the mesh itself by default. Implemented by child classes
  27987. * @param camera defines the camera to use to pick the right LOD level
  27988. * @returns the currentAbstractMesh
  27989. */
  27990. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27991. /**
  27992. * Returns 0 by default. Implemented by child classes
  27993. * @returns an integer
  27994. */
  27995. getTotalVertices(): number;
  27996. /**
  27997. * Returns a positive integer : the total number of indices in this mesh geometry.
  27998. * @returns the numner of indices or zero if the mesh has no geometry.
  27999. */
  28000. getTotalIndices(): number;
  28001. /**
  28002. * Returns null by default. Implemented by child classes
  28003. * @returns null
  28004. */
  28005. getIndices(): Nullable<IndicesArray>;
  28006. /**
  28007. * Returns the array of the requested vertex data kind. Implemented by child classes
  28008. * @param kind defines the vertex data kind to use
  28009. * @returns null
  28010. */
  28011. getVerticesData(kind: string): Nullable<FloatArray>;
  28012. /**
  28013. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28014. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28015. * Note that a new underlying VertexBuffer object is created each call.
  28016. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28017. * @param kind defines vertex data kind:
  28018. * * VertexBuffer.PositionKind
  28019. * * VertexBuffer.UVKind
  28020. * * VertexBuffer.UV2Kind
  28021. * * VertexBuffer.UV3Kind
  28022. * * VertexBuffer.UV4Kind
  28023. * * VertexBuffer.UV5Kind
  28024. * * VertexBuffer.UV6Kind
  28025. * * VertexBuffer.ColorKind
  28026. * * VertexBuffer.MatricesIndicesKind
  28027. * * VertexBuffer.MatricesIndicesExtraKind
  28028. * * VertexBuffer.MatricesWeightsKind
  28029. * * VertexBuffer.MatricesWeightsExtraKind
  28030. * @param data defines the data source
  28031. * @param updatable defines if the data must be flagged as updatable (or static)
  28032. * @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
  28033. * @returns the current mesh
  28034. */
  28035. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28036. /**
  28037. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28038. * If the mesh has no geometry, it is simply returned as it is.
  28039. * @param kind defines vertex data kind:
  28040. * * VertexBuffer.PositionKind
  28041. * * VertexBuffer.UVKind
  28042. * * VertexBuffer.UV2Kind
  28043. * * VertexBuffer.UV3Kind
  28044. * * VertexBuffer.UV4Kind
  28045. * * VertexBuffer.UV5Kind
  28046. * * VertexBuffer.UV6Kind
  28047. * * VertexBuffer.ColorKind
  28048. * * VertexBuffer.MatricesIndicesKind
  28049. * * VertexBuffer.MatricesIndicesExtraKind
  28050. * * VertexBuffer.MatricesWeightsKind
  28051. * * VertexBuffer.MatricesWeightsExtraKind
  28052. * @param data defines the data source
  28053. * @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
  28054. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28055. * @returns the current mesh
  28056. */
  28057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28058. /**
  28059. * Sets the mesh indices,
  28060. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28061. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28062. * @param totalVertices Defines the total number of vertices
  28063. * @returns the current mesh
  28064. */
  28065. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28066. /**
  28067. * Gets a boolean indicating if specific vertex data is present
  28068. * @param kind defines the vertex data kind to use
  28069. * @returns true is data kind is present
  28070. */
  28071. isVerticesDataPresent(kind: string): boolean;
  28072. /**
  28073. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28074. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28075. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28076. * @returns a BoundingInfo
  28077. */
  28078. getBoundingInfo(): BoundingInfo;
  28079. /**
  28080. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28081. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28082. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28083. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28084. * @returns the current mesh
  28085. */
  28086. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28087. /**
  28088. * Overwrite the current bounding info
  28089. * @param boundingInfo defines the new bounding info
  28090. * @returns the current mesh
  28091. */
  28092. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28093. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28094. get useBones(): boolean;
  28095. /** @hidden */
  28096. _preActivate(): void;
  28097. /** @hidden */
  28098. _preActivateForIntermediateRendering(renderId: number): void;
  28099. /** @hidden */
  28100. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28101. /** @hidden */
  28102. _postActivate(): void;
  28103. /** @hidden */
  28104. _freeze(): void;
  28105. /** @hidden */
  28106. _unFreeze(): void;
  28107. /**
  28108. * Gets the current world matrix
  28109. * @returns a Matrix
  28110. */
  28111. getWorldMatrix(): Matrix;
  28112. /** @hidden */
  28113. _getWorldMatrixDeterminant(): number;
  28114. /**
  28115. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28116. */
  28117. get isAnInstance(): boolean;
  28118. /**
  28119. * Gets a boolean indicating if this mesh has instances
  28120. */
  28121. get hasInstances(): boolean;
  28122. /**
  28123. * Perform relative position change from the point of view of behind the front of the mesh.
  28124. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28125. * Supports definition of mesh facing forward or backward
  28126. * @param amountRight defines the distance on the right axis
  28127. * @param amountUp defines the distance on the up axis
  28128. * @param amountForward defines the distance on the forward axis
  28129. * @returns the current mesh
  28130. */
  28131. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28132. /**
  28133. * Calculate relative position change from the point of view of behind the front of the mesh.
  28134. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28135. * Supports definition of mesh facing forward or backward
  28136. * @param amountRight defines the distance on the right axis
  28137. * @param amountUp defines the distance on the up axis
  28138. * @param amountForward defines the distance on the forward axis
  28139. * @returns the new displacement vector
  28140. */
  28141. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28142. /**
  28143. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28144. * Supports definition of mesh facing forward or backward
  28145. * @param flipBack defines the flip
  28146. * @param twirlClockwise defines the twirl
  28147. * @param tiltRight defines the tilt
  28148. * @returns the current mesh
  28149. */
  28150. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28151. /**
  28152. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28153. * Supports definition of mesh facing forward or backward.
  28154. * @param flipBack defines the flip
  28155. * @param twirlClockwise defines the twirl
  28156. * @param tiltRight defines the tilt
  28157. * @returns the new rotation vector
  28158. */
  28159. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28160. /**
  28161. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28162. * This means the mesh underlying bounding box and sphere are recomputed.
  28163. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28164. * @returns the current mesh
  28165. */
  28166. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28167. /** @hidden */
  28168. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28169. /** @hidden */
  28170. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28171. /** @hidden */
  28172. _updateBoundingInfo(): AbstractMesh;
  28173. /** @hidden */
  28174. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28175. /** @hidden */
  28176. protected _afterComputeWorldMatrix(): void;
  28177. /** @hidden */
  28178. get _effectiveMesh(): AbstractMesh;
  28179. /**
  28180. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28181. * A mesh is in the frustum if its bounding box intersects the frustum
  28182. * @param frustumPlanes defines the frustum to test
  28183. * @returns true if the mesh is in the frustum planes
  28184. */
  28185. isInFrustum(frustumPlanes: Plane[]): boolean;
  28186. /**
  28187. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28188. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28189. * @param frustumPlanes defines the frustum to test
  28190. * @returns true if the mesh is completely in the frustum planes
  28191. */
  28192. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28193. /**
  28194. * True if the mesh intersects another mesh or a SolidParticle object
  28195. * @param mesh defines a target mesh or SolidParticle to test
  28196. * @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)
  28197. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28198. * @returns true if there is an intersection
  28199. */
  28200. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28201. /**
  28202. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28203. * @param point defines the point to test
  28204. * @returns true if there is an intersection
  28205. */
  28206. intersectsPoint(point: Vector3): boolean;
  28207. /**
  28208. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28210. */
  28211. get checkCollisions(): boolean;
  28212. set checkCollisions(collisionEnabled: boolean);
  28213. /**
  28214. * Gets Collider object used to compute collisions (not physics)
  28215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28216. */
  28217. get collider(): Nullable<Collider>;
  28218. /**
  28219. * Move the mesh using collision engine
  28220. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28221. * @param displacement defines the requested displacement vector
  28222. * @returns the current mesh
  28223. */
  28224. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28225. private _onCollisionPositionChange;
  28226. /** @hidden */
  28227. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28228. /** @hidden */
  28229. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28230. /** @hidden */
  28231. _checkCollision(collider: Collider): AbstractMesh;
  28232. /** @hidden */
  28233. _generatePointsArray(): boolean;
  28234. /**
  28235. * Checks if the passed Ray intersects with the mesh
  28236. * @param ray defines the ray to use
  28237. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28238. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28239. * @returns the picking info
  28240. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28241. */
  28242. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28243. /**
  28244. * Clones the current mesh
  28245. * @param name defines the mesh name
  28246. * @param newParent defines the new mesh parent
  28247. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28248. * @returns the new mesh
  28249. */
  28250. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28251. /**
  28252. * Disposes all the submeshes of the current meshnp
  28253. * @returns the current mesh
  28254. */
  28255. releaseSubMeshes(): AbstractMesh;
  28256. /**
  28257. * Releases resources associated with this abstract mesh.
  28258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28260. */
  28261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28262. /**
  28263. * Adds the passed mesh as a child to the current mesh
  28264. * @param mesh defines the child mesh
  28265. * @returns the current mesh
  28266. */
  28267. addChild(mesh: AbstractMesh): AbstractMesh;
  28268. /**
  28269. * Removes the passed mesh from the current mesh children list
  28270. * @param mesh defines the child mesh
  28271. * @returns the current mesh
  28272. */
  28273. removeChild(mesh: AbstractMesh): AbstractMesh;
  28274. /** @hidden */
  28275. private _initFacetData;
  28276. /**
  28277. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28278. * This method can be called within the render loop.
  28279. * 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
  28280. * @returns the current mesh
  28281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28282. */
  28283. updateFacetData(): AbstractMesh;
  28284. /**
  28285. * Returns the facetLocalNormals array.
  28286. * The normals are expressed in the mesh local spac
  28287. * @returns an array of Vector3
  28288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28289. */
  28290. getFacetLocalNormals(): Vector3[];
  28291. /**
  28292. * Returns the facetLocalPositions array.
  28293. * The facet positions are expressed in the mesh local space
  28294. * @returns an array of Vector3
  28295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28296. */
  28297. getFacetLocalPositions(): Vector3[];
  28298. /**
  28299. * Returns the facetLocalPartioning array
  28300. * @returns an array of array of numbers
  28301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28302. */
  28303. getFacetLocalPartitioning(): number[][];
  28304. /**
  28305. * Returns the i-th facet position in the world system.
  28306. * This method allocates a new Vector3 per call
  28307. * @param i defines the facet index
  28308. * @returns a new Vector3
  28309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28310. */
  28311. getFacetPosition(i: number): Vector3;
  28312. /**
  28313. * Sets the reference Vector3 with the i-th facet position in the world system
  28314. * @param i defines the facet index
  28315. * @param ref defines the target vector
  28316. * @returns the current mesh
  28317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28318. */
  28319. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28320. /**
  28321. * Returns the i-th facet normal in the world system.
  28322. * This method allocates a new Vector3 per call
  28323. * @param i defines the facet index
  28324. * @returns a new Vector3
  28325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28326. */
  28327. getFacetNormal(i: number): Vector3;
  28328. /**
  28329. * Sets the reference Vector3 with the i-th facet normal in the world system
  28330. * @param i defines the facet index
  28331. * @param ref defines the target vector
  28332. * @returns the current mesh
  28333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28334. */
  28335. getFacetNormalToRef(i: number, ref: Vector3): this;
  28336. /**
  28337. * 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)
  28338. * @param x defines x coordinate
  28339. * @param y defines y coordinate
  28340. * @param z defines z coordinate
  28341. * @returns the array of facet indexes
  28342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28343. */
  28344. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28345. /**
  28346. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28347. * @param projected sets as the (x,y,z) world projection on the facet
  28348. * @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
  28349. * @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
  28350. * @param x defines x coordinate
  28351. * @param y defines y coordinate
  28352. * @param z defines z coordinate
  28353. * @returns the face index if found (or null instead)
  28354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28355. */
  28356. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28357. /**
  28358. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28359. * @param projected sets as the (x,y,z) local projection on the facet
  28360. * @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
  28361. * @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
  28362. * @param x defines x coordinate
  28363. * @param y defines y coordinate
  28364. * @param z defines z coordinate
  28365. * @returns the face index if found (or null instead)
  28366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28367. */
  28368. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28369. /**
  28370. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28371. * @returns the parameters
  28372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28373. */
  28374. getFacetDataParameters(): any;
  28375. /**
  28376. * Disables the feature FacetData and frees the related memory
  28377. * @returns the current mesh
  28378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28379. */
  28380. disableFacetData(): AbstractMesh;
  28381. /**
  28382. * Updates the AbstractMesh indices array
  28383. * @param indices defines the data source
  28384. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28385. * @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)
  28386. * @returns the current mesh
  28387. */
  28388. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28389. /**
  28390. * Creates new normals data for the mesh
  28391. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28392. * @returns the current mesh
  28393. */
  28394. createNormals(updatable: boolean): AbstractMesh;
  28395. /**
  28396. * Align the mesh with a normal
  28397. * @param normal defines the normal to use
  28398. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28399. * @returns the current mesh
  28400. */
  28401. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28402. /** @hidden */
  28403. _checkOcclusionQuery(): boolean;
  28404. /**
  28405. * Disables the mesh edge rendering mode
  28406. * @returns the currentAbstractMesh
  28407. */
  28408. disableEdgesRendering(): AbstractMesh;
  28409. /**
  28410. * Enables the edge rendering mode on the mesh.
  28411. * This mode makes the mesh edges visible
  28412. * @param epsilon defines the maximal distance between two angles to detect a face
  28413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28414. * @returns the currentAbstractMesh
  28415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28416. */
  28417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28418. }
  28419. }
  28420. declare module BABYLON {
  28421. /**
  28422. * Interface used to define ActionEvent
  28423. */
  28424. export interface IActionEvent {
  28425. /** The mesh or sprite that triggered the action */
  28426. source: any;
  28427. /** The X mouse cursor position at the time of the event */
  28428. pointerX: number;
  28429. /** The Y mouse cursor position at the time of the event */
  28430. pointerY: number;
  28431. /** The mesh that is currently pointed at (can be null) */
  28432. meshUnderPointer: Nullable<AbstractMesh>;
  28433. /** the original (browser) event that triggered the ActionEvent */
  28434. sourceEvent?: any;
  28435. /** additional data for the event */
  28436. additionalData?: any;
  28437. }
  28438. /**
  28439. * ActionEvent is the event being sent when an action is triggered.
  28440. */
  28441. export class ActionEvent implements IActionEvent {
  28442. /** The mesh or sprite that triggered the action */
  28443. source: any;
  28444. /** The X mouse cursor position at the time of the event */
  28445. pointerX: number;
  28446. /** The Y mouse cursor position at the time of the event */
  28447. pointerY: number;
  28448. /** The mesh that is currently pointed at (can be null) */
  28449. meshUnderPointer: Nullable<AbstractMesh>;
  28450. /** the original (browser) event that triggered the ActionEvent */
  28451. sourceEvent?: any;
  28452. /** additional data for the event */
  28453. additionalData?: any;
  28454. /**
  28455. * Creates a new ActionEvent
  28456. * @param source The mesh or sprite that triggered the action
  28457. * @param pointerX The X mouse cursor position at the time of the event
  28458. * @param pointerY The Y mouse cursor position at the time of the event
  28459. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28460. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28461. * @param additionalData additional data for the event
  28462. */
  28463. constructor(
  28464. /** The mesh or sprite that triggered the action */
  28465. source: any,
  28466. /** The X mouse cursor position at the time of the event */
  28467. pointerX: number,
  28468. /** The Y mouse cursor position at the time of the event */
  28469. pointerY: number,
  28470. /** The mesh that is currently pointed at (can be null) */
  28471. meshUnderPointer: Nullable<AbstractMesh>,
  28472. /** the original (browser) event that triggered the ActionEvent */
  28473. sourceEvent?: any,
  28474. /** additional data for the event */
  28475. additionalData?: any);
  28476. /**
  28477. * Helper function to auto-create an ActionEvent from a source mesh.
  28478. * @param source The source mesh that triggered the event
  28479. * @param evt The original (browser) event
  28480. * @param additionalData additional data for the event
  28481. * @returns the new ActionEvent
  28482. */
  28483. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28484. /**
  28485. * Helper function to auto-create an ActionEvent from a source sprite
  28486. * @param source The source sprite that triggered the event
  28487. * @param scene Scene associated with the sprite
  28488. * @param evt The original (browser) event
  28489. * @param additionalData additional data for the event
  28490. * @returns the new ActionEvent
  28491. */
  28492. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28493. /**
  28494. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28495. * @param scene the scene where the event occurred
  28496. * @param evt The original (browser) event
  28497. * @returns the new ActionEvent
  28498. */
  28499. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28500. /**
  28501. * Helper function to auto-create an ActionEvent from a primitive
  28502. * @param prim defines the target primitive
  28503. * @param pointerPos defines the pointer position
  28504. * @param evt The original (browser) event
  28505. * @param additionalData additional data for the event
  28506. * @returns the new ActionEvent
  28507. */
  28508. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28509. }
  28510. }
  28511. declare module BABYLON {
  28512. /**
  28513. * Abstract class used to decouple action Manager from scene and meshes.
  28514. * Do not instantiate.
  28515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28516. */
  28517. export abstract class AbstractActionManager implements IDisposable {
  28518. /** Gets the list of active triggers */
  28519. static Triggers: {
  28520. [key: string]: number;
  28521. };
  28522. /** Gets the cursor to use when hovering items */
  28523. hoverCursor: string;
  28524. /** Gets the list of actions */
  28525. actions: IAction[];
  28526. /**
  28527. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28528. */
  28529. isRecursive: boolean;
  28530. /**
  28531. * Releases all associated resources
  28532. */
  28533. abstract dispose(): void;
  28534. /**
  28535. * Does this action manager has pointer triggers
  28536. */
  28537. abstract get hasPointerTriggers(): boolean;
  28538. /**
  28539. * Does this action manager has pick triggers
  28540. */
  28541. abstract get hasPickTriggers(): boolean;
  28542. /**
  28543. * Process a specific trigger
  28544. * @param trigger defines the trigger to process
  28545. * @param evt defines the event details to be processed
  28546. */
  28547. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28548. /**
  28549. * Does this action manager handles actions of any of the given triggers
  28550. * @param triggers defines the triggers to be tested
  28551. * @return a boolean indicating whether one (or more) of the triggers is handled
  28552. */
  28553. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28554. /**
  28555. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28556. * speed.
  28557. * @param triggerA defines the trigger to be tested
  28558. * @param triggerB defines the trigger to be tested
  28559. * @return a boolean indicating whether one (or more) of the triggers is handled
  28560. */
  28561. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28562. /**
  28563. * Does this action manager handles actions of a given trigger
  28564. * @param trigger defines the trigger to be tested
  28565. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28566. * @return whether the trigger is handled
  28567. */
  28568. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28569. /**
  28570. * Serialize this manager to a JSON object
  28571. * @param name defines the property name to store this manager
  28572. * @returns a JSON representation of this manager
  28573. */
  28574. abstract serialize(name: string): any;
  28575. /**
  28576. * Registers an action to this action manager
  28577. * @param action defines the action to be registered
  28578. * @return the action amended (prepared) after registration
  28579. */
  28580. abstract registerAction(action: IAction): Nullable<IAction>;
  28581. /**
  28582. * Unregisters an action to this action manager
  28583. * @param action defines the action to be unregistered
  28584. * @return a boolean indicating whether the action has been unregistered
  28585. */
  28586. abstract unregisterAction(action: IAction): Boolean;
  28587. /**
  28588. * Does exist one action manager with at least one trigger
  28589. **/
  28590. static get HasTriggers(): boolean;
  28591. /**
  28592. * Does exist one action manager with at least one pick trigger
  28593. **/
  28594. static get HasPickTriggers(): boolean;
  28595. /**
  28596. * Does exist one action manager that handles actions of a given trigger
  28597. * @param trigger defines the trigger to be tested
  28598. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28599. **/
  28600. static HasSpecificTrigger(trigger: number): boolean;
  28601. }
  28602. }
  28603. declare module BABYLON {
  28604. /**
  28605. * Defines how a node can be built from a string name.
  28606. */
  28607. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28608. /**
  28609. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28610. */
  28611. export class Node implements IBehaviorAware<Node> {
  28612. /** @hidden */
  28613. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28614. private static _NodeConstructors;
  28615. /**
  28616. * Add a new node constructor
  28617. * @param type defines the type name of the node to construct
  28618. * @param constructorFunc defines the constructor function
  28619. */
  28620. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28621. /**
  28622. * Returns a node constructor based on type name
  28623. * @param type defines the type name
  28624. * @param name defines the new node name
  28625. * @param scene defines the hosting scene
  28626. * @param options defines optional options to transmit to constructors
  28627. * @returns the new constructor or null
  28628. */
  28629. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28630. /**
  28631. * Gets or sets the name of the node
  28632. */
  28633. name: string;
  28634. /**
  28635. * Gets or sets the id of the node
  28636. */
  28637. id: string;
  28638. /**
  28639. * Gets or sets the unique id of the node
  28640. */
  28641. uniqueId: number;
  28642. /**
  28643. * Gets or sets a string used to store user defined state for the node
  28644. */
  28645. state: string;
  28646. /**
  28647. * Gets or sets an object used to store user defined information for the node
  28648. */
  28649. metadata: any;
  28650. /**
  28651. * For internal use only. Please do not use.
  28652. */
  28653. reservedDataStore: any;
  28654. /**
  28655. * List of inspectable custom properties (used by the Inspector)
  28656. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28657. */
  28658. inspectableCustomProperties: IInspectable[];
  28659. private _doNotSerialize;
  28660. /**
  28661. * Gets or sets a boolean used to define if the node must be serialized
  28662. */
  28663. get doNotSerialize(): boolean;
  28664. set doNotSerialize(value: boolean);
  28665. /** @hidden */
  28666. _isDisposed: boolean;
  28667. /**
  28668. * Gets a list of Animations associated with the node
  28669. */
  28670. animations: Animation[];
  28671. protected _ranges: {
  28672. [name: string]: Nullable<AnimationRange>;
  28673. };
  28674. /**
  28675. * Callback raised when the node is ready to be used
  28676. */
  28677. onReady: Nullable<(node: Node) => void>;
  28678. private _isEnabled;
  28679. private _isParentEnabled;
  28680. private _isReady;
  28681. /** @hidden */
  28682. _currentRenderId: number;
  28683. private _parentUpdateId;
  28684. /** @hidden */
  28685. _childUpdateId: number;
  28686. /** @hidden */
  28687. _waitingParentId: Nullable<string>;
  28688. /** @hidden */
  28689. _scene: Scene;
  28690. /** @hidden */
  28691. _cache: any;
  28692. private _parentNode;
  28693. private _children;
  28694. /** @hidden */
  28695. _worldMatrix: Matrix;
  28696. /** @hidden */
  28697. _worldMatrixDeterminant: number;
  28698. /** @hidden */
  28699. _worldMatrixDeterminantIsDirty: boolean;
  28700. /** @hidden */
  28701. private _sceneRootNodesIndex;
  28702. /**
  28703. * Gets a boolean indicating if the node has been disposed
  28704. * @returns true if the node was disposed
  28705. */
  28706. isDisposed(): boolean;
  28707. /**
  28708. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28709. * @see https://doc.babylonjs.com/how_to/parenting
  28710. */
  28711. set parent(parent: Nullable<Node>);
  28712. get parent(): Nullable<Node>;
  28713. /** @hidden */
  28714. _addToSceneRootNodes(): void;
  28715. /** @hidden */
  28716. _removeFromSceneRootNodes(): void;
  28717. private _animationPropertiesOverride;
  28718. /**
  28719. * Gets or sets the animation properties override
  28720. */
  28721. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28722. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28723. /**
  28724. * Gets a string idenfifying the name of the class
  28725. * @returns "Node" string
  28726. */
  28727. getClassName(): string;
  28728. /** @hidden */
  28729. readonly _isNode: boolean;
  28730. /**
  28731. * An event triggered when the mesh is disposed
  28732. */
  28733. onDisposeObservable: Observable<Node>;
  28734. private _onDisposeObserver;
  28735. /**
  28736. * Sets a callback that will be raised when the node will be disposed
  28737. */
  28738. set onDispose(callback: () => void);
  28739. /**
  28740. * Creates a new Node
  28741. * @param name the name and id to be given to this node
  28742. * @param scene the scene this node will be added to
  28743. */
  28744. constructor(name: string, scene?: Nullable<Scene>);
  28745. /**
  28746. * Gets the scene of the node
  28747. * @returns a scene
  28748. */
  28749. getScene(): Scene;
  28750. /**
  28751. * Gets the engine of the node
  28752. * @returns a Engine
  28753. */
  28754. getEngine(): Engine;
  28755. private _behaviors;
  28756. /**
  28757. * Attach a behavior to the node
  28758. * @see http://doc.babylonjs.com/features/behaviour
  28759. * @param behavior defines the behavior to attach
  28760. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28761. * @returns the current Node
  28762. */
  28763. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28764. /**
  28765. * Remove an attached behavior
  28766. * @see http://doc.babylonjs.com/features/behaviour
  28767. * @param behavior defines the behavior to attach
  28768. * @returns the current Node
  28769. */
  28770. removeBehavior(behavior: Behavior<Node>): Node;
  28771. /**
  28772. * Gets the list of attached behaviors
  28773. * @see http://doc.babylonjs.com/features/behaviour
  28774. */
  28775. get behaviors(): Behavior<Node>[];
  28776. /**
  28777. * Gets an attached behavior by name
  28778. * @param name defines the name of the behavior to look for
  28779. * @see http://doc.babylonjs.com/features/behaviour
  28780. * @returns null if behavior was not found else the requested behavior
  28781. */
  28782. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28783. /**
  28784. * Returns the latest update of the World matrix
  28785. * @returns a Matrix
  28786. */
  28787. getWorldMatrix(): Matrix;
  28788. /** @hidden */
  28789. _getWorldMatrixDeterminant(): number;
  28790. /**
  28791. * Returns directly the latest state of the mesh World matrix.
  28792. * A Matrix is returned.
  28793. */
  28794. get worldMatrixFromCache(): Matrix;
  28795. /** @hidden */
  28796. _initCache(): void;
  28797. /** @hidden */
  28798. updateCache(force?: boolean): void;
  28799. /** @hidden */
  28800. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28801. /** @hidden */
  28802. _updateCache(ignoreParentClass?: boolean): void;
  28803. /** @hidden */
  28804. _isSynchronized(): boolean;
  28805. /** @hidden */
  28806. _markSyncedWithParent(): void;
  28807. /** @hidden */
  28808. isSynchronizedWithParent(): boolean;
  28809. /** @hidden */
  28810. isSynchronized(): boolean;
  28811. /**
  28812. * Is this node ready to be used/rendered
  28813. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28814. * @return true if the node is ready
  28815. */
  28816. isReady(completeCheck?: boolean): boolean;
  28817. /**
  28818. * Is this node enabled?
  28819. * 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
  28820. * @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
  28821. * @return whether this node (and its parent) is enabled
  28822. */
  28823. isEnabled(checkAncestors?: boolean): boolean;
  28824. /** @hidden */
  28825. protected _syncParentEnabledState(): void;
  28826. /**
  28827. * Set the enabled state of this node
  28828. * @param value defines the new enabled state
  28829. */
  28830. setEnabled(value: boolean): void;
  28831. /**
  28832. * Is this node a descendant of the given node?
  28833. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28834. * @param ancestor defines the parent node to inspect
  28835. * @returns a boolean indicating if this node is a descendant of the given node
  28836. */
  28837. isDescendantOf(ancestor: Node): boolean;
  28838. /** @hidden */
  28839. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28840. /**
  28841. * Will return all nodes that have this node as ascendant
  28842. * @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
  28843. * @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
  28844. * @return all children nodes of all types
  28845. */
  28846. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28847. /**
  28848. * Get all child-meshes of this node
  28849. * @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)
  28850. * @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
  28851. * @returns an array of AbstractMesh
  28852. */
  28853. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28854. /**
  28855. * Get all direct children of this node
  28856. * @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
  28857. * @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)
  28858. * @returns an array of Node
  28859. */
  28860. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28861. /** @hidden */
  28862. _setReady(state: boolean): void;
  28863. /**
  28864. * Get an animation by name
  28865. * @param name defines the name of the animation to look for
  28866. * @returns null if not found else the requested animation
  28867. */
  28868. getAnimationByName(name: string): Nullable<Animation>;
  28869. /**
  28870. * Creates an animation range for this node
  28871. * @param name defines the name of the range
  28872. * @param from defines the starting key
  28873. * @param to defines the end key
  28874. */
  28875. createAnimationRange(name: string, from: number, to: number): void;
  28876. /**
  28877. * Delete a specific animation range
  28878. * @param name defines the name of the range to delete
  28879. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28880. */
  28881. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28882. /**
  28883. * Get an animation range by name
  28884. * @param name defines the name of the animation range to look for
  28885. * @returns null if not found else the requested animation range
  28886. */
  28887. getAnimationRange(name: string): Nullable<AnimationRange>;
  28888. /**
  28889. * Gets the list of all animation ranges defined on this node
  28890. * @returns an array
  28891. */
  28892. getAnimationRanges(): Nullable<AnimationRange>[];
  28893. /**
  28894. * Will start the animation sequence
  28895. * @param name defines the range frames for animation sequence
  28896. * @param loop defines if the animation should loop (false by default)
  28897. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28898. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28899. * @returns the object created for this animation. If range does not exist, it will return null
  28900. */
  28901. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28902. /**
  28903. * Serialize animation ranges into a JSON compatible object
  28904. * @returns serialization object
  28905. */
  28906. serializeAnimationRanges(): any;
  28907. /**
  28908. * Computes the world matrix of the node
  28909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28910. * @returns the world matrix
  28911. */
  28912. computeWorldMatrix(force?: boolean): Matrix;
  28913. /**
  28914. * Releases resources associated with this node.
  28915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28917. */
  28918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28919. /**
  28920. * Parse animation range data from a serialization object and store them into a given node
  28921. * @param node defines where to store the animation ranges
  28922. * @param parsedNode defines the serialization object to read data from
  28923. * @param scene defines the hosting scene
  28924. */
  28925. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28926. /**
  28927. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28928. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28929. * @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
  28930. * @returns the new bounding vectors
  28931. */
  28932. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28933. min: Vector3;
  28934. max: Vector3;
  28935. };
  28936. }
  28937. }
  28938. declare module BABYLON {
  28939. /**
  28940. * @hidden
  28941. */
  28942. export class _IAnimationState {
  28943. key: number;
  28944. repeatCount: number;
  28945. workValue?: any;
  28946. loopMode?: number;
  28947. offsetValue?: any;
  28948. highLimitValue?: any;
  28949. }
  28950. /**
  28951. * Class used to store any kind of animation
  28952. */
  28953. export class Animation {
  28954. /**Name of the animation */
  28955. name: string;
  28956. /**Property to animate */
  28957. targetProperty: string;
  28958. /**The frames per second of the animation */
  28959. framePerSecond: number;
  28960. /**The data type of the animation */
  28961. dataType: number;
  28962. /**The loop mode of the animation */
  28963. loopMode?: number | undefined;
  28964. /**Specifies if blending should be enabled */
  28965. enableBlending?: boolean | undefined;
  28966. /**
  28967. * Use matrix interpolation instead of using direct key value when animating matrices
  28968. */
  28969. static AllowMatricesInterpolation: boolean;
  28970. /**
  28971. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28972. */
  28973. static AllowMatrixDecomposeForInterpolation: boolean;
  28974. /**
  28975. * Stores the key frames of the animation
  28976. */
  28977. private _keys;
  28978. /**
  28979. * Stores the easing function of the animation
  28980. */
  28981. private _easingFunction;
  28982. /**
  28983. * @hidden Internal use only
  28984. */
  28985. _runtimeAnimations: RuntimeAnimation[];
  28986. /**
  28987. * The set of event that will be linked to this animation
  28988. */
  28989. private _events;
  28990. /**
  28991. * Stores an array of target property paths
  28992. */
  28993. targetPropertyPath: string[];
  28994. /**
  28995. * Stores the blending speed of the animation
  28996. */
  28997. blendingSpeed: number;
  28998. /**
  28999. * Stores the animation ranges for the animation
  29000. */
  29001. private _ranges;
  29002. /**
  29003. * @hidden Internal use
  29004. */
  29005. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29006. /**
  29007. * Sets up an animation
  29008. * @param property The property to animate
  29009. * @param animationType The animation type to apply
  29010. * @param framePerSecond The frames per second of the animation
  29011. * @param easingFunction The easing function used in the animation
  29012. * @returns The created animation
  29013. */
  29014. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29015. /**
  29016. * Create and start an animation on a node
  29017. * @param name defines the name of the global animation that will be run on all nodes
  29018. * @param node defines the root node where the animation will take place
  29019. * @param targetProperty defines property to animate
  29020. * @param framePerSecond defines the number of frame per second yo use
  29021. * @param totalFrame defines the number of frames in total
  29022. * @param from defines the initial value
  29023. * @param to defines the final value
  29024. * @param loopMode defines which loop mode you want to use (off by default)
  29025. * @param easingFunction defines the easing function to use (linear by default)
  29026. * @param onAnimationEnd defines the callback to call when animation end
  29027. * @returns the animatable created for this animation
  29028. */
  29029. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29030. /**
  29031. * Create and start an animation on a node and its descendants
  29032. * @param name defines the name of the global animation that will be run on all nodes
  29033. * @param node defines the root node where the animation will take place
  29034. * @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
  29035. * @param targetProperty defines property to animate
  29036. * @param framePerSecond defines the number of frame per second to use
  29037. * @param totalFrame defines the number of frames in total
  29038. * @param from defines the initial value
  29039. * @param to defines the final value
  29040. * @param loopMode defines which loop mode you want to use (off by default)
  29041. * @param easingFunction defines the easing function to use (linear by default)
  29042. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29043. * @returns the list of animatables created for all nodes
  29044. * @example https://www.babylonjs-playground.com/#MH0VLI
  29045. */
  29046. 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[]>;
  29047. /**
  29048. * Creates a new animation, merges it with the existing animations and starts it
  29049. * @param name Name of the animation
  29050. * @param node Node which contains the scene that begins the animations
  29051. * @param targetProperty Specifies which property to animate
  29052. * @param framePerSecond The frames per second of the animation
  29053. * @param totalFrame The total number of frames
  29054. * @param from The frame at the beginning of the animation
  29055. * @param to The frame at the end of the animation
  29056. * @param loopMode Specifies the loop mode of the animation
  29057. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29058. * @param onAnimationEnd Callback to run once the animation is complete
  29059. * @returns Nullable animation
  29060. */
  29061. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29062. /**
  29063. * Transition property of an host to the target Value
  29064. * @param property The property to transition
  29065. * @param targetValue The target Value of the property
  29066. * @param host The object where the property to animate belongs
  29067. * @param scene Scene used to run the animation
  29068. * @param frameRate Framerate (in frame/s) to use
  29069. * @param transition The transition type we want to use
  29070. * @param duration The duration of the animation, in milliseconds
  29071. * @param onAnimationEnd Callback trigger at the end of the animation
  29072. * @returns Nullable animation
  29073. */
  29074. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29075. /**
  29076. * Return the array of runtime animations currently using this animation
  29077. */
  29078. get runtimeAnimations(): RuntimeAnimation[];
  29079. /**
  29080. * Specifies if any of the runtime animations are currently running
  29081. */
  29082. get hasRunningRuntimeAnimations(): boolean;
  29083. /**
  29084. * Initializes the animation
  29085. * @param name Name of the animation
  29086. * @param targetProperty Property to animate
  29087. * @param framePerSecond The frames per second of the animation
  29088. * @param dataType The data type of the animation
  29089. * @param loopMode The loop mode of the animation
  29090. * @param enableBlending Specifies if blending should be enabled
  29091. */
  29092. constructor(
  29093. /**Name of the animation */
  29094. name: string,
  29095. /**Property to animate */
  29096. targetProperty: string,
  29097. /**The frames per second of the animation */
  29098. framePerSecond: number,
  29099. /**The data type of the animation */
  29100. dataType: number,
  29101. /**The loop mode of the animation */
  29102. loopMode?: number | undefined,
  29103. /**Specifies if blending should be enabled */
  29104. enableBlending?: boolean | undefined);
  29105. /**
  29106. * Converts the animation to a string
  29107. * @param fullDetails support for multiple levels of logging within scene loading
  29108. * @returns String form of the animation
  29109. */
  29110. toString(fullDetails?: boolean): string;
  29111. /**
  29112. * Add an event to this animation
  29113. * @param event Event to add
  29114. */
  29115. addEvent(event: AnimationEvent): void;
  29116. /**
  29117. * Remove all events found at the given frame
  29118. * @param frame The frame to remove events from
  29119. */
  29120. removeEvents(frame: number): void;
  29121. /**
  29122. * Retrieves all the events from the animation
  29123. * @returns Events from the animation
  29124. */
  29125. getEvents(): AnimationEvent[];
  29126. /**
  29127. * Creates an animation range
  29128. * @param name Name of the animation range
  29129. * @param from Starting frame of the animation range
  29130. * @param to Ending frame of the animation
  29131. */
  29132. createRange(name: string, from: number, to: number): void;
  29133. /**
  29134. * Deletes an animation range by name
  29135. * @param name Name of the animation range to delete
  29136. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29137. */
  29138. deleteRange(name: string, deleteFrames?: boolean): void;
  29139. /**
  29140. * Gets the animation range by name, or null if not defined
  29141. * @param name Name of the animation range
  29142. * @returns Nullable animation range
  29143. */
  29144. getRange(name: string): Nullable<AnimationRange>;
  29145. /**
  29146. * Gets the key frames from the animation
  29147. * @returns The key frames of the animation
  29148. */
  29149. getKeys(): Array<IAnimationKey>;
  29150. /**
  29151. * Gets the highest frame rate of the animation
  29152. * @returns Highest frame rate of the animation
  29153. */
  29154. getHighestFrame(): number;
  29155. /**
  29156. * Gets the easing function of the animation
  29157. * @returns Easing function of the animation
  29158. */
  29159. getEasingFunction(): IEasingFunction;
  29160. /**
  29161. * Sets the easing function of the animation
  29162. * @param easingFunction A custom mathematical formula for animation
  29163. */
  29164. setEasingFunction(easingFunction: EasingFunction): void;
  29165. /**
  29166. * Interpolates a scalar linearly
  29167. * @param startValue Start value of the animation curve
  29168. * @param endValue End value of the animation curve
  29169. * @param gradient Scalar amount to interpolate
  29170. * @returns Interpolated scalar value
  29171. */
  29172. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29173. /**
  29174. * Interpolates a scalar cubically
  29175. * @param startValue Start value of the animation curve
  29176. * @param outTangent End tangent of the animation
  29177. * @param endValue End value of the animation curve
  29178. * @param inTangent Start tangent of the animation curve
  29179. * @param gradient Scalar amount to interpolate
  29180. * @returns Interpolated scalar value
  29181. */
  29182. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29183. /**
  29184. * Interpolates a quaternion using a spherical linear interpolation
  29185. * @param startValue Start value of the animation curve
  29186. * @param endValue End value of the animation curve
  29187. * @param gradient Scalar amount to interpolate
  29188. * @returns Interpolated quaternion value
  29189. */
  29190. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29191. /**
  29192. * Interpolates a quaternion cubically
  29193. * @param startValue Start value of the animation curve
  29194. * @param outTangent End tangent of the animation curve
  29195. * @param endValue End value of the animation curve
  29196. * @param inTangent Start tangent of the animation curve
  29197. * @param gradient Scalar amount to interpolate
  29198. * @returns Interpolated quaternion value
  29199. */
  29200. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29201. /**
  29202. * Interpolates a Vector3 linearl
  29203. * @param startValue Start value of the animation curve
  29204. * @param endValue End value of the animation curve
  29205. * @param gradient Scalar amount to interpolate
  29206. * @returns Interpolated scalar value
  29207. */
  29208. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29209. /**
  29210. * Interpolates a Vector3 cubically
  29211. * @param startValue Start value of the animation curve
  29212. * @param outTangent End tangent of the animation
  29213. * @param endValue End value of the animation curve
  29214. * @param inTangent Start tangent of the animation curve
  29215. * @param gradient Scalar amount to interpolate
  29216. * @returns InterpolatedVector3 value
  29217. */
  29218. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29219. /**
  29220. * Interpolates a Vector2 linearly
  29221. * @param startValue Start value of the animation curve
  29222. * @param endValue End value of the animation curve
  29223. * @param gradient Scalar amount to interpolate
  29224. * @returns Interpolated Vector2 value
  29225. */
  29226. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29227. /**
  29228. * Interpolates a Vector2 cubically
  29229. * @param startValue Start value of the animation curve
  29230. * @param outTangent End tangent of the animation
  29231. * @param endValue End value of the animation curve
  29232. * @param inTangent Start tangent of the animation curve
  29233. * @param gradient Scalar amount to interpolate
  29234. * @returns Interpolated Vector2 value
  29235. */
  29236. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29237. /**
  29238. * Interpolates a size linearly
  29239. * @param startValue Start value of the animation curve
  29240. * @param endValue End value of the animation curve
  29241. * @param gradient Scalar amount to interpolate
  29242. * @returns Interpolated Size value
  29243. */
  29244. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29245. /**
  29246. * Interpolates a Color3 linearly
  29247. * @param startValue Start value of the animation curve
  29248. * @param endValue End value of the animation curve
  29249. * @param gradient Scalar amount to interpolate
  29250. * @returns Interpolated Color3 value
  29251. */
  29252. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29253. /**
  29254. * Interpolates a Color4 linearly
  29255. * @param startValue Start value of the animation curve
  29256. * @param endValue End value of the animation curve
  29257. * @param gradient Scalar amount to interpolate
  29258. * @returns Interpolated Color3 value
  29259. */
  29260. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29261. /**
  29262. * @hidden Internal use only
  29263. */
  29264. _getKeyValue(value: any): any;
  29265. /**
  29266. * @hidden Internal use only
  29267. */
  29268. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29269. /**
  29270. * Defines the function to use to interpolate matrices
  29271. * @param startValue defines the start matrix
  29272. * @param endValue defines the end matrix
  29273. * @param gradient defines the gradient between both matrices
  29274. * @param result defines an optional target matrix where to store the interpolation
  29275. * @returns the interpolated matrix
  29276. */
  29277. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29278. /**
  29279. * Makes a copy of the animation
  29280. * @returns Cloned animation
  29281. */
  29282. clone(): Animation;
  29283. /**
  29284. * Sets the key frames of the animation
  29285. * @param values The animation key frames to set
  29286. */
  29287. setKeys(values: Array<IAnimationKey>): void;
  29288. /**
  29289. * Serializes the animation to an object
  29290. * @returns Serialized object
  29291. */
  29292. serialize(): any;
  29293. /**
  29294. * Float animation type
  29295. */
  29296. static readonly ANIMATIONTYPE_FLOAT: number;
  29297. /**
  29298. * Vector3 animation type
  29299. */
  29300. static readonly ANIMATIONTYPE_VECTOR3: number;
  29301. /**
  29302. * Quaternion animation type
  29303. */
  29304. static readonly ANIMATIONTYPE_QUATERNION: number;
  29305. /**
  29306. * Matrix animation type
  29307. */
  29308. static readonly ANIMATIONTYPE_MATRIX: number;
  29309. /**
  29310. * Color3 animation type
  29311. */
  29312. static readonly ANIMATIONTYPE_COLOR3: number;
  29313. /**
  29314. * Color3 animation type
  29315. */
  29316. static readonly ANIMATIONTYPE_COLOR4: number;
  29317. /**
  29318. * Vector2 animation type
  29319. */
  29320. static readonly ANIMATIONTYPE_VECTOR2: number;
  29321. /**
  29322. * Size animation type
  29323. */
  29324. static readonly ANIMATIONTYPE_SIZE: number;
  29325. /**
  29326. * Relative Loop Mode
  29327. */
  29328. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29329. /**
  29330. * Cycle Loop Mode
  29331. */
  29332. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29333. /**
  29334. * Constant Loop Mode
  29335. */
  29336. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29337. /** @hidden */
  29338. static _UniversalLerp(left: any, right: any, amount: number): any;
  29339. /**
  29340. * Parses an animation object and creates an animation
  29341. * @param parsedAnimation Parsed animation object
  29342. * @returns Animation object
  29343. */
  29344. static Parse(parsedAnimation: any): Animation;
  29345. /**
  29346. * Appends the serialized animations from the source animations
  29347. * @param source Source containing the animations
  29348. * @param destination Target to store the animations
  29349. */
  29350. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29351. }
  29352. }
  29353. declare module BABYLON {
  29354. /**
  29355. * Interface containing an array of animations
  29356. */
  29357. export interface IAnimatable {
  29358. /**
  29359. * Array of animations
  29360. */
  29361. animations: Nullable<Array<Animation>>;
  29362. }
  29363. }
  29364. declare module BABYLON {
  29365. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29366. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29367. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29368. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29369. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29370. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29371. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29372. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29373. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29374. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29375. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29376. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29377. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29378. /**
  29379. * Decorator used to define property that can be serialized as reference to a camera
  29380. * @param sourceName defines the name of the property to decorate
  29381. */
  29382. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29383. /**
  29384. * Class used to help serialization objects
  29385. */
  29386. export class SerializationHelper {
  29387. /** @hidden */
  29388. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29389. /** @hidden */
  29390. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29391. /** @hidden */
  29392. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29393. /** @hidden */
  29394. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29395. /**
  29396. * Appends the serialized animations from the source animations
  29397. * @param source Source containing the animations
  29398. * @param destination Target to store the animations
  29399. */
  29400. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29401. /**
  29402. * Static function used to serialized a specific entity
  29403. * @param entity defines the entity to serialize
  29404. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29405. * @returns a JSON compatible object representing the serialization of the entity
  29406. */
  29407. static Serialize<T>(entity: T, serializationObject?: any): any;
  29408. /**
  29409. * Creates a new entity from a serialization data object
  29410. * @param creationFunction defines a function used to instanciated the new entity
  29411. * @param source defines the source serialization data
  29412. * @param scene defines the hosting scene
  29413. * @param rootUrl defines the root url for resources
  29414. * @returns a new entity
  29415. */
  29416. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29417. /**
  29418. * Clones an object
  29419. * @param creationFunction defines the function used to instanciate the new object
  29420. * @param source defines the source object
  29421. * @returns the cloned object
  29422. */
  29423. static Clone<T>(creationFunction: () => T, source: T): T;
  29424. /**
  29425. * Instanciates a new object based on a source one (some data will be shared between both object)
  29426. * @param creationFunction defines the function used to instanciate the new object
  29427. * @param source defines the source object
  29428. * @returns the new object
  29429. */
  29430. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29431. }
  29432. }
  29433. declare module BABYLON {
  29434. /**
  29435. * Class used to manipulate GUIDs
  29436. */
  29437. export class GUID {
  29438. /**
  29439. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29440. * Be aware Math.random() could cause collisions, but:
  29441. * "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"
  29442. * @returns a pseudo random id
  29443. */
  29444. static RandomId(): string;
  29445. }
  29446. }
  29447. declare module BABYLON {
  29448. /**
  29449. * Base class of all the textures in babylon.
  29450. * It groups all the common properties the materials, post process, lights... might need
  29451. * in order to make a correct use of the texture.
  29452. */
  29453. export class BaseTexture implements IAnimatable {
  29454. /**
  29455. * Default anisotropic filtering level for the application.
  29456. * It is set to 4 as a good tradeoff between perf and quality.
  29457. */
  29458. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29459. /**
  29460. * Gets or sets the unique id of the texture
  29461. */
  29462. uniqueId: number;
  29463. /**
  29464. * Define the name of the texture.
  29465. */
  29466. name: string;
  29467. /**
  29468. * Gets or sets an object used to store user defined information.
  29469. */
  29470. metadata: any;
  29471. /**
  29472. * For internal use only. Please do not use.
  29473. */
  29474. reservedDataStore: any;
  29475. private _hasAlpha;
  29476. /**
  29477. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29478. */
  29479. set hasAlpha(value: boolean);
  29480. get hasAlpha(): boolean;
  29481. /**
  29482. * Defines if the alpha value should be determined via the rgb values.
  29483. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29484. */
  29485. getAlphaFromRGB: boolean;
  29486. /**
  29487. * Intensity or strength of the texture.
  29488. * It is commonly used by materials to fine tune the intensity of the texture
  29489. */
  29490. level: number;
  29491. /**
  29492. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29493. * This is part of the texture as textures usually maps to one uv set.
  29494. */
  29495. coordinatesIndex: number;
  29496. private _coordinatesMode;
  29497. /**
  29498. * How a texture is mapped.
  29499. *
  29500. * | Value | Type | Description |
  29501. * | ----- | ----------------------------------- | ----------- |
  29502. * | 0 | EXPLICIT_MODE | |
  29503. * | 1 | SPHERICAL_MODE | |
  29504. * | 2 | PLANAR_MODE | |
  29505. * | 3 | CUBIC_MODE | |
  29506. * | 4 | PROJECTION_MODE | |
  29507. * | 5 | SKYBOX_MODE | |
  29508. * | 6 | INVCUBIC_MODE | |
  29509. * | 7 | EQUIRECTANGULAR_MODE | |
  29510. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29511. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29512. */
  29513. set coordinatesMode(value: number);
  29514. get coordinatesMode(): number;
  29515. /**
  29516. * | Value | Type | Description |
  29517. * | ----- | ------------------ | ----------- |
  29518. * | 0 | CLAMP_ADDRESSMODE | |
  29519. * | 1 | WRAP_ADDRESSMODE | |
  29520. * | 2 | MIRROR_ADDRESSMODE | |
  29521. */
  29522. wrapU: number;
  29523. /**
  29524. * | Value | Type | Description |
  29525. * | ----- | ------------------ | ----------- |
  29526. * | 0 | CLAMP_ADDRESSMODE | |
  29527. * | 1 | WRAP_ADDRESSMODE | |
  29528. * | 2 | MIRROR_ADDRESSMODE | |
  29529. */
  29530. wrapV: number;
  29531. /**
  29532. * | Value | Type | Description |
  29533. * | ----- | ------------------ | ----------- |
  29534. * | 0 | CLAMP_ADDRESSMODE | |
  29535. * | 1 | WRAP_ADDRESSMODE | |
  29536. * | 2 | MIRROR_ADDRESSMODE | |
  29537. */
  29538. wrapR: number;
  29539. /**
  29540. * With compliant hardware and browser (supporting anisotropic filtering)
  29541. * this defines the level of anisotropic filtering in the texture.
  29542. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29543. */
  29544. anisotropicFilteringLevel: number;
  29545. /**
  29546. * Define if the texture is a cube texture or if false a 2d texture.
  29547. */
  29548. get isCube(): boolean;
  29549. set isCube(value: boolean);
  29550. /**
  29551. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29552. */
  29553. get is3D(): boolean;
  29554. set is3D(value: boolean);
  29555. /**
  29556. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29557. */
  29558. get is2DArray(): boolean;
  29559. set is2DArray(value: boolean);
  29560. /**
  29561. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29562. * HDR texture are usually stored in linear space.
  29563. * This only impacts the PBR and Background materials
  29564. */
  29565. gammaSpace: boolean;
  29566. /**
  29567. * Gets or sets whether or not the texture contains RGBD data.
  29568. */
  29569. get isRGBD(): boolean;
  29570. set isRGBD(value: boolean);
  29571. /**
  29572. * Is Z inverted in the texture (useful in a cube texture).
  29573. */
  29574. invertZ: boolean;
  29575. /**
  29576. * Are mip maps generated for this texture or not.
  29577. */
  29578. get noMipmap(): boolean;
  29579. /**
  29580. * @hidden
  29581. */
  29582. lodLevelInAlpha: boolean;
  29583. /**
  29584. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29585. */
  29586. get lodGenerationOffset(): number;
  29587. set lodGenerationOffset(value: number);
  29588. /**
  29589. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29590. */
  29591. get lodGenerationScale(): number;
  29592. set lodGenerationScale(value: number);
  29593. /**
  29594. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29595. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29596. * average roughness values.
  29597. */
  29598. get linearSpecularLOD(): boolean;
  29599. set linearSpecularLOD(value: boolean);
  29600. /**
  29601. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29602. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29603. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29604. */
  29605. get irradianceTexture(): Nullable<BaseTexture>;
  29606. set irradianceTexture(value: Nullable<BaseTexture>);
  29607. /**
  29608. * Define if the texture is a render target.
  29609. */
  29610. isRenderTarget: boolean;
  29611. /**
  29612. * Define the unique id of the texture in the scene.
  29613. */
  29614. get uid(): string;
  29615. /**
  29616. * Return a string representation of the texture.
  29617. * @returns the texture as a string
  29618. */
  29619. toString(): string;
  29620. /**
  29621. * Get the class name of the texture.
  29622. * @returns "BaseTexture"
  29623. */
  29624. getClassName(): string;
  29625. /**
  29626. * Define the list of animation attached to the texture.
  29627. */
  29628. animations: Animation[];
  29629. /**
  29630. * An event triggered when the texture is disposed.
  29631. */
  29632. onDisposeObservable: Observable<BaseTexture>;
  29633. private _onDisposeObserver;
  29634. /**
  29635. * Callback triggered when the texture has been disposed.
  29636. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29637. */
  29638. set onDispose(callback: () => void);
  29639. /**
  29640. * Define the current state of the loading sequence when in delayed load mode.
  29641. */
  29642. delayLoadState: number;
  29643. private _scene;
  29644. /** @hidden */
  29645. _texture: Nullable<InternalTexture>;
  29646. private _uid;
  29647. /**
  29648. * Define if the texture is preventinga material to render or not.
  29649. * If not and the texture is not ready, the engine will use a default black texture instead.
  29650. */
  29651. get isBlocking(): boolean;
  29652. /**
  29653. * Instantiates a new BaseTexture.
  29654. * Base class of all the textures in babylon.
  29655. * It groups all the common properties the materials, post process, lights... might need
  29656. * in order to make a correct use of the texture.
  29657. * @param scene Define the scene the texture blongs to
  29658. */
  29659. constructor(scene: Nullable<Scene>);
  29660. /**
  29661. * Get the scene the texture belongs to.
  29662. * @returns the scene or null if undefined
  29663. */
  29664. getScene(): Nullable<Scene>;
  29665. /**
  29666. * Get the texture transform matrix used to offset tile the texture for istance.
  29667. * @returns the transformation matrix
  29668. */
  29669. getTextureMatrix(): Matrix;
  29670. /**
  29671. * Get the texture reflection matrix used to rotate/transform the reflection.
  29672. * @returns the reflection matrix
  29673. */
  29674. getReflectionTextureMatrix(): Matrix;
  29675. /**
  29676. * Get the underlying lower level texture from Babylon.
  29677. * @returns the insternal texture
  29678. */
  29679. getInternalTexture(): Nullable<InternalTexture>;
  29680. /**
  29681. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29682. * @returns true if ready or not blocking
  29683. */
  29684. isReadyOrNotBlocking(): boolean;
  29685. /**
  29686. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29687. * @returns true if fully ready
  29688. */
  29689. isReady(): boolean;
  29690. private _cachedSize;
  29691. /**
  29692. * Get the size of the texture.
  29693. * @returns the texture size.
  29694. */
  29695. getSize(): ISize;
  29696. /**
  29697. * Get the base size of the texture.
  29698. * It can be different from the size if the texture has been resized for POT for instance
  29699. * @returns the base size
  29700. */
  29701. getBaseSize(): ISize;
  29702. /**
  29703. * Update the sampling mode of the texture.
  29704. * Default is Trilinear mode.
  29705. *
  29706. * | Value | Type | Description |
  29707. * | ----- | ------------------ | ----------- |
  29708. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29709. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29710. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29711. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29712. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29713. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29714. * | 7 | NEAREST_LINEAR | |
  29715. * | 8 | NEAREST_NEAREST | |
  29716. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29717. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29718. * | 11 | LINEAR_LINEAR | |
  29719. * | 12 | LINEAR_NEAREST | |
  29720. *
  29721. * > _mag_: magnification filter (close to the viewer)
  29722. * > _min_: minification filter (far from the viewer)
  29723. * > _mip_: filter used between mip map levels
  29724. *@param samplingMode Define the new sampling mode of the texture
  29725. */
  29726. updateSamplingMode(samplingMode: number): void;
  29727. /**
  29728. * Scales the texture if is `canRescale()`
  29729. * @param ratio the resize factor we want to use to rescale
  29730. */
  29731. scale(ratio: number): void;
  29732. /**
  29733. * Get if the texture can rescale.
  29734. */
  29735. get canRescale(): boolean;
  29736. /** @hidden */
  29737. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29738. /** @hidden */
  29739. _rebuild(): void;
  29740. /**
  29741. * Triggers the load sequence in delayed load mode.
  29742. */
  29743. delayLoad(): void;
  29744. /**
  29745. * Clones the texture.
  29746. * @returns the cloned texture
  29747. */
  29748. clone(): Nullable<BaseTexture>;
  29749. /**
  29750. * Get the texture underlying type (INT, FLOAT...)
  29751. */
  29752. get textureType(): number;
  29753. /**
  29754. * Get the texture underlying format (RGB, RGBA...)
  29755. */
  29756. get textureFormat(): number;
  29757. /**
  29758. * Indicates that textures need to be re-calculated for all materials
  29759. */
  29760. protected _markAllSubMeshesAsTexturesDirty(): void;
  29761. /**
  29762. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29763. * This will returns an RGBA array buffer containing either in values (0-255) or
  29764. * float values (0-1) depending of the underlying buffer type.
  29765. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29766. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29767. * @param buffer defines a user defined buffer to fill with data (can be null)
  29768. * @returns The Array buffer containing the pixels data.
  29769. */
  29770. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29771. /**
  29772. * Release and destroy the underlying lower level texture aka internalTexture.
  29773. */
  29774. releaseInternalTexture(): void;
  29775. /** @hidden */
  29776. get _lodTextureHigh(): Nullable<BaseTexture>;
  29777. /** @hidden */
  29778. get _lodTextureMid(): Nullable<BaseTexture>;
  29779. /** @hidden */
  29780. get _lodTextureLow(): Nullable<BaseTexture>;
  29781. /**
  29782. * Dispose the texture and release its associated resources.
  29783. */
  29784. dispose(): void;
  29785. /**
  29786. * Serialize the texture into a JSON representation that can be parsed later on.
  29787. * @returns the JSON representation of the texture
  29788. */
  29789. serialize(): any;
  29790. /**
  29791. * Helper function to be called back once a list of texture contains only ready textures.
  29792. * @param textures Define the list of textures to wait for
  29793. * @param callback Define the callback triggered once the entire list will be ready
  29794. */
  29795. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29796. }
  29797. }
  29798. declare module BABYLON {
  29799. /**
  29800. * Options to be used when creating an effect.
  29801. */
  29802. export interface IEffectCreationOptions {
  29803. /**
  29804. * Atrributes that will be used in the shader.
  29805. */
  29806. attributes: string[];
  29807. /**
  29808. * Uniform varible names that will be set in the shader.
  29809. */
  29810. uniformsNames: string[];
  29811. /**
  29812. * Uniform buffer variable names that will be set in the shader.
  29813. */
  29814. uniformBuffersNames: string[];
  29815. /**
  29816. * Sampler texture variable names that will be set in the shader.
  29817. */
  29818. samplers: string[];
  29819. /**
  29820. * Define statements that will be set in the shader.
  29821. */
  29822. defines: any;
  29823. /**
  29824. * Possible fallbacks for this effect to improve performance when needed.
  29825. */
  29826. fallbacks: Nullable<IEffectFallbacks>;
  29827. /**
  29828. * Callback that will be called when the shader is compiled.
  29829. */
  29830. onCompiled: Nullable<(effect: Effect) => void>;
  29831. /**
  29832. * Callback that will be called if an error occurs during shader compilation.
  29833. */
  29834. onError: Nullable<(effect: Effect, errors: string) => void>;
  29835. /**
  29836. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29837. */
  29838. indexParameters?: any;
  29839. /**
  29840. * Max number of lights that can be used in the shader.
  29841. */
  29842. maxSimultaneousLights?: number;
  29843. /**
  29844. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29845. */
  29846. transformFeedbackVaryings?: Nullable<string[]>;
  29847. }
  29848. /**
  29849. * Effect containing vertex and fragment shader that can be executed on an object.
  29850. */
  29851. export class Effect implements IDisposable {
  29852. /**
  29853. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29854. */
  29855. static ShadersRepository: string;
  29856. /**
  29857. * Name of the effect.
  29858. */
  29859. name: any;
  29860. /**
  29861. * String container all the define statements that should be set on the shader.
  29862. */
  29863. defines: string;
  29864. /**
  29865. * Callback that will be called when the shader is compiled.
  29866. */
  29867. onCompiled: Nullable<(effect: Effect) => void>;
  29868. /**
  29869. * Callback that will be called if an error occurs during shader compilation.
  29870. */
  29871. onError: Nullable<(effect: Effect, errors: string) => void>;
  29872. /**
  29873. * Callback that will be called when effect is bound.
  29874. */
  29875. onBind: Nullable<(effect: Effect) => void>;
  29876. /**
  29877. * Unique ID of the effect.
  29878. */
  29879. uniqueId: number;
  29880. /**
  29881. * Observable that will be called when the shader is compiled.
  29882. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29883. */
  29884. onCompileObservable: Observable<Effect>;
  29885. /**
  29886. * Observable that will be called if an error occurs during shader compilation.
  29887. */
  29888. onErrorObservable: Observable<Effect>;
  29889. /** @hidden */
  29890. _onBindObservable: Nullable<Observable<Effect>>;
  29891. /**
  29892. * @hidden
  29893. * Specifies if the effect was previously ready
  29894. */
  29895. _wasPreviouslyReady: boolean;
  29896. /**
  29897. * Observable that will be called when effect is bound.
  29898. */
  29899. get onBindObservable(): Observable<Effect>;
  29900. /** @hidden */
  29901. _bonesComputationForcedToCPU: boolean;
  29902. private static _uniqueIdSeed;
  29903. private _engine;
  29904. private _uniformBuffersNames;
  29905. private _uniformsNames;
  29906. private _samplerList;
  29907. private _samplers;
  29908. private _isReady;
  29909. private _compilationError;
  29910. private _allFallbacksProcessed;
  29911. private _attributesNames;
  29912. private _attributes;
  29913. private _attributeLocationByName;
  29914. private _uniforms;
  29915. /**
  29916. * Key for the effect.
  29917. * @hidden
  29918. */
  29919. _key: string;
  29920. private _indexParameters;
  29921. private _fallbacks;
  29922. private _vertexSourceCode;
  29923. private _fragmentSourceCode;
  29924. private _vertexSourceCodeOverride;
  29925. private _fragmentSourceCodeOverride;
  29926. private _transformFeedbackVaryings;
  29927. /**
  29928. * Compiled shader to webGL program.
  29929. * @hidden
  29930. */
  29931. _pipelineContext: Nullable<IPipelineContext>;
  29932. private _valueCache;
  29933. private static _baseCache;
  29934. /**
  29935. * Instantiates an effect.
  29936. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29937. * @param baseName Name of the effect.
  29938. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29939. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29940. * @param samplers List of sampler variables that will be passed to the shader.
  29941. * @param engine Engine to be used to render the effect
  29942. * @param defines Define statements to be added to the shader.
  29943. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29944. * @param onCompiled Callback that will be called when the shader is compiled.
  29945. * @param onError Callback that will be called if an error occurs during shader compilation.
  29946. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29947. */
  29948. 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);
  29949. private _useFinalCode;
  29950. /**
  29951. * Unique key for this effect
  29952. */
  29953. get key(): string;
  29954. /**
  29955. * If the effect has been compiled and prepared.
  29956. * @returns if the effect is compiled and prepared.
  29957. */
  29958. isReady(): boolean;
  29959. private _isReadyInternal;
  29960. /**
  29961. * The engine the effect was initialized with.
  29962. * @returns the engine.
  29963. */
  29964. getEngine(): Engine;
  29965. /**
  29966. * The pipeline context for this effect
  29967. * @returns the associated pipeline context
  29968. */
  29969. getPipelineContext(): Nullable<IPipelineContext>;
  29970. /**
  29971. * The set of names of attribute variables for the shader.
  29972. * @returns An array of attribute names.
  29973. */
  29974. getAttributesNames(): string[];
  29975. /**
  29976. * Returns the attribute at the given index.
  29977. * @param index The index of the attribute.
  29978. * @returns The location of the attribute.
  29979. */
  29980. getAttributeLocation(index: number): number;
  29981. /**
  29982. * Returns the attribute based on the name of the variable.
  29983. * @param name of the attribute to look up.
  29984. * @returns the attribute location.
  29985. */
  29986. getAttributeLocationByName(name: string): number;
  29987. /**
  29988. * The number of attributes.
  29989. * @returns the numnber of attributes.
  29990. */
  29991. getAttributesCount(): number;
  29992. /**
  29993. * Gets the index of a uniform variable.
  29994. * @param uniformName of the uniform to look up.
  29995. * @returns the index.
  29996. */
  29997. getUniformIndex(uniformName: string): number;
  29998. /**
  29999. * Returns the attribute based on the name of the variable.
  30000. * @param uniformName of the uniform to look up.
  30001. * @returns the location of the uniform.
  30002. */
  30003. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30004. /**
  30005. * Returns an array of sampler variable names
  30006. * @returns The array of sampler variable neames.
  30007. */
  30008. getSamplers(): string[];
  30009. /**
  30010. * The error from the last compilation.
  30011. * @returns the error string.
  30012. */
  30013. getCompilationError(): string;
  30014. /**
  30015. * Gets a boolean indicating that all fallbacks were used during compilation
  30016. * @returns true if all fallbacks were used
  30017. */
  30018. allFallbacksProcessed(): boolean;
  30019. /**
  30020. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30021. * @param func The callback to be used.
  30022. */
  30023. executeWhenCompiled(func: (effect: Effect) => void): void;
  30024. private _checkIsReady;
  30025. private _loadShader;
  30026. /**
  30027. * Recompiles the webGL program
  30028. * @param vertexSourceCode The source code for the vertex shader.
  30029. * @param fragmentSourceCode The source code for the fragment shader.
  30030. * @param onCompiled Callback called when completed.
  30031. * @param onError Callback called on error.
  30032. * @hidden
  30033. */
  30034. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30035. /**
  30036. * Prepares the effect
  30037. * @hidden
  30038. */
  30039. _prepareEffect(): void;
  30040. private _processCompilationErrors;
  30041. /**
  30042. * Checks if the effect is supported. (Must be called after compilation)
  30043. */
  30044. get isSupported(): boolean;
  30045. /**
  30046. * Binds a texture to the engine to be used as output of the shader.
  30047. * @param channel Name of the output variable.
  30048. * @param texture Texture to bind.
  30049. * @hidden
  30050. */
  30051. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30052. /**
  30053. * Sets a texture on the engine to be used in the shader.
  30054. * @param channel Name of the sampler variable.
  30055. * @param texture Texture to set.
  30056. */
  30057. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30058. /**
  30059. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30060. * @param channel Name of the sampler variable.
  30061. * @param texture Texture to set.
  30062. */
  30063. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30064. /**
  30065. * Sets an array of textures on the engine to be used in the shader.
  30066. * @param channel Name of the variable.
  30067. * @param textures Textures to set.
  30068. */
  30069. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30070. /**
  30071. * 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)
  30072. * @param channel Name of the sampler variable.
  30073. * @param postProcess Post process to get the input texture from.
  30074. */
  30075. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30076. /**
  30077. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30078. * 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)
  30079. * @param channel Name of the sampler variable.
  30080. * @param postProcess Post process to get the output texture from.
  30081. */
  30082. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30083. /** @hidden */
  30084. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30085. /** @hidden */
  30086. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30087. /** @hidden */
  30088. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30089. /** @hidden */
  30090. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30091. /**
  30092. * Binds a buffer to a uniform.
  30093. * @param buffer Buffer to bind.
  30094. * @param name Name of the uniform variable to bind to.
  30095. */
  30096. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30097. /**
  30098. * Binds block to a uniform.
  30099. * @param blockName Name of the block to bind.
  30100. * @param index Index to bind.
  30101. */
  30102. bindUniformBlock(blockName: string, index: number): void;
  30103. /**
  30104. * Sets an interger value on a uniform variable.
  30105. * @param uniformName Name of the variable.
  30106. * @param value Value to be set.
  30107. * @returns this effect.
  30108. */
  30109. setInt(uniformName: string, value: number): Effect;
  30110. /**
  30111. * Sets an int array on a uniform variable.
  30112. * @param uniformName Name of the variable.
  30113. * @param array array to be set.
  30114. * @returns this effect.
  30115. */
  30116. setIntArray(uniformName: string, array: Int32Array): Effect;
  30117. /**
  30118. * 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)
  30119. * @param uniformName Name of the variable.
  30120. * @param array array to be set.
  30121. * @returns this effect.
  30122. */
  30123. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30124. /**
  30125. * 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)
  30126. * @param uniformName Name of the variable.
  30127. * @param array array to be set.
  30128. * @returns this effect.
  30129. */
  30130. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30131. /**
  30132. * 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)
  30133. * @param uniformName Name of the variable.
  30134. * @param array array to be set.
  30135. * @returns this effect.
  30136. */
  30137. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30138. /**
  30139. * Sets an float array on a uniform variable.
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30145. /**
  30146. * 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)
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30152. /**
  30153. * 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)
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30166. /**
  30167. * Sets an array on a uniform variable.
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setArray(uniformName: string, array: number[]): Effect;
  30173. /**
  30174. * 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)
  30175. * @param uniformName Name of the variable.
  30176. * @param array array to be set.
  30177. * @returns this effect.
  30178. */
  30179. setArray2(uniformName: string, array: number[]): Effect;
  30180. /**
  30181. * 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)
  30182. * @param uniformName Name of the variable.
  30183. * @param array array to be set.
  30184. * @returns this effect.
  30185. */
  30186. setArray3(uniformName: string, array: number[]): Effect;
  30187. /**
  30188. * 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)
  30189. * @param uniformName Name of the variable.
  30190. * @param array array to be set.
  30191. * @returns this effect.
  30192. */
  30193. setArray4(uniformName: string, array: number[]): Effect;
  30194. /**
  30195. * Sets matrices on a uniform variable.
  30196. * @param uniformName Name of the variable.
  30197. * @param matrices matrices to be set.
  30198. * @returns this effect.
  30199. */
  30200. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30201. /**
  30202. * Sets matrix on a uniform variable.
  30203. * @param uniformName Name of the variable.
  30204. * @param matrix matrix to be set.
  30205. * @returns this effect.
  30206. */
  30207. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30208. /**
  30209. * 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)
  30210. * @param uniformName Name of the variable.
  30211. * @param matrix matrix to be set.
  30212. * @returns this effect.
  30213. */
  30214. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30215. /**
  30216. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30217. * @param uniformName Name of the variable.
  30218. * @param matrix matrix to be set.
  30219. * @returns this effect.
  30220. */
  30221. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30222. /**
  30223. * Sets a float on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param value value to be set.
  30226. * @returns this effect.
  30227. */
  30228. setFloat(uniformName: string, value: number): Effect;
  30229. /**
  30230. * Sets a boolean on a uniform variable.
  30231. * @param uniformName Name of the variable.
  30232. * @param bool value to be set.
  30233. * @returns this effect.
  30234. */
  30235. setBool(uniformName: string, bool: boolean): Effect;
  30236. /**
  30237. * Sets a Vector2 on a uniform variable.
  30238. * @param uniformName Name of the variable.
  30239. * @param vector2 vector2 to be set.
  30240. * @returns this effect.
  30241. */
  30242. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30243. /**
  30244. * Sets a float2 on a uniform variable.
  30245. * @param uniformName Name of the variable.
  30246. * @param x First float in float2.
  30247. * @param y Second float in float2.
  30248. * @returns this effect.
  30249. */
  30250. setFloat2(uniformName: string, x: number, y: number): Effect;
  30251. /**
  30252. * Sets a Vector3 on a uniform variable.
  30253. * @param uniformName Name of the variable.
  30254. * @param vector3 Value to be set.
  30255. * @returns this effect.
  30256. */
  30257. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30258. /**
  30259. * Sets a float3 on a uniform variable.
  30260. * @param uniformName Name of the variable.
  30261. * @param x First float in float3.
  30262. * @param y Second float in float3.
  30263. * @param z Third float in float3.
  30264. * @returns this effect.
  30265. */
  30266. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30267. /**
  30268. * Sets a Vector4 on a uniform variable.
  30269. * @param uniformName Name of the variable.
  30270. * @param vector4 Value to be set.
  30271. * @returns this effect.
  30272. */
  30273. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30274. /**
  30275. * Sets a float4 on a uniform variable.
  30276. * @param uniformName Name of the variable.
  30277. * @param x First float in float4.
  30278. * @param y Second float in float4.
  30279. * @param z Third float in float4.
  30280. * @param w Fourth float in float4.
  30281. * @returns this effect.
  30282. */
  30283. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30284. /**
  30285. * Sets a Color3 on a uniform variable.
  30286. * @param uniformName Name of the variable.
  30287. * @param color3 Value to be set.
  30288. * @returns this effect.
  30289. */
  30290. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30291. /**
  30292. * Sets a Color4 on a uniform variable.
  30293. * @param uniformName Name of the variable.
  30294. * @param color3 Value to be set.
  30295. * @param alpha Alpha value to be set.
  30296. * @returns this effect.
  30297. */
  30298. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30299. /**
  30300. * Sets a Color4 on a uniform variable
  30301. * @param uniformName defines the name of the variable
  30302. * @param color4 defines the value to be set
  30303. * @returns this effect.
  30304. */
  30305. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30306. /** Release all associated resources */
  30307. dispose(): void;
  30308. /**
  30309. * This function will add a new shader to the shader store
  30310. * @param name the name of the shader
  30311. * @param pixelShader optional pixel shader content
  30312. * @param vertexShader optional vertex shader content
  30313. */
  30314. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30315. /**
  30316. * Store of each shader (The can be looked up using effect.key)
  30317. */
  30318. static ShadersStore: {
  30319. [key: string]: string;
  30320. };
  30321. /**
  30322. * Store of each included file for a shader (The can be looked up using effect.key)
  30323. */
  30324. static IncludesShadersStore: {
  30325. [key: string]: string;
  30326. };
  30327. /**
  30328. * Resets the cache of effects.
  30329. */
  30330. static ResetCache(): void;
  30331. }
  30332. }
  30333. declare module BABYLON {
  30334. /**
  30335. * Interface used to describe the capabilities of the engine relatively to the current browser
  30336. */
  30337. export interface EngineCapabilities {
  30338. /** Maximum textures units per fragment shader */
  30339. maxTexturesImageUnits: number;
  30340. /** Maximum texture units per vertex shader */
  30341. maxVertexTextureImageUnits: number;
  30342. /** Maximum textures units in the entire pipeline */
  30343. maxCombinedTexturesImageUnits: number;
  30344. /** Maximum texture size */
  30345. maxTextureSize: number;
  30346. /** Maximum texture samples */
  30347. maxSamples?: number;
  30348. /** Maximum cube texture size */
  30349. maxCubemapTextureSize: number;
  30350. /** Maximum render texture size */
  30351. maxRenderTextureSize: number;
  30352. /** Maximum number of vertex attributes */
  30353. maxVertexAttribs: number;
  30354. /** Maximum number of varyings */
  30355. maxVaryingVectors: number;
  30356. /** Maximum number of uniforms per vertex shader */
  30357. maxVertexUniformVectors: number;
  30358. /** Maximum number of uniforms per fragment shader */
  30359. maxFragmentUniformVectors: number;
  30360. /** Defines if standard derivates (dx/dy) are supported */
  30361. standardDerivatives: boolean;
  30362. /** Defines if s3tc texture compression is supported */
  30363. s3tc?: WEBGL_compressed_texture_s3tc;
  30364. /** Defines if pvrtc texture compression is supported */
  30365. pvrtc: any;
  30366. /** Defines if etc1 texture compression is supported */
  30367. etc1: any;
  30368. /** Defines if etc2 texture compression is supported */
  30369. etc2: any;
  30370. /** Defines if astc texture compression is supported */
  30371. astc: any;
  30372. /** Defines if float textures are supported */
  30373. textureFloat: boolean;
  30374. /** Defines if vertex array objects are supported */
  30375. vertexArrayObject: boolean;
  30376. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30377. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30378. /** Gets the maximum level of anisotropy supported */
  30379. maxAnisotropy: number;
  30380. /** Defines if instancing is supported */
  30381. instancedArrays: boolean;
  30382. /** Defines if 32 bits indices are supported */
  30383. uintIndices: boolean;
  30384. /** Defines if high precision shaders are supported */
  30385. highPrecisionShaderSupported: boolean;
  30386. /** Defines if depth reading in the fragment shader is supported */
  30387. fragmentDepthSupported: boolean;
  30388. /** Defines if float texture linear filtering is supported*/
  30389. textureFloatLinearFiltering: boolean;
  30390. /** Defines if rendering to float textures is supported */
  30391. textureFloatRender: boolean;
  30392. /** Defines if half float textures are supported*/
  30393. textureHalfFloat: boolean;
  30394. /** Defines if half float texture linear filtering is supported*/
  30395. textureHalfFloatLinearFiltering: boolean;
  30396. /** Defines if rendering to half float textures is supported */
  30397. textureHalfFloatRender: boolean;
  30398. /** Defines if textureLOD shader command is supported */
  30399. textureLOD: boolean;
  30400. /** Defines if draw buffers extension is supported */
  30401. drawBuffersExtension: boolean;
  30402. /** Defines if depth textures are supported */
  30403. depthTextureExtension: boolean;
  30404. /** Defines if float color buffer are supported */
  30405. colorBufferFloat: boolean;
  30406. /** Gets disjoint timer query extension (null if not supported) */
  30407. timerQuery?: EXT_disjoint_timer_query;
  30408. /** Defines if timestamp can be used with timer query */
  30409. canUseTimestampForTimerQuery: boolean;
  30410. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30411. multiview?: any;
  30412. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30413. oculusMultiview?: any;
  30414. /** Function used to let the system compiles shaders in background */
  30415. parallelShaderCompile?: {
  30416. COMPLETION_STATUS_KHR: number;
  30417. };
  30418. /** Max number of texture samples for MSAA */
  30419. maxMSAASamples: number;
  30420. /** Defines if the blend min max extension is supported */
  30421. blendMinMax: boolean;
  30422. }
  30423. }
  30424. declare module BABYLON {
  30425. /**
  30426. * @hidden
  30427. **/
  30428. export class DepthCullingState {
  30429. private _isDepthTestDirty;
  30430. private _isDepthMaskDirty;
  30431. private _isDepthFuncDirty;
  30432. private _isCullFaceDirty;
  30433. private _isCullDirty;
  30434. private _isZOffsetDirty;
  30435. private _isFrontFaceDirty;
  30436. private _depthTest;
  30437. private _depthMask;
  30438. private _depthFunc;
  30439. private _cull;
  30440. private _cullFace;
  30441. private _zOffset;
  30442. private _frontFace;
  30443. /**
  30444. * Initializes the state.
  30445. */
  30446. constructor();
  30447. get isDirty(): boolean;
  30448. get zOffset(): number;
  30449. set zOffset(value: number);
  30450. get cullFace(): Nullable<number>;
  30451. set cullFace(value: Nullable<number>);
  30452. get cull(): Nullable<boolean>;
  30453. set cull(value: Nullable<boolean>);
  30454. get depthFunc(): Nullable<number>;
  30455. set depthFunc(value: Nullable<number>);
  30456. get depthMask(): boolean;
  30457. set depthMask(value: boolean);
  30458. get depthTest(): boolean;
  30459. set depthTest(value: boolean);
  30460. get frontFace(): Nullable<number>;
  30461. set frontFace(value: Nullable<number>);
  30462. reset(): void;
  30463. apply(gl: WebGLRenderingContext): void;
  30464. }
  30465. }
  30466. declare module BABYLON {
  30467. /**
  30468. * @hidden
  30469. **/
  30470. export class StencilState {
  30471. /** 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 */
  30472. static readonly ALWAYS: number;
  30473. /** Passed to stencilOperation to specify that stencil value must be kept */
  30474. static readonly KEEP: number;
  30475. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30476. static readonly REPLACE: number;
  30477. private _isStencilTestDirty;
  30478. private _isStencilMaskDirty;
  30479. private _isStencilFuncDirty;
  30480. private _isStencilOpDirty;
  30481. private _stencilTest;
  30482. private _stencilMask;
  30483. private _stencilFunc;
  30484. private _stencilFuncRef;
  30485. private _stencilFuncMask;
  30486. private _stencilOpStencilFail;
  30487. private _stencilOpDepthFail;
  30488. private _stencilOpStencilDepthPass;
  30489. get isDirty(): boolean;
  30490. get stencilFunc(): number;
  30491. set stencilFunc(value: number);
  30492. get stencilFuncRef(): number;
  30493. set stencilFuncRef(value: number);
  30494. get stencilFuncMask(): number;
  30495. set stencilFuncMask(value: number);
  30496. get stencilOpStencilFail(): number;
  30497. set stencilOpStencilFail(value: number);
  30498. get stencilOpDepthFail(): number;
  30499. set stencilOpDepthFail(value: number);
  30500. get stencilOpStencilDepthPass(): number;
  30501. set stencilOpStencilDepthPass(value: number);
  30502. get stencilMask(): number;
  30503. set stencilMask(value: number);
  30504. get stencilTest(): boolean;
  30505. set stencilTest(value: boolean);
  30506. constructor();
  30507. reset(): void;
  30508. apply(gl: WebGLRenderingContext): void;
  30509. }
  30510. }
  30511. declare module BABYLON {
  30512. /**
  30513. * @hidden
  30514. **/
  30515. export class AlphaState {
  30516. private _isAlphaBlendDirty;
  30517. private _isBlendFunctionParametersDirty;
  30518. private _isBlendEquationParametersDirty;
  30519. private _isBlendConstantsDirty;
  30520. private _alphaBlend;
  30521. private _blendFunctionParameters;
  30522. private _blendEquationParameters;
  30523. private _blendConstants;
  30524. /**
  30525. * Initializes the state.
  30526. */
  30527. constructor();
  30528. get isDirty(): boolean;
  30529. get alphaBlend(): boolean;
  30530. set alphaBlend(value: boolean);
  30531. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30532. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30533. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30534. reset(): void;
  30535. apply(gl: WebGLRenderingContext): void;
  30536. }
  30537. }
  30538. declare module BABYLON {
  30539. /** @hidden */
  30540. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30541. attributeProcessor(attribute: string): string;
  30542. varyingProcessor(varying: string, isFragment: boolean): string;
  30543. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30544. }
  30545. }
  30546. declare module BABYLON {
  30547. /**
  30548. * Interface for attribute information associated with buffer instanciation
  30549. */
  30550. export interface InstancingAttributeInfo {
  30551. /**
  30552. * Name of the GLSL attribute
  30553. * if attribute index is not specified, this is used to retrieve the index from the effect
  30554. */
  30555. attributeName: string;
  30556. /**
  30557. * Index/offset of the attribute in the vertex shader
  30558. * if not specified, this will be computes from the name.
  30559. */
  30560. index?: number;
  30561. /**
  30562. * size of the attribute, 1, 2, 3 or 4
  30563. */
  30564. attributeSize: number;
  30565. /**
  30566. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30567. */
  30568. offset: number;
  30569. /**
  30570. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30571. * default to 1
  30572. */
  30573. divisor?: number;
  30574. /**
  30575. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30576. * default is FLOAT
  30577. */
  30578. attributeType?: number;
  30579. /**
  30580. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30581. */
  30582. normalized?: boolean;
  30583. }
  30584. }
  30585. declare module BABYLON {
  30586. interface ThinEngine {
  30587. /**
  30588. * Update a video texture
  30589. * @param texture defines the texture to update
  30590. * @param video defines the video element to use
  30591. * @param invertY defines if data must be stored with Y axis inverted
  30592. */
  30593. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30594. }
  30595. }
  30596. declare module BABYLON {
  30597. /**
  30598. * Settings for finer control over video usage
  30599. */
  30600. export interface VideoTextureSettings {
  30601. /**
  30602. * Applies `autoplay` to video, if specified
  30603. */
  30604. autoPlay?: boolean;
  30605. /**
  30606. * Applies `loop` to video, if specified
  30607. */
  30608. loop?: boolean;
  30609. /**
  30610. * Automatically updates internal texture from video at every frame in the render loop
  30611. */
  30612. autoUpdateTexture: boolean;
  30613. /**
  30614. * Image src displayed during the video loading or until the user interacts with the video.
  30615. */
  30616. poster?: string;
  30617. }
  30618. /**
  30619. * If you want to display a video in your scene, this is the special texture for that.
  30620. * This special texture works similar to other textures, with the exception of a few parameters.
  30621. * @see https://doc.babylonjs.com/how_to/video_texture
  30622. */
  30623. export class VideoTexture extends Texture {
  30624. /**
  30625. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30626. */
  30627. readonly autoUpdateTexture: boolean;
  30628. /**
  30629. * The video instance used by the texture internally
  30630. */
  30631. readonly video: HTMLVideoElement;
  30632. private _onUserActionRequestedObservable;
  30633. /**
  30634. * Event triggerd when a dom action is required by the user to play the video.
  30635. * This happens due to recent changes in browser policies preventing video to auto start.
  30636. */
  30637. get onUserActionRequestedObservable(): Observable<Texture>;
  30638. private _generateMipMaps;
  30639. private _engine;
  30640. private _stillImageCaptured;
  30641. private _displayingPosterTexture;
  30642. private _settings;
  30643. private _createInternalTextureOnEvent;
  30644. private _frameId;
  30645. private _currentSrc;
  30646. /**
  30647. * Creates a video texture.
  30648. * If you want to display a video in your scene, this is the special texture for that.
  30649. * This special texture works similar to other textures, with the exception of a few parameters.
  30650. * @see https://doc.babylonjs.com/how_to/video_texture
  30651. * @param name optional name, will detect from video source, if not defined
  30652. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30653. * @param scene is obviously the current scene.
  30654. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30655. * @param invertY is false by default but can be used to invert video on Y axis
  30656. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30657. * @param settings allows finer control over video usage
  30658. */
  30659. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30660. private _getName;
  30661. private _getVideo;
  30662. private _createInternalTexture;
  30663. private reset;
  30664. /**
  30665. * @hidden Internal method to initiate `update`.
  30666. */
  30667. _rebuild(): void;
  30668. /**
  30669. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30670. */
  30671. update(): void;
  30672. /**
  30673. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30674. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30675. */
  30676. updateTexture(isVisible: boolean): void;
  30677. protected _updateInternalTexture: () => void;
  30678. /**
  30679. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30680. * @param url New url.
  30681. */
  30682. updateURL(url: string): void;
  30683. /**
  30684. * Clones the texture.
  30685. * @returns the cloned texture
  30686. */
  30687. clone(): VideoTexture;
  30688. /**
  30689. * Dispose the texture and release its associated resources.
  30690. */
  30691. dispose(): void;
  30692. /**
  30693. * Creates a video texture straight from a stream.
  30694. * @param scene Define the scene the texture should be created in
  30695. * @param stream Define the stream the texture should be created from
  30696. * @returns The created video texture as a promise
  30697. */
  30698. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30699. /**
  30700. * Creates a video texture straight from your WebCam video feed.
  30701. * @param scene Define the scene the texture should be created in
  30702. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30703. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30704. * @returns The created video texture as a promise
  30705. */
  30706. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30707. minWidth: number;
  30708. maxWidth: number;
  30709. minHeight: number;
  30710. maxHeight: number;
  30711. deviceId: string;
  30712. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30713. /**
  30714. * Creates a video texture straight from your WebCam video feed.
  30715. * @param scene Define the scene the texture should be created in
  30716. * @param onReady Define a callback to triggered once the texture will be ready
  30717. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30718. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30719. */
  30720. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30721. minWidth: number;
  30722. maxWidth: number;
  30723. minHeight: number;
  30724. maxHeight: number;
  30725. deviceId: string;
  30726. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30727. }
  30728. }
  30729. declare module BABYLON {
  30730. /**
  30731. * Defines the interface used by objects working like Scene
  30732. * @hidden
  30733. */
  30734. interface ISceneLike {
  30735. _addPendingData(data: any): void;
  30736. _removePendingData(data: any): void;
  30737. offlineProvider: IOfflineProvider;
  30738. }
  30739. /** Interface defining initialization parameters for Engine class */
  30740. export interface EngineOptions extends WebGLContextAttributes {
  30741. /**
  30742. * Defines if the engine should no exceed a specified device ratio
  30743. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30744. */
  30745. limitDeviceRatio?: number;
  30746. /**
  30747. * Defines if webvr should be enabled automatically
  30748. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30749. */
  30750. autoEnableWebVR?: boolean;
  30751. /**
  30752. * Defines if webgl2 should be turned off even if supported
  30753. * @see http://doc.babylonjs.com/features/webgl2
  30754. */
  30755. disableWebGL2Support?: boolean;
  30756. /**
  30757. * Defines if webaudio should be initialized as well
  30758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30759. */
  30760. audioEngine?: boolean;
  30761. /**
  30762. * Defines if animations should run using a deterministic lock step
  30763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30764. */
  30765. deterministicLockstep?: boolean;
  30766. /** Defines the maximum steps to use with deterministic lock step mode */
  30767. lockstepMaxSteps?: number;
  30768. /** Defines the seconds between each deterministic lock step */
  30769. timeStep?: number;
  30770. /**
  30771. * Defines that engine should ignore context lost events
  30772. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30773. */
  30774. doNotHandleContextLost?: boolean;
  30775. /**
  30776. * Defines that engine should ignore modifying touch action attribute and style
  30777. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30778. */
  30779. doNotHandleTouchAction?: boolean;
  30780. /**
  30781. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30782. */
  30783. useHighPrecisionFloats?: boolean;
  30784. }
  30785. /**
  30786. * The base engine class (root of all engines)
  30787. */
  30788. export class ThinEngine {
  30789. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30790. static ExceptionList: ({
  30791. key: string;
  30792. capture: string;
  30793. captureConstraint: number;
  30794. targets: string[];
  30795. } | {
  30796. key: string;
  30797. capture: null;
  30798. captureConstraint: null;
  30799. targets: string[];
  30800. })[];
  30801. /** @hidden */
  30802. static _TextureLoaders: IInternalTextureLoader[];
  30803. /**
  30804. * Returns the current npm package of the sdk
  30805. */
  30806. static get NpmPackage(): string;
  30807. /**
  30808. * Returns the current version of the framework
  30809. */
  30810. static get Version(): string;
  30811. /**
  30812. * Returns a string describing the current engine
  30813. */
  30814. get description(): string;
  30815. /**
  30816. * Gets or sets the epsilon value used by collision engine
  30817. */
  30818. static CollisionsEpsilon: number;
  30819. /**
  30820. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30821. */
  30822. static get ShadersRepository(): string;
  30823. static set ShadersRepository(value: string);
  30824. /**
  30825. * Gets or sets the textures that the engine should not attempt to load as compressed
  30826. */
  30827. protected _excludedCompressedTextures: string[];
  30828. /**
  30829. * Filters the compressed texture formats to only include
  30830. * files that are not included in the skippable list
  30831. *
  30832. * @param url the current extension
  30833. * @param textureFormatInUse the current compressed texture format
  30834. * @returns "format" string
  30835. */
  30836. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30837. /** @hidden */
  30838. _shaderProcessor: IShaderProcessor;
  30839. /**
  30840. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30841. */
  30842. forcePOTTextures: boolean;
  30843. /**
  30844. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30845. */
  30846. isFullscreen: boolean;
  30847. /**
  30848. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30849. */
  30850. cullBackFaces: boolean;
  30851. /**
  30852. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30853. */
  30854. renderEvenInBackground: boolean;
  30855. /**
  30856. * Gets or sets a boolean indicating that cache can be kept between frames
  30857. */
  30858. preventCacheWipeBetweenFrames: boolean;
  30859. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30860. validateShaderPrograms: boolean;
  30861. /**
  30862. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30863. * This can provide greater z depth for distant objects.
  30864. */
  30865. useReverseDepthBuffer: boolean;
  30866. /**
  30867. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30868. */
  30869. disableUniformBuffers: boolean;
  30870. /** @hidden */
  30871. _uniformBuffers: UniformBuffer[];
  30872. /**
  30873. * Gets a boolean indicating that the engine supports uniform buffers
  30874. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30875. */
  30876. get supportsUniformBuffers(): boolean;
  30877. /** @hidden */
  30878. _gl: WebGLRenderingContext;
  30879. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30880. protected _windowIsBackground: boolean;
  30881. protected _webGLVersion: number;
  30882. protected _creationOptions: EngineOptions;
  30883. protected _highPrecisionShadersAllowed: boolean;
  30884. /** @hidden */
  30885. get _shouldUseHighPrecisionShader(): boolean;
  30886. /**
  30887. * Gets a boolean indicating that only power of 2 textures are supported
  30888. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30889. */
  30890. get needPOTTextures(): boolean;
  30891. /** @hidden */
  30892. _badOS: boolean;
  30893. /** @hidden */
  30894. _badDesktopOS: boolean;
  30895. private _hardwareScalingLevel;
  30896. /** @hidden */
  30897. _caps: EngineCapabilities;
  30898. private _isStencilEnable;
  30899. private _glVersion;
  30900. private _glRenderer;
  30901. private _glVendor;
  30902. /** @hidden */
  30903. _videoTextureSupported: boolean;
  30904. protected _renderingQueueLaunched: boolean;
  30905. protected _activeRenderLoops: (() => void)[];
  30906. /**
  30907. * Observable signaled when a context lost event is raised
  30908. */
  30909. onContextLostObservable: Observable<ThinEngine>;
  30910. /**
  30911. * Observable signaled when a context restored event is raised
  30912. */
  30913. onContextRestoredObservable: Observable<ThinEngine>;
  30914. private _onContextLost;
  30915. private _onContextRestored;
  30916. protected _contextWasLost: boolean;
  30917. /** @hidden */
  30918. _doNotHandleContextLost: boolean;
  30919. /**
  30920. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30922. */
  30923. get doNotHandleContextLost(): boolean;
  30924. set doNotHandleContextLost(value: boolean);
  30925. /**
  30926. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30927. */
  30928. disableVertexArrayObjects: boolean;
  30929. /** @hidden */
  30930. protected _colorWrite: boolean;
  30931. /** @hidden */
  30932. protected _colorWriteChanged: boolean;
  30933. /** @hidden */
  30934. protected _depthCullingState: DepthCullingState;
  30935. /** @hidden */
  30936. protected _stencilState: StencilState;
  30937. /** @hidden */
  30938. _alphaState: AlphaState;
  30939. /** @hidden */
  30940. _alphaMode: number;
  30941. /** @hidden */
  30942. _alphaEquation: number;
  30943. /** @hidden */
  30944. _internalTexturesCache: InternalTexture[];
  30945. /** @hidden */
  30946. protected _activeChannel: number;
  30947. private _currentTextureChannel;
  30948. /** @hidden */
  30949. protected _boundTexturesCache: {
  30950. [key: string]: Nullable<InternalTexture>;
  30951. };
  30952. /** @hidden */
  30953. protected _currentEffect: Nullable<Effect>;
  30954. /** @hidden */
  30955. protected _currentProgram: Nullable<WebGLProgram>;
  30956. private _compiledEffects;
  30957. private _vertexAttribArraysEnabled;
  30958. /** @hidden */
  30959. protected _cachedViewport: Nullable<IViewportLike>;
  30960. private _cachedVertexArrayObject;
  30961. /** @hidden */
  30962. protected _cachedVertexBuffers: any;
  30963. /** @hidden */
  30964. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30965. /** @hidden */
  30966. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30967. /** @hidden */
  30968. _currentRenderTarget: Nullable<InternalTexture>;
  30969. private _uintIndicesCurrentlySet;
  30970. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30971. /** @hidden */
  30972. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30973. private _currentBufferPointers;
  30974. private _currentInstanceLocations;
  30975. private _currentInstanceBuffers;
  30976. private _textureUnits;
  30977. /** @hidden */
  30978. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30979. /** @hidden */
  30980. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30981. /** @hidden */
  30982. _boundRenderFunction: any;
  30983. private _vaoRecordInProgress;
  30984. private _mustWipeVertexAttributes;
  30985. private _emptyTexture;
  30986. private _emptyCubeTexture;
  30987. private _emptyTexture3D;
  30988. private _emptyTexture2DArray;
  30989. /** @hidden */
  30990. _frameHandler: number;
  30991. private _nextFreeTextureSlots;
  30992. private _maxSimultaneousTextures;
  30993. private _activeRequests;
  30994. protected _texturesSupported: string[];
  30995. /** @hidden */
  30996. _textureFormatInUse: Nullable<string>;
  30997. protected get _supportsHardwareTextureRescaling(): boolean;
  30998. /**
  30999. * Gets the list of texture formats supported
  31000. */
  31001. get texturesSupported(): Array<string>;
  31002. /**
  31003. * Gets the list of texture formats in use
  31004. */
  31005. get textureFormatInUse(): Nullable<string>;
  31006. /**
  31007. * Gets the current viewport
  31008. */
  31009. get currentViewport(): Nullable<IViewportLike>;
  31010. /**
  31011. * Gets the default empty texture
  31012. */
  31013. get emptyTexture(): InternalTexture;
  31014. /**
  31015. * Gets the default empty 3D texture
  31016. */
  31017. get emptyTexture3D(): InternalTexture;
  31018. /**
  31019. * Gets the default empty 2D array texture
  31020. */
  31021. get emptyTexture2DArray(): InternalTexture;
  31022. /**
  31023. * Gets the default empty cube texture
  31024. */
  31025. get emptyCubeTexture(): InternalTexture;
  31026. /**
  31027. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31028. */
  31029. readonly premultipliedAlpha: boolean;
  31030. /**
  31031. * Observable event triggered before each texture is initialized
  31032. */
  31033. onBeforeTextureInitObservable: Observable<Texture>;
  31034. /**
  31035. * Creates a new engine
  31036. * @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
  31037. * @param antialias defines enable antialiasing (default: false)
  31038. * @param options defines further options to be sent to the getContext() function
  31039. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31040. */
  31041. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31042. private _rebuildInternalTextures;
  31043. private _rebuildEffects;
  31044. /**
  31045. * Gets a boolean indicating if all created effects are ready
  31046. * @returns true if all effects are ready
  31047. */
  31048. areAllEffectsReady(): boolean;
  31049. protected _rebuildBuffers(): void;
  31050. private _initGLContext;
  31051. /**
  31052. * Gets version of the current webGL context
  31053. */
  31054. get webGLVersion(): number;
  31055. /**
  31056. * Gets a string idenfifying the name of the class
  31057. * @returns "Engine" string
  31058. */
  31059. getClassName(): string;
  31060. /**
  31061. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31062. */
  31063. get isStencilEnable(): boolean;
  31064. /** @hidden */
  31065. _prepareWorkingCanvas(): void;
  31066. /**
  31067. * Reset the texture cache to empty state
  31068. */
  31069. resetTextureCache(): void;
  31070. /**
  31071. * Gets an object containing information about the current webGL context
  31072. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31073. */
  31074. getGlInfo(): {
  31075. vendor: string;
  31076. renderer: string;
  31077. version: string;
  31078. };
  31079. /**
  31080. * Defines the hardware scaling level.
  31081. * By default the hardware scaling level is computed from the window device ratio.
  31082. * 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.
  31083. * @param level defines the level to use
  31084. */
  31085. setHardwareScalingLevel(level: number): void;
  31086. /**
  31087. * Gets the current hardware scaling level.
  31088. * By default the hardware scaling level is computed from the window device ratio.
  31089. * 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.
  31090. * @returns a number indicating the current hardware scaling level
  31091. */
  31092. getHardwareScalingLevel(): number;
  31093. /**
  31094. * Gets the list of loaded textures
  31095. * @returns an array containing all loaded textures
  31096. */
  31097. getLoadedTexturesCache(): InternalTexture[];
  31098. /**
  31099. * Gets the object containing all engine capabilities
  31100. * @returns the EngineCapabilities object
  31101. */
  31102. getCaps(): EngineCapabilities;
  31103. /**
  31104. * stop executing a render loop function and remove it from the execution array
  31105. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31106. */
  31107. stopRenderLoop(renderFunction?: () => void): void;
  31108. /** @hidden */
  31109. _renderLoop(): void;
  31110. /**
  31111. * Gets the HTML canvas attached with the current webGL context
  31112. * @returns a HTML canvas
  31113. */
  31114. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31115. /**
  31116. * Gets host window
  31117. * @returns the host window object
  31118. */
  31119. getHostWindow(): Nullable<Window>;
  31120. /**
  31121. * Gets the current render width
  31122. * @param useScreen defines if screen size must be used (or the current render target if any)
  31123. * @returns a number defining the current render width
  31124. */
  31125. getRenderWidth(useScreen?: boolean): number;
  31126. /**
  31127. * Gets the current render height
  31128. * @param useScreen defines if screen size must be used (or the current render target if any)
  31129. * @returns a number defining the current render height
  31130. */
  31131. getRenderHeight(useScreen?: boolean): number;
  31132. /**
  31133. * Can be used to override the current requestAnimationFrame requester.
  31134. * @hidden
  31135. */
  31136. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31137. /**
  31138. * Register and execute a render loop. The engine can have more than one render function
  31139. * @param renderFunction defines the function to continuously execute
  31140. */
  31141. runRenderLoop(renderFunction: () => void): void;
  31142. /**
  31143. * Clear the current render buffer or the current render target (if any is set up)
  31144. * @param color defines the color to use
  31145. * @param backBuffer defines if the back buffer must be cleared
  31146. * @param depth defines if the depth buffer must be cleared
  31147. * @param stencil defines if the stencil buffer must be cleared
  31148. */
  31149. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31150. private _viewportCached;
  31151. /** @hidden */
  31152. _viewport(x: number, y: number, width: number, height: number): void;
  31153. /**
  31154. * Set the WebGL's viewport
  31155. * @param viewport defines the viewport element to be used
  31156. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31157. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31158. */
  31159. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31160. /**
  31161. * Begin a new frame
  31162. */
  31163. beginFrame(): void;
  31164. /**
  31165. * Enf the current frame
  31166. */
  31167. endFrame(): void;
  31168. /**
  31169. * Resize the view according to the canvas' size
  31170. */
  31171. resize(): void;
  31172. /**
  31173. * Force a specific size of the canvas
  31174. * @param width defines the new canvas' width
  31175. * @param height defines the new canvas' height
  31176. */
  31177. setSize(width: number, height: number): void;
  31178. /**
  31179. * Binds the frame buffer to the specified texture.
  31180. * @param texture The texture to render to or null for the default canvas
  31181. * @param faceIndex The face of the texture to render to in case of cube texture
  31182. * @param requiredWidth The width of the target to render to
  31183. * @param requiredHeight The height of the target to render to
  31184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31185. * @param lodLevel defines the lod level to bind to the frame buffer
  31186. * @param layer defines the 2d array index to bind to frame buffer to
  31187. */
  31188. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31189. /** @hidden */
  31190. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31191. /**
  31192. * Unbind the current render target texture from the webGL context
  31193. * @param texture defines the render target texture to unbind
  31194. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31195. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31196. */
  31197. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31198. /**
  31199. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31200. */
  31201. flushFramebuffer(): void;
  31202. /**
  31203. * Unbind the current render target and bind the default framebuffer
  31204. */
  31205. restoreDefaultFramebuffer(): void;
  31206. /** @hidden */
  31207. protected _resetVertexBufferBinding(): void;
  31208. /**
  31209. * Creates a vertex buffer
  31210. * @param data the data for the vertex buffer
  31211. * @returns the new WebGL static buffer
  31212. */
  31213. createVertexBuffer(data: DataArray): DataBuffer;
  31214. private _createVertexBuffer;
  31215. /**
  31216. * Creates a dynamic vertex buffer
  31217. * @param data the data for the dynamic vertex buffer
  31218. * @returns the new WebGL dynamic buffer
  31219. */
  31220. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31221. protected _resetIndexBufferBinding(): void;
  31222. /**
  31223. * Creates a new index buffer
  31224. * @param indices defines the content of the index buffer
  31225. * @param updatable defines if the index buffer must be updatable
  31226. * @returns a new webGL buffer
  31227. */
  31228. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31229. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31230. /**
  31231. * Bind a webGL buffer to the webGL context
  31232. * @param buffer defines the buffer to bind
  31233. */
  31234. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31235. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31236. private bindBuffer;
  31237. /**
  31238. * update the bound buffer with the given data
  31239. * @param data defines the data to update
  31240. */
  31241. updateArrayBuffer(data: Float32Array): void;
  31242. private _vertexAttribPointer;
  31243. private _bindIndexBufferWithCache;
  31244. private _bindVertexBuffersAttributes;
  31245. /**
  31246. * Records a vertex array object
  31247. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31248. * @param vertexBuffers defines the list of vertex buffers to store
  31249. * @param indexBuffer defines the index buffer to store
  31250. * @param effect defines the effect to store
  31251. * @returns the new vertex array object
  31252. */
  31253. recordVertexArrayObject(vertexBuffers: {
  31254. [key: string]: VertexBuffer;
  31255. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31256. /**
  31257. * Bind a specific vertex array object
  31258. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31259. * @param vertexArrayObject defines the vertex array object to bind
  31260. * @param indexBuffer defines the index buffer to bind
  31261. */
  31262. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31263. /**
  31264. * Bind webGl buffers directly to the webGL context
  31265. * @param vertexBuffer defines the vertex buffer to bind
  31266. * @param indexBuffer defines the index buffer to bind
  31267. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31268. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31269. * @param effect defines the effect associated with the vertex buffer
  31270. */
  31271. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31272. private _unbindVertexArrayObject;
  31273. /**
  31274. * Bind a list of vertex buffers to the webGL context
  31275. * @param vertexBuffers defines the list of vertex buffers to bind
  31276. * @param indexBuffer defines the index buffer to bind
  31277. * @param effect defines the effect associated with the vertex buffers
  31278. */
  31279. bindBuffers(vertexBuffers: {
  31280. [key: string]: Nullable<VertexBuffer>;
  31281. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31282. /**
  31283. * Unbind all instance attributes
  31284. */
  31285. unbindInstanceAttributes(): void;
  31286. /**
  31287. * Release and free the memory of a vertex array object
  31288. * @param vao defines the vertex array object to delete
  31289. */
  31290. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31291. /** @hidden */
  31292. _releaseBuffer(buffer: DataBuffer): boolean;
  31293. protected _deleteBuffer(buffer: DataBuffer): void;
  31294. /**
  31295. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31296. * @param instancesBuffer defines the webGL buffer to update and bind
  31297. * @param data defines the data to store in the buffer
  31298. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31299. */
  31300. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31301. /**
  31302. * Bind the content of a webGL buffer used with instanciation
  31303. * @param instancesBuffer defines the webGL buffer to bind
  31304. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31305. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31306. */
  31307. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31308. /**
  31309. * Disable the instance attribute corresponding to the name in parameter
  31310. * @param name defines the name of the attribute to disable
  31311. */
  31312. disableInstanceAttributeByName(name: string): void;
  31313. /**
  31314. * Disable the instance attribute corresponding to the location in parameter
  31315. * @param attributeLocation defines the attribute location of the attribute to disable
  31316. */
  31317. disableInstanceAttribute(attributeLocation: number): void;
  31318. /**
  31319. * Disable the attribute corresponding to the location in parameter
  31320. * @param attributeLocation defines the attribute location of the attribute to disable
  31321. */
  31322. disableAttributeByIndex(attributeLocation: number): void;
  31323. /**
  31324. * Send a draw order
  31325. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31326. * @param indexStart defines the starting index
  31327. * @param indexCount defines the number of index to draw
  31328. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31329. */
  31330. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31331. /**
  31332. * Draw a list of points
  31333. * @param verticesStart defines the index of first vertex to draw
  31334. * @param verticesCount defines the count of vertices to draw
  31335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31336. */
  31337. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31338. /**
  31339. * Draw a list of unindexed primitives
  31340. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31341. * @param verticesStart defines the index of first vertex to draw
  31342. * @param verticesCount defines the count of vertices to draw
  31343. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31344. */
  31345. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31346. /**
  31347. * Draw a list of indexed primitives
  31348. * @param fillMode defines the primitive to use
  31349. * @param indexStart defines the starting index
  31350. * @param indexCount defines the number of index to draw
  31351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31352. */
  31353. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31354. /**
  31355. * Draw a list of unindexed primitives
  31356. * @param fillMode defines the primitive to use
  31357. * @param verticesStart defines the index of first vertex to draw
  31358. * @param verticesCount defines the count of vertices to draw
  31359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31360. */
  31361. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31362. private _drawMode;
  31363. /** @hidden */
  31364. protected _reportDrawCall(): void;
  31365. /** @hidden */
  31366. _releaseEffect(effect: Effect): void;
  31367. /** @hidden */
  31368. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31369. /**
  31370. * Create a new effect (used to store vertex/fragment shaders)
  31371. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31372. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31373. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31374. * @param samplers defines an array of string used to represent textures
  31375. * @param defines defines the string containing the defines to use to compile the shaders
  31376. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31377. * @param onCompiled defines a function to call when the effect creation is successful
  31378. * @param onError defines a function to call when the effect creation has failed
  31379. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31380. * @returns the new Effect
  31381. */
  31382. 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;
  31383. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31384. private _compileShader;
  31385. private _compileRawShader;
  31386. /**
  31387. * Directly creates a webGL program
  31388. * @param pipelineContext defines the pipeline context to attach to
  31389. * @param vertexCode defines the vertex shader code to use
  31390. * @param fragmentCode defines the fragment shader code to use
  31391. * @param context defines the webGL context to use (if not set, the current one will be used)
  31392. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31393. * @returns the new webGL program
  31394. */
  31395. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31396. /**
  31397. * Creates a webGL program
  31398. * @param pipelineContext defines the pipeline context to attach to
  31399. * @param vertexCode defines the vertex shader code to use
  31400. * @param fragmentCode defines the fragment shader code to use
  31401. * @param defines defines the string containing the defines to use to compile the shaders
  31402. * @param context defines the webGL context to use (if not set, the current one will be used)
  31403. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31404. * @returns the new webGL program
  31405. */
  31406. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31407. /**
  31408. * Creates a new pipeline context
  31409. * @returns the new pipeline
  31410. */
  31411. createPipelineContext(): IPipelineContext;
  31412. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31413. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31414. /** @hidden */
  31415. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31416. /** @hidden */
  31417. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31418. /** @hidden */
  31419. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31420. /**
  31421. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31422. * @param pipelineContext defines the pipeline context to use
  31423. * @param uniformsNames defines the list of uniform names
  31424. * @returns an array of webGL uniform locations
  31425. */
  31426. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31427. /**
  31428. * Gets the lsit of active attributes for a given webGL program
  31429. * @param pipelineContext defines the pipeline context to use
  31430. * @param attributesNames defines the list of attribute names to get
  31431. * @returns an array of indices indicating the offset of each attribute
  31432. */
  31433. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31434. /**
  31435. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31436. * @param effect defines the effect to activate
  31437. */
  31438. enableEffect(effect: Nullable<Effect>): void;
  31439. /**
  31440. * Set the value of an uniform to a number (int)
  31441. * @param uniform defines the webGL uniform location where to store the value
  31442. * @param value defines the int number to store
  31443. */
  31444. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31445. /**
  31446. * Set the value of an uniform to an array of int32
  31447. * @param uniform defines the webGL uniform location where to store the value
  31448. * @param array defines the array of int32 to store
  31449. */
  31450. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31451. /**
  31452. * Set the value of an uniform to an array of int32 (stored as vec2)
  31453. * @param uniform defines the webGL uniform location where to store the value
  31454. * @param array defines the array of int32 to store
  31455. */
  31456. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31457. /**
  31458. * Set the value of an uniform to an array of int32 (stored as vec3)
  31459. * @param uniform defines the webGL uniform location where to store the value
  31460. * @param array defines the array of int32 to store
  31461. */
  31462. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31463. /**
  31464. * Set the value of an uniform to an array of int32 (stored as vec4)
  31465. * @param uniform defines the webGL uniform location where to store the value
  31466. * @param array defines the array of int32 to store
  31467. */
  31468. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31469. /**
  31470. * Set the value of an uniform to an array of number
  31471. * @param uniform defines the webGL uniform location where to store the value
  31472. * @param array defines the array of number to store
  31473. */
  31474. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31475. /**
  31476. * Set the value of an uniform to an array of number (stored as vec2)
  31477. * @param uniform defines the webGL uniform location where to store the value
  31478. * @param array defines the array of number to store
  31479. */
  31480. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31481. /**
  31482. * Set the value of an uniform to an array of number (stored as vec3)
  31483. * @param uniform defines the webGL uniform location where to store the value
  31484. * @param array defines the array of number to store
  31485. */
  31486. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31487. /**
  31488. * Set the value of an uniform to an array of number (stored as vec4)
  31489. * @param uniform defines the webGL uniform location where to store the value
  31490. * @param array defines the array of number to store
  31491. */
  31492. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31493. /**
  31494. * Set the value of an uniform to an array of float32 (stored as matrices)
  31495. * @param uniform defines the webGL uniform location where to store the value
  31496. * @param matrices defines the array of float32 to store
  31497. */
  31498. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31499. /**
  31500. * Set the value of an uniform to a matrix (3x3)
  31501. * @param uniform defines the webGL uniform location where to store the value
  31502. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31503. */
  31504. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31505. /**
  31506. * Set the value of an uniform to a matrix (2x2)
  31507. * @param uniform defines the webGL uniform location where to store the value
  31508. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31509. */
  31510. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31511. /**
  31512. * Set the value of an uniform to a number (float)
  31513. * @param uniform defines the webGL uniform location where to store the value
  31514. * @param value defines the float number to store
  31515. */
  31516. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31517. /**
  31518. * Set the value of an uniform to a vec2
  31519. * @param uniform defines the webGL uniform location where to store the value
  31520. * @param x defines the 1st component of the value
  31521. * @param y defines the 2nd component of the value
  31522. */
  31523. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31524. /**
  31525. * Set the value of an uniform to a vec3
  31526. * @param uniform defines the webGL uniform location where to store the value
  31527. * @param x defines the 1st component of the value
  31528. * @param y defines the 2nd component of the value
  31529. * @param z defines the 3rd component of the value
  31530. */
  31531. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31532. /**
  31533. * Set the value of an uniform to a vec4
  31534. * @param uniform defines the webGL uniform location where to store the value
  31535. * @param x defines the 1st component of the value
  31536. * @param y defines the 2nd component of the value
  31537. * @param z defines the 3rd component of the value
  31538. * @param w defines the 4th component of the value
  31539. */
  31540. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31541. /**
  31542. * Apply all cached states (depth, culling, stencil and alpha)
  31543. */
  31544. applyStates(): void;
  31545. /**
  31546. * Enable or disable color writing
  31547. * @param enable defines the state to set
  31548. */
  31549. setColorWrite(enable: boolean): void;
  31550. /**
  31551. * Gets a boolean indicating if color writing is enabled
  31552. * @returns the current color writing state
  31553. */
  31554. getColorWrite(): boolean;
  31555. /**
  31556. * Gets the depth culling state manager
  31557. */
  31558. get depthCullingState(): DepthCullingState;
  31559. /**
  31560. * Gets the alpha state manager
  31561. */
  31562. get alphaState(): AlphaState;
  31563. /**
  31564. * Gets the stencil state manager
  31565. */
  31566. get stencilState(): StencilState;
  31567. /**
  31568. * Clears the list of texture accessible through engine.
  31569. * This can help preventing texture load conflict due to name collision.
  31570. */
  31571. clearInternalTexturesCache(): void;
  31572. /**
  31573. * Force the entire cache to be cleared
  31574. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31575. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31576. */
  31577. wipeCaches(bruteForce?: boolean): void;
  31578. /** @hidden */
  31579. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31580. min: number;
  31581. mag: number;
  31582. };
  31583. /** @hidden */
  31584. _createTexture(): WebGLTexture;
  31585. /**
  31586. * Usually called from Texture.ts.
  31587. * Passed information to create a WebGLTexture
  31588. * @param urlArg defines a value which contains one of the following:
  31589. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31590. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31591. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31592. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31593. * @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)
  31594. * @param scene needed for loading to the correct scene
  31595. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31596. * @param onLoad optional callback to be called upon successful completion
  31597. * @param onError optional callback to be called upon failure
  31598. * @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
  31599. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31600. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31601. * @param forcedExtension defines the extension to use to pick the right loader
  31602. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31603. * @param mimeType defines an optional mime type
  31604. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31605. */
  31606. 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;
  31607. /**
  31608. * Loads an image as an HTMLImageElement.
  31609. * @param input url string, ArrayBuffer, or Blob to load
  31610. * @param onLoad callback called when the image successfully loads
  31611. * @param onError callback called when the image fails to load
  31612. * @param offlineProvider offline provider for caching
  31613. * @param mimeType optional mime type
  31614. * @returns the HTMLImageElement of the loaded image
  31615. * @hidden
  31616. */
  31617. 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>;
  31618. /**
  31619. * @hidden
  31620. */
  31621. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31622. /**
  31623. * Creates a raw texture
  31624. * @param data defines the data to store in the texture
  31625. * @param width defines the width of the texture
  31626. * @param height defines the height of the texture
  31627. * @param format defines the format of the data
  31628. * @param generateMipMaps defines if the engine should generate the mip levels
  31629. * @param invertY defines if data must be stored with Y axis inverted
  31630. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31631. * @param compression defines the compression used (null by default)
  31632. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31633. * @returns the raw texture inside an InternalTexture
  31634. */
  31635. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31636. /**
  31637. * Creates a new raw cube texture
  31638. * @param data defines the array of data to use to create each face
  31639. * @param size defines the size of the textures
  31640. * @param format defines the format of the data
  31641. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31642. * @param generateMipMaps defines if the engine should generate the mip levels
  31643. * @param invertY defines if data must be stored with Y axis inverted
  31644. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31645. * @param compression defines the compression used (null by default)
  31646. * @returns the cube texture as an InternalTexture
  31647. */
  31648. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31649. /**
  31650. * Creates a new raw 3D texture
  31651. * @param data defines the data used to create the texture
  31652. * @param width defines the width of the texture
  31653. * @param height defines the height of the texture
  31654. * @param depth defines the depth of the texture
  31655. * @param format defines the format of the texture
  31656. * @param generateMipMaps defines if the engine must generate mip levels
  31657. * @param invertY defines if data must be stored with Y axis inverted
  31658. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31659. * @param compression defines the compressed used (can be null)
  31660. * @param textureType defines the compressed used (can be null)
  31661. * @returns a new raw 3D texture (stored in an InternalTexture)
  31662. */
  31663. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31664. /**
  31665. * Creates a new raw 2D array texture
  31666. * @param data defines the data used to create the texture
  31667. * @param width defines the width of the texture
  31668. * @param height defines the height of the texture
  31669. * @param depth defines the number of layers of the texture
  31670. * @param format defines the format of the texture
  31671. * @param generateMipMaps defines if the engine must generate mip levels
  31672. * @param invertY defines if data must be stored with Y axis inverted
  31673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31674. * @param compression defines the compressed used (can be null)
  31675. * @param textureType defines the compressed used (can be null)
  31676. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31677. */
  31678. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31679. private _unpackFlipYCached;
  31680. /**
  31681. * In case you are sharing the context with other applications, it might
  31682. * be interested to not cache the unpack flip y state to ensure a consistent
  31683. * value would be set.
  31684. */
  31685. enableUnpackFlipYCached: boolean;
  31686. /** @hidden */
  31687. _unpackFlipY(value: boolean): void;
  31688. /** @hidden */
  31689. _getUnpackAlignement(): number;
  31690. private _getTextureTarget;
  31691. /**
  31692. * Update the sampling mode of a given texture
  31693. * @param samplingMode defines the required sampling mode
  31694. * @param texture defines the texture to update
  31695. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31696. */
  31697. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31698. /**
  31699. * Update the sampling mode of a given texture
  31700. * @param texture defines the texture to update
  31701. * @param wrapU defines the texture wrap mode of the u coordinates
  31702. * @param wrapV defines the texture wrap mode of the v coordinates
  31703. * @param wrapR defines the texture wrap mode of the r coordinates
  31704. */
  31705. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31706. /** @hidden */
  31707. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31708. width: number;
  31709. height: number;
  31710. layers?: number;
  31711. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31712. /** @hidden */
  31713. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31714. /** @hidden */
  31715. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31716. /**
  31717. * Update a portion of an internal texture
  31718. * @param texture defines the texture to update
  31719. * @param imageData defines the data to store into the texture
  31720. * @param xOffset defines the x coordinates of the update rectangle
  31721. * @param yOffset defines the y coordinates of the update rectangle
  31722. * @param width defines the width of the update rectangle
  31723. * @param height defines the height of the update rectangle
  31724. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31725. * @param lod defines the lod level to update (0 by default)
  31726. */
  31727. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31728. /** @hidden */
  31729. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31730. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31731. private _prepareWebGLTexture;
  31732. /** @hidden */
  31733. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31734. private _getDepthStencilBuffer;
  31735. /** @hidden */
  31736. _releaseFramebufferObjects(texture: InternalTexture): void;
  31737. /** @hidden */
  31738. _releaseTexture(texture: InternalTexture): void;
  31739. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31740. protected _setProgram(program: WebGLProgram): void;
  31741. protected _boundUniforms: {
  31742. [key: number]: WebGLUniformLocation;
  31743. };
  31744. /**
  31745. * Binds an effect to the webGL context
  31746. * @param effect defines the effect to bind
  31747. */
  31748. bindSamplers(effect: Effect): void;
  31749. private _activateCurrentTexture;
  31750. /** @hidden */
  31751. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31752. /** @hidden */
  31753. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31754. /**
  31755. * Unbind all textures from the webGL context
  31756. */
  31757. unbindAllTextures(): void;
  31758. /**
  31759. * Sets a texture to the according uniform.
  31760. * @param channel The texture channel
  31761. * @param uniform The uniform to set
  31762. * @param texture The texture to apply
  31763. */
  31764. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31765. private _bindSamplerUniformToChannel;
  31766. private _getTextureWrapMode;
  31767. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31768. /**
  31769. * Sets an array of texture to the webGL context
  31770. * @param channel defines the channel where the texture array must be set
  31771. * @param uniform defines the associated uniform location
  31772. * @param textures defines the array of textures to bind
  31773. */
  31774. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31775. /** @hidden */
  31776. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31777. private _setTextureParameterFloat;
  31778. private _setTextureParameterInteger;
  31779. /**
  31780. * Unbind all vertex attributes from the webGL context
  31781. */
  31782. unbindAllAttributes(): void;
  31783. /**
  31784. * 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
  31785. */
  31786. releaseEffects(): void;
  31787. /**
  31788. * Dispose and release all associated resources
  31789. */
  31790. dispose(): void;
  31791. /**
  31792. * Attach a new callback raised when context lost event is fired
  31793. * @param callback defines the callback to call
  31794. */
  31795. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31796. /**
  31797. * Attach a new callback raised when context restored event is fired
  31798. * @param callback defines the callback to call
  31799. */
  31800. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31801. /**
  31802. * Get the current error code of the webGL context
  31803. * @returns the error code
  31804. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31805. */
  31806. getError(): number;
  31807. private _canRenderToFloatFramebuffer;
  31808. private _canRenderToHalfFloatFramebuffer;
  31809. private _canRenderToFramebuffer;
  31810. /** @hidden */
  31811. _getWebGLTextureType(type: number): number;
  31812. /** @hidden */
  31813. _getInternalFormat(format: number): number;
  31814. /** @hidden */
  31815. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31816. /** @hidden */
  31817. _getRGBAMultiSampleBufferFormat(type: number): number;
  31818. /** @hidden */
  31819. _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;
  31820. /**
  31821. * Loads a file from a url
  31822. * @param url url to load
  31823. * @param onSuccess callback called when the file successfully loads
  31824. * @param onProgress callback called while file is loading (if the server supports this mode)
  31825. * @param offlineProvider defines the offline provider for caching
  31826. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31827. * @param onError callback called when the file fails to load
  31828. * @returns a file request object
  31829. * @hidden
  31830. */
  31831. 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;
  31832. /**
  31833. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31834. * @param x defines the x coordinate of the rectangle where pixels must be read
  31835. * @param y defines the y coordinate of the rectangle where pixels must be read
  31836. * @param width defines the width of the rectangle where pixels must be read
  31837. * @param height defines the height of the rectangle where pixels must be read
  31838. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31839. * @returns a Uint8Array containing RGBA colors
  31840. */
  31841. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31842. private static _isSupported;
  31843. /**
  31844. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31845. * @returns true if the engine can be created
  31846. * @ignorenaming
  31847. */
  31848. static isSupported(): boolean;
  31849. /**
  31850. * Find the next highest power of two.
  31851. * @param x Number to start search from.
  31852. * @return Next highest power of two.
  31853. */
  31854. static CeilingPOT(x: number): number;
  31855. /**
  31856. * Find the next lowest power of two.
  31857. * @param x Number to start search from.
  31858. * @return Next lowest power of two.
  31859. */
  31860. static FloorPOT(x: number): number;
  31861. /**
  31862. * Find the nearest power of two.
  31863. * @param x Number to start search from.
  31864. * @return Next nearest power of two.
  31865. */
  31866. static NearestPOT(x: number): number;
  31867. /**
  31868. * Get the closest exponent of two
  31869. * @param value defines the value to approximate
  31870. * @param max defines the maximum value to return
  31871. * @param mode defines how to define the closest value
  31872. * @returns closest exponent of two of the given value
  31873. */
  31874. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31875. /**
  31876. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31877. * @param func - the function to be called
  31878. * @param requester - the object that will request the next frame. Falls back to window.
  31879. * @returns frame number
  31880. */
  31881. static QueueNewFrame(func: () => void, requester?: any): number;
  31882. /**
  31883. * Gets host document
  31884. * @returns the host document object
  31885. */
  31886. getHostDocument(): Nullable<Document>;
  31887. }
  31888. }
  31889. declare module BABYLON {
  31890. /**
  31891. * Class representing spherical harmonics coefficients to the 3rd degree
  31892. */
  31893. export class SphericalHarmonics {
  31894. /**
  31895. * Defines whether or not the harmonics have been prescaled for rendering.
  31896. */
  31897. preScaled: boolean;
  31898. /**
  31899. * The l0,0 coefficients of the spherical harmonics
  31900. */
  31901. l00: Vector3;
  31902. /**
  31903. * The l1,-1 coefficients of the spherical harmonics
  31904. */
  31905. l1_1: Vector3;
  31906. /**
  31907. * The l1,0 coefficients of the spherical harmonics
  31908. */
  31909. l10: Vector3;
  31910. /**
  31911. * The l1,1 coefficients of the spherical harmonics
  31912. */
  31913. l11: Vector3;
  31914. /**
  31915. * The l2,-2 coefficients of the spherical harmonics
  31916. */
  31917. l2_2: Vector3;
  31918. /**
  31919. * The l2,-1 coefficients of the spherical harmonics
  31920. */
  31921. l2_1: Vector3;
  31922. /**
  31923. * The l2,0 coefficients of the spherical harmonics
  31924. */
  31925. l20: Vector3;
  31926. /**
  31927. * The l2,1 coefficients of the spherical harmonics
  31928. */
  31929. l21: Vector3;
  31930. /**
  31931. * The l2,2 coefficients of the spherical harmonics
  31932. */
  31933. l22: Vector3;
  31934. /**
  31935. * Adds a light to the spherical harmonics
  31936. * @param direction the direction of the light
  31937. * @param color the color of the light
  31938. * @param deltaSolidAngle the delta solid angle of the light
  31939. */
  31940. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31941. /**
  31942. * Scales the spherical harmonics by the given amount
  31943. * @param scale the amount to scale
  31944. */
  31945. scaleInPlace(scale: number): void;
  31946. /**
  31947. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31948. *
  31949. * ```
  31950. * E_lm = A_l * L_lm
  31951. * ```
  31952. *
  31953. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31954. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31955. * the scaling factors are given in equation 9.
  31956. */
  31957. convertIncidentRadianceToIrradiance(): void;
  31958. /**
  31959. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31960. *
  31961. * ```
  31962. * L = (1/pi) * E * rho
  31963. * ```
  31964. *
  31965. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31966. */
  31967. convertIrradianceToLambertianRadiance(): void;
  31968. /**
  31969. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31970. * required operations at run time.
  31971. *
  31972. * This is simply done by scaling back the SH with Ylm constants parameter.
  31973. * The trigonometric part being applied by the shader at run time.
  31974. */
  31975. preScaleForRendering(): void;
  31976. /**
  31977. * Constructs a spherical harmonics from an array.
  31978. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31979. * @returns the spherical harmonics
  31980. */
  31981. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31982. /**
  31983. * Gets the spherical harmonics from polynomial
  31984. * @param polynomial the spherical polynomial
  31985. * @returns the spherical harmonics
  31986. */
  31987. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31988. }
  31989. /**
  31990. * Class representing spherical polynomial coefficients to the 3rd degree
  31991. */
  31992. export class SphericalPolynomial {
  31993. private _harmonics;
  31994. /**
  31995. * The spherical harmonics used to create the polynomials.
  31996. */
  31997. get preScaledHarmonics(): SphericalHarmonics;
  31998. /**
  31999. * The x coefficients of the spherical polynomial
  32000. */
  32001. x: Vector3;
  32002. /**
  32003. * The y coefficients of the spherical polynomial
  32004. */
  32005. y: Vector3;
  32006. /**
  32007. * The z coefficients of the spherical polynomial
  32008. */
  32009. z: Vector3;
  32010. /**
  32011. * The xx coefficients of the spherical polynomial
  32012. */
  32013. xx: Vector3;
  32014. /**
  32015. * The yy coefficients of the spherical polynomial
  32016. */
  32017. yy: Vector3;
  32018. /**
  32019. * The zz coefficients of the spherical polynomial
  32020. */
  32021. zz: Vector3;
  32022. /**
  32023. * The xy coefficients of the spherical polynomial
  32024. */
  32025. xy: Vector3;
  32026. /**
  32027. * The yz coefficients of the spherical polynomial
  32028. */
  32029. yz: Vector3;
  32030. /**
  32031. * The zx coefficients of the spherical polynomial
  32032. */
  32033. zx: Vector3;
  32034. /**
  32035. * Adds an ambient color to the spherical polynomial
  32036. * @param color the color to add
  32037. */
  32038. addAmbient(color: Color3): void;
  32039. /**
  32040. * Scales the spherical polynomial by the given amount
  32041. * @param scale the amount to scale
  32042. */
  32043. scaleInPlace(scale: number): void;
  32044. /**
  32045. * Gets the spherical polynomial from harmonics
  32046. * @param harmonics the spherical harmonics
  32047. * @returns the spherical polynomial
  32048. */
  32049. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32050. /**
  32051. * Constructs a spherical polynomial from an array.
  32052. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32053. * @returns the spherical polynomial
  32054. */
  32055. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32056. }
  32057. }
  32058. declare module BABYLON {
  32059. /**
  32060. * Defines the source of the internal texture
  32061. */
  32062. export enum InternalTextureSource {
  32063. /**
  32064. * The source of the texture data is unknown
  32065. */
  32066. Unknown = 0,
  32067. /**
  32068. * Texture data comes from an URL
  32069. */
  32070. Url = 1,
  32071. /**
  32072. * Texture data is only used for temporary storage
  32073. */
  32074. Temp = 2,
  32075. /**
  32076. * Texture data comes from raw data (ArrayBuffer)
  32077. */
  32078. Raw = 3,
  32079. /**
  32080. * Texture content is dynamic (video or dynamic texture)
  32081. */
  32082. Dynamic = 4,
  32083. /**
  32084. * Texture content is generated by rendering to it
  32085. */
  32086. RenderTarget = 5,
  32087. /**
  32088. * Texture content is part of a multi render target process
  32089. */
  32090. MultiRenderTarget = 6,
  32091. /**
  32092. * Texture data comes from a cube data file
  32093. */
  32094. Cube = 7,
  32095. /**
  32096. * Texture data comes from a raw cube data
  32097. */
  32098. CubeRaw = 8,
  32099. /**
  32100. * Texture data come from a prefiltered cube data file
  32101. */
  32102. CubePrefiltered = 9,
  32103. /**
  32104. * Texture content is raw 3D data
  32105. */
  32106. Raw3D = 10,
  32107. /**
  32108. * Texture content is raw 2D array data
  32109. */
  32110. Raw2DArray = 11,
  32111. /**
  32112. * Texture content is a depth texture
  32113. */
  32114. Depth = 12,
  32115. /**
  32116. * Texture data comes from a raw cube data encoded with RGBD
  32117. */
  32118. CubeRawRGBD = 13
  32119. }
  32120. /**
  32121. * Class used to store data associated with WebGL texture data for the engine
  32122. * This class should not be used directly
  32123. */
  32124. export class InternalTexture {
  32125. /** @hidden */
  32126. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32127. /**
  32128. * Defines if the texture is ready
  32129. */
  32130. isReady: boolean;
  32131. /**
  32132. * Defines if the texture is a cube texture
  32133. */
  32134. isCube: boolean;
  32135. /**
  32136. * Defines if the texture contains 3D data
  32137. */
  32138. is3D: boolean;
  32139. /**
  32140. * Defines if the texture contains 2D array data
  32141. */
  32142. is2DArray: boolean;
  32143. /**
  32144. * Defines if the texture contains multiview data
  32145. */
  32146. isMultiview: boolean;
  32147. /**
  32148. * Gets the URL used to load this texture
  32149. */
  32150. url: string;
  32151. /**
  32152. * Gets the sampling mode of the texture
  32153. */
  32154. samplingMode: number;
  32155. /**
  32156. * Gets a boolean indicating if the texture needs mipmaps generation
  32157. */
  32158. generateMipMaps: boolean;
  32159. /**
  32160. * Gets the number of samples used by the texture (WebGL2+ only)
  32161. */
  32162. samples: number;
  32163. /**
  32164. * Gets the type of the texture (int, float...)
  32165. */
  32166. type: number;
  32167. /**
  32168. * Gets the format of the texture (RGB, RGBA...)
  32169. */
  32170. format: number;
  32171. /**
  32172. * Observable called when the texture is loaded
  32173. */
  32174. onLoadedObservable: Observable<InternalTexture>;
  32175. /**
  32176. * Gets the width of the texture
  32177. */
  32178. width: number;
  32179. /**
  32180. * Gets the height of the texture
  32181. */
  32182. height: number;
  32183. /**
  32184. * Gets the depth of the texture
  32185. */
  32186. depth: number;
  32187. /**
  32188. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32189. */
  32190. baseWidth: number;
  32191. /**
  32192. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32193. */
  32194. baseHeight: number;
  32195. /**
  32196. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32197. */
  32198. baseDepth: number;
  32199. /**
  32200. * Gets a boolean indicating if the texture is inverted on Y axis
  32201. */
  32202. invertY: boolean;
  32203. /** @hidden */
  32204. _invertVScale: boolean;
  32205. /** @hidden */
  32206. _associatedChannel: number;
  32207. /** @hidden */
  32208. _source: InternalTextureSource;
  32209. /** @hidden */
  32210. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32211. /** @hidden */
  32212. _bufferView: Nullable<ArrayBufferView>;
  32213. /** @hidden */
  32214. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32215. /** @hidden */
  32216. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32217. /** @hidden */
  32218. _size: number;
  32219. /** @hidden */
  32220. _extension: string;
  32221. /** @hidden */
  32222. _files: Nullable<string[]>;
  32223. /** @hidden */
  32224. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32225. /** @hidden */
  32226. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32227. /** @hidden */
  32228. _framebuffer: Nullable<WebGLFramebuffer>;
  32229. /** @hidden */
  32230. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32231. /** @hidden */
  32232. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32233. /** @hidden */
  32234. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32235. /** @hidden */
  32236. _attachments: Nullable<number[]>;
  32237. /** @hidden */
  32238. _cachedCoordinatesMode: Nullable<number>;
  32239. /** @hidden */
  32240. _cachedWrapU: Nullable<number>;
  32241. /** @hidden */
  32242. _cachedWrapV: Nullable<number>;
  32243. /** @hidden */
  32244. _cachedWrapR: Nullable<number>;
  32245. /** @hidden */
  32246. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32247. /** @hidden */
  32248. _isDisabled: boolean;
  32249. /** @hidden */
  32250. _compression: Nullable<string>;
  32251. /** @hidden */
  32252. _generateStencilBuffer: boolean;
  32253. /** @hidden */
  32254. _generateDepthBuffer: boolean;
  32255. /** @hidden */
  32256. _comparisonFunction: number;
  32257. /** @hidden */
  32258. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32259. /** @hidden */
  32260. _lodGenerationScale: number;
  32261. /** @hidden */
  32262. _lodGenerationOffset: number;
  32263. /** @hidden */
  32264. _depthStencilTexture: Nullable<InternalTexture>;
  32265. /** @hidden */
  32266. _colorTextureArray: Nullable<WebGLTexture>;
  32267. /** @hidden */
  32268. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32269. /** @hidden */
  32270. _lodTextureHigh: Nullable<BaseTexture>;
  32271. /** @hidden */
  32272. _lodTextureMid: Nullable<BaseTexture>;
  32273. /** @hidden */
  32274. _lodTextureLow: Nullable<BaseTexture>;
  32275. /** @hidden */
  32276. _isRGBD: boolean;
  32277. /** @hidden */
  32278. _linearSpecularLOD: boolean;
  32279. /** @hidden */
  32280. _irradianceTexture: Nullable<BaseTexture>;
  32281. /** @hidden */
  32282. _webGLTexture: Nullable<WebGLTexture>;
  32283. /** @hidden */
  32284. _references: number;
  32285. private _engine;
  32286. /**
  32287. * Gets the Engine the texture belongs to.
  32288. * @returns The babylon engine
  32289. */
  32290. getEngine(): ThinEngine;
  32291. /**
  32292. * Gets the data source type of the texture
  32293. */
  32294. get source(): InternalTextureSource;
  32295. /**
  32296. * Creates a new InternalTexture
  32297. * @param engine defines the engine to use
  32298. * @param source defines the type of data that will be used
  32299. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32300. */
  32301. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32302. /**
  32303. * Increments the number of references (ie. the number of Texture that point to it)
  32304. */
  32305. incrementReferences(): void;
  32306. /**
  32307. * Change the size of the texture (not the size of the content)
  32308. * @param width defines the new width
  32309. * @param height defines the new height
  32310. * @param depth defines the new depth (1 by default)
  32311. */
  32312. updateSize(width: int, height: int, depth?: int): void;
  32313. /** @hidden */
  32314. _rebuild(): void;
  32315. /** @hidden */
  32316. _swapAndDie(target: InternalTexture): void;
  32317. /**
  32318. * Dispose the current allocated resources
  32319. */
  32320. dispose(): void;
  32321. }
  32322. }
  32323. declare module BABYLON {
  32324. /**
  32325. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32327. */
  32328. export class Analyser {
  32329. /**
  32330. * Gets or sets the smoothing
  32331. * @ignorenaming
  32332. */
  32333. SMOOTHING: number;
  32334. /**
  32335. * Gets or sets the FFT table size
  32336. * @ignorenaming
  32337. */
  32338. FFT_SIZE: number;
  32339. /**
  32340. * Gets or sets the bar graph amplitude
  32341. * @ignorenaming
  32342. */
  32343. BARGRAPHAMPLITUDE: number;
  32344. /**
  32345. * Gets or sets the position of the debug canvas
  32346. * @ignorenaming
  32347. */
  32348. DEBUGCANVASPOS: {
  32349. x: number;
  32350. y: number;
  32351. };
  32352. /**
  32353. * Gets or sets the debug canvas size
  32354. * @ignorenaming
  32355. */
  32356. DEBUGCANVASSIZE: {
  32357. width: number;
  32358. height: number;
  32359. };
  32360. private _byteFreqs;
  32361. private _byteTime;
  32362. private _floatFreqs;
  32363. private _webAudioAnalyser;
  32364. private _debugCanvas;
  32365. private _debugCanvasContext;
  32366. private _scene;
  32367. private _registerFunc;
  32368. private _audioEngine;
  32369. /**
  32370. * Creates a new analyser
  32371. * @param scene defines hosting scene
  32372. */
  32373. constructor(scene: Scene);
  32374. /**
  32375. * Get the number of data values you will have to play with for the visualization
  32376. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32377. * @returns a number
  32378. */
  32379. getFrequencyBinCount(): number;
  32380. /**
  32381. * Gets the current frequency data as a byte array
  32382. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32383. * @returns a Uint8Array
  32384. */
  32385. getByteFrequencyData(): Uint8Array;
  32386. /**
  32387. * Gets the current waveform as a byte array
  32388. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32389. * @returns a Uint8Array
  32390. */
  32391. getByteTimeDomainData(): Uint8Array;
  32392. /**
  32393. * Gets the current frequency data as a float array
  32394. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32395. * @returns a Float32Array
  32396. */
  32397. getFloatFrequencyData(): Float32Array;
  32398. /**
  32399. * Renders the debug canvas
  32400. */
  32401. drawDebugCanvas(): void;
  32402. /**
  32403. * Stops rendering the debug canvas and removes it
  32404. */
  32405. stopDebugCanvas(): void;
  32406. /**
  32407. * Connects two audio nodes
  32408. * @param inputAudioNode defines first node to connect
  32409. * @param outputAudioNode defines second node to connect
  32410. */
  32411. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32412. /**
  32413. * Releases all associated resources
  32414. */
  32415. dispose(): void;
  32416. }
  32417. }
  32418. declare module BABYLON {
  32419. /**
  32420. * This represents an audio engine and it is responsible
  32421. * to play, synchronize and analyse sounds throughout the application.
  32422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32423. */
  32424. export interface IAudioEngine extends IDisposable {
  32425. /**
  32426. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32427. */
  32428. readonly canUseWebAudio: boolean;
  32429. /**
  32430. * Gets the current AudioContext if available.
  32431. */
  32432. readonly audioContext: Nullable<AudioContext>;
  32433. /**
  32434. * The master gain node defines the global audio volume of your audio engine.
  32435. */
  32436. readonly masterGain: GainNode;
  32437. /**
  32438. * Gets whether or not mp3 are supported by your browser.
  32439. */
  32440. readonly isMP3supported: boolean;
  32441. /**
  32442. * Gets whether or not ogg are supported by your browser.
  32443. */
  32444. readonly isOGGsupported: boolean;
  32445. /**
  32446. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32447. * @ignoreNaming
  32448. */
  32449. WarnedWebAudioUnsupported: boolean;
  32450. /**
  32451. * Defines if the audio engine relies on a custom unlocked button.
  32452. * In this case, the embedded button will not be displayed.
  32453. */
  32454. useCustomUnlockedButton: boolean;
  32455. /**
  32456. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32457. */
  32458. readonly unlocked: boolean;
  32459. /**
  32460. * Event raised when audio has been unlocked on the browser.
  32461. */
  32462. onAudioUnlockedObservable: Observable<AudioEngine>;
  32463. /**
  32464. * Event raised when audio has been locked on the browser.
  32465. */
  32466. onAudioLockedObservable: Observable<AudioEngine>;
  32467. /**
  32468. * Flags the audio engine in Locked state.
  32469. * This happens due to new browser policies preventing audio to autoplay.
  32470. */
  32471. lock(): void;
  32472. /**
  32473. * Unlocks the audio engine once a user action has been done on the dom.
  32474. * This is helpful to resume play once browser policies have been satisfied.
  32475. */
  32476. unlock(): void;
  32477. }
  32478. /**
  32479. * This represents the default audio engine used in babylon.
  32480. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32482. */
  32483. export class AudioEngine implements IAudioEngine {
  32484. private _audioContext;
  32485. private _audioContextInitialized;
  32486. private _muteButton;
  32487. private _hostElement;
  32488. /**
  32489. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32490. */
  32491. canUseWebAudio: boolean;
  32492. /**
  32493. * The master gain node defines the global audio volume of your audio engine.
  32494. */
  32495. masterGain: GainNode;
  32496. /**
  32497. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32498. * @ignoreNaming
  32499. */
  32500. WarnedWebAudioUnsupported: boolean;
  32501. /**
  32502. * Gets whether or not mp3 are supported by your browser.
  32503. */
  32504. isMP3supported: boolean;
  32505. /**
  32506. * Gets whether or not ogg are supported by your browser.
  32507. */
  32508. isOGGsupported: boolean;
  32509. /**
  32510. * Gets whether audio has been unlocked on the device.
  32511. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32512. * a user interaction has happened.
  32513. */
  32514. unlocked: boolean;
  32515. /**
  32516. * Defines if the audio engine relies on a custom unlocked button.
  32517. * In this case, the embedded button will not be displayed.
  32518. */
  32519. useCustomUnlockedButton: boolean;
  32520. /**
  32521. * Event raised when audio has been unlocked on the browser.
  32522. */
  32523. onAudioUnlockedObservable: Observable<AudioEngine>;
  32524. /**
  32525. * Event raised when audio has been locked on the browser.
  32526. */
  32527. onAudioLockedObservable: Observable<AudioEngine>;
  32528. /**
  32529. * Gets the current AudioContext if available.
  32530. */
  32531. get audioContext(): Nullable<AudioContext>;
  32532. private _connectedAnalyser;
  32533. /**
  32534. * Instantiates a new audio engine.
  32535. *
  32536. * There should be only one per page as some browsers restrict the number
  32537. * of audio contexts you can create.
  32538. * @param hostElement defines the host element where to display the mute icon if necessary
  32539. */
  32540. constructor(hostElement?: Nullable<HTMLElement>);
  32541. /**
  32542. * Flags the audio engine in Locked state.
  32543. * This happens due to new browser policies preventing audio to autoplay.
  32544. */
  32545. lock(): void;
  32546. /**
  32547. * Unlocks the audio engine once a user action has been done on the dom.
  32548. * This is helpful to resume play once browser policies have been satisfied.
  32549. */
  32550. unlock(): void;
  32551. private _resumeAudioContext;
  32552. private _initializeAudioContext;
  32553. private _tryToRun;
  32554. private _triggerRunningState;
  32555. private _triggerSuspendedState;
  32556. private _displayMuteButton;
  32557. private _moveButtonToTopLeft;
  32558. private _onResize;
  32559. private _hideMuteButton;
  32560. /**
  32561. * Destroy and release the resources associated with the audio ccontext.
  32562. */
  32563. dispose(): void;
  32564. /**
  32565. * Gets the global volume sets on the master gain.
  32566. * @returns the global volume if set or -1 otherwise
  32567. */
  32568. getGlobalVolume(): number;
  32569. /**
  32570. * Sets the global volume of your experience (sets on the master gain).
  32571. * @param newVolume Defines the new global volume of the application
  32572. */
  32573. setGlobalVolume(newVolume: number): void;
  32574. /**
  32575. * Connect the audio engine to an audio analyser allowing some amazing
  32576. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32578. * @param analyser The analyser to connect to the engine
  32579. */
  32580. connectToAnalyser(analyser: Analyser): void;
  32581. }
  32582. }
  32583. declare module BABYLON {
  32584. /**
  32585. * Interface used to present a loading screen while loading a scene
  32586. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32587. */
  32588. export interface ILoadingScreen {
  32589. /**
  32590. * Function called to display the loading screen
  32591. */
  32592. displayLoadingUI: () => void;
  32593. /**
  32594. * Function called to hide the loading screen
  32595. */
  32596. hideLoadingUI: () => void;
  32597. /**
  32598. * Gets or sets the color to use for the background
  32599. */
  32600. loadingUIBackgroundColor: string;
  32601. /**
  32602. * Gets or sets the text to display while loading
  32603. */
  32604. loadingUIText: string;
  32605. }
  32606. /**
  32607. * Class used for the default loading screen
  32608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32609. */
  32610. export class DefaultLoadingScreen implements ILoadingScreen {
  32611. private _renderingCanvas;
  32612. private _loadingText;
  32613. private _loadingDivBackgroundColor;
  32614. private _loadingDiv;
  32615. private _loadingTextDiv;
  32616. /** Gets or sets the logo url to use for the default loading screen */
  32617. static DefaultLogoUrl: string;
  32618. /** Gets or sets the spinner url to use for the default loading screen */
  32619. static DefaultSpinnerUrl: string;
  32620. /**
  32621. * Creates a new default loading screen
  32622. * @param _renderingCanvas defines the canvas used to render the scene
  32623. * @param _loadingText defines the default text to display
  32624. * @param _loadingDivBackgroundColor defines the default background color
  32625. */
  32626. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32627. /**
  32628. * Function called to display the loading screen
  32629. */
  32630. displayLoadingUI(): void;
  32631. /**
  32632. * Function called to hide the loading screen
  32633. */
  32634. hideLoadingUI(): void;
  32635. /**
  32636. * Gets or sets the text to display while loading
  32637. */
  32638. set loadingUIText(text: string);
  32639. get loadingUIText(): string;
  32640. /**
  32641. * Gets or sets the color to use for the background
  32642. */
  32643. get loadingUIBackgroundColor(): string;
  32644. set loadingUIBackgroundColor(color: string);
  32645. private _resizeLoadingUI;
  32646. }
  32647. }
  32648. declare module BABYLON {
  32649. /**
  32650. * Interface for any object that can request an animation frame
  32651. */
  32652. export interface ICustomAnimationFrameRequester {
  32653. /**
  32654. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32655. */
  32656. renderFunction?: Function;
  32657. /**
  32658. * Called to request the next frame to render to
  32659. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32660. */
  32661. requestAnimationFrame: Function;
  32662. /**
  32663. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32664. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32665. */
  32666. requestID?: number;
  32667. }
  32668. }
  32669. declare module BABYLON {
  32670. /**
  32671. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32672. */
  32673. export class PerformanceMonitor {
  32674. private _enabled;
  32675. private _rollingFrameTime;
  32676. private _lastFrameTimeMs;
  32677. /**
  32678. * constructor
  32679. * @param frameSampleSize The number of samples required to saturate the sliding window
  32680. */
  32681. constructor(frameSampleSize?: number);
  32682. /**
  32683. * Samples current frame
  32684. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32685. */
  32686. sampleFrame(timeMs?: number): void;
  32687. /**
  32688. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32689. */
  32690. get averageFrameTime(): number;
  32691. /**
  32692. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32693. */
  32694. get averageFrameTimeVariance(): number;
  32695. /**
  32696. * Returns the frame time of the most recent frame
  32697. */
  32698. get instantaneousFrameTime(): number;
  32699. /**
  32700. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32701. */
  32702. get averageFPS(): number;
  32703. /**
  32704. * Returns the average framerate in frames per second using the most recent frame time
  32705. */
  32706. get instantaneousFPS(): number;
  32707. /**
  32708. * Returns true if enough samples have been taken to completely fill the sliding window
  32709. */
  32710. get isSaturated(): boolean;
  32711. /**
  32712. * Enables contributions to the sliding window sample set
  32713. */
  32714. enable(): void;
  32715. /**
  32716. * Disables contributions to the sliding window sample set
  32717. * Samples will not be interpolated over the disabled period
  32718. */
  32719. disable(): void;
  32720. /**
  32721. * Returns true if sampling is enabled
  32722. */
  32723. get isEnabled(): boolean;
  32724. /**
  32725. * Resets performance monitor
  32726. */
  32727. reset(): void;
  32728. }
  32729. /**
  32730. * RollingAverage
  32731. *
  32732. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32733. */
  32734. export class RollingAverage {
  32735. /**
  32736. * Current average
  32737. */
  32738. average: number;
  32739. /**
  32740. * Current variance
  32741. */
  32742. variance: number;
  32743. protected _samples: Array<number>;
  32744. protected _sampleCount: number;
  32745. protected _pos: number;
  32746. protected _m2: number;
  32747. /**
  32748. * constructor
  32749. * @param length The number of samples required to saturate the sliding window
  32750. */
  32751. constructor(length: number);
  32752. /**
  32753. * Adds a sample to the sample set
  32754. * @param v The sample value
  32755. */
  32756. add(v: number): void;
  32757. /**
  32758. * Returns previously added values or null if outside of history or outside the sliding window domain
  32759. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32760. * @return Value previously recorded with add() or null if outside of range
  32761. */
  32762. history(i: number): number;
  32763. /**
  32764. * Returns true if enough samples have been taken to completely fill the sliding window
  32765. * @return true if sample-set saturated
  32766. */
  32767. isSaturated(): boolean;
  32768. /**
  32769. * Resets the rolling average (equivalent to 0 samples taken so far)
  32770. */
  32771. reset(): void;
  32772. /**
  32773. * Wraps a value around the sample range boundaries
  32774. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32775. * @return Wrapped position in sample range
  32776. */
  32777. protected _wrapPosition(i: number): number;
  32778. }
  32779. }
  32780. declare module BABYLON {
  32781. /**
  32782. * This class is used to track a performance counter which is number based.
  32783. * The user has access to many properties which give statistics of different nature.
  32784. *
  32785. * The implementer can track two kinds of Performance Counter: time and count.
  32786. * 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.
  32787. * 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.
  32788. */
  32789. export class PerfCounter {
  32790. /**
  32791. * Gets or sets a global boolean to turn on and off all the counters
  32792. */
  32793. static Enabled: boolean;
  32794. /**
  32795. * Returns the smallest value ever
  32796. */
  32797. get min(): number;
  32798. /**
  32799. * Returns the biggest value ever
  32800. */
  32801. get max(): number;
  32802. /**
  32803. * Returns the average value since the performance counter is running
  32804. */
  32805. get average(): number;
  32806. /**
  32807. * Returns the average value of the last second the counter was monitored
  32808. */
  32809. get lastSecAverage(): number;
  32810. /**
  32811. * Returns the current value
  32812. */
  32813. get current(): number;
  32814. /**
  32815. * Gets the accumulated total
  32816. */
  32817. get total(): number;
  32818. /**
  32819. * Gets the total value count
  32820. */
  32821. get count(): number;
  32822. /**
  32823. * Creates a new counter
  32824. */
  32825. constructor();
  32826. /**
  32827. * Call this method to start monitoring a new frame.
  32828. * 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.
  32829. */
  32830. fetchNewFrame(): void;
  32831. /**
  32832. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32833. * @param newCount the count value to add to the monitored count
  32834. * @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.
  32835. */
  32836. addCount(newCount: number, fetchResult: boolean): void;
  32837. /**
  32838. * Start monitoring this performance counter
  32839. */
  32840. beginMonitoring(): void;
  32841. /**
  32842. * Compute the time lapsed since the previous beginMonitoring() call.
  32843. * @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
  32844. */
  32845. endMonitoring(newFrame?: boolean): void;
  32846. private _fetchResult;
  32847. private _startMonitoringTime;
  32848. private _min;
  32849. private _max;
  32850. private _average;
  32851. private _current;
  32852. private _totalValueCount;
  32853. private _totalAccumulated;
  32854. private _lastSecAverage;
  32855. private _lastSecAccumulated;
  32856. private _lastSecTime;
  32857. private _lastSecValueCount;
  32858. }
  32859. }
  32860. declare module BABYLON {
  32861. interface ThinEngine {
  32862. /**
  32863. * Sets alpha constants used by some alpha blending modes
  32864. * @param r defines the red component
  32865. * @param g defines the green component
  32866. * @param b defines the blue component
  32867. * @param a defines the alpha component
  32868. */
  32869. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32870. /**
  32871. * Sets the current alpha mode
  32872. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32873. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32874. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32875. */
  32876. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32877. /**
  32878. * Gets the current alpha mode
  32879. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32880. * @returns the current alpha mode
  32881. */
  32882. getAlphaMode(): number;
  32883. /**
  32884. * Sets the current alpha equation
  32885. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32886. */
  32887. setAlphaEquation(equation: number): void;
  32888. /**
  32889. * Gets the current alpha equation.
  32890. * @returns the current alpha equation
  32891. */
  32892. getAlphaEquation(): number;
  32893. }
  32894. }
  32895. declare module BABYLON {
  32896. /**
  32897. * Defines the interface used by display changed events
  32898. */
  32899. export interface IDisplayChangedEventArgs {
  32900. /** Gets the vrDisplay object (if any) */
  32901. vrDisplay: Nullable<any>;
  32902. /** Gets a boolean indicating if webVR is supported */
  32903. vrSupported: boolean;
  32904. }
  32905. /**
  32906. * Defines the interface used by objects containing a viewport (like a camera)
  32907. */
  32908. interface IViewportOwnerLike {
  32909. /**
  32910. * Gets or sets the viewport
  32911. */
  32912. viewport: IViewportLike;
  32913. }
  32914. /**
  32915. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32916. */
  32917. export class Engine extends ThinEngine {
  32918. /** Defines that alpha blending is disabled */
  32919. static readonly ALPHA_DISABLE: number;
  32920. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32921. static readonly ALPHA_ADD: number;
  32922. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32923. static readonly ALPHA_COMBINE: number;
  32924. /** Defines that alpha blending to DEST - SRC * DEST */
  32925. static readonly ALPHA_SUBTRACT: number;
  32926. /** Defines that alpha blending to SRC * DEST */
  32927. static readonly ALPHA_MULTIPLY: number;
  32928. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32929. static readonly ALPHA_MAXIMIZED: number;
  32930. /** Defines that alpha blending to SRC + DEST */
  32931. static readonly ALPHA_ONEONE: number;
  32932. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32933. static readonly ALPHA_PREMULTIPLIED: number;
  32934. /**
  32935. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32936. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32937. */
  32938. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32939. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32940. static readonly ALPHA_INTERPOLATE: number;
  32941. /**
  32942. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32943. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32944. */
  32945. static readonly ALPHA_SCREENMODE: number;
  32946. /** Defines that the ressource is not delayed*/
  32947. static readonly DELAYLOADSTATE_NONE: number;
  32948. /** Defines that the ressource was successfully delay loaded */
  32949. static readonly DELAYLOADSTATE_LOADED: number;
  32950. /** Defines that the ressource is currently delay loading */
  32951. static readonly DELAYLOADSTATE_LOADING: number;
  32952. /** Defines that the ressource is delayed and has not started loading */
  32953. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32954. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32955. static readonly NEVER: number;
  32956. /** 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 */
  32957. static readonly ALWAYS: number;
  32958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32959. static readonly LESS: number;
  32960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32961. static readonly EQUAL: number;
  32962. /** 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 */
  32963. static readonly LEQUAL: number;
  32964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32965. static readonly GREATER: number;
  32966. /** 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 */
  32967. static readonly GEQUAL: number;
  32968. /** 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 */
  32969. static readonly NOTEQUAL: number;
  32970. /** Passed to stencilOperation to specify that stencil value must be kept */
  32971. static readonly KEEP: number;
  32972. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32973. static readonly REPLACE: number;
  32974. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32975. static readonly INCR: number;
  32976. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32977. static readonly DECR: number;
  32978. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32979. static readonly INVERT: number;
  32980. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32981. static readonly INCR_WRAP: number;
  32982. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32983. static readonly DECR_WRAP: number;
  32984. /** Texture is not repeating outside of 0..1 UVs */
  32985. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32986. /** Texture is repeating outside of 0..1 UVs */
  32987. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32988. /** Texture is repeating and mirrored */
  32989. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32990. /** ALPHA */
  32991. static readonly TEXTUREFORMAT_ALPHA: number;
  32992. /** LUMINANCE */
  32993. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32994. /** LUMINANCE_ALPHA */
  32995. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32996. /** RGB */
  32997. static readonly TEXTUREFORMAT_RGB: number;
  32998. /** RGBA */
  32999. static readonly TEXTUREFORMAT_RGBA: number;
  33000. /** RED */
  33001. static readonly TEXTUREFORMAT_RED: number;
  33002. /** RED (2nd reference) */
  33003. static readonly TEXTUREFORMAT_R: number;
  33004. /** RG */
  33005. static readonly TEXTUREFORMAT_RG: number;
  33006. /** RED_INTEGER */
  33007. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33008. /** RED_INTEGER (2nd reference) */
  33009. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33010. /** RG_INTEGER */
  33011. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33012. /** RGB_INTEGER */
  33013. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33014. /** RGBA_INTEGER */
  33015. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33016. /** UNSIGNED_BYTE */
  33017. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33018. /** UNSIGNED_BYTE (2nd reference) */
  33019. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33020. /** FLOAT */
  33021. static readonly TEXTURETYPE_FLOAT: number;
  33022. /** HALF_FLOAT */
  33023. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33024. /** BYTE */
  33025. static readonly TEXTURETYPE_BYTE: number;
  33026. /** SHORT */
  33027. static readonly TEXTURETYPE_SHORT: number;
  33028. /** UNSIGNED_SHORT */
  33029. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33030. /** INT */
  33031. static readonly TEXTURETYPE_INT: number;
  33032. /** UNSIGNED_INT */
  33033. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33034. /** UNSIGNED_SHORT_4_4_4_4 */
  33035. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33036. /** UNSIGNED_SHORT_5_5_5_1 */
  33037. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33038. /** UNSIGNED_SHORT_5_6_5 */
  33039. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33040. /** UNSIGNED_INT_2_10_10_10_REV */
  33041. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33042. /** UNSIGNED_INT_24_8 */
  33043. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33044. /** UNSIGNED_INT_10F_11F_11F_REV */
  33045. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33046. /** UNSIGNED_INT_5_9_9_9_REV */
  33047. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33048. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33049. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33050. /** nearest is mag = nearest and min = nearest and mip = linear */
  33051. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33052. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33053. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33054. /** Trilinear is mag = linear and min = linear and mip = linear */
  33055. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33056. /** nearest is mag = nearest and min = nearest and mip = linear */
  33057. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33058. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33059. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33060. /** Trilinear is mag = linear and min = linear and mip = linear */
  33061. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33062. /** mag = nearest and min = nearest and mip = nearest */
  33063. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33064. /** mag = nearest and min = linear and mip = nearest */
  33065. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33066. /** mag = nearest and min = linear and mip = linear */
  33067. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33068. /** mag = nearest and min = linear and mip = none */
  33069. static readonly TEXTURE_NEAREST_LINEAR: number;
  33070. /** mag = nearest and min = nearest and mip = none */
  33071. static readonly TEXTURE_NEAREST_NEAREST: number;
  33072. /** mag = linear and min = nearest and mip = nearest */
  33073. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33074. /** mag = linear and min = nearest and mip = linear */
  33075. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33076. /** mag = linear and min = linear and mip = none */
  33077. static readonly TEXTURE_LINEAR_LINEAR: number;
  33078. /** mag = linear and min = nearest and mip = none */
  33079. static readonly TEXTURE_LINEAR_NEAREST: number;
  33080. /** Explicit coordinates mode */
  33081. static readonly TEXTURE_EXPLICIT_MODE: number;
  33082. /** Spherical coordinates mode */
  33083. static readonly TEXTURE_SPHERICAL_MODE: number;
  33084. /** Planar coordinates mode */
  33085. static readonly TEXTURE_PLANAR_MODE: number;
  33086. /** Cubic coordinates mode */
  33087. static readonly TEXTURE_CUBIC_MODE: number;
  33088. /** Projection coordinates mode */
  33089. static readonly TEXTURE_PROJECTION_MODE: number;
  33090. /** Skybox coordinates mode */
  33091. static readonly TEXTURE_SKYBOX_MODE: number;
  33092. /** Inverse Cubic coordinates mode */
  33093. static readonly TEXTURE_INVCUBIC_MODE: number;
  33094. /** Equirectangular coordinates mode */
  33095. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33096. /** Equirectangular Fixed coordinates mode */
  33097. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33098. /** Equirectangular Fixed Mirrored coordinates mode */
  33099. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33100. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33101. static readonly SCALEMODE_FLOOR: number;
  33102. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33103. static readonly SCALEMODE_NEAREST: number;
  33104. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33105. static readonly SCALEMODE_CEILING: number;
  33106. /**
  33107. * Returns the current npm package of the sdk
  33108. */
  33109. static get NpmPackage(): string;
  33110. /**
  33111. * Returns the current version of the framework
  33112. */
  33113. static get Version(): string;
  33114. /** Gets the list of created engines */
  33115. static get Instances(): Engine[];
  33116. /**
  33117. * Gets the latest created engine
  33118. */
  33119. static get LastCreatedEngine(): Nullable<Engine>;
  33120. /**
  33121. * Gets the latest created scene
  33122. */
  33123. static get LastCreatedScene(): Nullable<Scene>;
  33124. /**
  33125. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33126. * @param flag defines which part of the materials must be marked as dirty
  33127. * @param predicate defines a predicate used to filter which materials should be affected
  33128. */
  33129. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33130. /**
  33131. * Method called to create the default loading screen.
  33132. * This can be overriden in your own app.
  33133. * @param canvas The rendering canvas element
  33134. * @returns The loading screen
  33135. */
  33136. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33137. /**
  33138. * Method called to create the default rescale post process on each engine.
  33139. */
  33140. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33141. /**
  33142. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33143. **/
  33144. enableOfflineSupport: boolean;
  33145. /**
  33146. * 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)
  33147. **/
  33148. disableManifestCheck: boolean;
  33149. /**
  33150. * Gets the list of created scenes
  33151. */
  33152. scenes: Scene[];
  33153. /**
  33154. * Event raised when a new scene is created
  33155. */
  33156. onNewSceneAddedObservable: Observable<Scene>;
  33157. /**
  33158. * Gets the list of created postprocesses
  33159. */
  33160. postProcesses: PostProcess[];
  33161. /**
  33162. * Gets a boolean indicating if the pointer is currently locked
  33163. */
  33164. isPointerLock: boolean;
  33165. /**
  33166. * Observable event triggered each time the rendering canvas is resized
  33167. */
  33168. onResizeObservable: Observable<Engine>;
  33169. /**
  33170. * Observable event triggered each time the canvas loses focus
  33171. */
  33172. onCanvasBlurObservable: Observable<Engine>;
  33173. /**
  33174. * Observable event triggered each time the canvas gains focus
  33175. */
  33176. onCanvasFocusObservable: Observable<Engine>;
  33177. /**
  33178. * Observable event triggered each time the canvas receives pointerout event
  33179. */
  33180. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33181. /**
  33182. * Observable raised when the engine begins a new frame
  33183. */
  33184. onBeginFrameObservable: Observable<Engine>;
  33185. /**
  33186. * If set, will be used to request the next animation frame for the render loop
  33187. */
  33188. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33189. /**
  33190. * Observable raised when the engine ends the current frame
  33191. */
  33192. onEndFrameObservable: Observable<Engine>;
  33193. /**
  33194. * Observable raised when the engine is about to compile a shader
  33195. */
  33196. onBeforeShaderCompilationObservable: Observable<Engine>;
  33197. /**
  33198. * Observable raised when the engine has jsut compiled a shader
  33199. */
  33200. onAfterShaderCompilationObservable: Observable<Engine>;
  33201. /**
  33202. * Gets the audio engine
  33203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33204. * @ignorenaming
  33205. */
  33206. static audioEngine: IAudioEngine;
  33207. /**
  33208. * Default AudioEngine factory responsible of creating the Audio Engine.
  33209. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33210. */
  33211. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33212. /**
  33213. * Default offline support factory responsible of creating a tool used to store data locally.
  33214. * By default, this will create a Database object if the workload has been embedded.
  33215. */
  33216. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33217. private _loadingScreen;
  33218. private _pointerLockRequested;
  33219. private _dummyFramebuffer;
  33220. private _rescalePostProcess;
  33221. private _deterministicLockstep;
  33222. private _lockstepMaxSteps;
  33223. private _timeStep;
  33224. protected get _supportsHardwareTextureRescaling(): boolean;
  33225. private _fps;
  33226. private _deltaTime;
  33227. /** @hidden */
  33228. _drawCalls: PerfCounter;
  33229. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33230. canvasTabIndex: number;
  33231. /**
  33232. * Turn this value on if you want to pause FPS computation when in background
  33233. */
  33234. disablePerformanceMonitorInBackground: boolean;
  33235. private _performanceMonitor;
  33236. /**
  33237. * Gets the performance monitor attached to this engine
  33238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33239. */
  33240. get performanceMonitor(): PerformanceMonitor;
  33241. private _onFocus;
  33242. private _onBlur;
  33243. private _onCanvasPointerOut;
  33244. private _onCanvasBlur;
  33245. private _onCanvasFocus;
  33246. private _onFullscreenChange;
  33247. private _onPointerLockChange;
  33248. /**
  33249. * Gets the HTML element used to attach event listeners
  33250. * @returns a HTML element
  33251. */
  33252. getInputElement(): Nullable<HTMLElement>;
  33253. /**
  33254. * Creates a new engine
  33255. * @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
  33256. * @param antialias defines enable antialiasing (default: false)
  33257. * @param options defines further options to be sent to the getContext() function
  33258. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33259. */
  33260. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33261. /**
  33262. * Gets current aspect ratio
  33263. * @param viewportOwner defines the camera to use to get the aspect ratio
  33264. * @param useScreen defines if screen size must be used (or the current render target if any)
  33265. * @returns a number defining the aspect ratio
  33266. */
  33267. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33268. /**
  33269. * Gets current screen aspect ratio
  33270. * @returns a number defining the aspect ratio
  33271. */
  33272. getScreenAspectRatio(): number;
  33273. /**
  33274. * Gets the client rect of the HTML canvas attached with the current webGL context
  33275. * @returns a client rectanglee
  33276. */
  33277. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33278. /**
  33279. * Gets the client rect of the HTML element used for events
  33280. * @returns a client rectanglee
  33281. */
  33282. getInputElementClientRect(): Nullable<ClientRect>;
  33283. /**
  33284. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33285. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33286. * @returns true if engine is in deterministic lock step mode
  33287. */
  33288. isDeterministicLockStep(): boolean;
  33289. /**
  33290. * Gets the max steps when engine is running in deterministic lock step
  33291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33292. * @returns the max steps
  33293. */
  33294. getLockstepMaxSteps(): number;
  33295. /**
  33296. * Returns the time in ms between steps when using deterministic lock step.
  33297. * @returns time step in (ms)
  33298. */
  33299. getTimeStep(): number;
  33300. /**
  33301. * Force the mipmap generation for the given render target texture
  33302. * @param texture defines the render target texture to use
  33303. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33304. */
  33305. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33306. /** States */
  33307. /**
  33308. * Set various states to the webGL context
  33309. * @param culling defines backface culling state
  33310. * @param zOffset defines the value to apply to zOffset (0 by default)
  33311. * @param force defines if states must be applied even if cache is up to date
  33312. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33313. */
  33314. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33315. /**
  33316. * Set the z offset to apply to current rendering
  33317. * @param value defines the offset to apply
  33318. */
  33319. setZOffset(value: number): void;
  33320. /**
  33321. * Gets the current value of the zOffset
  33322. * @returns the current zOffset state
  33323. */
  33324. getZOffset(): number;
  33325. /**
  33326. * Enable or disable depth buffering
  33327. * @param enable defines the state to set
  33328. */
  33329. setDepthBuffer(enable: boolean): void;
  33330. /**
  33331. * Gets a boolean indicating if depth writing is enabled
  33332. * @returns the current depth writing state
  33333. */
  33334. getDepthWrite(): boolean;
  33335. /**
  33336. * Enable or disable depth writing
  33337. * @param enable defines the state to set
  33338. */
  33339. setDepthWrite(enable: boolean): void;
  33340. /**
  33341. * Gets a boolean indicating if stencil buffer is enabled
  33342. * @returns the current stencil buffer state
  33343. */
  33344. getStencilBuffer(): boolean;
  33345. /**
  33346. * Enable or disable the stencil buffer
  33347. * @param enable defines if the stencil buffer must be enabled or disabled
  33348. */
  33349. setStencilBuffer(enable: boolean): void;
  33350. /**
  33351. * Gets the current stencil mask
  33352. * @returns a number defining the new stencil mask to use
  33353. */
  33354. getStencilMask(): number;
  33355. /**
  33356. * Sets the current stencil mask
  33357. * @param mask defines the new stencil mask to use
  33358. */
  33359. setStencilMask(mask: number): void;
  33360. /**
  33361. * Gets the current stencil function
  33362. * @returns a number defining the stencil function to use
  33363. */
  33364. getStencilFunction(): number;
  33365. /**
  33366. * Gets the current stencil reference value
  33367. * @returns a number defining the stencil reference value to use
  33368. */
  33369. getStencilFunctionReference(): number;
  33370. /**
  33371. * Gets the current stencil mask
  33372. * @returns a number defining the stencil mask to use
  33373. */
  33374. getStencilFunctionMask(): number;
  33375. /**
  33376. * Sets the current stencil function
  33377. * @param stencilFunc defines the new stencil function to use
  33378. */
  33379. setStencilFunction(stencilFunc: number): void;
  33380. /**
  33381. * Sets the current stencil reference
  33382. * @param reference defines the new stencil reference to use
  33383. */
  33384. setStencilFunctionReference(reference: number): void;
  33385. /**
  33386. * Sets the current stencil mask
  33387. * @param mask defines the new stencil mask to use
  33388. */
  33389. setStencilFunctionMask(mask: number): void;
  33390. /**
  33391. * Gets the current stencil operation when stencil fails
  33392. * @returns a number defining stencil operation to use when stencil fails
  33393. */
  33394. getStencilOperationFail(): number;
  33395. /**
  33396. * Gets the current stencil operation when depth fails
  33397. * @returns a number defining stencil operation to use when depth fails
  33398. */
  33399. getStencilOperationDepthFail(): number;
  33400. /**
  33401. * Gets the current stencil operation when stencil passes
  33402. * @returns a number defining stencil operation to use when stencil passes
  33403. */
  33404. getStencilOperationPass(): number;
  33405. /**
  33406. * Sets the stencil operation to use when stencil fails
  33407. * @param operation defines the stencil operation to use when stencil fails
  33408. */
  33409. setStencilOperationFail(operation: number): void;
  33410. /**
  33411. * Sets the stencil operation to use when depth fails
  33412. * @param operation defines the stencil operation to use when depth fails
  33413. */
  33414. setStencilOperationDepthFail(operation: number): void;
  33415. /**
  33416. * Sets the stencil operation to use when stencil passes
  33417. * @param operation defines the stencil operation to use when stencil passes
  33418. */
  33419. setStencilOperationPass(operation: number): void;
  33420. /**
  33421. * Sets a boolean indicating if the dithering state is enabled or disabled
  33422. * @param value defines the dithering state
  33423. */
  33424. setDitheringState(value: boolean): void;
  33425. /**
  33426. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33427. * @param value defines the rasterizer state
  33428. */
  33429. setRasterizerState(value: boolean): void;
  33430. /**
  33431. * Gets the current depth function
  33432. * @returns a number defining the depth function
  33433. */
  33434. getDepthFunction(): Nullable<number>;
  33435. /**
  33436. * Sets the current depth function
  33437. * @param depthFunc defines the function to use
  33438. */
  33439. setDepthFunction(depthFunc: number): void;
  33440. /**
  33441. * Sets the current depth function to GREATER
  33442. */
  33443. setDepthFunctionToGreater(): void;
  33444. /**
  33445. * Sets the current depth function to GEQUAL
  33446. */
  33447. setDepthFunctionToGreaterOrEqual(): void;
  33448. /**
  33449. * Sets the current depth function to LESS
  33450. */
  33451. setDepthFunctionToLess(): void;
  33452. /**
  33453. * Sets the current depth function to LEQUAL
  33454. */
  33455. setDepthFunctionToLessOrEqual(): void;
  33456. private _cachedStencilBuffer;
  33457. private _cachedStencilFunction;
  33458. private _cachedStencilMask;
  33459. private _cachedStencilOperationPass;
  33460. private _cachedStencilOperationFail;
  33461. private _cachedStencilOperationDepthFail;
  33462. private _cachedStencilReference;
  33463. /**
  33464. * Caches the the state of the stencil buffer
  33465. */
  33466. cacheStencilState(): void;
  33467. /**
  33468. * Restores the state of the stencil buffer
  33469. */
  33470. restoreStencilState(): void;
  33471. /**
  33472. * Directly set the WebGL Viewport
  33473. * @param x defines the x coordinate of the viewport (in screen space)
  33474. * @param y defines the y coordinate of the viewport (in screen space)
  33475. * @param width defines the width of the viewport (in screen space)
  33476. * @param height defines the height of the viewport (in screen space)
  33477. * @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
  33478. */
  33479. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33480. /**
  33481. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33482. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33483. * @param y defines the y-coordinate of the corner of the clear rectangle
  33484. * @param width defines the width of the clear rectangle
  33485. * @param height defines the height of the clear rectangle
  33486. * @param clearColor defines the clear color
  33487. */
  33488. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33489. /**
  33490. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33491. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33492. * @param y defines the y-coordinate of the corner of the clear rectangle
  33493. * @param width defines the width of the clear rectangle
  33494. * @param height defines the height of the clear rectangle
  33495. */
  33496. enableScissor(x: number, y: number, width: number, height: number): void;
  33497. /**
  33498. * Disable previously set scissor test rectangle
  33499. */
  33500. disableScissor(): void;
  33501. protected _reportDrawCall(): void;
  33502. /**
  33503. * Initializes a webVR display and starts listening to display change events
  33504. * The onVRDisplayChangedObservable will be notified upon these changes
  33505. * @returns The onVRDisplayChangedObservable
  33506. */
  33507. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33508. /** @hidden */
  33509. _prepareVRComponent(): void;
  33510. /** @hidden */
  33511. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33512. /** @hidden */
  33513. _submitVRFrame(): void;
  33514. /**
  33515. * Call this function to leave webVR mode
  33516. * Will do nothing if webVR is not supported or if there is no webVR device
  33517. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33518. */
  33519. disableVR(): void;
  33520. /**
  33521. * Gets a boolean indicating that the system is in VR mode and is presenting
  33522. * @returns true if VR mode is engaged
  33523. */
  33524. isVRPresenting(): boolean;
  33525. /** @hidden */
  33526. _requestVRFrame(): void;
  33527. /** @hidden */
  33528. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33529. /**
  33530. * Gets the source code of the vertex shader associated with a specific webGL program
  33531. * @param program defines the program to use
  33532. * @returns a string containing the source code of the vertex shader associated with the program
  33533. */
  33534. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33535. /**
  33536. * Gets the source code of the fragment shader associated with a specific webGL program
  33537. * @param program defines the program to use
  33538. * @returns a string containing the source code of the fragment shader associated with the program
  33539. */
  33540. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33541. /**
  33542. * Sets a depth stencil texture from a render target to the according uniform.
  33543. * @param channel The texture channel
  33544. * @param uniform The uniform to set
  33545. * @param texture The render target texture containing the depth stencil texture to apply
  33546. */
  33547. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33548. /**
  33549. * Sets a texture to the webGL context from a postprocess
  33550. * @param channel defines the channel to use
  33551. * @param postProcess defines the source postprocess
  33552. */
  33553. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33554. /**
  33555. * Binds the output of the passed in post process to the texture channel specified
  33556. * @param channel The channel the texture should be bound to
  33557. * @param postProcess The post process which's output should be bound
  33558. */
  33559. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33560. /** @hidden */
  33561. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33562. protected _rebuildBuffers(): void;
  33563. /** @hidden */
  33564. _renderFrame(): void;
  33565. _renderLoop(): void;
  33566. /** @hidden */
  33567. _renderViews(): boolean;
  33568. /**
  33569. * Toggle full screen mode
  33570. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33571. */
  33572. switchFullscreen(requestPointerLock: boolean): void;
  33573. /**
  33574. * Enters full screen mode
  33575. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33576. */
  33577. enterFullscreen(requestPointerLock: boolean): void;
  33578. /**
  33579. * Exits full screen mode
  33580. */
  33581. exitFullscreen(): void;
  33582. /**
  33583. * Enters Pointerlock mode
  33584. */
  33585. enterPointerlock(): void;
  33586. /**
  33587. * Exits Pointerlock mode
  33588. */
  33589. exitPointerlock(): void;
  33590. /**
  33591. * Begin a new frame
  33592. */
  33593. beginFrame(): void;
  33594. /**
  33595. * Enf the current frame
  33596. */
  33597. endFrame(): void;
  33598. resize(): void;
  33599. /**
  33600. * Set the compressed texture format to use, based on the formats you have, and the formats
  33601. * supported by the hardware / browser.
  33602. *
  33603. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33604. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33605. * to API arguments needed to compressed textures. This puts the burden on the container
  33606. * generator to house the arcane code for determining these for current & future formats.
  33607. *
  33608. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33609. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33610. *
  33611. * Note: The result of this call is not taken into account when a texture is base64.
  33612. *
  33613. * @param formatsAvailable defines the list of those format families you have created
  33614. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33615. *
  33616. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33617. * @returns The extension selected.
  33618. */
  33619. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33620. /**
  33621. * Set the compressed texture extensions or file names to skip.
  33622. *
  33623. * @param skippedFiles defines the list of those texture files you want to skip
  33624. * Example: [".dds", ".env", "myfile.png"]
  33625. */
  33626. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33627. /**
  33628. * Force a specific size of the canvas
  33629. * @param width defines the new canvas' width
  33630. * @param height defines the new canvas' height
  33631. */
  33632. setSize(width: number, height: number): void;
  33633. /**
  33634. * Updates a dynamic vertex buffer.
  33635. * @param vertexBuffer the vertex buffer to update
  33636. * @param data the data used to update the vertex buffer
  33637. * @param byteOffset the byte offset of the data
  33638. * @param byteLength the byte length of the data
  33639. */
  33640. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33641. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33642. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33643. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33644. _releaseTexture(texture: InternalTexture): void;
  33645. /**
  33646. * @hidden
  33647. * Rescales a texture
  33648. * @param source input texutre
  33649. * @param destination destination texture
  33650. * @param scene scene to use to render the resize
  33651. * @param internalFormat format to use when resizing
  33652. * @param onComplete callback to be called when resize has completed
  33653. */
  33654. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33655. /**
  33656. * Gets the current framerate
  33657. * @returns a number representing the framerate
  33658. */
  33659. getFps(): number;
  33660. /**
  33661. * Gets the time spent between current and previous frame
  33662. * @returns a number representing the delta time in ms
  33663. */
  33664. getDeltaTime(): number;
  33665. private _measureFps;
  33666. /** @hidden */
  33667. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33668. /**
  33669. * Update a dynamic index buffer
  33670. * @param indexBuffer defines the target index buffer
  33671. * @param indices defines the data to update
  33672. * @param offset defines the offset in the target index buffer where update should start
  33673. */
  33674. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33675. /**
  33676. * Updates the sample count of a render target texture
  33677. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33678. * @param texture defines the texture to update
  33679. * @param samples defines the sample count to set
  33680. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33681. */
  33682. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33683. /**
  33684. * Updates a depth texture Comparison Mode and Function.
  33685. * If the comparison Function is equal to 0, the mode will be set to none.
  33686. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33687. * @param texture The texture to set the comparison function for
  33688. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33689. */
  33690. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33691. /**
  33692. * Creates a webGL buffer to use with instanciation
  33693. * @param capacity defines the size of the buffer
  33694. * @returns the webGL buffer
  33695. */
  33696. createInstancesBuffer(capacity: number): DataBuffer;
  33697. /**
  33698. * Delete a webGL buffer used with instanciation
  33699. * @param buffer defines the webGL buffer to delete
  33700. */
  33701. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33702. /** @hidden */
  33703. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33704. dispose(): void;
  33705. private _disableTouchAction;
  33706. /**
  33707. * Display the loading screen
  33708. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33709. */
  33710. displayLoadingUI(): void;
  33711. /**
  33712. * Hide the loading screen
  33713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33714. */
  33715. hideLoadingUI(): void;
  33716. /**
  33717. * Gets the current loading screen object
  33718. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33719. */
  33720. get loadingScreen(): ILoadingScreen;
  33721. /**
  33722. * Sets the current loading screen object
  33723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33724. */
  33725. set loadingScreen(loadingScreen: ILoadingScreen);
  33726. /**
  33727. * Sets the current loading screen text
  33728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33729. */
  33730. set loadingUIText(text: string);
  33731. /**
  33732. * Sets the current loading screen background color
  33733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33734. */
  33735. set loadingUIBackgroundColor(color: string);
  33736. /** Pointerlock and fullscreen */
  33737. /**
  33738. * Ask the browser to promote the current element to pointerlock mode
  33739. * @param element defines the DOM element to promote
  33740. */
  33741. static _RequestPointerlock(element: HTMLElement): void;
  33742. /**
  33743. * Asks the browser to exit pointerlock mode
  33744. */
  33745. static _ExitPointerlock(): void;
  33746. /**
  33747. * Ask the browser to promote the current element to fullscreen rendering mode
  33748. * @param element defines the DOM element to promote
  33749. */
  33750. static _RequestFullscreen(element: HTMLElement): void;
  33751. /**
  33752. * Asks the browser to exit fullscreen mode
  33753. */
  33754. static _ExitFullscreen(): void;
  33755. }
  33756. }
  33757. declare module BABYLON {
  33758. /**
  33759. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33760. * during the life time of the application.
  33761. */
  33762. export class EngineStore {
  33763. /** Gets the list of created engines */
  33764. static Instances: Engine[];
  33765. /** @hidden */
  33766. static _LastCreatedScene: Nullable<Scene>;
  33767. /**
  33768. * Gets the latest created engine
  33769. */
  33770. static get LastCreatedEngine(): Nullable<Engine>;
  33771. /**
  33772. * Gets the latest created scene
  33773. */
  33774. static get LastCreatedScene(): Nullable<Scene>;
  33775. /**
  33776. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33777. * @ignorenaming
  33778. */
  33779. static UseFallbackTexture: boolean;
  33780. /**
  33781. * Texture content used if a texture cannot loaded
  33782. * @ignorenaming
  33783. */
  33784. static FallbackTexture: string;
  33785. }
  33786. }
  33787. declare module BABYLON {
  33788. /**
  33789. * Helper class that provides a small promise polyfill
  33790. */
  33791. export class PromisePolyfill {
  33792. /**
  33793. * Static function used to check if the polyfill is required
  33794. * If this is the case then the function will inject the polyfill to window.Promise
  33795. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33796. */
  33797. static Apply(force?: boolean): void;
  33798. }
  33799. }
  33800. declare module BABYLON {
  33801. /**
  33802. * Interface for screenshot methods with describe argument called `size` as object with options
  33803. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33804. */
  33805. export interface IScreenshotSize {
  33806. /**
  33807. * number in pixels for canvas height
  33808. */
  33809. height?: number;
  33810. /**
  33811. * multiplier allowing render at a higher or lower resolution
  33812. * If value is defined then height and width will be ignored and taken from camera
  33813. */
  33814. precision?: number;
  33815. /**
  33816. * number in pixels for canvas width
  33817. */
  33818. width?: number;
  33819. }
  33820. }
  33821. declare module BABYLON {
  33822. interface IColor4Like {
  33823. r: float;
  33824. g: float;
  33825. b: float;
  33826. a: float;
  33827. }
  33828. /**
  33829. * Class containing a set of static utilities functions
  33830. */
  33831. export class Tools {
  33832. /**
  33833. * Gets or sets the base URL to use to load assets
  33834. */
  33835. static get BaseUrl(): string;
  33836. static set BaseUrl(value: string);
  33837. /**
  33838. * Enable/Disable Custom HTTP Request Headers globally.
  33839. * default = false
  33840. * @see CustomRequestHeaders
  33841. */
  33842. static UseCustomRequestHeaders: boolean;
  33843. /**
  33844. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33845. * i.e. when loading files, where the server/service expects an Authorization header
  33846. */
  33847. static CustomRequestHeaders: {
  33848. [key: string]: string;
  33849. };
  33850. /**
  33851. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33852. */
  33853. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33854. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33855. /**
  33856. * Default behaviour for cors in the application.
  33857. * It can be a string if the expected behavior is identical in the entire app.
  33858. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33859. */
  33860. static CorsBehavior: string | ((url: string | string[]) => string);
  33861. /**
  33862. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33863. * @ignorenaming
  33864. */
  33865. static get UseFallbackTexture(): boolean;
  33866. static set UseFallbackTexture(value: boolean);
  33867. /**
  33868. * Use this object to register external classes like custom textures or material
  33869. * to allow the laoders to instantiate them
  33870. */
  33871. static get RegisteredExternalClasses(): {
  33872. [key: string]: Object;
  33873. };
  33874. static set RegisteredExternalClasses(classes: {
  33875. [key: string]: Object;
  33876. });
  33877. /**
  33878. * Texture content used if a texture cannot loaded
  33879. * @ignorenaming
  33880. */
  33881. static get fallbackTexture(): string;
  33882. static set fallbackTexture(value: string);
  33883. /**
  33884. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33885. * @param u defines the coordinate on X axis
  33886. * @param v defines the coordinate on Y axis
  33887. * @param width defines the width of the source data
  33888. * @param height defines the height of the source data
  33889. * @param pixels defines the source byte array
  33890. * @param color defines the output color
  33891. */
  33892. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33893. /**
  33894. * Interpolates between a and b via alpha
  33895. * @param a The lower value (returned when alpha = 0)
  33896. * @param b The upper value (returned when alpha = 1)
  33897. * @param alpha The interpolation-factor
  33898. * @return The mixed value
  33899. */
  33900. static Mix(a: number, b: number, alpha: number): number;
  33901. /**
  33902. * Tries to instantiate a new object from a given class name
  33903. * @param className defines the class name to instantiate
  33904. * @returns the new object or null if the system was not able to do the instantiation
  33905. */
  33906. static Instantiate(className: string): any;
  33907. /**
  33908. * Provides a slice function that will work even on IE
  33909. * @param data defines the array to slice
  33910. * @param start defines the start of the data (optional)
  33911. * @param end defines the end of the data (optional)
  33912. * @returns the new sliced array
  33913. */
  33914. static Slice<T>(data: T, start?: number, end?: number): T;
  33915. /**
  33916. * Polyfill for setImmediate
  33917. * @param action defines the action to execute after the current execution block
  33918. */
  33919. static SetImmediate(action: () => void): void;
  33920. /**
  33921. * Function indicating if a number is an exponent of 2
  33922. * @param value defines the value to test
  33923. * @returns true if the value is an exponent of 2
  33924. */
  33925. static IsExponentOfTwo(value: number): boolean;
  33926. private static _tmpFloatArray;
  33927. /**
  33928. * Returns the nearest 32-bit single precision float representation of a Number
  33929. * @param value A Number. If the parameter is of a different type, it will get converted
  33930. * to a number or to NaN if it cannot be converted
  33931. * @returns number
  33932. */
  33933. static FloatRound(value: number): number;
  33934. /**
  33935. * Extracts the filename from a path
  33936. * @param path defines the path to use
  33937. * @returns the filename
  33938. */
  33939. static GetFilename(path: string): string;
  33940. /**
  33941. * Extracts the "folder" part of a path (everything before the filename).
  33942. * @param uri The URI to extract the info from
  33943. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33944. * @returns The "folder" part of the path
  33945. */
  33946. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33947. /**
  33948. * Extracts text content from a DOM element hierarchy
  33949. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33950. */
  33951. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33952. /**
  33953. * Convert an angle in radians to degrees
  33954. * @param angle defines the angle to convert
  33955. * @returns the angle in degrees
  33956. */
  33957. static ToDegrees(angle: number): number;
  33958. /**
  33959. * Convert an angle in degrees to radians
  33960. * @param angle defines the angle to convert
  33961. * @returns the angle in radians
  33962. */
  33963. static ToRadians(angle: number): number;
  33964. /**
  33965. * Returns an array if obj is not an array
  33966. * @param obj defines the object to evaluate as an array
  33967. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33968. * @returns either obj directly if obj is an array or a new array containing obj
  33969. */
  33970. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33971. /**
  33972. * Gets the pointer prefix to use
  33973. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33974. */
  33975. static GetPointerPrefix(): string;
  33976. /**
  33977. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33978. * @param url define the url we are trying
  33979. * @param element define the dom element where to configure the cors policy
  33980. */
  33981. static SetCorsBehavior(url: string | string[], element: {
  33982. crossOrigin: string | null;
  33983. }): void;
  33984. /**
  33985. * Removes unwanted characters from an url
  33986. * @param url defines the url to clean
  33987. * @returns the cleaned url
  33988. */
  33989. static CleanUrl(url: string): string;
  33990. /**
  33991. * Gets or sets a function used to pre-process url before using them to load assets
  33992. */
  33993. static get PreprocessUrl(): (url: string) => string;
  33994. static set PreprocessUrl(processor: (url: string) => string);
  33995. /**
  33996. * Loads an image as an HTMLImageElement.
  33997. * @param input url string, ArrayBuffer, or Blob to load
  33998. * @param onLoad callback called when the image successfully loads
  33999. * @param onError callback called when the image fails to load
  34000. * @param offlineProvider offline provider for caching
  34001. * @param mimeType optional mime type
  34002. * @returns the HTMLImageElement of the loaded image
  34003. */
  34004. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34005. /**
  34006. * Loads a file from a url
  34007. * @param url url string, ArrayBuffer, or Blob to load
  34008. * @param onSuccess callback called when the file successfully loads
  34009. * @param onProgress callback called while file is loading (if the server supports this mode)
  34010. * @param offlineProvider defines the offline provider for caching
  34011. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34012. * @param onError callback called when the file fails to load
  34013. * @returns a file request object
  34014. */
  34015. 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;
  34016. /**
  34017. * Loads a file from a url
  34018. * @param url the file url to load
  34019. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34020. */
  34021. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34022. /**
  34023. * Load a script (identified by an url). When the url returns, the
  34024. * content of this file is added into a new script element, attached to the DOM (body element)
  34025. * @param scriptUrl defines the url of the script to laod
  34026. * @param onSuccess defines the callback called when the script is loaded
  34027. * @param onError defines the callback to call if an error occurs
  34028. * @param scriptId defines the id of the script element
  34029. */
  34030. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34031. /**
  34032. * Load an asynchronous script (identified by an url). When the url returns, the
  34033. * content of this file is added into a new script element, attached to the DOM (body element)
  34034. * @param scriptUrl defines the url of the script to laod
  34035. * @param scriptId defines the id of the script element
  34036. * @returns a promise request object
  34037. */
  34038. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34039. /**
  34040. * Loads a file from a blob
  34041. * @param fileToLoad defines the blob to use
  34042. * @param callback defines the callback to call when data is loaded
  34043. * @param progressCallback defines the callback to call during loading process
  34044. * @returns a file request object
  34045. */
  34046. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34047. /**
  34048. * Reads a file from a File object
  34049. * @param file defines the file to load
  34050. * @param onSuccess defines the callback to call when data is loaded
  34051. * @param onProgress defines the callback to call during loading process
  34052. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34053. * @param onError defines the callback to call when an error occurs
  34054. * @returns a file request object
  34055. */
  34056. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34057. /**
  34058. * Creates a data url from a given string content
  34059. * @param content defines the content to convert
  34060. * @returns the new data url link
  34061. */
  34062. static FileAsURL(content: string): string;
  34063. /**
  34064. * Format the given number to a specific decimal format
  34065. * @param value defines the number to format
  34066. * @param decimals defines the number of decimals to use
  34067. * @returns the formatted string
  34068. */
  34069. static Format(value: number, decimals?: number): string;
  34070. /**
  34071. * Tries to copy an object by duplicating every property
  34072. * @param source defines the source object
  34073. * @param destination defines the target object
  34074. * @param doNotCopyList defines a list of properties to avoid
  34075. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34076. */
  34077. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34078. /**
  34079. * Gets a boolean indicating if the given object has no own property
  34080. * @param obj defines the object to test
  34081. * @returns true if object has no own property
  34082. */
  34083. static IsEmpty(obj: any): boolean;
  34084. /**
  34085. * Function used to register events at window level
  34086. * @param windowElement defines the Window object to use
  34087. * @param events defines the events to register
  34088. */
  34089. static RegisterTopRootEvents(windowElement: Window, events: {
  34090. name: string;
  34091. handler: Nullable<(e: FocusEvent) => any>;
  34092. }[]): void;
  34093. /**
  34094. * Function used to unregister events from window level
  34095. * @param windowElement defines the Window object to use
  34096. * @param events defines the events to unregister
  34097. */
  34098. static UnregisterTopRootEvents(windowElement: Window, events: {
  34099. name: string;
  34100. handler: Nullable<(e: FocusEvent) => any>;
  34101. }[]): void;
  34102. /**
  34103. * @ignore
  34104. */
  34105. static _ScreenshotCanvas: HTMLCanvasElement;
  34106. /**
  34107. * Dumps the current bound framebuffer
  34108. * @param width defines the rendering width
  34109. * @param height defines the rendering height
  34110. * @param engine defines the hosting engine
  34111. * @param successCallback defines the callback triggered once the data are available
  34112. * @param mimeType defines the mime type of the result
  34113. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34114. */
  34115. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34116. /**
  34117. * Converts the canvas data to blob.
  34118. * This acts as a polyfill for browsers not supporting the to blob function.
  34119. * @param canvas Defines the canvas to extract the data from
  34120. * @param successCallback Defines the callback triggered once the data are available
  34121. * @param mimeType Defines the mime type of the result
  34122. */
  34123. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34124. /**
  34125. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34126. * @param successCallback defines the callback triggered once the data are available
  34127. * @param mimeType defines the mime type of the result
  34128. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34129. */
  34130. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34131. /**
  34132. * Downloads a blob in the browser
  34133. * @param blob defines the blob to download
  34134. * @param fileName defines the name of the downloaded file
  34135. */
  34136. static Download(blob: Blob, fileName: string): void;
  34137. /**
  34138. * Captures a screenshot of the current rendering
  34139. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34140. * @param engine defines the rendering engine
  34141. * @param camera defines the source camera
  34142. * @param size This parameter can be set to a single number or to an object with the
  34143. * following (optional) properties: precision, width, height. If a single number is passed,
  34144. * it will be used for both width and height. If an object is passed, the screenshot size
  34145. * will be derived from the parameters. The precision property is a multiplier allowing
  34146. * rendering at a higher or lower resolution
  34147. * @param successCallback defines the callback receives a single parameter which contains the
  34148. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34149. * src parameter of an <img> to display it
  34150. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34151. * Check your browser for supported MIME types
  34152. */
  34153. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34154. /**
  34155. * Captures a screenshot of the current rendering
  34156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34157. * @param engine defines the rendering engine
  34158. * @param camera defines the source camera
  34159. * @param size This parameter can be set to a single number or to an object with the
  34160. * following (optional) properties: precision, width, height. If a single number is passed,
  34161. * it will be used for both width and height. If an object is passed, the screenshot size
  34162. * will be derived from the parameters. The precision property is a multiplier allowing
  34163. * rendering at a higher or lower resolution
  34164. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34165. * Check your browser for supported MIME types
  34166. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34167. * to the src parameter of an <img> to display it
  34168. */
  34169. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34170. /**
  34171. * Generates an image screenshot from the specified camera.
  34172. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34173. * @param engine The engine to use for rendering
  34174. * @param camera The camera to use for rendering
  34175. * @param size This parameter can be set to a single number or to an object with the
  34176. * following (optional) properties: precision, width, height. If a single number is passed,
  34177. * it will be used for both width and height. If an object is passed, the screenshot size
  34178. * will be derived from the parameters. The precision property is a multiplier allowing
  34179. * rendering at a higher or lower resolution
  34180. * @param successCallback The callback receives a single parameter which contains the
  34181. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34182. * src parameter of an <img> to display it
  34183. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34184. * Check your browser for supported MIME types
  34185. * @param samples Texture samples (default: 1)
  34186. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34187. * @param fileName A name for for the downloaded file.
  34188. */
  34189. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34190. /**
  34191. * Generates an image screenshot from the specified camera.
  34192. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34193. * @param engine The engine to use for rendering
  34194. * @param camera The camera to use for rendering
  34195. * @param size This parameter can be set to a single number or to an object with the
  34196. * following (optional) properties: precision, width, height. If a single number is passed,
  34197. * it will be used for both width and height. If an object is passed, the screenshot size
  34198. * will be derived from the parameters. The precision property is a multiplier allowing
  34199. * rendering at a higher or lower resolution
  34200. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34201. * Check your browser for supported MIME types
  34202. * @param samples Texture samples (default: 1)
  34203. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34204. * @param fileName A name for for the downloaded file.
  34205. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34206. * to the src parameter of an <img> to display it
  34207. */
  34208. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34209. /**
  34210. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34211. * Be aware Math.random() could cause collisions, but:
  34212. * "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"
  34213. * @returns a pseudo random id
  34214. */
  34215. static RandomId(): string;
  34216. /**
  34217. * Test if the given uri is a base64 string
  34218. * @param uri The uri to test
  34219. * @return True if the uri is a base64 string or false otherwise
  34220. */
  34221. static IsBase64(uri: string): boolean;
  34222. /**
  34223. * Decode the given base64 uri.
  34224. * @param uri The uri to decode
  34225. * @return The decoded base64 data.
  34226. */
  34227. static DecodeBase64(uri: string): ArrayBuffer;
  34228. /**
  34229. * Gets the absolute url.
  34230. * @param url the input url
  34231. * @return the absolute url
  34232. */
  34233. static GetAbsoluteUrl(url: string): string;
  34234. /**
  34235. * No log
  34236. */
  34237. static readonly NoneLogLevel: number;
  34238. /**
  34239. * Only message logs
  34240. */
  34241. static readonly MessageLogLevel: number;
  34242. /**
  34243. * Only warning logs
  34244. */
  34245. static readonly WarningLogLevel: number;
  34246. /**
  34247. * Only error logs
  34248. */
  34249. static readonly ErrorLogLevel: number;
  34250. /**
  34251. * All logs
  34252. */
  34253. static readonly AllLogLevel: number;
  34254. /**
  34255. * Gets a value indicating the number of loading errors
  34256. * @ignorenaming
  34257. */
  34258. static get errorsCount(): number;
  34259. /**
  34260. * Callback called when a new log is added
  34261. */
  34262. static OnNewCacheEntry: (entry: string) => void;
  34263. /**
  34264. * Log a message to the console
  34265. * @param message defines the message to log
  34266. */
  34267. static Log(message: string): void;
  34268. /**
  34269. * Write a warning message to the console
  34270. * @param message defines the message to log
  34271. */
  34272. static Warn(message: string): void;
  34273. /**
  34274. * Write an error message to the console
  34275. * @param message defines the message to log
  34276. */
  34277. static Error(message: string): void;
  34278. /**
  34279. * Gets current log cache (list of logs)
  34280. */
  34281. static get LogCache(): string;
  34282. /**
  34283. * Clears the log cache
  34284. */
  34285. static ClearLogCache(): void;
  34286. /**
  34287. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34288. */
  34289. static set LogLevels(level: number);
  34290. /**
  34291. * Checks if the window object exists
  34292. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34293. */
  34294. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34295. /**
  34296. * No performance log
  34297. */
  34298. static readonly PerformanceNoneLogLevel: number;
  34299. /**
  34300. * Use user marks to log performance
  34301. */
  34302. static readonly PerformanceUserMarkLogLevel: number;
  34303. /**
  34304. * Log performance to the console
  34305. */
  34306. static readonly PerformanceConsoleLogLevel: number;
  34307. private static _performance;
  34308. /**
  34309. * Sets the current performance log level
  34310. */
  34311. static set PerformanceLogLevel(level: number);
  34312. private static _StartPerformanceCounterDisabled;
  34313. private static _EndPerformanceCounterDisabled;
  34314. private static _StartUserMark;
  34315. private static _EndUserMark;
  34316. private static _StartPerformanceConsole;
  34317. private static _EndPerformanceConsole;
  34318. /**
  34319. * Starts a performance counter
  34320. */
  34321. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34322. /**
  34323. * Ends a specific performance coutner
  34324. */
  34325. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34326. /**
  34327. * Gets either window.performance.now() if supported or Date.now() else
  34328. */
  34329. static get Now(): number;
  34330. /**
  34331. * This method will return the name of the class used to create the instance of the given object.
  34332. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34333. * @param object the object to get the class name from
  34334. * @param isType defines if the object is actually a type
  34335. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34336. */
  34337. static GetClassName(object: any, isType?: boolean): string;
  34338. /**
  34339. * Gets the first element of an array satisfying a given predicate
  34340. * @param array defines the array to browse
  34341. * @param predicate defines the predicate to use
  34342. * @returns null if not found or the element
  34343. */
  34344. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34345. /**
  34346. * This method will return the name of the full name of the class, including its owning module (if any).
  34347. * 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).
  34348. * @param object the object to get the class name from
  34349. * @param isType defines if the object is actually a type
  34350. * @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.
  34351. * @ignorenaming
  34352. */
  34353. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34354. /**
  34355. * Returns a promise that resolves after the given amount of time.
  34356. * @param delay Number of milliseconds to delay
  34357. * @returns Promise that resolves after the given amount of time
  34358. */
  34359. static DelayAsync(delay: number): Promise<void>;
  34360. /**
  34361. * Utility function to detect if the current user agent is Safari
  34362. * @returns whether or not the current user agent is safari
  34363. */
  34364. static IsSafari(): boolean;
  34365. }
  34366. /**
  34367. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34368. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34369. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34370. * @param name The name of the class, case should be preserved
  34371. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34372. */
  34373. export function className(name: string, module?: string): (target: Object) => void;
  34374. /**
  34375. * An implementation of a loop for asynchronous functions.
  34376. */
  34377. export class AsyncLoop {
  34378. /**
  34379. * Defines the number of iterations for the loop
  34380. */
  34381. iterations: number;
  34382. /**
  34383. * Defines the current index of the loop.
  34384. */
  34385. index: number;
  34386. private _done;
  34387. private _fn;
  34388. private _successCallback;
  34389. /**
  34390. * Constructor.
  34391. * @param iterations the number of iterations.
  34392. * @param func the function to run each iteration
  34393. * @param successCallback the callback that will be called upon succesful execution
  34394. * @param offset starting offset.
  34395. */
  34396. constructor(
  34397. /**
  34398. * Defines the number of iterations for the loop
  34399. */
  34400. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34401. /**
  34402. * Execute the next iteration. Must be called after the last iteration was finished.
  34403. */
  34404. executeNext(): void;
  34405. /**
  34406. * Break the loop and run the success callback.
  34407. */
  34408. breakLoop(): void;
  34409. /**
  34410. * Create and run an async loop.
  34411. * @param iterations the number of iterations.
  34412. * @param fn the function to run each iteration
  34413. * @param successCallback the callback that will be called upon succesful execution
  34414. * @param offset starting offset.
  34415. * @returns the created async loop object
  34416. */
  34417. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34418. /**
  34419. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34420. * @param iterations total number of iterations
  34421. * @param syncedIterations number of synchronous iterations in each async iteration.
  34422. * @param fn the function to call each iteration.
  34423. * @param callback a success call back that will be called when iterating stops.
  34424. * @param breakFunction a break condition (optional)
  34425. * @param timeout timeout settings for the setTimeout function. default - 0.
  34426. * @returns the created async loop object
  34427. */
  34428. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34429. }
  34430. }
  34431. declare module BABYLON {
  34432. /**
  34433. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34434. * The underlying implementation relies on an associative array to ensure the best performances.
  34435. * The value can be anything including 'null' but except 'undefined'
  34436. */
  34437. export class StringDictionary<T> {
  34438. /**
  34439. * This will clear this dictionary and copy the content from the 'source' one.
  34440. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34441. * @param source the dictionary to take the content from and copy to this dictionary
  34442. */
  34443. copyFrom(source: StringDictionary<T>): void;
  34444. /**
  34445. * Get a value based from its key
  34446. * @param key the given key to get the matching value from
  34447. * @return the value if found, otherwise undefined is returned
  34448. */
  34449. get(key: string): T | undefined;
  34450. /**
  34451. * Get a value from its key or add it if it doesn't exist.
  34452. * This method will ensure you that a given key/data will be present in the dictionary.
  34453. * @param key the given key to get the matching value from
  34454. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34455. * The factory will only be invoked if there's no data for the given key.
  34456. * @return the value corresponding to the key.
  34457. */
  34458. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34459. /**
  34460. * Get a value from its key if present in the dictionary otherwise add it
  34461. * @param key the key to get the value from
  34462. * @param val if there's no such key/value pair in the dictionary add it with this value
  34463. * @return the value corresponding to the key
  34464. */
  34465. getOrAdd(key: string, val: T): T;
  34466. /**
  34467. * Check if there's a given key in the dictionary
  34468. * @param key the key to check for
  34469. * @return true if the key is present, false otherwise
  34470. */
  34471. contains(key: string): boolean;
  34472. /**
  34473. * Add a new key and its corresponding value
  34474. * @param key the key to add
  34475. * @param value the value corresponding to the key
  34476. * @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
  34477. */
  34478. add(key: string, value: T): boolean;
  34479. /**
  34480. * Update a specific value associated to a key
  34481. * @param key defines the key to use
  34482. * @param value defines the value to store
  34483. * @returns true if the value was updated (or false if the key was not found)
  34484. */
  34485. set(key: string, value: T): boolean;
  34486. /**
  34487. * Get the element of the given key and remove it from the dictionary
  34488. * @param key defines the key to search
  34489. * @returns the value associated with the key or null if not found
  34490. */
  34491. getAndRemove(key: string): Nullable<T>;
  34492. /**
  34493. * Remove a key/value from the dictionary.
  34494. * @param key the key to remove
  34495. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34496. */
  34497. remove(key: string): boolean;
  34498. /**
  34499. * Clear the whole content of the dictionary
  34500. */
  34501. clear(): void;
  34502. /**
  34503. * Gets the current count
  34504. */
  34505. get count(): number;
  34506. /**
  34507. * Execute a callback on each key/val of the dictionary.
  34508. * Note that you can remove any element in this dictionary in the callback implementation
  34509. * @param callback the callback to execute on a given key/value pair
  34510. */
  34511. forEach(callback: (key: string, val: T) => void): void;
  34512. /**
  34513. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34514. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34515. * Note that you can remove any element in this dictionary in the callback implementation
  34516. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34517. * @returns the first item
  34518. */
  34519. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34520. private _count;
  34521. private _data;
  34522. }
  34523. }
  34524. declare module BABYLON {
  34525. /** @hidden */
  34526. export interface ICollisionCoordinator {
  34527. createCollider(): Collider;
  34528. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34529. init(scene: Scene): void;
  34530. }
  34531. /** @hidden */
  34532. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34533. private _scene;
  34534. private _scaledPosition;
  34535. private _scaledVelocity;
  34536. private _finalPosition;
  34537. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34538. createCollider(): Collider;
  34539. init(scene: Scene): void;
  34540. private _collideWithWorld;
  34541. }
  34542. }
  34543. declare module BABYLON {
  34544. /**
  34545. * Class used to manage all inputs for the scene.
  34546. */
  34547. export class InputManager {
  34548. /** The distance in pixel that you have to move to prevent some events */
  34549. static DragMovementThreshold: number;
  34550. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34551. static LongPressDelay: number;
  34552. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34553. static DoubleClickDelay: number;
  34554. /** If you need to check double click without raising a single click at first click, enable this flag */
  34555. static ExclusiveDoubleClickMode: boolean;
  34556. private _wheelEventName;
  34557. private _onPointerMove;
  34558. private _onPointerDown;
  34559. private _onPointerUp;
  34560. private _initClickEvent;
  34561. private _initActionManager;
  34562. private _delayedSimpleClick;
  34563. private _delayedSimpleClickTimeout;
  34564. private _previousDelayedSimpleClickTimeout;
  34565. private _meshPickProceed;
  34566. private _previousButtonPressed;
  34567. private _currentPickResult;
  34568. private _previousPickResult;
  34569. private _totalPointersPressed;
  34570. private _doubleClickOccured;
  34571. private _pointerOverMesh;
  34572. private _pickedDownMesh;
  34573. private _pickedUpMesh;
  34574. private _pointerX;
  34575. private _pointerY;
  34576. private _unTranslatedPointerX;
  34577. private _unTranslatedPointerY;
  34578. private _startingPointerPosition;
  34579. private _previousStartingPointerPosition;
  34580. private _startingPointerTime;
  34581. private _previousStartingPointerTime;
  34582. private _pointerCaptures;
  34583. private _onKeyDown;
  34584. private _onKeyUp;
  34585. private _onCanvasFocusObserver;
  34586. private _onCanvasBlurObserver;
  34587. private _scene;
  34588. /**
  34589. * Creates a new InputManager
  34590. * @param scene defines the hosting scene
  34591. */
  34592. constructor(scene: Scene);
  34593. /**
  34594. * Gets the mesh that is currently under the pointer
  34595. */
  34596. get meshUnderPointer(): Nullable<AbstractMesh>;
  34597. /**
  34598. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34599. */
  34600. get unTranslatedPointer(): Vector2;
  34601. /**
  34602. * Gets or sets the current on-screen X position of the pointer
  34603. */
  34604. get pointerX(): number;
  34605. set pointerX(value: number);
  34606. /**
  34607. * Gets or sets the current on-screen Y position of the pointer
  34608. */
  34609. get pointerY(): number;
  34610. set pointerY(value: number);
  34611. private _updatePointerPosition;
  34612. private _processPointerMove;
  34613. private _setRayOnPointerInfo;
  34614. private _checkPrePointerObservable;
  34615. /**
  34616. * Use this method to simulate a pointer move on a mesh
  34617. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34618. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34619. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34620. */
  34621. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34622. /**
  34623. * Use this method to simulate a pointer down on a mesh
  34624. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34625. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34626. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34627. */
  34628. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34629. private _processPointerDown;
  34630. /** @hidden */
  34631. _isPointerSwiping(): boolean;
  34632. /**
  34633. * Use this method to simulate a pointer up on a mesh
  34634. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34635. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34636. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34637. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34638. */
  34639. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34640. private _processPointerUp;
  34641. /**
  34642. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34643. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34644. * @returns true if the pointer was captured
  34645. */
  34646. isPointerCaptured(pointerId?: number): boolean;
  34647. /**
  34648. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34649. * @param attachUp defines if you want to attach events to pointerup
  34650. * @param attachDown defines if you want to attach events to pointerdown
  34651. * @param attachMove defines if you want to attach events to pointermove
  34652. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34653. */
  34654. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34655. /**
  34656. * Detaches all event handlers
  34657. */
  34658. detachControl(): void;
  34659. /**
  34660. * Force the value of meshUnderPointer
  34661. * @param mesh defines the mesh to use
  34662. */
  34663. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34664. /**
  34665. * Gets the mesh under the pointer
  34666. * @returns a Mesh or null if no mesh is under the pointer
  34667. */
  34668. getPointerOverMesh(): Nullable<AbstractMesh>;
  34669. }
  34670. }
  34671. declare module BABYLON {
  34672. /**
  34673. * Helper class used to generate session unique ID
  34674. */
  34675. export class UniqueIdGenerator {
  34676. private static _UniqueIdCounter;
  34677. /**
  34678. * Gets an unique (relatively to the current scene) Id
  34679. */
  34680. static get UniqueId(): number;
  34681. }
  34682. }
  34683. declare module BABYLON {
  34684. /**
  34685. * This class defines the direct association between an animation and a target
  34686. */
  34687. export class TargetedAnimation {
  34688. /**
  34689. * Animation to perform
  34690. */
  34691. animation: Animation;
  34692. /**
  34693. * Target to animate
  34694. */
  34695. target: any;
  34696. /**
  34697. * Serialize the object
  34698. * @returns the JSON object representing the current entity
  34699. */
  34700. serialize(): any;
  34701. }
  34702. /**
  34703. * Use this class to create coordinated animations on multiple targets
  34704. */
  34705. export class AnimationGroup implements IDisposable {
  34706. /** The name of the animation group */
  34707. name: string;
  34708. private _scene;
  34709. private _targetedAnimations;
  34710. private _animatables;
  34711. private _from;
  34712. private _to;
  34713. private _isStarted;
  34714. private _isPaused;
  34715. private _speedRatio;
  34716. private _loopAnimation;
  34717. /**
  34718. * Gets or sets the unique id of the node
  34719. */
  34720. uniqueId: number;
  34721. /**
  34722. * This observable will notify when one animation have ended
  34723. */
  34724. onAnimationEndObservable: Observable<TargetedAnimation>;
  34725. /**
  34726. * Observer raised when one animation loops
  34727. */
  34728. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34729. /**
  34730. * Observer raised when all animations have looped
  34731. */
  34732. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34733. /**
  34734. * This observable will notify when all animations have ended.
  34735. */
  34736. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34737. /**
  34738. * This observable will notify when all animations have paused.
  34739. */
  34740. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34741. /**
  34742. * This observable will notify when all animations are playing.
  34743. */
  34744. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34745. /**
  34746. * Gets the first frame
  34747. */
  34748. get from(): number;
  34749. /**
  34750. * Gets the last frame
  34751. */
  34752. get to(): number;
  34753. /**
  34754. * Define if the animations are started
  34755. */
  34756. get isStarted(): boolean;
  34757. /**
  34758. * Gets a value indicating that the current group is playing
  34759. */
  34760. get isPlaying(): boolean;
  34761. /**
  34762. * Gets or sets the speed ratio to use for all animations
  34763. */
  34764. get speedRatio(): number;
  34765. /**
  34766. * Gets or sets the speed ratio to use for all animations
  34767. */
  34768. set speedRatio(value: number);
  34769. /**
  34770. * Gets or sets if all animations should loop or not
  34771. */
  34772. get loopAnimation(): boolean;
  34773. set loopAnimation(value: boolean);
  34774. /**
  34775. * Gets the targeted animations for this animation group
  34776. */
  34777. get targetedAnimations(): Array<TargetedAnimation>;
  34778. /**
  34779. * returning the list of animatables controlled by this animation group.
  34780. */
  34781. get animatables(): Array<Animatable>;
  34782. /**
  34783. * Instantiates a new Animation Group.
  34784. * This helps managing several animations at once.
  34785. * @see http://doc.babylonjs.com/how_to/group
  34786. * @param name Defines the name of the group
  34787. * @param scene Defines the scene the group belongs to
  34788. */
  34789. constructor(
  34790. /** The name of the animation group */
  34791. name: string, scene?: Nullable<Scene>);
  34792. /**
  34793. * Add an animation (with its target) in the group
  34794. * @param animation defines the animation we want to add
  34795. * @param target defines the target of the animation
  34796. * @returns the TargetedAnimation object
  34797. */
  34798. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34799. /**
  34800. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34801. * It can add constant keys at begin or end
  34802. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34803. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34804. * @returns the animation group
  34805. */
  34806. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34807. private _animationLoopCount;
  34808. private _animationLoopFlags;
  34809. private _processLoop;
  34810. /**
  34811. * Start all animations on given targets
  34812. * @param loop defines if animations must loop
  34813. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34814. * @param from defines the from key (optional)
  34815. * @param to defines the to key (optional)
  34816. * @returns the current animation group
  34817. */
  34818. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34819. /**
  34820. * Pause all animations
  34821. * @returns the animation group
  34822. */
  34823. pause(): AnimationGroup;
  34824. /**
  34825. * Play all animations to initial state
  34826. * This function will start() the animations if they were not started or will restart() them if they were paused
  34827. * @param loop defines if animations must loop
  34828. * @returns the animation group
  34829. */
  34830. play(loop?: boolean): AnimationGroup;
  34831. /**
  34832. * Reset all animations to initial state
  34833. * @returns the animation group
  34834. */
  34835. reset(): AnimationGroup;
  34836. /**
  34837. * Restart animations from key 0
  34838. * @returns the animation group
  34839. */
  34840. restart(): AnimationGroup;
  34841. /**
  34842. * Stop all animations
  34843. * @returns the animation group
  34844. */
  34845. stop(): AnimationGroup;
  34846. /**
  34847. * Set animation weight for all animatables
  34848. * @param weight defines the weight to use
  34849. * @return the animationGroup
  34850. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34851. */
  34852. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34853. /**
  34854. * Synchronize and normalize all animatables with a source animatable
  34855. * @param root defines the root animatable to synchronize with
  34856. * @return the animationGroup
  34857. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34858. */
  34859. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34860. /**
  34861. * Goes to a specific frame in this animation group
  34862. * @param frame the frame number to go to
  34863. * @return the animationGroup
  34864. */
  34865. goToFrame(frame: number): AnimationGroup;
  34866. /**
  34867. * Dispose all associated resources
  34868. */
  34869. dispose(): void;
  34870. private _checkAnimationGroupEnded;
  34871. /**
  34872. * Clone the current animation group and returns a copy
  34873. * @param newName defines the name of the new group
  34874. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34875. * @returns the new aniamtion group
  34876. */
  34877. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34878. /**
  34879. * Serializes the animationGroup to an object
  34880. * @returns Serialized object
  34881. */
  34882. serialize(): any;
  34883. /**
  34884. * Returns a new AnimationGroup object parsed from the source provided.
  34885. * @param parsedAnimationGroup defines the source
  34886. * @param scene defines the scene that will receive the animationGroup
  34887. * @returns a new AnimationGroup
  34888. */
  34889. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34890. /**
  34891. * Returns the string "AnimationGroup"
  34892. * @returns "AnimationGroup"
  34893. */
  34894. getClassName(): string;
  34895. /**
  34896. * Creates a detailled string about the object
  34897. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34898. * @returns a string representing the object
  34899. */
  34900. toString(fullDetails?: boolean): string;
  34901. }
  34902. }
  34903. declare module BABYLON {
  34904. /**
  34905. * Define an interface for all classes that will hold resources
  34906. */
  34907. export interface IDisposable {
  34908. /**
  34909. * Releases all held resources
  34910. */
  34911. dispose(): void;
  34912. }
  34913. /** Interface defining initialization parameters for Scene class */
  34914. export interface SceneOptions {
  34915. /**
  34916. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34917. * It will improve performance when the number of geometries becomes important.
  34918. */
  34919. useGeometryUniqueIdsMap?: boolean;
  34920. /**
  34921. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34922. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34923. */
  34924. useMaterialMeshMap?: boolean;
  34925. /**
  34926. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34927. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34928. */
  34929. useClonedMeshMap?: boolean;
  34930. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34931. virtual?: boolean;
  34932. }
  34933. /**
  34934. * Represents a scene to be rendered by the engine.
  34935. * @see http://doc.babylonjs.com/features/scene
  34936. */
  34937. export class Scene extends AbstractScene implements IAnimatable {
  34938. /** The fog is deactivated */
  34939. static readonly FOGMODE_NONE: number;
  34940. /** The fog density is following an exponential function */
  34941. static readonly FOGMODE_EXP: number;
  34942. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34943. static readonly FOGMODE_EXP2: number;
  34944. /** The fog density is following a linear function. */
  34945. static readonly FOGMODE_LINEAR: number;
  34946. /**
  34947. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34948. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34949. */
  34950. static MinDeltaTime: number;
  34951. /**
  34952. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34954. */
  34955. static MaxDeltaTime: number;
  34956. /**
  34957. * Factory used to create the default material.
  34958. * @param name The name of the material to create
  34959. * @param scene The scene to create the material for
  34960. * @returns The default material
  34961. */
  34962. static DefaultMaterialFactory(scene: Scene): Material;
  34963. /**
  34964. * Factory used to create the a collision coordinator.
  34965. * @returns The collision coordinator
  34966. */
  34967. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34968. /** @hidden */
  34969. _inputManager: InputManager;
  34970. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34971. cameraToUseForPointers: Nullable<Camera>;
  34972. /** @hidden */
  34973. readonly _isScene: boolean;
  34974. /**
  34975. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34976. */
  34977. autoClear: boolean;
  34978. /**
  34979. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34980. */
  34981. autoClearDepthAndStencil: boolean;
  34982. /**
  34983. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34984. */
  34985. clearColor: Color4;
  34986. /**
  34987. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34988. */
  34989. ambientColor: Color3;
  34990. /**
  34991. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34992. * It should only be one of the following (if not the default embedded one):
  34993. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34994. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34995. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34996. * The material properties need to be setup according to the type of texture in use.
  34997. */
  34998. environmentBRDFTexture: BaseTexture;
  34999. /** @hidden */
  35000. protected _environmentTexture: Nullable<BaseTexture>;
  35001. /**
  35002. * Texture used in all pbr material as the reflection texture.
  35003. * As in the majority of the scene they are the same (exception for multi room and so on),
  35004. * this is easier to reference from here than from all the materials.
  35005. */
  35006. get environmentTexture(): Nullable<BaseTexture>;
  35007. /**
  35008. * Texture used in all pbr material as the reflection texture.
  35009. * As in the majority of the scene they are the same (exception for multi room and so on),
  35010. * this is easier to set here than in all the materials.
  35011. */
  35012. set environmentTexture(value: Nullable<BaseTexture>);
  35013. /** @hidden */
  35014. protected _environmentIntensity: number;
  35015. /**
  35016. * Intensity of the environment in all pbr material.
  35017. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35018. * As in the majority of the scene they are the same (exception for multi room and so on),
  35019. * this is easier to reference from here than from all the materials.
  35020. */
  35021. get environmentIntensity(): number;
  35022. /**
  35023. * Intensity of the environment in all pbr material.
  35024. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35025. * As in the majority of the scene they are the same (exception for multi room and so on),
  35026. * this is easier to set here than in all the materials.
  35027. */
  35028. set environmentIntensity(value: number);
  35029. /** @hidden */
  35030. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35031. /**
  35032. * Default image processing configuration used either in the rendering
  35033. * Forward main pass or through the imageProcessingPostProcess if present.
  35034. * As in the majority of the scene they are the same (exception for multi camera),
  35035. * this is easier to reference from here than from all the materials and post process.
  35036. *
  35037. * No setter as we it is a shared configuration, you can set the values instead.
  35038. */
  35039. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35040. private _forceWireframe;
  35041. /**
  35042. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35043. */
  35044. set forceWireframe(value: boolean);
  35045. get forceWireframe(): boolean;
  35046. private _skipFrustumClipping;
  35047. /**
  35048. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35049. */
  35050. set skipFrustumClipping(value: boolean);
  35051. get skipFrustumClipping(): boolean;
  35052. private _forcePointsCloud;
  35053. /**
  35054. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35055. */
  35056. set forcePointsCloud(value: boolean);
  35057. get forcePointsCloud(): boolean;
  35058. /**
  35059. * Gets or sets the active clipplane 1
  35060. */
  35061. clipPlane: Nullable<Plane>;
  35062. /**
  35063. * Gets or sets the active clipplane 2
  35064. */
  35065. clipPlane2: Nullable<Plane>;
  35066. /**
  35067. * Gets or sets the active clipplane 3
  35068. */
  35069. clipPlane3: Nullable<Plane>;
  35070. /**
  35071. * Gets or sets the active clipplane 4
  35072. */
  35073. clipPlane4: Nullable<Plane>;
  35074. /**
  35075. * Gets or sets the active clipplane 5
  35076. */
  35077. clipPlane5: Nullable<Plane>;
  35078. /**
  35079. * Gets or sets the active clipplane 6
  35080. */
  35081. clipPlane6: Nullable<Plane>;
  35082. /**
  35083. * Gets or sets a boolean indicating if animations are enabled
  35084. */
  35085. animationsEnabled: boolean;
  35086. private _animationPropertiesOverride;
  35087. /**
  35088. * Gets or sets the animation properties override
  35089. */
  35090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35091. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35092. /**
  35093. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35094. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35095. */
  35096. useConstantAnimationDeltaTime: boolean;
  35097. /**
  35098. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35099. * Please note that it requires to run a ray cast through the scene on every frame
  35100. */
  35101. constantlyUpdateMeshUnderPointer: boolean;
  35102. /**
  35103. * Defines the HTML cursor to use when hovering over interactive elements
  35104. */
  35105. hoverCursor: string;
  35106. /**
  35107. * Defines the HTML default cursor to use (empty by default)
  35108. */
  35109. defaultCursor: string;
  35110. /**
  35111. * Defines wether cursors are handled by the scene.
  35112. */
  35113. doNotHandleCursors: boolean;
  35114. /**
  35115. * This is used to call preventDefault() on pointer down
  35116. * in order to block unwanted artifacts like system double clicks
  35117. */
  35118. preventDefaultOnPointerDown: boolean;
  35119. /**
  35120. * This is used to call preventDefault() on pointer up
  35121. * in order to block unwanted artifacts like system double clicks
  35122. */
  35123. preventDefaultOnPointerUp: boolean;
  35124. /**
  35125. * Gets or sets user defined metadata
  35126. */
  35127. metadata: any;
  35128. /**
  35129. * For internal use only. Please do not use.
  35130. */
  35131. reservedDataStore: any;
  35132. /**
  35133. * Gets the name of the plugin used to load this scene (null by default)
  35134. */
  35135. loadingPluginName: string;
  35136. /**
  35137. * Use this array to add regular expressions used to disable offline support for specific urls
  35138. */
  35139. disableOfflineSupportExceptionRules: RegExp[];
  35140. /**
  35141. * An event triggered when the scene is disposed.
  35142. */
  35143. onDisposeObservable: Observable<Scene>;
  35144. private _onDisposeObserver;
  35145. /** Sets a function to be executed when this scene is disposed. */
  35146. set onDispose(callback: () => void);
  35147. /**
  35148. * An event triggered before rendering the scene (right after animations and physics)
  35149. */
  35150. onBeforeRenderObservable: Observable<Scene>;
  35151. private _onBeforeRenderObserver;
  35152. /** Sets a function to be executed before rendering this scene */
  35153. set beforeRender(callback: Nullable<() => void>);
  35154. /**
  35155. * An event triggered after rendering the scene
  35156. */
  35157. onAfterRenderObservable: Observable<Scene>;
  35158. /**
  35159. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35160. */
  35161. onAfterRenderCameraObservable: Observable<Camera>;
  35162. private _onAfterRenderObserver;
  35163. /** Sets a function to be executed after rendering this scene */
  35164. set afterRender(callback: Nullable<() => void>);
  35165. /**
  35166. * An event triggered before animating the scene
  35167. */
  35168. onBeforeAnimationsObservable: Observable<Scene>;
  35169. /**
  35170. * An event triggered after animations processing
  35171. */
  35172. onAfterAnimationsObservable: Observable<Scene>;
  35173. /**
  35174. * An event triggered before draw calls are ready to be sent
  35175. */
  35176. onBeforeDrawPhaseObservable: Observable<Scene>;
  35177. /**
  35178. * An event triggered after draw calls have been sent
  35179. */
  35180. onAfterDrawPhaseObservable: Observable<Scene>;
  35181. /**
  35182. * An event triggered when the scene is ready
  35183. */
  35184. onReadyObservable: Observable<Scene>;
  35185. /**
  35186. * An event triggered before rendering a camera
  35187. */
  35188. onBeforeCameraRenderObservable: Observable<Camera>;
  35189. private _onBeforeCameraRenderObserver;
  35190. /** Sets a function to be executed before rendering a camera*/
  35191. set beforeCameraRender(callback: () => void);
  35192. /**
  35193. * An event triggered after rendering a camera
  35194. */
  35195. onAfterCameraRenderObservable: Observable<Camera>;
  35196. private _onAfterCameraRenderObserver;
  35197. /** Sets a function to be executed after rendering a camera*/
  35198. set afterCameraRender(callback: () => void);
  35199. /**
  35200. * An event triggered when active meshes evaluation is about to start
  35201. */
  35202. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35203. /**
  35204. * An event triggered when active meshes evaluation is done
  35205. */
  35206. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35207. /**
  35208. * An event triggered when particles rendering is about to start
  35209. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35210. */
  35211. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35212. /**
  35213. * An event triggered when particles rendering is done
  35214. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35215. */
  35216. onAfterParticlesRenderingObservable: Observable<Scene>;
  35217. /**
  35218. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35219. */
  35220. onDataLoadedObservable: Observable<Scene>;
  35221. /**
  35222. * An event triggered when a camera is created
  35223. */
  35224. onNewCameraAddedObservable: Observable<Camera>;
  35225. /**
  35226. * An event triggered when a camera is removed
  35227. */
  35228. onCameraRemovedObservable: Observable<Camera>;
  35229. /**
  35230. * An event triggered when a light is created
  35231. */
  35232. onNewLightAddedObservable: Observable<Light>;
  35233. /**
  35234. * An event triggered when a light is removed
  35235. */
  35236. onLightRemovedObservable: Observable<Light>;
  35237. /**
  35238. * An event triggered when a geometry is created
  35239. */
  35240. onNewGeometryAddedObservable: Observable<Geometry>;
  35241. /**
  35242. * An event triggered when a geometry is removed
  35243. */
  35244. onGeometryRemovedObservable: Observable<Geometry>;
  35245. /**
  35246. * An event triggered when a transform node is created
  35247. */
  35248. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35249. /**
  35250. * An event triggered when a transform node is removed
  35251. */
  35252. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35253. /**
  35254. * An event triggered when a mesh is created
  35255. */
  35256. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35257. /**
  35258. * An event triggered when a mesh is removed
  35259. */
  35260. onMeshRemovedObservable: Observable<AbstractMesh>;
  35261. /**
  35262. * An event triggered when a skeleton is created
  35263. */
  35264. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35265. /**
  35266. * An event triggered when a skeleton is removed
  35267. */
  35268. onSkeletonRemovedObservable: Observable<Skeleton>;
  35269. /**
  35270. * An event triggered when a material is created
  35271. */
  35272. onNewMaterialAddedObservable: Observable<Material>;
  35273. /**
  35274. * An event triggered when a material is removed
  35275. */
  35276. onMaterialRemovedObservable: Observable<Material>;
  35277. /**
  35278. * An event triggered when a texture is created
  35279. */
  35280. onNewTextureAddedObservable: Observable<BaseTexture>;
  35281. /**
  35282. * An event triggered when a texture is removed
  35283. */
  35284. onTextureRemovedObservable: Observable<BaseTexture>;
  35285. /**
  35286. * An event triggered when render targets are about to be rendered
  35287. * Can happen multiple times per frame.
  35288. */
  35289. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35290. /**
  35291. * An event triggered when render targets were rendered.
  35292. * Can happen multiple times per frame.
  35293. */
  35294. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35295. /**
  35296. * An event triggered before calculating deterministic simulation step
  35297. */
  35298. onBeforeStepObservable: Observable<Scene>;
  35299. /**
  35300. * An event triggered after calculating deterministic simulation step
  35301. */
  35302. onAfterStepObservable: Observable<Scene>;
  35303. /**
  35304. * An event triggered when the activeCamera property is updated
  35305. */
  35306. onActiveCameraChanged: Observable<Scene>;
  35307. /**
  35308. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35309. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35310. * 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)
  35311. */
  35312. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35313. /**
  35314. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35315. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35316. * 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)
  35317. */
  35318. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35319. /**
  35320. * This Observable will when a mesh has been imported into the scene.
  35321. */
  35322. onMeshImportedObservable: Observable<AbstractMesh>;
  35323. /**
  35324. * This Observable will when an animation file has been imported into the scene.
  35325. */
  35326. onAnimationFileImportedObservable: Observable<Scene>;
  35327. /**
  35328. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35329. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35330. */
  35331. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35332. /** @hidden */
  35333. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35334. /**
  35335. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35336. */
  35337. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35338. /**
  35339. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35340. */
  35341. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35342. /**
  35343. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35344. */
  35345. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35346. /** Callback called when a pointer move is detected */
  35347. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35348. /** Callback called when a pointer down is detected */
  35349. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35350. /** Callback called when a pointer up is detected */
  35351. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35352. /** Callback called when a pointer pick is detected */
  35353. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35354. /**
  35355. * 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).
  35356. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35357. */
  35358. onPrePointerObservable: Observable<PointerInfoPre>;
  35359. /**
  35360. * Observable event triggered each time an input event is received from the rendering canvas
  35361. */
  35362. onPointerObservable: Observable<PointerInfo>;
  35363. /**
  35364. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35365. */
  35366. get unTranslatedPointer(): Vector2;
  35367. /**
  35368. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35369. */
  35370. static get DragMovementThreshold(): number;
  35371. static set DragMovementThreshold(value: number);
  35372. /**
  35373. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35374. */
  35375. static get LongPressDelay(): number;
  35376. static set LongPressDelay(value: number);
  35377. /**
  35378. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35379. */
  35380. static get DoubleClickDelay(): number;
  35381. static set DoubleClickDelay(value: number);
  35382. /** If you need to check double click without raising a single click at first click, enable this flag */
  35383. static get ExclusiveDoubleClickMode(): boolean;
  35384. static set ExclusiveDoubleClickMode(value: boolean);
  35385. /** @hidden */
  35386. _mirroredCameraPosition: Nullable<Vector3>;
  35387. /**
  35388. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35389. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35390. */
  35391. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35392. /**
  35393. * Observable event triggered each time an keyboard event is received from the hosting window
  35394. */
  35395. onKeyboardObservable: Observable<KeyboardInfo>;
  35396. private _useRightHandedSystem;
  35397. /**
  35398. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35399. */
  35400. set useRightHandedSystem(value: boolean);
  35401. get useRightHandedSystem(): boolean;
  35402. private _timeAccumulator;
  35403. private _currentStepId;
  35404. private _currentInternalStep;
  35405. /**
  35406. * Sets the step Id used by deterministic lock step
  35407. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35408. * @param newStepId defines the step Id
  35409. */
  35410. setStepId(newStepId: number): void;
  35411. /**
  35412. * Gets the step Id used by deterministic lock step
  35413. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35414. * @returns the step Id
  35415. */
  35416. getStepId(): number;
  35417. /**
  35418. * Gets the internal step used by deterministic lock step
  35419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35420. * @returns the internal step
  35421. */
  35422. getInternalStep(): number;
  35423. private _fogEnabled;
  35424. /**
  35425. * Gets or sets a boolean indicating if fog is enabled on this scene
  35426. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35427. * (Default is true)
  35428. */
  35429. set fogEnabled(value: boolean);
  35430. get fogEnabled(): boolean;
  35431. private _fogMode;
  35432. /**
  35433. * Gets or sets the fog mode to use
  35434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35435. * | mode | value |
  35436. * | --- | --- |
  35437. * | FOGMODE_NONE | 0 |
  35438. * | FOGMODE_EXP | 1 |
  35439. * | FOGMODE_EXP2 | 2 |
  35440. * | FOGMODE_LINEAR | 3 |
  35441. */
  35442. set fogMode(value: number);
  35443. get fogMode(): number;
  35444. /**
  35445. * Gets or sets the fog color to use
  35446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35447. * (Default is Color3(0.2, 0.2, 0.3))
  35448. */
  35449. fogColor: Color3;
  35450. /**
  35451. * Gets or sets the fog density to use
  35452. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35453. * (Default is 0.1)
  35454. */
  35455. fogDensity: number;
  35456. /**
  35457. * Gets or sets the fog start distance to use
  35458. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35459. * (Default is 0)
  35460. */
  35461. fogStart: number;
  35462. /**
  35463. * Gets or sets the fog end distance to use
  35464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35465. * (Default is 1000)
  35466. */
  35467. fogEnd: number;
  35468. private _shadowsEnabled;
  35469. /**
  35470. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35471. */
  35472. set shadowsEnabled(value: boolean);
  35473. get shadowsEnabled(): boolean;
  35474. private _lightsEnabled;
  35475. /**
  35476. * Gets or sets a boolean indicating if lights are enabled on this scene
  35477. */
  35478. set lightsEnabled(value: boolean);
  35479. get lightsEnabled(): boolean;
  35480. /** All of the active cameras added to this scene. */
  35481. activeCameras: Camera[];
  35482. /** @hidden */
  35483. _activeCamera: Nullable<Camera>;
  35484. /** Gets or sets the current active camera */
  35485. get activeCamera(): Nullable<Camera>;
  35486. set activeCamera(value: Nullable<Camera>);
  35487. private _defaultMaterial;
  35488. /** The default material used on meshes when no material is affected */
  35489. get defaultMaterial(): Material;
  35490. /** The default material used on meshes when no material is affected */
  35491. set defaultMaterial(value: Material);
  35492. private _texturesEnabled;
  35493. /**
  35494. * Gets or sets a boolean indicating if textures are enabled on this scene
  35495. */
  35496. set texturesEnabled(value: boolean);
  35497. get texturesEnabled(): boolean;
  35498. /**
  35499. * Gets or sets a boolean indicating if particles are enabled on this scene
  35500. */
  35501. particlesEnabled: boolean;
  35502. /**
  35503. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35504. */
  35505. spritesEnabled: boolean;
  35506. private _skeletonsEnabled;
  35507. /**
  35508. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35509. */
  35510. set skeletonsEnabled(value: boolean);
  35511. get skeletonsEnabled(): boolean;
  35512. /**
  35513. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35514. */
  35515. lensFlaresEnabled: boolean;
  35516. /**
  35517. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35519. */
  35520. collisionsEnabled: boolean;
  35521. private _collisionCoordinator;
  35522. /** @hidden */
  35523. get collisionCoordinator(): ICollisionCoordinator;
  35524. /**
  35525. * Defines the gravity applied to this scene (used only for collisions)
  35526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35527. */
  35528. gravity: Vector3;
  35529. /**
  35530. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35531. */
  35532. postProcessesEnabled: boolean;
  35533. /**
  35534. * The list of postprocesses added to the scene
  35535. */
  35536. postProcesses: PostProcess[];
  35537. /**
  35538. * Gets the current postprocess manager
  35539. */
  35540. postProcessManager: PostProcessManager;
  35541. /**
  35542. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35543. */
  35544. renderTargetsEnabled: boolean;
  35545. /**
  35546. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35547. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35548. */
  35549. dumpNextRenderTargets: boolean;
  35550. /**
  35551. * The list of user defined render targets added to the scene
  35552. */
  35553. customRenderTargets: RenderTargetTexture[];
  35554. /**
  35555. * Defines if texture loading must be delayed
  35556. * If true, textures will only be loaded when they need to be rendered
  35557. */
  35558. useDelayedTextureLoading: boolean;
  35559. /**
  35560. * Gets the list of meshes imported to the scene through SceneLoader
  35561. */
  35562. importedMeshesFiles: String[];
  35563. /**
  35564. * Gets or sets a boolean indicating if probes are enabled on this scene
  35565. */
  35566. probesEnabled: boolean;
  35567. /**
  35568. * Gets or sets the current offline provider to use to store scene data
  35569. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35570. */
  35571. offlineProvider: IOfflineProvider;
  35572. /**
  35573. * Gets or sets the action manager associated with the scene
  35574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35575. */
  35576. actionManager: AbstractActionManager;
  35577. private _meshesForIntersections;
  35578. /**
  35579. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35580. */
  35581. proceduralTexturesEnabled: boolean;
  35582. private _engine;
  35583. private _totalVertices;
  35584. /** @hidden */
  35585. _activeIndices: PerfCounter;
  35586. /** @hidden */
  35587. _activeParticles: PerfCounter;
  35588. /** @hidden */
  35589. _activeBones: PerfCounter;
  35590. private _animationRatio;
  35591. /** @hidden */
  35592. _animationTimeLast: number;
  35593. /** @hidden */
  35594. _animationTime: number;
  35595. /**
  35596. * Gets or sets a general scale for animation speed
  35597. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35598. */
  35599. animationTimeScale: number;
  35600. /** @hidden */
  35601. _cachedMaterial: Nullable<Material>;
  35602. /** @hidden */
  35603. _cachedEffect: Nullable<Effect>;
  35604. /** @hidden */
  35605. _cachedVisibility: Nullable<number>;
  35606. private _renderId;
  35607. private _frameId;
  35608. private _executeWhenReadyTimeoutId;
  35609. private _intermediateRendering;
  35610. private _viewUpdateFlag;
  35611. private _projectionUpdateFlag;
  35612. /** @hidden */
  35613. _toBeDisposed: Nullable<IDisposable>[];
  35614. private _activeRequests;
  35615. /** @hidden */
  35616. _pendingData: any[];
  35617. private _isDisposed;
  35618. /**
  35619. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35620. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35621. */
  35622. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35623. private _activeMeshes;
  35624. private _processedMaterials;
  35625. private _renderTargets;
  35626. /** @hidden */
  35627. _activeParticleSystems: SmartArray<IParticleSystem>;
  35628. private _activeSkeletons;
  35629. private _softwareSkinnedMeshes;
  35630. private _renderingManager;
  35631. /** @hidden */
  35632. _activeAnimatables: Animatable[];
  35633. private _transformMatrix;
  35634. private _sceneUbo;
  35635. /** @hidden */
  35636. _viewMatrix: Matrix;
  35637. private _projectionMatrix;
  35638. /** @hidden */
  35639. _forcedViewPosition: Nullable<Vector3>;
  35640. /** @hidden */
  35641. _frustumPlanes: Plane[];
  35642. /**
  35643. * Gets the list of frustum planes (built from the active camera)
  35644. */
  35645. get frustumPlanes(): Plane[];
  35646. /**
  35647. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35648. * This is useful if there are more lights that the maximum simulteanous authorized
  35649. */
  35650. requireLightSorting: boolean;
  35651. /** @hidden */
  35652. readonly useMaterialMeshMap: boolean;
  35653. /** @hidden */
  35654. readonly useClonedMeshMap: boolean;
  35655. private _externalData;
  35656. private _uid;
  35657. /**
  35658. * @hidden
  35659. * Backing store of defined scene components.
  35660. */
  35661. _components: ISceneComponent[];
  35662. /**
  35663. * @hidden
  35664. * Backing store of defined scene components.
  35665. */
  35666. _serializableComponents: ISceneSerializableComponent[];
  35667. /**
  35668. * List of components to register on the next registration step.
  35669. */
  35670. private _transientComponents;
  35671. /**
  35672. * Registers the transient components if needed.
  35673. */
  35674. private _registerTransientComponents;
  35675. /**
  35676. * @hidden
  35677. * Add a component to the scene.
  35678. * Note that the ccomponent could be registered on th next frame if this is called after
  35679. * the register component stage.
  35680. * @param component Defines the component to add to the scene
  35681. */
  35682. _addComponent(component: ISceneComponent): void;
  35683. /**
  35684. * @hidden
  35685. * Gets a component from the scene.
  35686. * @param name defines the name of the component to retrieve
  35687. * @returns the component or null if not present
  35688. */
  35689. _getComponent(name: string): Nullable<ISceneComponent>;
  35690. /**
  35691. * @hidden
  35692. * Defines the actions happening before camera updates.
  35693. */
  35694. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35695. /**
  35696. * @hidden
  35697. * Defines the actions happening before clear the canvas.
  35698. */
  35699. _beforeClearStage: Stage<SimpleStageAction>;
  35700. /**
  35701. * @hidden
  35702. * Defines the actions when collecting render targets for the frame.
  35703. */
  35704. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35705. /**
  35706. * @hidden
  35707. * Defines the actions happening for one camera in the frame.
  35708. */
  35709. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35710. /**
  35711. * @hidden
  35712. * Defines the actions happening during the per mesh ready checks.
  35713. */
  35714. _isReadyForMeshStage: Stage<MeshStageAction>;
  35715. /**
  35716. * @hidden
  35717. * Defines the actions happening before evaluate active mesh checks.
  35718. */
  35719. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35720. /**
  35721. * @hidden
  35722. * Defines the actions happening during the evaluate sub mesh checks.
  35723. */
  35724. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35725. /**
  35726. * @hidden
  35727. * Defines the actions happening during the active mesh stage.
  35728. */
  35729. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35730. /**
  35731. * @hidden
  35732. * Defines the actions happening during the per camera render target step.
  35733. */
  35734. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35735. /**
  35736. * @hidden
  35737. * Defines the actions happening just before the active camera is drawing.
  35738. */
  35739. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35740. /**
  35741. * @hidden
  35742. * Defines the actions happening just before a render target is drawing.
  35743. */
  35744. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35745. /**
  35746. * @hidden
  35747. * Defines the actions happening just before a rendering group is drawing.
  35748. */
  35749. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35750. /**
  35751. * @hidden
  35752. * Defines the actions happening just before a mesh is drawing.
  35753. */
  35754. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35755. /**
  35756. * @hidden
  35757. * Defines the actions happening just after a mesh has been drawn.
  35758. */
  35759. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35760. /**
  35761. * @hidden
  35762. * Defines the actions happening just after a rendering group has been drawn.
  35763. */
  35764. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35765. /**
  35766. * @hidden
  35767. * Defines the actions happening just after the active camera has been drawn.
  35768. */
  35769. _afterCameraDrawStage: Stage<CameraStageAction>;
  35770. /**
  35771. * @hidden
  35772. * Defines the actions happening just after a render target has been drawn.
  35773. */
  35774. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35775. /**
  35776. * @hidden
  35777. * Defines the actions happening just after rendering all cameras and computing intersections.
  35778. */
  35779. _afterRenderStage: Stage<SimpleStageAction>;
  35780. /**
  35781. * @hidden
  35782. * Defines the actions happening when a pointer move event happens.
  35783. */
  35784. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35785. /**
  35786. * @hidden
  35787. * Defines the actions happening when a pointer down event happens.
  35788. */
  35789. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35790. /**
  35791. * @hidden
  35792. * Defines the actions happening when a pointer up event happens.
  35793. */
  35794. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35795. /**
  35796. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35797. */
  35798. private geometriesByUniqueId;
  35799. /**
  35800. * Creates a new Scene
  35801. * @param engine defines the engine to use to render this scene
  35802. * @param options defines the scene options
  35803. */
  35804. constructor(engine: Engine, options?: SceneOptions);
  35805. /**
  35806. * Gets a string idenfifying the name of the class
  35807. * @returns "Scene" string
  35808. */
  35809. getClassName(): string;
  35810. private _defaultMeshCandidates;
  35811. /**
  35812. * @hidden
  35813. */
  35814. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35815. private _defaultSubMeshCandidates;
  35816. /**
  35817. * @hidden
  35818. */
  35819. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35820. /**
  35821. * Sets the default candidate providers for the scene.
  35822. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35823. * and getCollidingSubMeshCandidates to their default function
  35824. */
  35825. setDefaultCandidateProviders(): void;
  35826. /**
  35827. * Gets the mesh that is currently under the pointer
  35828. */
  35829. get meshUnderPointer(): Nullable<AbstractMesh>;
  35830. /**
  35831. * Gets or sets the current on-screen X position of the pointer
  35832. */
  35833. get pointerX(): number;
  35834. set pointerX(value: number);
  35835. /**
  35836. * Gets or sets the current on-screen Y position of the pointer
  35837. */
  35838. get pointerY(): number;
  35839. set pointerY(value: number);
  35840. /**
  35841. * Gets the cached material (ie. the latest rendered one)
  35842. * @returns the cached material
  35843. */
  35844. getCachedMaterial(): Nullable<Material>;
  35845. /**
  35846. * Gets the cached effect (ie. the latest rendered one)
  35847. * @returns the cached effect
  35848. */
  35849. getCachedEffect(): Nullable<Effect>;
  35850. /**
  35851. * Gets the cached visibility state (ie. the latest rendered one)
  35852. * @returns the cached visibility state
  35853. */
  35854. getCachedVisibility(): Nullable<number>;
  35855. /**
  35856. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35857. * @param material defines the current material
  35858. * @param effect defines the current effect
  35859. * @param visibility defines the current visibility state
  35860. * @returns true if one parameter is not cached
  35861. */
  35862. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35863. /**
  35864. * Gets the engine associated with the scene
  35865. * @returns an Engine
  35866. */
  35867. getEngine(): Engine;
  35868. /**
  35869. * Gets the total number of vertices rendered per frame
  35870. * @returns the total number of vertices rendered per frame
  35871. */
  35872. getTotalVertices(): number;
  35873. /**
  35874. * Gets the performance counter for total vertices
  35875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35876. */
  35877. get totalVerticesPerfCounter(): PerfCounter;
  35878. /**
  35879. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35880. * @returns the total number of active indices rendered per frame
  35881. */
  35882. getActiveIndices(): number;
  35883. /**
  35884. * Gets the performance counter for active indices
  35885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35886. */
  35887. get totalActiveIndicesPerfCounter(): PerfCounter;
  35888. /**
  35889. * Gets the total number of active particles rendered per frame
  35890. * @returns the total number of active particles rendered per frame
  35891. */
  35892. getActiveParticles(): number;
  35893. /**
  35894. * Gets the performance counter for active particles
  35895. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35896. */
  35897. get activeParticlesPerfCounter(): PerfCounter;
  35898. /**
  35899. * Gets the total number of active bones rendered per frame
  35900. * @returns the total number of active bones rendered per frame
  35901. */
  35902. getActiveBones(): number;
  35903. /**
  35904. * Gets the performance counter for active bones
  35905. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35906. */
  35907. get activeBonesPerfCounter(): PerfCounter;
  35908. /**
  35909. * Gets the array of active meshes
  35910. * @returns an array of AbstractMesh
  35911. */
  35912. getActiveMeshes(): SmartArray<AbstractMesh>;
  35913. /**
  35914. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35915. * @returns a number
  35916. */
  35917. getAnimationRatio(): number;
  35918. /**
  35919. * Gets an unique Id for the current render phase
  35920. * @returns a number
  35921. */
  35922. getRenderId(): number;
  35923. /**
  35924. * Gets an unique Id for the current frame
  35925. * @returns a number
  35926. */
  35927. getFrameId(): number;
  35928. /** Call this function if you want to manually increment the render Id*/
  35929. incrementRenderId(): void;
  35930. private _createUbo;
  35931. /**
  35932. * Use this method to simulate a pointer move on a mesh
  35933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35936. * @returns the current scene
  35937. */
  35938. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35939. /**
  35940. * Use this method to simulate a pointer down on a mesh
  35941. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35942. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35943. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35944. * @returns the current scene
  35945. */
  35946. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35947. /**
  35948. * Use this method to simulate a pointer up on a mesh
  35949. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35950. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35951. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35952. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35953. * @returns the current scene
  35954. */
  35955. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35956. /**
  35957. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35958. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35959. * @returns true if the pointer was captured
  35960. */
  35961. isPointerCaptured(pointerId?: number): boolean;
  35962. /**
  35963. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35964. * @param attachUp defines if you want to attach events to pointerup
  35965. * @param attachDown defines if you want to attach events to pointerdown
  35966. * @param attachMove defines if you want to attach events to pointermove
  35967. */
  35968. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35969. /** Detaches all event handlers*/
  35970. detachControl(): void;
  35971. /**
  35972. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35973. * Delay loaded resources are not taking in account
  35974. * @return true if all required resources are ready
  35975. */
  35976. isReady(): boolean;
  35977. /** Resets all cached information relative to material (including effect and visibility) */
  35978. resetCachedMaterial(): void;
  35979. /**
  35980. * Registers a function to be called before every frame render
  35981. * @param func defines the function to register
  35982. */
  35983. registerBeforeRender(func: () => void): void;
  35984. /**
  35985. * Unregisters a function called before every frame render
  35986. * @param func defines the function to unregister
  35987. */
  35988. unregisterBeforeRender(func: () => void): void;
  35989. /**
  35990. * Registers a function to be called after every frame render
  35991. * @param func defines the function to register
  35992. */
  35993. registerAfterRender(func: () => void): void;
  35994. /**
  35995. * Unregisters a function called after every frame render
  35996. * @param func defines the function to unregister
  35997. */
  35998. unregisterAfterRender(func: () => void): void;
  35999. private _executeOnceBeforeRender;
  36000. /**
  36001. * The provided function will run before render once and will be disposed afterwards.
  36002. * A timeout delay can be provided so that the function will be executed in N ms.
  36003. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36004. * @param func The function to be executed.
  36005. * @param timeout optional delay in ms
  36006. */
  36007. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36008. /** @hidden */
  36009. _addPendingData(data: any): void;
  36010. /** @hidden */
  36011. _removePendingData(data: any): void;
  36012. /**
  36013. * Returns the number of items waiting to be loaded
  36014. * @returns the number of items waiting to be loaded
  36015. */
  36016. getWaitingItemsCount(): number;
  36017. /**
  36018. * Returns a boolean indicating if the scene is still loading data
  36019. */
  36020. get isLoading(): boolean;
  36021. /**
  36022. * Registers a function to be executed when the scene is ready
  36023. * @param {Function} func - the function to be executed
  36024. */
  36025. executeWhenReady(func: () => void): void;
  36026. /**
  36027. * Returns a promise that resolves when the scene is ready
  36028. * @returns A promise that resolves when the scene is ready
  36029. */
  36030. whenReadyAsync(): Promise<void>;
  36031. /** @hidden */
  36032. _checkIsReady(): void;
  36033. /**
  36034. * Gets all animatable attached to the scene
  36035. */
  36036. get animatables(): Animatable[];
  36037. /**
  36038. * Resets the last animation time frame.
  36039. * Useful to override when animations start running when loading a scene for the first time.
  36040. */
  36041. resetLastAnimationTimeFrame(): void;
  36042. /**
  36043. * Gets the current view matrix
  36044. * @returns a Matrix
  36045. */
  36046. getViewMatrix(): Matrix;
  36047. /**
  36048. * Gets the current projection matrix
  36049. * @returns a Matrix
  36050. */
  36051. getProjectionMatrix(): Matrix;
  36052. /**
  36053. * Gets the current transform matrix
  36054. * @returns a Matrix made of View * Projection
  36055. */
  36056. getTransformMatrix(): Matrix;
  36057. /**
  36058. * Sets the current transform matrix
  36059. * @param viewL defines the View matrix to use
  36060. * @param projectionL defines the Projection matrix to use
  36061. * @param viewR defines the right View matrix to use (if provided)
  36062. * @param projectionR defines the right Projection matrix to use (if provided)
  36063. */
  36064. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36065. /**
  36066. * Gets the uniform buffer used to store scene data
  36067. * @returns a UniformBuffer
  36068. */
  36069. getSceneUniformBuffer(): UniformBuffer;
  36070. /**
  36071. * Gets an unique (relatively to the current scene) Id
  36072. * @returns an unique number for the scene
  36073. */
  36074. getUniqueId(): number;
  36075. /**
  36076. * Add a mesh to the list of scene's meshes
  36077. * @param newMesh defines the mesh to add
  36078. * @param recursive if all child meshes should also be added to the scene
  36079. */
  36080. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36081. /**
  36082. * Remove a mesh for the list of scene's meshes
  36083. * @param toRemove defines the mesh to remove
  36084. * @param recursive if all child meshes should also be removed from the scene
  36085. * @returns the index where the mesh was in the mesh list
  36086. */
  36087. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36088. /**
  36089. * Add a transform node to the list of scene's transform nodes
  36090. * @param newTransformNode defines the transform node to add
  36091. */
  36092. addTransformNode(newTransformNode: TransformNode): void;
  36093. /**
  36094. * Remove a transform node for the list of scene's transform nodes
  36095. * @param toRemove defines the transform node to remove
  36096. * @returns the index where the transform node was in the transform node list
  36097. */
  36098. removeTransformNode(toRemove: TransformNode): number;
  36099. /**
  36100. * Remove a skeleton for the list of scene's skeletons
  36101. * @param toRemove defines the skeleton to remove
  36102. * @returns the index where the skeleton was in the skeleton list
  36103. */
  36104. removeSkeleton(toRemove: Skeleton): number;
  36105. /**
  36106. * Remove a morph target for the list of scene's morph targets
  36107. * @param toRemove defines the morph target to remove
  36108. * @returns the index where the morph target was in the morph target list
  36109. */
  36110. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36111. /**
  36112. * Remove a light for the list of scene's lights
  36113. * @param toRemove defines the light to remove
  36114. * @returns the index where the light was in the light list
  36115. */
  36116. removeLight(toRemove: Light): number;
  36117. /**
  36118. * Remove a camera for the list of scene's cameras
  36119. * @param toRemove defines the camera to remove
  36120. * @returns the index where the camera was in the camera list
  36121. */
  36122. removeCamera(toRemove: Camera): number;
  36123. /**
  36124. * Remove a particle system for the list of scene's particle systems
  36125. * @param toRemove defines the particle system to remove
  36126. * @returns the index where the particle system was in the particle system list
  36127. */
  36128. removeParticleSystem(toRemove: IParticleSystem): number;
  36129. /**
  36130. * Remove a animation for the list of scene's animations
  36131. * @param toRemove defines the animation to remove
  36132. * @returns the index where the animation was in the animation list
  36133. */
  36134. removeAnimation(toRemove: Animation): number;
  36135. /**
  36136. * Will stop the animation of the given target
  36137. * @param target - the target
  36138. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36139. * @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)
  36140. */
  36141. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36142. /**
  36143. * Removes the given animation group from this scene.
  36144. * @param toRemove The animation group to remove
  36145. * @returns The index of the removed animation group
  36146. */
  36147. removeAnimationGroup(toRemove: AnimationGroup): number;
  36148. /**
  36149. * Removes the given multi-material from this scene.
  36150. * @param toRemove The multi-material to remove
  36151. * @returns The index of the removed multi-material
  36152. */
  36153. removeMultiMaterial(toRemove: MultiMaterial): number;
  36154. /**
  36155. * Removes the given material from this scene.
  36156. * @param toRemove The material to remove
  36157. * @returns The index of the removed material
  36158. */
  36159. removeMaterial(toRemove: Material): number;
  36160. /**
  36161. * Removes the given action manager from this scene.
  36162. * @param toRemove The action manager to remove
  36163. * @returns The index of the removed action manager
  36164. */
  36165. removeActionManager(toRemove: AbstractActionManager): number;
  36166. /**
  36167. * Removes the given texture from this scene.
  36168. * @param toRemove The texture to remove
  36169. * @returns The index of the removed texture
  36170. */
  36171. removeTexture(toRemove: BaseTexture): number;
  36172. /**
  36173. * Adds the given light to this scene
  36174. * @param newLight The light to add
  36175. */
  36176. addLight(newLight: Light): void;
  36177. /**
  36178. * Sorts the list list based on light priorities
  36179. */
  36180. sortLightsByPriority(): void;
  36181. /**
  36182. * Adds the given camera to this scene
  36183. * @param newCamera The camera to add
  36184. */
  36185. addCamera(newCamera: Camera): void;
  36186. /**
  36187. * Adds the given skeleton to this scene
  36188. * @param newSkeleton The skeleton to add
  36189. */
  36190. addSkeleton(newSkeleton: Skeleton): void;
  36191. /**
  36192. * Adds the given particle system to this scene
  36193. * @param newParticleSystem The particle system to add
  36194. */
  36195. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36196. /**
  36197. * Adds the given animation to this scene
  36198. * @param newAnimation The animation to add
  36199. */
  36200. addAnimation(newAnimation: Animation): void;
  36201. /**
  36202. * Adds the given animation group to this scene.
  36203. * @param newAnimationGroup The animation group to add
  36204. */
  36205. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36206. /**
  36207. * Adds the given multi-material to this scene
  36208. * @param newMultiMaterial The multi-material to add
  36209. */
  36210. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36211. /**
  36212. * Adds the given material to this scene
  36213. * @param newMaterial The material to add
  36214. */
  36215. addMaterial(newMaterial: Material): void;
  36216. /**
  36217. * Adds the given morph target to this scene
  36218. * @param newMorphTargetManager The morph target to add
  36219. */
  36220. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36221. /**
  36222. * Adds the given geometry to this scene
  36223. * @param newGeometry The geometry to add
  36224. */
  36225. addGeometry(newGeometry: Geometry): void;
  36226. /**
  36227. * Adds the given action manager to this scene
  36228. * @param newActionManager The action manager to add
  36229. */
  36230. addActionManager(newActionManager: AbstractActionManager): void;
  36231. /**
  36232. * Adds the given texture to this scene.
  36233. * @param newTexture The texture to add
  36234. */
  36235. addTexture(newTexture: BaseTexture): void;
  36236. /**
  36237. * Switch active camera
  36238. * @param newCamera defines the new active camera
  36239. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36240. */
  36241. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36242. /**
  36243. * sets the active camera of the scene using its ID
  36244. * @param id defines the camera's ID
  36245. * @return the new active camera or null if none found.
  36246. */
  36247. setActiveCameraByID(id: string): Nullable<Camera>;
  36248. /**
  36249. * sets the active camera of the scene using its name
  36250. * @param name defines the camera's name
  36251. * @returns the new active camera or null if none found.
  36252. */
  36253. setActiveCameraByName(name: string): Nullable<Camera>;
  36254. /**
  36255. * get an animation group using its name
  36256. * @param name defines the material's name
  36257. * @return the animation group or null if none found.
  36258. */
  36259. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36260. /**
  36261. * Get a material using its unique id
  36262. * @param uniqueId defines the material's unique id
  36263. * @return the material or null if none found.
  36264. */
  36265. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36266. /**
  36267. * get a material using its id
  36268. * @param id defines the material's ID
  36269. * @return the material or null if none found.
  36270. */
  36271. getMaterialByID(id: string): Nullable<Material>;
  36272. /**
  36273. * Gets a the last added material using a given id
  36274. * @param id defines the material's ID
  36275. * @return the last material with the given id or null if none found.
  36276. */
  36277. getLastMaterialByID(id: string): Nullable<Material>;
  36278. /**
  36279. * Gets a material using its name
  36280. * @param name defines the material's name
  36281. * @return the material or null if none found.
  36282. */
  36283. getMaterialByName(name: string): Nullable<Material>;
  36284. /**
  36285. * Get a texture using its unique id
  36286. * @param uniqueId defines the texture's unique id
  36287. * @return the texture or null if none found.
  36288. */
  36289. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36290. /**
  36291. * Gets a camera using its id
  36292. * @param id defines the id to look for
  36293. * @returns the camera or null if not found
  36294. */
  36295. getCameraByID(id: string): Nullable<Camera>;
  36296. /**
  36297. * Gets a camera using its unique id
  36298. * @param uniqueId defines the unique id to look for
  36299. * @returns the camera or null if not found
  36300. */
  36301. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36302. /**
  36303. * Gets a camera using its name
  36304. * @param name defines the camera's name
  36305. * @return the camera or null if none found.
  36306. */
  36307. getCameraByName(name: string): Nullable<Camera>;
  36308. /**
  36309. * Gets a bone using its id
  36310. * @param id defines the bone's id
  36311. * @return the bone or null if not found
  36312. */
  36313. getBoneByID(id: string): Nullable<Bone>;
  36314. /**
  36315. * Gets a bone using its id
  36316. * @param name defines the bone's name
  36317. * @return the bone or null if not found
  36318. */
  36319. getBoneByName(name: string): Nullable<Bone>;
  36320. /**
  36321. * Gets a light node using its name
  36322. * @param name defines the the light's name
  36323. * @return the light or null if none found.
  36324. */
  36325. getLightByName(name: string): Nullable<Light>;
  36326. /**
  36327. * Gets a light node using its id
  36328. * @param id defines the light's id
  36329. * @return the light or null if none found.
  36330. */
  36331. getLightByID(id: string): Nullable<Light>;
  36332. /**
  36333. * Gets a light node using its scene-generated unique ID
  36334. * @param uniqueId defines the light's unique id
  36335. * @return the light or null if none found.
  36336. */
  36337. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36338. /**
  36339. * Gets a particle system by id
  36340. * @param id defines the particle system id
  36341. * @return the corresponding system or null if none found
  36342. */
  36343. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36344. /**
  36345. * Gets a geometry using its ID
  36346. * @param id defines the geometry's id
  36347. * @return the geometry or null if none found.
  36348. */
  36349. getGeometryByID(id: string): Nullable<Geometry>;
  36350. private _getGeometryByUniqueID;
  36351. /**
  36352. * Add a new geometry to this scene
  36353. * @param geometry defines the geometry to be added to the scene.
  36354. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36355. * @return a boolean defining if the geometry was added or not
  36356. */
  36357. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36358. /**
  36359. * Removes an existing geometry
  36360. * @param geometry defines the geometry to be removed from the scene
  36361. * @return a boolean defining if the geometry was removed or not
  36362. */
  36363. removeGeometry(geometry: Geometry): boolean;
  36364. /**
  36365. * Gets the list of geometries attached to the scene
  36366. * @returns an array of Geometry
  36367. */
  36368. getGeometries(): Geometry[];
  36369. /**
  36370. * Gets the first added mesh found of a given ID
  36371. * @param id defines the id to search for
  36372. * @return the mesh found or null if not found at all
  36373. */
  36374. getMeshByID(id: string): Nullable<AbstractMesh>;
  36375. /**
  36376. * Gets a list of meshes using their id
  36377. * @param id defines the id to search for
  36378. * @returns a list of meshes
  36379. */
  36380. getMeshesByID(id: string): Array<AbstractMesh>;
  36381. /**
  36382. * Gets the first added transform node found of a given ID
  36383. * @param id defines the id to search for
  36384. * @return the found transform node or null if not found at all.
  36385. */
  36386. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36387. /**
  36388. * Gets a transform node with its auto-generated unique id
  36389. * @param uniqueId efines the unique id to search for
  36390. * @return the found transform node or null if not found at all.
  36391. */
  36392. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36393. /**
  36394. * Gets a list of transform nodes using their id
  36395. * @param id defines the id to search for
  36396. * @returns a list of transform nodes
  36397. */
  36398. getTransformNodesByID(id: string): Array<TransformNode>;
  36399. /**
  36400. * Gets a mesh with its auto-generated unique id
  36401. * @param uniqueId defines the unique id to search for
  36402. * @return the found mesh or null if not found at all.
  36403. */
  36404. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36405. /**
  36406. * Gets a the last added mesh using a given id
  36407. * @param id defines the id to search for
  36408. * @return the found mesh or null if not found at all.
  36409. */
  36410. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36411. /**
  36412. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36413. * @param id defines the id to search for
  36414. * @return the found node or null if not found at all
  36415. */
  36416. getLastEntryByID(id: string): Nullable<Node>;
  36417. /**
  36418. * Gets a node (Mesh, Camera, Light) using a given id
  36419. * @param id defines the id to search for
  36420. * @return the found node or null if not found at all
  36421. */
  36422. getNodeByID(id: string): Nullable<Node>;
  36423. /**
  36424. * Gets a node (Mesh, Camera, Light) using a given name
  36425. * @param name defines the name to search for
  36426. * @return the found node or null if not found at all.
  36427. */
  36428. getNodeByName(name: string): Nullable<Node>;
  36429. /**
  36430. * Gets a mesh using a given name
  36431. * @param name defines the name to search for
  36432. * @return the found mesh or null if not found at all.
  36433. */
  36434. getMeshByName(name: string): Nullable<AbstractMesh>;
  36435. /**
  36436. * Gets a transform node using a given name
  36437. * @param name defines the name to search for
  36438. * @return the found transform node or null if not found at all.
  36439. */
  36440. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36441. /**
  36442. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36443. * @param id defines the id to search for
  36444. * @return the found skeleton or null if not found at all.
  36445. */
  36446. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36447. /**
  36448. * Gets a skeleton using a given auto generated unique id
  36449. * @param uniqueId defines the unique id to search for
  36450. * @return the found skeleton or null if not found at all.
  36451. */
  36452. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36453. /**
  36454. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36455. * @param id defines the id to search for
  36456. * @return the found skeleton or null if not found at all.
  36457. */
  36458. getSkeletonById(id: string): Nullable<Skeleton>;
  36459. /**
  36460. * Gets a skeleton using a given name
  36461. * @param name defines the name to search for
  36462. * @return the found skeleton or null if not found at all.
  36463. */
  36464. getSkeletonByName(name: string): Nullable<Skeleton>;
  36465. /**
  36466. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36467. * @param id defines the id to search for
  36468. * @return the found morph target manager or null if not found at all.
  36469. */
  36470. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36471. /**
  36472. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36473. * @param id defines the id to search for
  36474. * @return the found morph target or null if not found at all.
  36475. */
  36476. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36477. /**
  36478. * Gets a boolean indicating if the given mesh is active
  36479. * @param mesh defines the mesh to look for
  36480. * @returns true if the mesh is in the active list
  36481. */
  36482. isActiveMesh(mesh: AbstractMesh): boolean;
  36483. /**
  36484. * Return a unique id as a string which can serve as an identifier for the scene
  36485. */
  36486. get uid(): string;
  36487. /**
  36488. * Add an externaly attached data from its key.
  36489. * This method call will fail and return false, if such key already exists.
  36490. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36491. * @param key the unique key that identifies the data
  36492. * @param data the data object to associate to the key for this Engine instance
  36493. * @return true if no such key were already present and the data was added successfully, false otherwise
  36494. */
  36495. addExternalData<T>(key: string, data: T): boolean;
  36496. /**
  36497. * Get an externaly attached data from its key
  36498. * @param key the unique key that identifies the data
  36499. * @return the associated data, if present (can be null), or undefined if not present
  36500. */
  36501. getExternalData<T>(key: string): Nullable<T>;
  36502. /**
  36503. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36504. * @param key the unique key that identifies the data
  36505. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36506. * @return the associated data, can be null if the factory returned null.
  36507. */
  36508. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36509. /**
  36510. * Remove an externaly attached data from the Engine instance
  36511. * @param key the unique key that identifies the data
  36512. * @return true if the data was successfully removed, false if it doesn't exist
  36513. */
  36514. removeExternalData(key: string): boolean;
  36515. private _evaluateSubMesh;
  36516. /**
  36517. * Clear the processed materials smart array preventing retention point in material dispose.
  36518. */
  36519. freeProcessedMaterials(): void;
  36520. private _preventFreeActiveMeshesAndRenderingGroups;
  36521. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36522. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36523. * when disposing several meshes in a row or a hierarchy of meshes.
  36524. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36525. */
  36526. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36527. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36528. /**
  36529. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36530. */
  36531. freeActiveMeshes(): void;
  36532. /**
  36533. * Clear the info related to rendering groups preventing retention points during dispose.
  36534. */
  36535. freeRenderingGroups(): void;
  36536. /** @hidden */
  36537. _isInIntermediateRendering(): boolean;
  36538. /**
  36539. * Lambda returning the list of potentially active meshes.
  36540. */
  36541. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36542. /**
  36543. * Lambda returning the list of potentially active sub meshes.
  36544. */
  36545. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36546. /**
  36547. * Lambda returning the list of potentially intersecting sub meshes.
  36548. */
  36549. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36550. /**
  36551. * Lambda returning the list of potentially colliding sub meshes.
  36552. */
  36553. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36554. private _activeMeshesFrozen;
  36555. private _skipEvaluateActiveMeshesCompletely;
  36556. /**
  36557. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36558. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36559. * @returns the current scene
  36560. */
  36561. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36562. /**
  36563. * Use this function to restart evaluating active meshes on every frame
  36564. * @returns the current scene
  36565. */
  36566. unfreezeActiveMeshes(): Scene;
  36567. private _evaluateActiveMeshes;
  36568. private _activeMesh;
  36569. /**
  36570. * Update the transform matrix to update from the current active camera
  36571. * @param force defines a boolean used to force the update even if cache is up to date
  36572. */
  36573. updateTransformMatrix(force?: boolean): void;
  36574. private _bindFrameBuffer;
  36575. /** @hidden */
  36576. _allowPostProcessClearColor: boolean;
  36577. /** @hidden */
  36578. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36579. private _processSubCameras;
  36580. private _checkIntersections;
  36581. /** @hidden */
  36582. _advancePhysicsEngineStep(step: number): void;
  36583. /**
  36584. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36585. */
  36586. getDeterministicFrameTime: () => number;
  36587. /** @hidden */
  36588. _animate(): void;
  36589. /** Execute all animations (for a frame) */
  36590. animate(): void;
  36591. /**
  36592. * Render the scene
  36593. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36594. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36595. */
  36596. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36597. /**
  36598. * Freeze all materials
  36599. * A frozen material will not be updatable but should be faster to render
  36600. */
  36601. freezeMaterials(): void;
  36602. /**
  36603. * Unfreeze all materials
  36604. * A frozen material will not be updatable but should be faster to render
  36605. */
  36606. unfreezeMaterials(): void;
  36607. /**
  36608. * Releases all held ressources
  36609. */
  36610. dispose(): void;
  36611. /**
  36612. * Gets if the scene is already disposed
  36613. */
  36614. get isDisposed(): boolean;
  36615. /**
  36616. * Call this function to reduce memory footprint of the scene.
  36617. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36618. */
  36619. clearCachedVertexData(): void;
  36620. /**
  36621. * This function will remove the local cached buffer data from texture.
  36622. * It will save memory but will prevent the texture from being rebuilt
  36623. */
  36624. cleanCachedTextureBuffer(): void;
  36625. /**
  36626. * Get the world extend vectors with an optional filter
  36627. *
  36628. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36629. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36630. */
  36631. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36632. min: Vector3;
  36633. max: Vector3;
  36634. };
  36635. /**
  36636. * Creates a ray that can be used to pick in the scene
  36637. * @param x defines the x coordinate of the origin (on-screen)
  36638. * @param y defines the y coordinate of the origin (on-screen)
  36639. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36640. * @param camera defines the camera to use for the picking
  36641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36642. * @returns a Ray
  36643. */
  36644. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36645. /**
  36646. * Creates a ray that can be used to pick in the scene
  36647. * @param x defines the x coordinate of the origin (on-screen)
  36648. * @param y defines the y coordinate of the origin (on-screen)
  36649. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36650. * @param result defines the ray where to store the picking ray
  36651. * @param camera defines the camera to use for the picking
  36652. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36653. * @returns the current scene
  36654. */
  36655. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36656. /**
  36657. * Creates a ray that can be used to pick in the scene
  36658. * @param x defines the x coordinate of the origin (on-screen)
  36659. * @param y defines the y coordinate of the origin (on-screen)
  36660. * @param camera defines the camera to use for the picking
  36661. * @returns a Ray
  36662. */
  36663. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36664. /**
  36665. * Creates a ray that can be used to pick in the scene
  36666. * @param x defines the x coordinate of the origin (on-screen)
  36667. * @param y defines the y coordinate of the origin (on-screen)
  36668. * @param result defines the ray where to store the picking ray
  36669. * @param camera defines the camera to use for the picking
  36670. * @returns the current scene
  36671. */
  36672. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36673. /** Launch a ray to try to pick a mesh in the scene
  36674. * @param x position on screen
  36675. * @param y position on screen
  36676. * @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
  36677. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36678. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36680. * @returns a PickingInfo
  36681. */
  36682. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36683. /** Use the given ray to pick a mesh in the scene
  36684. * @param ray The ray to use to pick meshes
  36685. * @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
  36686. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36688. * @returns a PickingInfo
  36689. */
  36690. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36691. /**
  36692. * Launch a ray to try to pick a mesh in the scene
  36693. * @param x X position on screen
  36694. * @param y Y position on screen
  36695. * @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
  36696. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36697. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36698. * @returns an array of PickingInfo
  36699. */
  36700. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36701. /**
  36702. * Launch a ray to try to pick a mesh in the scene
  36703. * @param ray Ray to use
  36704. * @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
  36705. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36706. * @returns an array of PickingInfo
  36707. */
  36708. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36709. /**
  36710. * Force the value of meshUnderPointer
  36711. * @param mesh defines the mesh to use
  36712. */
  36713. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36714. /**
  36715. * Gets the mesh under the pointer
  36716. * @returns a Mesh or null if no mesh is under the pointer
  36717. */
  36718. getPointerOverMesh(): Nullable<AbstractMesh>;
  36719. /** @hidden */
  36720. _rebuildGeometries(): void;
  36721. /** @hidden */
  36722. _rebuildTextures(): void;
  36723. private _getByTags;
  36724. /**
  36725. * Get a list of meshes by tags
  36726. * @param tagsQuery defines the tags query to use
  36727. * @param forEach defines a predicate used to filter results
  36728. * @returns an array of Mesh
  36729. */
  36730. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36731. /**
  36732. * Get a list of cameras by tags
  36733. * @param tagsQuery defines the tags query to use
  36734. * @param forEach defines a predicate used to filter results
  36735. * @returns an array of Camera
  36736. */
  36737. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36738. /**
  36739. * Get a list of lights by tags
  36740. * @param tagsQuery defines the tags query to use
  36741. * @param forEach defines a predicate used to filter results
  36742. * @returns an array of Light
  36743. */
  36744. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36745. /**
  36746. * Get a list of materials by tags
  36747. * @param tagsQuery defines the tags query to use
  36748. * @param forEach defines a predicate used to filter results
  36749. * @returns an array of Material
  36750. */
  36751. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36752. /**
  36753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36754. * This allowed control for front to back rendering or reversly depending of the special needs.
  36755. *
  36756. * @param renderingGroupId The rendering group id corresponding to its index
  36757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36760. */
  36761. 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;
  36762. /**
  36763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36764. *
  36765. * @param renderingGroupId The rendering group id corresponding to its index
  36766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36767. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36768. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36769. */
  36770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36771. /**
  36772. * Gets the current auto clear configuration for one rendering group of the rendering
  36773. * manager.
  36774. * @param index the rendering group index to get the information for
  36775. * @returns The auto clear setup for the requested rendering group
  36776. */
  36777. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36778. private _blockMaterialDirtyMechanism;
  36779. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36780. get blockMaterialDirtyMechanism(): boolean;
  36781. set blockMaterialDirtyMechanism(value: boolean);
  36782. /**
  36783. * Will flag all materials as dirty to trigger new shader compilation
  36784. * @param flag defines the flag used to specify which material part must be marked as dirty
  36785. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36786. */
  36787. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36788. /** @hidden */
  36789. _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;
  36790. /** @hidden */
  36791. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36792. /** @hidden */
  36793. _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;
  36794. /** @hidden */
  36795. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36796. /** @hidden */
  36797. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36798. /** @hidden */
  36799. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36800. }
  36801. }
  36802. declare module BABYLON {
  36803. /**
  36804. * Set of assets to keep when moving a scene into an asset container.
  36805. */
  36806. export class KeepAssets extends AbstractScene {
  36807. }
  36808. /**
  36809. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36810. */
  36811. export class InstantiatedEntries {
  36812. /**
  36813. * List of new root nodes (eg. nodes with no parent)
  36814. */
  36815. rootNodes: TransformNode[];
  36816. /**
  36817. * List of new skeletons
  36818. */
  36819. skeletons: Skeleton[];
  36820. /**
  36821. * List of new animation groups
  36822. */
  36823. animationGroups: AnimationGroup[];
  36824. }
  36825. /**
  36826. * Container with a set of assets that can be added or removed from a scene.
  36827. */
  36828. export class AssetContainer extends AbstractScene {
  36829. /**
  36830. * The scene the AssetContainer belongs to.
  36831. */
  36832. scene: Scene;
  36833. /**
  36834. * Instantiates an AssetContainer.
  36835. * @param scene The scene the AssetContainer belongs to.
  36836. */
  36837. constructor(scene: Scene);
  36838. /**
  36839. * Instantiate or clone all meshes and add the new ones to the scene.
  36840. * Skeletons and animation groups will all be cloned
  36841. * @param nameFunction defines an optional function used to get new names for clones
  36842. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36843. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36844. */
  36845. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36846. /**
  36847. * Adds all the assets from the container to the scene.
  36848. */
  36849. addAllToScene(): void;
  36850. /**
  36851. * Removes all the assets in the container from the scene
  36852. */
  36853. removeAllFromScene(): void;
  36854. /**
  36855. * Disposes all the assets in the container
  36856. */
  36857. dispose(): void;
  36858. private _moveAssets;
  36859. /**
  36860. * Removes all the assets contained in the scene and adds them to the container.
  36861. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36862. */
  36863. moveAllFromScene(keepAssets?: KeepAssets): void;
  36864. /**
  36865. * 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.
  36866. * @returns the root mesh
  36867. */
  36868. createRootMesh(): Mesh;
  36869. /**
  36870. * Merge animations from this asset container into a scene
  36871. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36872. * @param animatables set of animatables to retarget to a node from the scene
  36873. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36874. */
  36875. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36876. }
  36877. }
  36878. declare module BABYLON {
  36879. /**
  36880. * Defines how the parser contract is defined.
  36881. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36882. */
  36883. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36884. /**
  36885. * Defines how the individual parser contract is defined.
  36886. * These parser can parse an individual asset
  36887. */
  36888. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36889. /**
  36890. * Base class of the scene acting as a container for the different elements composing a scene.
  36891. * This class is dynamically extended by the different components of the scene increasing
  36892. * flexibility and reducing coupling
  36893. */
  36894. export abstract class AbstractScene {
  36895. /**
  36896. * Stores the list of available parsers in the application.
  36897. */
  36898. private static _BabylonFileParsers;
  36899. /**
  36900. * Stores the list of available individual parsers in the application.
  36901. */
  36902. private static _IndividualBabylonFileParsers;
  36903. /**
  36904. * Adds a parser in the list of available ones
  36905. * @param name Defines the name of the parser
  36906. * @param parser Defines the parser to add
  36907. */
  36908. static AddParser(name: string, parser: BabylonFileParser): void;
  36909. /**
  36910. * Gets a general parser from the list of avaialble ones
  36911. * @param name Defines the name of the parser
  36912. * @returns the requested parser or null
  36913. */
  36914. static GetParser(name: string): Nullable<BabylonFileParser>;
  36915. /**
  36916. * Adds n individual parser in the list of available ones
  36917. * @param name Defines the name of the parser
  36918. * @param parser Defines the parser to add
  36919. */
  36920. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36921. /**
  36922. * Gets an individual parser from the list of avaialble ones
  36923. * @param name Defines the name of the parser
  36924. * @returns the requested parser or null
  36925. */
  36926. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36927. /**
  36928. * Parser json data and populate both a scene and its associated container object
  36929. * @param jsonData Defines the data to parse
  36930. * @param scene Defines the scene to parse the data for
  36931. * @param container Defines the container attached to the parsing sequence
  36932. * @param rootUrl Defines the root url of the data
  36933. */
  36934. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36935. /**
  36936. * Gets the list of root nodes (ie. nodes with no parent)
  36937. */
  36938. rootNodes: Node[];
  36939. /** All of the cameras added to this scene
  36940. * @see http://doc.babylonjs.com/babylon101/cameras
  36941. */
  36942. cameras: Camera[];
  36943. /**
  36944. * All of the lights added to this scene
  36945. * @see http://doc.babylonjs.com/babylon101/lights
  36946. */
  36947. lights: Light[];
  36948. /**
  36949. * All of the (abstract) meshes added to this scene
  36950. */
  36951. meshes: AbstractMesh[];
  36952. /**
  36953. * The list of skeletons added to the scene
  36954. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36955. */
  36956. skeletons: Skeleton[];
  36957. /**
  36958. * All of the particle systems added to this scene
  36959. * @see http://doc.babylonjs.com/babylon101/particles
  36960. */
  36961. particleSystems: IParticleSystem[];
  36962. /**
  36963. * Gets a list of Animations associated with the scene
  36964. */
  36965. animations: Animation[];
  36966. /**
  36967. * All of the animation groups added to this scene
  36968. * @see http://doc.babylonjs.com/how_to/group
  36969. */
  36970. animationGroups: AnimationGroup[];
  36971. /**
  36972. * All of the multi-materials added to this scene
  36973. * @see http://doc.babylonjs.com/how_to/multi_materials
  36974. */
  36975. multiMaterials: MultiMaterial[];
  36976. /**
  36977. * All of the materials added to this scene
  36978. * In the context of a Scene, it is not supposed to be modified manually.
  36979. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36980. * Note also that the order of the Material within the array is not significant and might change.
  36981. * @see http://doc.babylonjs.com/babylon101/materials
  36982. */
  36983. materials: Material[];
  36984. /**
  36985. * The list of morph target managers added to the scene
  36986. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36987. */
  36988. morphTargetManagers: MorphTargetManager[];
  36989. /**
  36990. * The list of geometries used in the scene.
  36991. */
  36992. geometries: Geometry[];
  36993. /**
  36994. * All of the tranform nodes added to this scene
  36995. * In the context of a Scene, it is not supposed to be modified manually.
  36996. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36997. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36998. * @see http://doc.babylonjs.com/how_to/transformnode
  36999. */
  37000. transformNodes: TransformNode[];
  37001. /**
  37002. * ActionManagers available on the scene.
  37003. */
  37004. actionManagers: AbstractActionManager[];
  37005. /**
  37006. * Textures to keep.
  37007. */
  37008. textures: BaseTexture[];
  37009. /**
  37010. * Environment texture for the scene
  37011. */
  37012. environmentTexture: Nullable<BaseTexture>;
  37013. /**
  37014. * @returns all meshes, lights, cameras, transformNodes and bones
  37015. */
  37016. getNodes(): Array<Node>;
  37017. }
  37018. }
  37019. declare module BABYLON {
  37020. /**
  37021. * Interface used to define options for Sound class
  37022. */
  37023. export interface ISoundOptions {
  37024. /**
  37025. * Does the sound autoplay once loaded.
  37026. */
  37027. autoplay?: boolean;
  37028. /**
  37029. * Does the sound loop after it finishes playing once.
  37030. */
  37031. loop?: boolean;
  37032. /**
  37033. * Sound's volume
  37034. */
  37035. volume?: number;
  37036. /**
  37037. * Is it a spatial sound?
  37038. */
  37039. spatialSound?: boolean;
  37040. /**
  37041. * Maximum distance to hear that sound
  37042. */
  37043. maxDistance?: number;
  37044. /**
  37045. * Uses user defined attenuation function
  37046. */
  37047. useCustomAttenuation?: boolean;
  37048. /**
  37049. * Define the roll off factor of spatial sounds.
  37050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37051. */
  37052. rolloffFactor?: number;
  37053. /**
  37054. * Define the reference distance the sound should be heard perfectly.
  37055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37056. */
  37057. refDistance?: number;
  37058. /**
  37059. * Define the distance attenuation model the sound will follow.
  37060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37061. */
  37062. distanceModel?: string;
  37063. /**
  37064. * Defines the playback speed (1 by default)
  37065. */
  37066. playbackRate?: number;
  37067. /**
  37068. * Defines if the sound is from a streaming source
  37069. */
  37070. streaming?: boolean;
  37071. /**
  37072. * Defines an optional length (in seconds) inside the sound file
  37073. */
  37074. length?: number;
  37075. /**
  37076. * Defines an optional offset (in seconds) inside the sound file
  37077. */
  37078. offset?: number;
  37079. /**
  37080. * If true, URLs will not be required to state the audio file codec to use.
  37081. */
  37082. skipCodecCheck?: boolean;
  37083. }
  37084. /**
  37085. * Defines a sound that can be played in the application.
  37086. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37088. */
  37089. export class Sound {
  37090. /**
  37091. * The name of the sound in the scene.
  37092. */
  37093. name: string;
  37094. /**
  37095. * Does the sound autoplay once loaded.
  37096. */
  37097. autoplay: boolean;
  37098. /**
  37099. * Does the sound loop after it finishes playing once.
  37100. */
  37101. loop: boolean;
  37102. /**
  37103. * Does the sound use a custom attenuation curve to simulate the falloff
  37104. * happening when the source gets further away from the camera.
  37105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37106. */
  37107. useCustomAttenuation: boolean;
  37108. /**
  37109. * The sound track id this sound belongs to.
  37110. */
  37111. soundTrackId: number;
  37112. /**
  37113. * Is this sound currently played.
  37114. */
  37115. isPlaying: boolean;
  37116. /**
  37117. * Is this sound currently paused.
  37118. */
  37119. isPaused: boolean;
  37120. /**
  37121. * Does this sound enables spatial sound.
  37122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37123. */
  37124. spatialSound: boolean;
  37125. /**
  37126. * Define the reference distance the sound should be heard perfectly.
  37127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37128. */
  37129. refDistance: number;
  37130. /**
  37131. * Define the roll off factor of spatial sounds.
  37132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37133. */
  37134. rolloffFactor: number;
  37135. /**
  37136. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37138. */
  37139. maxDistance: number;
  37140. /**
  37141. * Define the distance attenuation model the sound will follow.
  37142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37143. */
  37144. distanceModel: string;
  37145. /**
  37146. * @hidden
  37147. * Back Compat
  37148. **/
  37149. onended: () => any;
  37150. /**
  37151. * Observable event when the current playing sound finishes.
  37152. */
  37153. onEndedObservable: Observable<Sound>;
  37154. private _panningModel;
  37155. private _playbackRate;
  37156. private _streaming;
  37157. private _startTime;
  37158. private _startOffset;
  37159. private _position;
  37160. /** @hidden */
  37161. _positionInEmitterSpace: boolean;
  37162. private _localDirection;
  37163. private _volume;
  37164. private _isReadyToPlay;
  37165. private _isDirectional;
  37166. private _readyToPlayCallback;
  37167. private _audioBuffer;
  37168. private _soundSource;
  37169. private _streamingSource;
  37170. private _soundPanner;
  37171. private _soundGain;
  37172. private _inputAudioNode;
  37173. private _outputAudioNode;
  37174. private _coneInnerAngle;
  37175. private _coneOuterAngle;
  37176. private _coneOuterGain;
  37177. private _scene;
  37178. private _connectedTransformNode;
  37179. private _customAttenuationFunction;
  37180. private _registerFunc;
  37181. private _isOutputConnected;
  37182. private _htmlAudioElement;
  37183. private _urlType;
  37184. private _length?;
  37185. private _offset?;
  37186. /** @hidden */
  37187. static _SceneComponentInitialization: (scene: Scene) => void;
  37188. /**
  37189. * Create a sound and attach it to a scene
  37190. * @param name Name of your sound
  37191. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37192. * @param scene defines the scene the sound belongs to
  37193. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37194. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37195. */
  37196. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37197. /**
  37198. * Release the sound and its associated resources
  37199. */
  37200. dispose(): void;
  37201. /**
  37202. * Gets if the sounds is ready to be played or not.
  37203. * @returns true if ready, otherwise false
  37204. */
  37205. isReady(): boolean;
  37206. private _soundLoaded;
  37207. /**
  37208. * Sets the data of the sound from an audiobuffer
  37209. * @param audioBuffer The audioBuffer containing the data
  37210. */
  37211. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37212. /**
  37213. * Updates the current sounds options such as maxdistance, loop...
  37214. * @param options A JSON object containing values named as the object properties
  37215. */
  37216. updateOptions(options: ISoundOptions): void;
  37217. private _createSpatialParameters;
  37218. private _updateSpatialParameters;
  37219. /**
  37220. * Switch the panning model to HRTF:
  37221. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37223. */
  37224. switchPanningModelToHRTF(): void;
  37225. /**
  37226. * Switch the panning model to Equal Power:
  37227. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37229. */
  37230. switchPanningModelToEqualPower(): void;
  37231. private _switchPanningModel;
  37232. /**
  37233. * Connect this sound to a sound track audio node like gain...
  37234. * @param soundTrackAudioNode the sound track audio node to connect to
  37235. */
  37236. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37237. /**
  37238. * Transform this sound into a directional source
  37239. * @param coneInnerAngle Size of the inner cone in degree
  37240. * @param coneOuterAngle Size of the outer cone in degree
  37241. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37242. */
  37243. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37244. /**
  37245. * Gets or sets the inner angle for the directional cone.
  37246. */
  37247. get directionalConeInnerAngle(): number;
  37248. /**
  37249. * Gets or sets the inner angle for the directional cone.
  37250. */
  37251. set directionalConeInnerAngle(value: number);
  37252. /**
  37253. * Gets or sets the outer angle for the directional cone.
  37254. */
  37255. get directionalConeOuterAngle(): number;
  37256. /**
  37257. * Gets or sets the outer angle for the directional cone.
  37258. */
  37259. set directionalConeOuterAngle(value: number);
  37260. /**
  37261. * Sets the position of the emitter if spatial sound is enabled
  37262. * @param newPosition Defines the new posisiton
  37263. */
  37264. setPosition(newPosition: Vector3): void;
  37265. /**
  37266. * Sets the local direction of the emitter if spatial sound is enabled
  37267. * @param newLocalDirection Defines the new local direction
  37268. */
  37269. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37270. private _updateDirection;
  37271. /** @hidden */
  37272. updateDistanceFromListener(): void;
  37273. /**
  37274. * Sets a new custom attenuation function for the sound.
  37275. * @param callback Defines the function used for the attenuation
  37276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37277. */
  37278. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37279. /**
  37280. * Play the sound
  37281. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37282. * @param offset (optional) Start the sound at a specific time in seconds
  37283. * @param length (optional) Sound duration (in seconds)
  37284. */
  37285. play(time?: number, offset?: number, length?: number): void;
  37286. private _onended;
  37287. /**
  37288. * Stop the sound
  37289. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37290. */
  37291. stop(time?: number): void;
  37292. /**
  37293. * Put the sound in pause
  37294. */
  37295. pause(): void;
  37296. /**
  37297. * Sets a dedicated volume for this sounds
  37298. * @param newVolume Define the new volume of the sound
  37299. * @param time Define time for gradual change to new volume
  37300. */
  37301. setVolume(newVolume: number, time?: number): void;
  37302. /**
  37303. * Set the sound play back rate
  37304. * @param newPlaybackRate Define the playback rate the sound should be played at
  37305. */
  37306. setPlaybackRate(newPlaybackRate: number): void;
  37307. /**
  37308. * Gets the volume of the sound.
  37309. * @returns the volume of the sound
  37310. */
  37311. getVolume(): number;
  37312. /**
  37313. * Attach the sound to a dedicated mesh
  37314. * @param transformNode The transform node to connect the sound with
  37315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37316. */
  37317. attachToMesh(transformNode: TransformNode): void;
  37318. /**
  37319. * Detach the sound from the previously attached mesh
  37320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37321. */
  37322. detachFromMesh(): void;
  37323. private _onRegisterAfterWorldMatrixUpdate;
  37324. /**
  37325. * Clone the current sound in the scene.
  37326. * @returns the new sound clone
  37327. */
  37328. clone(): Nullable<Sound>;
  37329. /**
  37330. * Gets the current underlying audio buffer containing the data
  37331. * @returns the audio buffer
  37332. */
  37333. getAudioBuffer(): Nullable<AudioBuffer>;
  37334. /**
  37335. * Serializes the Sound in a JSON representation
  37336. * @returns the JSON representation of the sound
  37337. */
  37338. serialize(): any;
  37339. /**
  37340. * Parse a JSON representation of a sound to innstantiate in a given scene
  37341. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37342. * @param scene Define the scene the new parsed sound should be created in
  37343. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37344. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37345. * @returns the newly parsed sound
  37346. */
  37347. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37348. }
  37349. }
  37350. declare module BABYLON {
  37351. /**
  37352. * This defines an action helpful to play a defined sound on a triggered action.
  37353. */
  37354. export class PlaySoundAction extends Action {
  37355. private _sound;
  37356. /**
  37357. * Instantiate the action
  37358. * @param triggerOptions defines the trigger options
  37359. * @param sound defines the sound to play
  37360. * @param condition defines the trigger related conditions
  37361. */
  37362. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37363. /** @hidden */
  37364. _prepare(): void;
  37365. /**
  37366. * Execute the action and play the sound.
  37367. */
  37368. execute(): void;
  37369. /**
  37370. * Serializes the actions and its related information.
  37371. * @param parent defines the object to serialize in
  37372. * @returns the serialized object
  37373. */
  37374. serialize(parent: any): any;
  37375. }
  37376. /**
  37377. * This defines an action helpful to stop a defined sound on a triggered action.
  37378. */
  37379. export class StopSoundAction extends Action {
  37380. private _sound;
  37381. /**
  37382. * Instantiate the action
  37383. * @param triggerOptions defines the trigger options
  37384. * @param sound defines the sound to stop
  37385. * @param condition defines the trigger related conditions
  37386. */
  37387. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37388. /** @hidden */
  37389. _prepare(): void;
  37390. /**
  37391. * Execute the action and stop the sound.
  37392. */
  37393. execute(): void;
  37394. /**
  37395. * Serializes the actions and its related information.
  37396. * @param parent defines the object to serialize in
  37397. * @returns the serialized object
  37398. */
  37399. serialize(parent: any): any;
  37400. }
  37401. }
  37402. declare module BABYLON {
  37403. /**
  37404. * This defines an action responsible to change the value of a property
  37405. * by interpolating between its current value and the newly set one once triggered.
  37406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37407. */
  37408. export class InterpolateValueAction extends Action {
  37409. /**
  37410. * Defines the path of the property where the value should be interpolated
  37411. */
  37412. propertyPath: string;
  37413. /**
  37414. * Defines the target value at the end of the interpolation.
  37415. */
  37416. value: any;
  37417. /**
  37418. * Defines the time it will take for the property to interpolate to the value.
  37419. */
  37420. duration: number;
  37421. /**
  37422. * Defines if the other scene animations should be stopped when the action has been triggered
  37423. */
  37424. stopOtherAnimations?: boolean;
  37425. /**
  37426. * Defines a callback raised once the interpolation animation has been done.
  37427. */
  37428. onInterpolationDone?: () => void;
  37429. /**
  37430. * Observable triggered once the interpolation animation has been done.
  37431. */
  37432. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37433. private _target;
  37434. private _effectiveTarget;
  37435. private _property;
  37436. /**
  37437. * Instantiate the action
  37438. * @param triggerOptions defines the trigger options
  37439. * @param target defines the object containing the value to interpolate
  37440. * @param propertyPath defines the path to the property in the target object
  37441. * @param value defines the target value at the end of the interpolation
  37442. * @param duration deines the time it will take for the property to interpolate to the value.
  37443. * @param condition defines the trigger related conditions
  37444. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37445. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37446. */
  37447. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37448. /** @hidden */
  37449. _prepare(): void;
  37450. /**
  37451. * Execute the action starts the value interpolation.
  37452. */
  37453. execute(): void;
  37454. /**
  37455. * Serializes the actions and its related information.
  37456. * @param parent defines the object to serialize in
  37457. * @returns the serialized object
  37458. */
  37459. serialize(parent: any): any;
  37460. }
  37461. }
  37462. declare module BABYLON {
  37463. /**
  37464. * Options allowed during the creation of a sound track.
  37465. */
  37466. export interface ISoundTrackOptions {
  37467. /**
  37468. * The volume the sound track should take during creation
  37469. */
  37470. volume?: number;
  37471. /**
  37472. * Define if the sound track is the main sound track of the scene
  37473. */
  37474. mainTrack?: boolean;
  37475. }
  37476. /**
  37477. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37478. * It will be also used in a future release to apply effects on a specific track.
  37479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37480. */
  37481. export class SoundTrack {
  37482. /**
  37483. * The unique identifier of the sound track in the scene.
  37484. */
  37485. id: number;
  37486. /**
  37487. * The list of sounds included in the sound track.
  37488. */
  37489. soundCollection: Array<Sound>;
  37490. private _outputAudioNode;
  37491. private _scene;
  37492. private _connectedAnalyser;
  37493. private _options;
  37494. private _isInitialized;
  37495. /**
  37496. * Creates a new sound track.
  37497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37498. * @param scene Define the scene the sound track belongs to
  37499. * @param options
  37500. */
  37501. constructor(scene: Scene, options?: ISoundTrackOptions);
  37502. private _initializeSoundTrackAudioGraph;
  37503. /**
  37504. * Release the sound track and its associated resources
  37505. */
  37506. dispose(): void;
  37507. /**
  37508. * Adds a sound to this sound track
  37509. * @param sound define the cound to add
  37510. * @ignoreNaming
  37511. */
  37512. AddSound(sound: Sound): void;
  37513. /**
  37514. * Removes a sound to this sound track
  37515. * @param sound define the cound to remove
  37516. * @ignoreNaming
  37517. */
  37518. RemoveSound(sound: Sound): void;
  37519. /**
  37520. * Set a global volume for the full sound track.
  37521. * @param newVolume Define the new volume of the sound track
  37522. */
  37523. setVolume(newVolume: number): void;
  37524. /**
  37525. * Switch the panning model to HRTF:
  37526. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37528. */
  37529. switchPanningModelToHRTF(): void;
  37530. /**
  37531. * Switch the panning model to Equal Power:
  37532. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37534. */
  37535. switchPanningModelToEqualPower(): void;
  37536. /**
  37537. * Connect the sound track to an audio analyser allowing some amazing
  37538. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37540. * @param analyser The analyser to connect to the engine
  37541. */
  37542. connectToAnalyser(analyser: Analyser): void;
  37543. }
  37544. }
  37545. declare module BABYLON {
  37546. interface AbstractScene {
  37547. /**
  37548. * The list of sounds used in the scene.
  37549. */
  37550. sounds: Nullable<Array<Sound>>;
  37551. }
  37552. interface Scene {
  37553. /**
  37554. * @hidden
  37555. * Backing field
  37556. */
  37557. _mainSoundTrack: SoundTrack;
  37558. /**
  37559. * The main sound track played by the scene.
  37560. * It cotains your primary collection of sounds.
  37561. */
  37562. mainSoundTrack: SoundTrack;
  37563. /**
  37564. * The list of sound tracks added to the scene
  37565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37566. */
  37567. soundTracks: Nullable<Array<SoundTrack>>;
  37568. /**
  37569. * Gets a sound using a given name
  37570. * @param name defines the name to search for
  37571. * @return the found sound or null if not found at all.
  37572. */
  37573. getSoundByName(name: string): Nullable<Sound>;
  37574. /**
  37575. * Gets or sets if audio support is enabled
  37576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37577. */
  37578. audioEnabled: boolean;
  37579. /**
  37580. * Gets or sets if audio will be output to headphones
  37581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37582. */
  37583. headphone: boolean;
  37584. /**
  37585. * Gets or sets custom audio listener position provider
  37586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37587. */
  37588. audioListenerPositionProvider: Nullable<() => Vector3>;
  37589. /**
  37590. * Gets or sets a refresh rate when using 3D audio positioning
  37591. */
  37592. audioPositioningRefreshRate: number;
  37593. }
  37594. /**
  37595. * Defines the sound scene component responsible to manage any sounds
  37596. * in a given scene.
  37597. */
  37598. export class AudioSceneComponent implements ISceneSerializableComponent {
  37599. /**
  37600. * The component name helpfull to identify the component in the list of scene components.
  37601. */
  37602. readonly name: string;
  37603. /**
  37604. * The scene the component belongs to.
  37605. */
  37606. scene: Scene;
  37607. private _audioEnabled;
  37608. /**
  37609. * Gets whether audio is enabled or not.
  37610. * Please use related enable/disable method to switch state.
  37611. */
  37612. get audioEnabled(): boolean;
  37613. private _headphone;
  37614. /**
  37615. * Gets whether audio is outputing to headphone or not.
  37616. * Please use the according Switch methods to change output.
  37617. */
  37618. get headphone(): boolean;
  37619. /**
  37620. * Gets or sets a refresh rate when using 3D audio positioning
  37621. */
  37622. audioPositioningRefreshRate: number;
  37623. private _audioListenerPositionProvider;
  37624. /**
  37625. * Gets the current audio listener position provider
  37626. */
  37627. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37628. /**
  37629. * Sets a custom listener position for all sounds in the scene
  37630. * By default, this is the position of the first active camera
  37631. */
  37632. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37633. /**
  37634. * Creates a new instance of the component for the given scene
  37635. * @param scene Defines the scene to register the component in
  37636. */
  37637. constructor(scene: Scene);
  37638. /**
  37639. * Registers the component in a given scene
  37640. */
  37641. register(): void;
  37642. /**
  37643. * Rebuilds the elements related to this component in case of
  37644. * context lost for instance.
  37645. */
  37646. rebuild(): void;
  37647. /**
  37648. * Serializes the component data to the specified json object
  37649. * @param serializationObject The object to serialize to
  37650. */
  37651. serialize(serializationObject: any): void;
  37652. /**
  37653. * Adds all the elements from the container to the scene
  37654. * @param container the container holding the elements
  37655. */
  37656. addFromContainer(container: AbstractScene): void;
  37657. /**
  37658. * Removes all the elements in the container from the scene
  37659. * @param container contains the elements to remove
  37660. * @param dispose if the removed element should be disposed (default: false)
  37661. */
  37662. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37663. /**
  37664. * Disposes the component and the associated ressources.
  37665. */
  37666. dispose(): void;
  37667. /**
  37668. * Disables audio in the associated scene.
  37669. */
  37670. disableAudio(): void;
  37671. /**
  37672. * Enables audio in the associated scene.
  37673. */
  37674. enableAudio(): void;
  37675. /**
  37676. * Switch audio to headphone output.
  37677. */
  37678. switchAudioModeForHeadphones(): void;
  37679. /**
  37680. * Switch audio to normal speakers.
  37681. */
  37682. switchAudioModeForNormalSpeakers(): void;
  37683. private _cachedCameraDirection;
  37684. private _cachedCameraPosition;
  37685. private _lastCheck;
  37686. private _afterRender;
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. /**
  37691. * Wraps one or more Sound objects and selects one with random weight for playback.
  37692. */
  37693. export class WeightedSound {
  37694. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37695. loop: boolean;
  37696. private _coneInnerAngle;
  37697. private _coneOuterAngle;
  37698. private _volume;
  37699. /** A Sound is currently playing. */
  37700. isPlaying: boolean;
  37701. /** A Sound is currently paused. */
  37702. isPaused: boolean;
  37703. private _sounds;
  37704. private _weights;
  37705. private _currentIndex?;
  37706. /**
  37707. * Creates a new WeightedSound from the list of sounds given.
  37708. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37709. * @param sounds Array of Sounds that will be selected from.
  37710. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37711. */
  37712. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37713. /**
  37714. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37715. */
  37716. get directionalConeInnerAngle(): number;
  37717. /**
  37718. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37719. */
  37720. set directionalConeInnerAngle(value: number);
  37721. /**
  37722. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37723. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37724. */
  37725. get directionalConeOuterAngle(): number;
  37726. /**
  37727. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37728. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37729. */
  37730. set directionalConeOuterAngle(value: number);
  37731. /**
  37732. * Playback volume.
  37733. */
  37734. get volume(): number;
  37735. /**
  37736. * Playback volume.
  37737. */
  37738. set volume(value: number);
  37739. private _onended;
  37740. /**
  37741. * Suspend playback
  37742. */
  37743. pause(): void;
  37744. /**
  37745. * Stop playback
  37746. */
  37747. stop(): void;
  37748. /**
  37749. * Start playback.
  37750. * @param startOffset Position the clip head at a specific time in seconds.
  37751. */
  37752. play(startOffset?: number): void;
  37753. }
  37754. }
  37755. declare module BABYLON {
  37756. /**
  37757. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37759. */
  37760. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37761. /**
  37762. * Gets the name of the behavior.
  37763. */
  37764. get name(): string;
  37765. /**
  37766. * The easing function used by animations
  37767. */
  37768. static EasingFunction: BackEase;
  37769. /**
  37770. * The easing mode used by animations
  37771. */
  37772. static EasingMode: number;
  37773. /**
  37774. * The duration of the animation, in milliseconds
  37775. */
  37776. transitionDuration: number;
  37777. /**
  37778. * Length of the distance animated by the transition when lower radius is reached
  37779. */
  37780. lowerRadiusTransitionRange: number;
  37781. /**
  37782. * Length of the distance animated by the transition when upper radius is reached
  37783. */
  37784. upperRadiusTransitionRange: number;
  37785. private _autoTransitionRange;
  37786. /**
  37787. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37788. */
  37789. get autoTransitionRange(): boolean;
  37790. /**
  37791. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37792. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37793. */
  37794. set autoTransitionRange(value: boolean);
  37795. private _attachedCamera;
  37796. private _onAfterCheckInputsObserver;
  37797. private _onMeshTargetChangedObserver;
  37798. /**
  37799. * Initializes the behavior.
  37800. */
  37801. init(): void;
  37802. /**
  37803. * Attaches the behavior to its arc rotate camera.
  37804. * @param camera Defines the camera to attach the behavior to
  37805. */
  37806. attach(camera: ArcRotateCamera): void;
  37807. /**
  37808. * Detaches the behavior from its current arc rotate camera.
  37809. */
  37810. detach(): void;
  37811. private _radiusIsAnimating;
  37812. private _radiusBounceTransition;
  37813. private _animatables;
  37814. private _cachedWheelPrecision;
  37815. /**
  37816. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37817. * @param radiusLimit The limit to check against.
  37818. * @return Bool to indicate if at limit.
  37819. */
  37820. private _isRadiusAtLimit;
  37821. /**
  37822. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37823. * @param radiusDelta The delta by which to animate to. Can be negative.
  37824. */
  37825. private _applyBoundRadiusAnimation;
  37826. /**
  37827. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37828. */
  37829. protected _clearAnimationLocks(): void;
  37830. /**
  37831. * Stops and removes all animations that have been applied to the camera
  37832. */
  37833. stopAllAnimations(): void;
  37834. }
  37835. }
  37836. declare module BABYLON {
  37837. /**
  37838. * 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.
  37839. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37840. */
  37841. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37842. /**
  37843. * Gets the name of the behavior.
  37844. */
  37845. get name(): string;
  37846. private _mode;
  37847. private _radiusScale;
  37848. private _positionScale;
  37849. private _defaultElevation;
  37850. private _elevationReturnTime;
  37851. private _elevationReturnWaitTime;
  37852. private _zoomStopsAnimation;
  37853. private _framingTime;
  37854. /**
  37855. * The easing function used by animations
  37856. */
  37857. static EasingFunction: ExponentialEase;
  37858. /**
  37859. * The easing mode used by animations
  37860. */
  37861. static EasingMode: number;
  37862. /**
  37863. * Sets the current mode used by the behavior
  37864. */
  37865. set mode(mode: number);
  37866. /**
  37867. * Gets current mode used by the behavior.
  37868. */
  37869. get mode(): number;
  37870. /**
  37871. * Sets the scale applied to the radius (1 by default)
  37872. */
  37873. set radiusScale(radius: number);
  37874. /**
  37875. * Gets the scale applied to the radius
  37876. */
  37877. get radiusScale(): number;
  37878. /**
  37879. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37880. */
  37881. set positionScale(scale: number);
  37882. /**
  37883. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37884. */
  37885. get positionScale(): number;
  37886. /**
  37887. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37888. * behaviour is triggered, in radians.
  37889. */
  37890. set defaultElevation(elevation: number);
  37891. /**
  37892. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37893. * behaviour is triggered, in radians.
  37894. */
  37895. get defaultElevation(): number;
  37896. /**
  37897. * Sets the time (in milliseconds) taken to return to the default beta position.
  37898. * Negative value indicates camera should not return to default.
  37899. */
  37900. set elevationReturnTime(speed: number);
  37901. /**
  37902. * Gets the time (in milliseconds) taken to return to the default beta position.
  37903. * Negative value indicates camera should not return to default.
  37904. */
  37905. get elevationReturnTime(): number;
  37906. /**
  37907. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37908. */
  37909. set elevationReturnWaitTime(time: number);
  37910. /**
  37911. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37912. */
  37913. get elevationReturnWaitTime(): number;
  37914. /**
  37915. * Sets the flag that indicates if user zooming should stop animation.
  37916. */
  37917. set zoomStopsAnimation(flag: boolean);
  37918. /**
  37919. * Gets the flag that indicates if user zooming should stop animation.
  37920. */
  37921. get zoomStopsAnimation(): boolean;
  37922. /**
  37923. * Sets the transition time when framing the mesh, in milliseconds
  37924. */
  37925. set framingTime(time: number);
  37926. /**
  37927. * Gets the transition time when framing the mesh, in milliseconds
  37928. */
  37929. get framingTime(): number;
  37930. /**
  37931. * Define if the behavior should automatically change the configured
  37932. * camera limits and sensibilities.
  37933. */
  37934. autoCorrectCameraLimitsAndSensibility: boolean;
  37935. private _onPrePointerObservableObserver;
  37936. private _onAfterCheckInputsObserver;
  37937. private _onMeshTargetChangedObserver;
  37938. private _attachedCamera;
  37939. private _isPointerDown;
  37940. private _lastInteractionTime;
  37941. /**
  37942. * Initializes the behavior.
  37943. */
  37944. init(): void;
  37945. /**
  37946. * Attaches the behavior to its arc rotate camera.
  37947. * @param camera Defines the camera to attach the behavior to
  37948. */
  37949. attach(camera: ArcRotateCamera): void;
  37950. /**
  37951. * Detaches the behavior from its current arc rotate camera.
  37952. */
  37953. detach(): void;
  37954. private _animatables;
  37955. private _betaIsAnimating;
  37956. private _betaTransition;
  37957. private _radiusTransition;
  37958. private _vectorTransition;
  37959. /**
  37960. * Targets the given mesh and updates zoom level accordingly.
  37961. * @param mesh The mesh to target.
  37962. * @param radius Optional. If a cached radius position already exists, overrides default.
  37963. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37966. */
  37967. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37968. /**
  37969. * Targets the given mesh with its children and updates zoom level accordingly.
  37970. * @param mesh The mesh to target.
  37971. * @param radius Optional. If a cached radius position already exists, overrides default.
  37972. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37973. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37974. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37975. */
  37976. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37977. /**
  37978. * Targets the given meshes with their children and updates zoom level accordingly.
  37979. * @param meshes The mesh to target.
  37980. * @param radius Optional. If a cached radius position already exists, overrides default.
  37981. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37982. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37983. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37984. */
  37985. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37986. /**
  37987. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37988. * @param minimumWorld Determines the smaller position of the bounding box extend
  37989. * @param maximumWorld Determines the bigger position of the bounding box extend
  37990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37992. */
  37993. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37994. /**
  37995. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37996. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37997. * frustum width.
  37998. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37999. * to fully enclose the mesh in the viewing frustum.
  38000. */
  38001. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38002. /**
  38003. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38004. * is automatically returned to its default position (expected to be above ground plane).
  38005. */
  38006. private _maintainCameraAboveGround;
  38007. /**
  38008. * Returns the frustum slope based on the canvas ratio and camera FOV
  38009. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38010. */
  38011. private _getFrustumSlope;
  38012. /**
  38013. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38014. */
  38015. private _clearAnimationLocks;
  38016. /**
  38017. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38018. */
  38019. private _applyUserInteraction;
  38020. /**
  38021. * Stops and removes all animations that have been applied to the camera
  38022. */
  38023. stopAllAnimations(): void;
  38024. /**
  38025. * Gets a value indicating if the user is moving the camera
  38026. */
  38027. get isUserIsMoving(): boolean;
  38028. /**
  38029. * The camera can move all the way towards the mesh.
  38030. */
  38031. static IgnoreBoundsSizeMode: number;
  38032. /**
  38033. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38034. */
  38035. static FitFrustumSidesMode: number;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. /**
  38040. * Base class for Camera Pointer Inputs.
  38041. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38042. * for example usage.
  38043. */
  38044. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38045. /**
  38046. * Defines the camera the input is attached to.
  38047. */
  38048. abstract camera: Camera;
  38049. /**
  38050. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38051. */
  38052. protected _altKey: boolean;
  38053. protected _ctrlKey: boolean;
  38054. protected _metaKey: boolean;
  38055. protected _shiftKey: boolean;
  38056. /**
  38057. * Which mouse buttons were pressed at time of last mouse event.
  38058. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38059. */
  38060. protected _buttonsPressed: number;
  38061. /**
  38062. * Defines the buttons associated with the input to handle camera move.
  38063. */
  38064. buttons: number[];
  38065. /**
  38066. * Attach the input controls to a specific dom element to get the input from.
  38067. * @param element Defines the element the controls should be listened from
  38068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38069. */
  38070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38071. /**
  38072. * Detach the current controls from the specified dom element.
  38073. * @param element Defines the element to stop listening the inputs from
  38074. */
  38075. detachControl(element: Nullable<HTMLElement>): void;
  38076. /**
  38077. * Gets the class name of the current input.
  38078. * @returns the class name
  38079. */
  38080. getClassName(): string;
  38081. /**
  38082. * Get the friendly name associated with the input class.
  38083. * @returns the input friendly name
  38084. */
  38085. getSimpleName(): string;
  38086. /**
  38087. * Called on pointer POINTERDOUBLETAP event.
  38088. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38089. */
  38090. protected onDoubleTap(type: string): void;
  38091. /**
  38092. * Called on pointer POINTERMOVE event if only a single touch is active.
  38093. * Override this method to provide functionality.
  38094. */
  38095. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38096. /**
  38097. * Called on pointer POINTERMOVE event if multiple touches are active.
  38098. * Override this method to provide functionality.
  38099. */
  38100. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38101. /**
  38102. * Called on JS contextmenu event.
  38103. * Override this method to provide functionality.
  38104. */
  38105. protected onContextMenu(evt: PointerEvent): void;
  38106. /**
  38107. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38108. * press.
  38109. * Override this method to provide functionality.
  38110. */
  38111. protected onButtonDown(evt: PointerEvent): void;
  38112. /**
  38113. * Called each time a new POINTERUP event occurs. Ie, for each button
  38114. * release.
  38115. * Override this method to provide functionality.
  38116. */
  38117. protected onButtonUp(evt: PointerEvent): void;
  38118. /**
  38119. * Called when window becomes inactive.
  38120. * Override this method to provide functionality.
  38121. */
  38122. protected onLostFocus(): void;
  38123. private _pointerInput;
  38124. private _observer;
  38125. private _onLostFocus;
  38126. private pointA;
  38127. private pointB;
  38128. }
  38129. }
  38130. declare module BABYLON {
  38131. /**
  38132. * Manage the pointers inputs to control an arc rotate camera.
  38133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38134. */
  38135. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38136. /**
  38137. * Defines the camera the input is attached to.
  38138. */
  38139. camera: ArcRotateCamera;
  38140. /**
  38141. * Gets the class name of the current input.
  38142. * @returns the class name
  38143. */
  38144. getClassName(): string;
  38145. /**
  38146. * Defines the buttons associated with the input to handle camera move.
  38147. */
  38148. buttons: number[];
  38149. /**
  38150. * Defines the pointer angular sensibility along the X axis or how fast is
  38151. * the camera rotating.
  38152. */
  38153. angularSensibilityX: number;
  38154. /**
  38155. * Defines the pointer angular sensibility along the Y axis or how fast is
  38156. * the camera rotating.
  38157. */
  38158. angularSensibilityY: number;
  38159. /**
  38160. * Defines the pointer pinch precision or how fast is the camera zooming.
  38161. */
  38162. pinchPrecision: number;
  38163. /**
  38164. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38165. * from 0.
  38166. * It defines the percentage of current camera.radius to use as delta when
  38167. * pinch zoom is used.
  38168. */
  38169. pinchDeltaPercentage: number;
  38170. /**
  38171. * Defines the pointer panning sensibility or how fast is the camera moving.
  38172. */
  38173. panningSensibility: number;
  38174. /**
  38175. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38176. */
  38177. multiTouchPanning: boolean;
  38178. /**
  38179. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38180. * zoom (pinch) through multitouch.
  38181. */
  38182. multiTouchPanAndZoom: boolean;
  38183. /**
  38184. * Revers pinch action direction.
  38185. */
  38186. pinchInwards: boolean;
  38187. private _isPanClick;
  38188. private _twoFingerActivityCount;
  38189. private _isPinching;
  38190. /**
  38191. * Called on pointer POINTERMOVE event if only a single touch is active.
  38192. */
  38193. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38194. /**
  38195. * Called on pointer POINTERDOUBLETAP event.
  38196. */
  38197. protected onDoubleTap(type: string): void;
  38198. /**
  38199. * Called on pointer POINTERMOVE event if multiple touches are active.
  38200. */
  38201. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38202. /**
  38203. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38204. * press.
  38205. */
  38206. protected onButtonDown(evt: PointerEvent): void;
  38207. /**
  38208. * Called each time a new POINTERUP event occurs. Ie, for each button
  38209. * release.
  38210. */
  38211. protected onButtonUp(evt: PointerEvent): void;
  38212. /**
  38213. * Called when window becomes inactive.
  38214. */
  38215. protected onLostFocus(): void;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. /**
  38220. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38222. */
  38223. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38224. /**
  38225. * Defines the camera the input is attached to.
  38226. */
  38227. camera: ArcRotateCamera;
  38228. /**
  38229. * Defines the list of key codes associated with the up action (increase alpha)
  38230. */
  38231. keysUp: number[];
  38232. /**
  38233. * Defines the list of key codes associated with the down action (decrease alpha)
  38234. */
  38235. keysDown: number[];
  38236. /**
  38237. * Defines the list of key codes associated with the left action (increase beta)
  38238. */
  38239. keysLeft: number[];
  38240. /**
  38241. * Defines the list of key codes associated with the right action (decrease beta)
  38242. */
  38243. keysRight: number[];
  38244. /**
  38245. * Defines the list of key codes associated with the reset action.
  38246. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38247. */
  38248. keysReset: number[];
  38249. /**
  38250. * Defines the panning sensibility of the inputs.
  38251. * (How fast is the camera paning)
  38252. */
  38253. panningSensibility: number;
  38254. /**
  38255. * Defines the zooming sensibility of the inputs.
  38256. * (How fast is the camera zooming)
  38257. */
  38258. zoomingSensibility: number;
  38259. /**
  38260. * Defines wether maintaining the alt key down switch the movement mode from
  38261. * orientation to zoom.
  38262. */
  38263. useAltToZoom: boolean;
  38264. /**
  38265. * Rotation speed of the camera
  38266. */
  38267. angularSpeed: number;
  38268. private _keys;
  38269. private _ctrlPressed;
  38270. private _altPressed;
  38271. private _onCanvasBlurObserver;
  38272. private _onKeyboardObserver;
  38273. private _engine;
  38274. private _scene;
  38275. /**
  38276. * Attach the input controls to a specific dom element to get the input from.
  38277. * @param element Defines the element the controls should be listened from
  38278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38279. */
  38280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38281. /**
  38282. * Detach the current controls from the specified dom element.
  38283. * @param element Defines the element to stop listening the inputs from
  38284. */
  38285. detachControl(element: Nullable<HTMLElement>): void;
  38286. /**
  38287. * Update the current camera state depending on the inputs that have been used this frame.
  38288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38289. */
  38290. checkInputs(): void;
  38291. /**
  38292. * Gets the class name of the current intput.
  38293. * @returns the class name
  38294. */
  38295. getClassName(): string;
  38296. /**
  38297. * Get the friendly name associated with the input class.
  38298. * @returns the input friendly name
  38299. */
  38300. getSimpleName(): string;
  38301. }
  38302. }
  38303. declare module BABYLON {
  38304. /**
  38305. * Manage the mouse wheel inputs to control an arc rotate camera.
  38306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38307. */
  38308. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38309. /**
  38310. * Defines the camera the input is attached to.
  38311. */
  38312. camera: ArcRotateCamera;
  38313. /**
  38314. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38315. */
  38316. wheelPrecision: number;
  38317. /**
  38318. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38319. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38320. */
  38321. wheelDeltaPercentage: number;
  38322. private _wheel;
  38323. private _observer;
  38324. private computeDeltaFromMouseWheelLegacyEvent;
  38325. /**
  38326. * Attach the input controls to a specific dom element to get the input from.
  38327. * @param element Defines the element the controls should be listened from
  38328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38329. */
  38330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38331. /**
  38332. * Detach the current controls from the specified dom element.
  38333. * @param element Defines the element to stop listening the inputs from
  38334. */
  38335. detachControl(element: Nullable<HTMLElement>): void;
  38336. /**
  38337. * Gets the class name of the current intput.
  38338. * @returns the class name
  38339. */
  38340. getClassName(): string;
  38341. /**
  38342. * Get the friendly name associated with the input class.
  38343. * @returns the input friendly name
  38344. */
  38345. getSimpleName(): string;
  38346. }
  38347. }
  38348. declare module BABYLON {
  38349. /**
  38350. * Default Inputs manager for the ArcRotateCamera.
  38351. * It groups all the default supported inputs for ease of use.
  38352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38353. */
  38354. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38355. /**
  38356. * Instantiates a new ArcRotateCameraInputsManager.
  38357. * @param camera Defines the camera the inputs belong to
  38358. */
  38359. constructor(camera: ArcRotateCamera);
  38360. /**
  38361. * Add mouse wheel input support to the input manager.
  38362. * @returns the current input manager
  38363. */
  38364. addMouseWheel(): ArcRotateCameraInputsManager;
  38365. /**
  38366. * Add pointers input support to the input manager.
  38367. * @returns the current input manager
  38368. */
  38369. addPointers(): ArcRotateCameraInputsManager;
  38370. /**
  38371. * Add keyboard input support to the input manager.
  38372. * @returns the current input manager
  38373. */
  38374. addKeyboard(): ArcRotateCameraInputsManager;
  38375. }
  38376. }
  38377. declare module BABYLON {
  38378. /**
  38379. * This represents an orbital type of camera.
  38380. *
  38381. * 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.
  38382. * 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.
  38383. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38384. */
  38385. export class ArcRotateCamera extends TargetCamera {
  38386. /**
  38387. * Defines the rotation angle of the camera along the longitudinal axis.
  38388. */
  38389. alpha: number;
  38390. /**
  38391. * Defines the rotation angle of the camera along the latitudinal axis.
  38392. */
  38393. beta: number;
  38394. /**
  38395. * Defines the radius of the camera from it s target point.
  38396. */
  38397. radius: number;
  38398. protected _target: Vector3;
  38399. protected _targetHost: Nullable<AbstractMesh>;
  38400. /**
  38401. * Defines the target point of the camera.
  38402. * The camera looks towards it form the radius distance.
  38403. */
  38404. get target(): Vector3;
  38405. set target(value: Vector3);
  38406. /**
  38407. * Define the current local position of the camera in the scene
  38408. */
  38409. get position(): Vector3;
  38410. set position(newPosition: Vector3);
  38411. protected _upVector: Vector3;
  38412. protected _upToYMatrix: Matrix;
  38413. protected _YToUpMatrix: Matrix;
  38414. /**
  38415. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38416. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38417. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38418. */
  38419. set upVector(vec: Vector3);
  38420. get upVector(): Vector3;
  38421. /**
  38422. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38423. */
  38424. setMatUp(): void;
  38425. /**
  38426. * Current inertia value on the longitudinal axis.
  38427. * The bigger this number the longer it will take for the camera to stop.
  38428. */
  38429. inertialAlphaOffset: number;
  38430. /**
  38431. * Current inertia value on the latitudinal axis.
  38432. * The bigger this number the longer it will take for the camera to stop.
  38433. */
  38434. inertialBetaOffset: number;
  38435. /**
  38436. * Current inertia value on the radius axis.
  38437. * The bigger this number the longer it will take for the camera to stop.
  38438. */
  38439. inertialRadiusOffset: number;
  38440. /**
  38441. * Minimum allowed angle on the longitudinal axis.
  38442. * This can help limiting how the Camera is able to move in the scene.
  38443. */
  38444. lowerAlphaLimit: Nullable<number>;
  38445. /**
  38446. * Maximum allowed angle on the longitudinal axis.
  38447. * This can help limiting how the Camera is able to move in the scene.
  38448. */
  38449. upperAlphaLimit: Nullable<number>;
  38450. /**
  38451. * Minimum allowed angle on the latitudinal axis.
  38452. * This can help limiting how the Camera is able to move in the scene.
  38453. */
  38454. lowerBetaLimit: number;
  38455. /**
  38456. * Maximum allowed angle on the latitudinal axis.
  38457. * This can help limiting how the Camera is able to move in the scene.
  38458. */
  38459. upperBetaLimit: number;
  38460. /**
  38461. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38462. * This can help limiting how the Camera is able to move in the scene.
  38463. */
  38464. lowerRadiusLimit: Nullable<number>;
  38465. /**
  38466. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38467. * This can help limiting how the Camera is able to move in the scene.
  38468. */
  38469. upperRadiusLimit: Nullable<number>;
  38470. /**
  38471. * Defines the current inertia value used during panning of the camera along the X axis.
  38472. */
  38473. inertialPanningX: number;
  38474. /**
  38475. * Defines the current inertia value used during panning of the camera along the Y axis.
  38476. */
  38477. inertialPanningY: number;
  38478. /**
  38479. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38480. * Basically if your fingers moves away from more than this distance you will be considered
  38481. * in pinch mode.
  38482. */
  38483. pinchToPanMaxDistance: number;
  38484. /**
  38485. * Defines the maximum distance the camera can pan.
  38486. * This could help keeping the cammera always in your scene.
  38487. */
  38488. panningDistanceLimit: Nullable<number>;
  38489. /**
  38490. * Defines the target of the camera before paning.
  38491. */
  38492. panningOriginTarget: Vector3;
  38493. /**
  38494. * Defines the value of the inertia used during panning.
  38495. * 0 would mean stop inertia and one would mean no decelleration at all.
  38496. */
  38497. panningInertia: number;
  38498. /**
  38499. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38500. */
  38501. get angularSensibilityX(): number;
  38502. set angularSensibilityX(value: number);
  38503. /**
  38504. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38505. */
  38506. get angularSensibilityY(): number;
  38507. set angularSensibilityY(value: number);
  38508. /**
  38509. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38510. */
  38511. get pinchPrecision(): number;
  38512. set pinchPrecision(value: number);
  38513. /**
  38514. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38515. * It will be used instead of pinchDeltaPrecision if different from 0.
  38516. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38517. */
  38518. get pinchDeltaPercentage(): number;
  38519. set pinchDeltaPercentage(value: number);
  38520. /**
  38521. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38522. */
  38523. get panningSensibility(): number;
  38524. set panningSensibility(value: number);
  38525. /**
  38526. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38527. */
  38528. get keysUp(): number[];
  38529. set keysUp(value: number[]);
  38530. /**
  38531. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38532. */
  38533. get keysDown(): number[];
  38534. set keysDown(value: number[]);
  38535. /**
  38536. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38537. */
  38538. get keysLeft(): number[];
  38539. set keysLeft(value: number[]);
  38540. /**
  38541. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38542. */
  38543. get keysRight(): number[];
  38544. set keysRight(value: number[]);
  38545. /**
  38546. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38547. */
  38548. get wheelPrecision(): number;
  38549. set wheelPrecision(value: number);
  38550. /**
  38551. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38552. * It will be used instead of pinchDeltaPrecision if different from 0.
  38553. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38554. */
  38555. get wheelDeltaPercentage(): number;
  38556. set wheelDeltaPercentage(value: number);
  38557. /**
  38558. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38559. */
  38560. zoomOnFactor: number;
  38561. /**
  38562. * Defines a screen offset for the camera position.
  38563. */
  38564. targetScreenOffset: Vector2;
  38565. /**
  38566. * Allows the camera to be completely reversed.
  38567. * If false the camera can not arrive upside down.
  38568. */
  38569. allowUpsideDown: boolean;
  38570. /**
  38571. * Define if double tap/click is used to restore the previously saved state of the camera.
  38572. */
  38573. useInputToRestoreState: boolean;
  38574. /** @hidden */
  38575. _viewMatrix: Matrix;
  38576. /** @hidden */
  38577. _useCtrlForPanning: boolean;
  38578. /** @hidden */
  38579. _panningMouseButton: number;
  38580. /**
  38581. * Defines the input associated to the camera.
  38582. */
  38583. inputs: ArcRotateCameraInputsManager;
  38584. /** @hidden */
  38585. _reset: () => void;
  38586. /**
  38587. * Defines the allowed panning axis.
  38588. */
  38589. panningAxis: Vector3;
  38590. protected _localDirection: Vector3;
  38591. protected _transformedDirection: Vector3;
  38592. private _bouncingBehavior;
  38593. /**
  38594. * Gets the bouncing behavior of the camera if it has been enabled.
  38595. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38596. */
  38597. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38598. /**
  38599. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38600. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38601. */
  38602. get useBouncingBehavior(): boolean;
  38603. set useBouncingBehavior(value: boolean);
  38604. private _framingBehavior;
  38605. /**
  38606. * Gets the framing behavior of the camera if it has been enabled.
  38607. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38608. */
  38609. get framingBehavior(): Nullable<FramingBehavior>;
  38610. /**
  38611. * Defines if the framing behavior of the camera is enabled on the camera.
  38612. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38613. */
  38614. get useFramingBehavior(): boolean;
  38615. set useFramingBehavior(value: boolean);
  38616. private _autoRotationBehavior;
  38617. /**
  38618. * Gets the auto rotation behavior of the camera if it has been enabled.
  38619. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38620. */
  38621. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38622. /**
  38623. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38625. */
  38626. get useAutoRotationBehavior(): boolean;
  38627. set useAutoRotationBehavior(value: boolean);
  38628. /**
  38629. * Observable triggered when the mesh target has been changed on the camera.
  38630. */
  38631. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38632. /**
  38633. * Event raised when the camera is colliding with a mesh.
  38634. */
  38635. onCollide: (collidedMesh: AbstractMesh) => void;
  38636. /**
  38637. * Defines whether the camera should check collision with the objects oh the scene.
  38638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38639. */
  38640. checkCollisions: boolean;
  38641. /**
  38642. * Defines the collision radius of the camera.
  38643. * This simulates a sphere around the camera.
  38644. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38645. */
  38646. collisionRadius: Vector3;
  38647. protected _collider: Collider;
  38648. protected _previousPosition: Vector3;
  38649. protected _collisionVelocity: Vector3;
  38650. protected _newPosition: Vector3;
  38651. protected _previousAlpha: number;
  38652. protected _previousBeta: number;
  38653. protected _previousRadius: number;
  38654. protected _collisionTriggered: boolean;
  38655. protected _targetBoundingCenter: Nullable<Vector3>;
  38656. private _computationVector;
  38657. /**
  38658. * Instantiates a new ArcRotateCamera in a given scene
  38659. * @param name Defines the name of the camera
  38660. * @param alpha Defines the camera rotation along the logitudinal axis
  38661. * @param beta Defines the camera rotation along the latitudinal axis
  38662. * @param radius Defines the camera distance from its target
  38663. * @param target Defines the camera target
  38664. * @param scene Defines the scene the camera belongs to
  38665. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38666. */
  38667. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38668. /** @hidden */
  38669. _initCache(): void;
  38670. /** @hidden */
  38671. _updateCache(ignoreParentClass?: boolean): void;
  38672. protected _getTargetPosition(): Vector3;
  38673. private _storedAlpha;
  38674. private _storedBeta;
  38675. private _storedRadius;
  38676. private _storedTarget;
  38677. private _storedTargetScreenOffset;
  38678. /**
  38679. * Stores the current state of the camera (alpha, beta, radius and target)
  38680. * @returns the camera itself
  38681. */
  38682. storeState(): Camera;
  38683. /**
  38684. * @hidden
  38685. * Restored camera state. You must call storeState() first
  38686. */
  38687. _restoreStateValues(): boolean;
  38688. /** @hidden */
  38689. _isSynchronizedViewMatrix(): boolean;
  38690. /**
  38691. * Attached controls to the current camera.
  38692. * @param element Defines the element the controls should be listened from
  38693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38694. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38695. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38696. */
  38697. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38698. /**
  38699. * Detach the current controls from the camera.
  38700. * The camera will stop reacting to inputs.
  38701. * @param element Defines the element to stop listening the inputs from
  38702. */
  38703. detachControl(element: HTMLElement): void;
  38704. /** @hidden */
  38705. _checkInputs(): void;
  38706. protected _checkLimits(): void;
  38707. /**
  38708. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38709. */
  38710. rebuildAnglesAndRadius(): void;
  38711. /**
  38712. * Use a position to define the current camera related information like alpha, beta and radius
  38713. * @param position Defines the position to set the camera at
  38714. */
  38715. setPosition(position: Vector3): void;
  38716. /**
  38717. * Defines the target the camera should look at.
  38718. * This will automatically adapt alpha beta and radius to fit within the new target.
  38719. * @param target Defines the new target as a Vector or a mesh
  38720. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38721. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38722. */
  38723. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38724. /** @hidden */
  38725. _getViewMatrix(): Matrix;
  38726. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38727. /**
  38728. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38729. * @param meshes Defines the mesh to zoom on
  38730. * @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)
  38731. */
  38732. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38733. /**
  38734. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38735. * The target will be changed but the radius
  38736. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38737. * @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)
  38738. */
  38739. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38740. min: Vector3;
  38741. max: Vector3;
  38742. distance: number;
  38743. }, doNotUpdateMaxZ?: boolean): void;
  38744. /**
  38745. * @override
  38746. * Override Camera.createRigCamera
  38747. */
  38748. createRigCamera(name: string, cameraIndex: number): Camera;
  38749. /**
  38750. * @hidden
  38751. * @override
  38752. * Override Camera._updateRigCameras
  38753. */
  38754. _updateRigCameras(): void;
  38755. /**
  38756. * Destroy the camera and release the current resources hold by it.
  38757. */
  38758. dispose(): void;
  38759. /**
  38760. * Gets the current object class name.
  38761. * @return the class name
  38762. */
  38763. getClassName(): string;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /**
  38768. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38770. */
  38771. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38772. /**
  38773. * Gets the name of the behavior.
  38774. */
  38775. get name(): string;
  38776. private _zoomStopsAnimation;
  38777. private _idleRotationSpeed;
  38778. private _idleRotationWaitTime;
  38779. private _idleRotationSpinupTime;
  38780. /**
  38781. * Sets the flag that indicates if user zooming should stop animation.
  38782. */
  38783. set zoomStopsAnimation(flag: boolean);
  38784. /**
  38785. * Gets the flag that indicates if user zooming should stop animation.
  38786. */
  38787. get zoomStopsAnimation(): boolean;
  38788. /**
  38789. * Sets the default speed at which the camera rotates around the model.
  38790. */
  38791. set idleRotationSpeed(speed: number);
  38792. /**
  38793. * Gets the default speed at which the camera rotates around the model.
  38794. */
  38795. get idleRotationSpeed(): number;
  38796. /**
  38797. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38798. */
  38799. set idleRotationWaitTime(time: number);
  38800. /**
  38801. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38802. */
  38803. get idleRotationWaitTime(): number;
  38804. /**
  38805. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38806. */
  38807. set idleRotationSpinupTime(time: number);
  38808. /**
  38809. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38810. */
  38811. get idleRotationSpinupTime(): number;
  38812. /**
  38813. * Gets a value indicating if the camera is currently rotating because of this behavior
  38814. */
  38815. get rotationInProgress(): boolean;
  38816. private _onPrePointerObservableObserver;
  38817. private _onAfterCheckInputsObserver;
  38818. private _attachedCamera;
  38819. private _isPointerDown;
  38820. private _lastFrameTime;
  38821. private _lastInteractionTime;
  38822. private _cameraRotationSpeed;
  38823. /**
  38824. * Initializes the behavior.
  38825. */
  38826. init(): void;
  38827. /**
  38828. * Attaches the behavior to its arc rotate camera.
  38829. * @param camera Defines the camera to attach the behavior to
  38830. */
  38831. attach(camera: ArcRotateCamera): void;
  38832. /**
  38833. * Detaches the behavior from its current arc rotate camera.
  38834. */
  38835. detach(): void;
  38836. /**
  38837. * Returns true if user is scrolling.
  38838. * @return true if user is scrolling.
  38839. */
  38840. private _userIsZooming;
  38841. private _lastFrameRadius;
  38842. private _shouldAnimationStopForInteraction;
  38843. /**
  38844. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38845. */
  38846. private _applyUserInteraction;
  38847. private _userIsMoving;
  38848. }
  38849. }
  38850. declare module BABYLON {
  38851. /**
  38852. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38853. */
  38854. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38855. private ui;
  38856. /**
  38857. * The name of the behavior
  38858. */
  38859. name: string;
  38860. /**
  38861. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38862. */
  38863. distanceAwayFromFace: number;
  38864. /**
  38865. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38866. */
  38867. distanceAwayFromBottomOfFace: number;
  38868. private _faceVectors;
  38869. private _target;
  38870. private _scene;
  38871. private _onRenderObserver;
  38872. private _tmpMatrix;
  38873. private _tmpVector;
  38874. /**
  38875. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38876. * @param ui The transform node that should be attched to the mesh
  38877. */
  38878. constructor(ui: TransformNode);
  38879. /**
  38880. * Initializes the behavior
  38881. */
  38882. init(): void;
  38883. private _closestFace;
  38884. private _zeroVector;
  38885. private _lookAtTmpMatrix;
  38886. private _lookAtToRef;
  38887. /**
  38888. * Attaches the AttachToBoxBehavior to the passed in mesh
  38889. * @param target The mesh that the specified node will be attached to
  38890. */
  38891. attach(target: Mesh): void;
  38892. /**
  38893. * Detaches the behavior from the mesh
  38894. */
  38895. detach(): void;
  38896. }
  38897. }
  38898. declare module BABYLON {
  38899. /**
  38900. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38901. */
  38902. export class FadeInOutBehavior implements Behavior<Mesh> {
  38903. /**
  38904. * Time in milliseconds to delay before fading in (Default: 0)
  38905. */
  38906. delay: number;
  38907. /**
  38908. * Time in milliseconds for the mesh to fade in (Default: 300)
  38909. */
  38910. fadeInTime: number;
  38911. private _millisecondsPerFrame;
  38912. private _hovered;
  38913. private _hoverValue;
  38914. private _ownerNode;
  38915. /**
  38916. * Instatiates the FadeInOutBehavior
  38917. */
  38918. constructor();
  38919. /**
  38920. * The name of the behavior
  38921. */
  38922. get name(): string;
  38923. /**
  38924. * Initializes the behavior
  38925. */
  38926. init(): void;
  38927. /**
  38928. * Attaches the fade behavior on the passed in mesh
  38929. * @param ownerNode The mesh that will be faded in/out once attached
  38930. */
  38931. attach(ownerNode: Mesh): void;
  38932. /**
  38933. * Detaches the behavior from the mesh
  38934. */
  38935. detach(): void;
  38936. /**
  38937. * Triggers the mesh to begin fading in or out
  38938. * @param value if the object should fade in or out (true to fade in)
  38939. */
  38940. fadeIn(value: boolean): void;
  38941. private _update;
  38942. private _setAllVisibility;
  38943. }
  38944. }
  38945. declare module BABYLON {
  38946. /**
  38947. * Class containing a set of static utilities functions for managing Pivots
  38948. * @hidden
  38949. */
  38950. export class PivotTools {
  38951. private static _PivotCached;
  38952. private static _OldPivotPoint;
  38953. private static _PivotTranslation;
  38954. private static _PivotTmpVector;
  38955. /** @hidden */
  38956. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38957. /** @hidden */
  38958. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38959. }
  38960. }
  38961. declare module BABYLON {
  38962. /**
  38963. * Class containing static functions to help procedurally build meshes
  38964. */
  38965. export class PlaneBuilder {
  38966. /**
  38967. * Creates a plane mesh
  38968. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38969. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38970. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38972. * * 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
  38973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38974. * @param name defines the name of the mesh
  38975. * @param options defines the options used to create the mesh
  38976. * @param scene defines the hosting scene
  38977. * @returns the plane mesh
  38978. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38979. */
  38980. static CreatePlane(name: string, options: {
  38981. size?: number;
  38982. width?: number;
  38983. height?: number;
  38984. sideOrientation?: number;
  38985. frontUVs?: Vector4;
  38986. backUVs?: Vector4;
  38987. updatable?: boolean;
  38988. sourcePlane?: Plane;
  38989. }, scene?: Nullable<Scene>): Mesh;
  38990. }
  38991. }
  38992. declare module BABYLON {
  38993. /**
  38994. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38995. */
  38996. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38997. private static _AnyMouseID;
  38998. /**
  38999. * Abstract mesh the behavior is set on
  39000. */
  39001. attachedNode: AbstractMesh;
  39002. private _dragPlane;
  39003. private _scene;
  39004. private _pointerObserver;
  39005. private _beforeRenderObserver;
  39006. private static _planeScene;
  39007. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39008. /**
  39009. * 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)
  39010. */
  39011. maxDragAngle: number;
  39012. /**
  39013. * @hidden
  39014. */
  39015. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39016. /**
  39017. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39018. */
  39019. currentDraggingPointerID: number;
  39020. /**
  39021. * The last position where the pointer hit the drag plane in world space
  39022. */
  39023. lastDragPosition: Vector3;
  39024. /**
  39025. * If the behavior is currently in a dragging state
  39026. */
  39027. dragging: boolean;
  39028. /**
  39029. * 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)
  39030. */
  39031. dragDeltaRatio: number;
  39032. /**
  39033. * If the drag plane orientation should be updated during the dragging (Default: true)
  39034. */
  39035. updateDragPlane: boolean;
  39036. private _debugMode;
  39037. private _moving;
  39038. /**
  39039. * Fires each time the attached mesh is dragged with the pointer
  39040. * * delta between last drag position and current drag position in world space
  39041. * * dragDistance along the drag axis
  39042. * * dragPlaneNormal normal of the current drag plane used during the drag
  39043. * * dragPlanePoint in world space where the drag intersects the drag plane
  39044. */
  39045. onDragObservable: Observable<{
  39046. delta: Vector3;
  39047. dragPlanePoint: Vector3;
  39048. dragPlaneNormal: Vector3;
  39049. dragDistance: number;
  39050. pointerId: number;
  39051. }>;
  39052. /**
  39053. * Fires each time a drag begins (eg. mouse down on mesh)
  39054. */
  39055. onDragStartObservable: Observable<{
  39056. dragPlanePoint: Vector3;
  39057. pointerId: number;
  39058. }>;
  39059. /**
  39060. * Fires each time a drag ends (eg. mouse release after drag)
  39061. */
  39062. onDragEndObservable: Observable<{
  39063. dragPlanePoint: Vector3;
  39064. pointerId: number;
  39065. }>;
  39066. /**
  39067. * If the attached mesh should be moved when dragged
  39068. */
  39069. moveAttached: boolean;
  39070. /**
  39071. * If the drag behavior will react to drag events (Default: true)
  39072. */
  39073. enabled: boolean;
  39074. /**
  39075. * If pointer events should start and release the drag (Default: true)
  39076. */
  39077. startAndReleaseDragOnPointerEvents: boolean;
  39078. /**
  39079. * If camera controls should be detached during the drag
  39080. */
  39081. detachCameraControls: boolean;
  39082. /**
  39083. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39084. */
  39085. useObjectOrientationForDragging: boolean;
  39086. private _options;
  39087. /**
  39088. * Gets the options used by the behavior
  39089. */
  39090. get options(): {
  39091. dragAxis?: Vector3;
  39092. dragPlaneNormal?: Vector3;
  39093. };
  39094. /**
  39095. * Sets the options used by the behavior
  39096. */
  39097. set options(options: {
  39098. dragAxis?: Vector3;
  39099. dragPlaneNormal?: Vector3;
  39100. });
  39101. /**
  39102. * Creates a pointer drag behavior that can be attached to a mesh
  39103. * @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)
  39104. */
  39105. constructor(options?: {
  39106. dragAxis?: Vector3;
  39107. dragPlaneNormal?: Vector3;
  39108. });
  39109. /**
  39110. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39111. */
  39112. validateDrag: (targetPosition: Vector3) => boolean;
  39113. /**
  39114. * The name of the behavior
  39115. */
  39116. get name(): string;
  39117. /**
  39118. * Initializes the behavior
  39119. */
  39120. init(): void;
  39121. private _tmpVector;
  39122. private _alternatePickedPoint;
  39123. private _worldDragAxis;
  39124. private _targetPosition;
  39125. private _attachedElement;
  39126. /**
  39127. * Attaches the drag behavior the passed in mesh
  39128. * @param ownerNode The mesh that will be dragged around once attached
  39129. * @param predicate Predicate to use for pick filtering
  39130. */
  39131. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39132. /**
  39133. * Force relase the drag action by code.
  39134. */
  39135. releaseDrag(): void;
  39136. private _startDragRay;
  39137. private _lastPointerRay;
  39138. /**
  39139. * Simulates the start of a pointer drag event on the behavior
  39140. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39141. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39142. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39143. */
  39144. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39145. private _startDrag;
  39146. private _dragDelta;
  39147. private _moveDrag;
  39148. private _pickWithRayOnDragPlane;
  39149. private _pointA;
  39150. private _pointB;
  39151. private _pointC;
  39152. private _lineA;
  39153. private _lineB;
  39154. private _localAxis;
  39155. private _lookAt;
  39156. private _updateDragPlanePosition;
  39157. /**
  39158. * Detaches the behavior from the mesh
  39159. */
  39160. detach(): void;
  39161. }
  39162. }
  39163. declare module BABYLON {
  39164. /**
  39165. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39166. */
  39167. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39168. private _dragBehaviorA;
  39169. private _dragBehaviorB;
  39170. private _startDistance;
  39171. private _initialScale;
  39172. private _targetScale;
  39173. private _ownerNode;
  39174. private _sceneRenderObserver;
  39175. /**
  39176. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39177. */
  39178. constructor();
  39179. /**
  39180. * The name of the behavior
  39181. */
  39182. get name(): string;
  39183. /**
  39184. * Initializes the behavior
  39185. */
  39186. init(): void;
  39187. private _getCurrentDistance;
  39188. /**
  39189. * Attaches the scale behavior the passed in mesh
  39190. * @param ownerNode The mesh that will be scaled around once attached
  39191. */
  39192. attach(ownerNode: Mesh): void;
  39193. /**
  39194. * Detaches the behavior from the mesh
  39195. */
  39196. detach(): void;
  39197. }
  39198. }
  39199. declare module BABYLON {
  39200. /**
  39201. * 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
  39202. */
  39203. export class SixDofDragBehavior implements Behavior<Mesh> {
  39204. private static _virtualScene;
  39205. private _ownerNode;
  39206. private _sceneRenderObserver;
  39207. private _scene;
  39208. private _targetPosition;
  39209. private _virtualOriginMesh;
  39210. private _virtualDragMesh;
  39211. private _pointerObserver;
  39212. private _moving;
  39213. private _startingOrientation;
  39214. /**
  39215. * 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)
  39216. */
  39217. private zDragFactor;
  39218. /**
  39219. * If the object should rotate to face the drag origin
  39220. */
  39221. rotateDraggedObject: boolean;
  39222. /**
  39223. * If the behavior is currently in a dragging state
  39224. */
  39225. dragging: boolean;
  39226. /**
  39227. * 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)
  39228. */
  39229. dragDeltaRatio: number;
  39230. /**
  39231. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39232. */
  39233. currentDraggingPointerID: number;
  39234. /**
  39235. * If camera controls should be detached during the drag
  39236. */
  39237. detachCameraControls: boolean;
  39238. /**
  39239. * Fires each time a drag starts
  39240. */
  39241. onDragStartObservable: Observable<{}>;
  39242. /**
  39243. * Fires each time a drag ends (eg. mouse release after drag)
  39244. */
  39245. onDragEndObservable: Observable<{}>;
  39246. /**
  39247. * 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
  39248. */
  39249. constructor();
  39250. /**
  39251. * The name of the behavior
  39252. */
  39253. get name(): string;
  39254. /**
  39255. * Initializes the behavior
  39256. */
  39257. init(): void;
  39258. /**
  39259. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39260. */
  39261. private get _pointerCamera();
  39262. /**
  39263. * Attaches the scale behavior the passed in mesh
  39264. * @param ownerNode The mesh that will be scaled around once attached
  39265. */
  39266. attach(ownerNode: Mesh): void;
  39267. /**
  39268. * Detaches the behavior from the mesh
  39269. */
  39270. detach(): void;
  39271. }
  39272. }
  39273. declare module BABYLON {
  39274. /**
  39275. * Class used to apply inverse kinematics to bones
  39276. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39277. */
  39278. export class BoneIKController {
  39279. private static _tmpVecs;
  39280. private static _tmpQuat;
  39281. private static _tmpMats;
  39282. /**
  39283. * Gets or sets the target mesh
  39284. */
  39285. targetMesh: AbstractMesh;
  39286. /** Gets or sets the mesh used as pole */
  39287. poleTargetMesh: AbstractMesh;
  39288. /**
  39289. * Gets or sets the bone used as pole
  39290. */
  39291. poleTargetBone: Nullable<Bone>;
  39292. /**
  39293. * Gets or sets the target position
  39294. */
  39295. targetPosition: Vector3;
  39296. /**
  39297. * Gets or sets the pole target position
  39298. */
  39299. poleTargetPosition: Vector3;
  39300. /**
  39301. * Gets or sets the pole target local offset
  39302. */
  39303. poleTargetLocalOffset: Vector3;
  39304. /**
  39305. * Gets or sets the pole angle
  39306. */
  39307. poleAngle: number;
  39308. /**
  39309. * Gets or sets the mesh associated with the controller
  39310. */
  39311. mesh: AbstractMesh;
  39312. /**
  39313. * 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)
  39314. */
  39315. slerpAmount: number;
  39316. private _bone1Quat;
  39317. private _bone1Mat;
  39318. private _bone2Ang;
  39319. private _bone1;
  39320. private _bone2;
  39321. private _bone1Length;
  39322. private _bone2Length;
  39323. private _maxAngle;
  39324. private _maxReach;
  39325. private _rightHandedSystem;
  39326. private _bendAxis;
  39327. private _slerping;
  39328. private _adjustRoll;
  39329. /**
  39330. * Gets or sets maximum allowed angle
  39331. */
  39332. get maxAngle(): number;
  39333. set maxAngle(value: number);
  39334. /**
  39335. * Creates a new BoneIKController
  39336. * @param mesh defines the mesh to control
  39337. * @param bone defines the bone to control
  39338. * @param options defines options to set up the controller
  39339. */
  39340. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39341. targetMesh?: AbstractMesh;
  39342. poleTargetMesh?: AbstractMesh;
  39343. poleTargetBone?: Bone;
  39344. poleTargetLocalOffset?: Vector3;
  39345. poleAngle?: number;
  39346. bendAxis?: Vector3;
  39347. maxAngle?: number;
  39348. slerpAmount?: number;
  39349. });
  39350. private _setMaxAngle;
  39351. /**
  39352. * Force the controller to update the bones
  39353. */
  39354. update(): void;
  39355. }
  39356. }
  39357. declare module BABYLON {
  39358. /**
  39359. * Class used to make a bone look toward a point in space
  39360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39361. */
  39362. export class BoneLookController {
  39363. private static _tmpVecs;
  39364. private static _tmpQuat;
  39365. private static _tmpMats;
  39366. /**
  39367. * The target Vector3 that the bone will look at
  39368. */
  39369. target: Vector3;
  39370. /**
  39371. * The mesh that the bone is attached to
  39372. */
  39373. mesh: AbstractMesh;
  39374. /**
  39375. * The bone that will be looking to the target
  39376. */
  39377. bone: Bone;
  39378. /**
  39379. * The up axis of the coordinate system that is used when the bone is rotated
  39380. */
  39381. upAxis: Vector3;
  39382. /**
  39383. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39384. */
  39385. upAxisSpace: Space;
  39386. /**
  39387. * Used to make an adjustment to the yaw of the bone
  39388. */
  39389. adjustYaw: number;
  39390. /**
  39391. * Used to make an adjustment to the pitch of the bone
  39392. */
  39393. adjustPitch: number;
  39394. /**
  39395. * Used to make an adjustment to the roll of the bone
  39396. */
  39397. adjustRoll: number;
  39398. /**
  39399. * 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)
  39400. */
  39401. slerpAmount: number;
  39402. private _minYaw;
  39403. private _maxYaw;
  39404. private _minPitch;
  39405. private _maxPitch;
  39406. private _minYawSin;
  39407. private _minYawCos;
  39408. private _maxYawSin;
  39409. private _maxYawCos;
  39410. private _midYawConstraint;
  39411. private _minPitchTan;
  39412. private _maxPitchTan;
  39413. private _boneQuat;
  39414. private _slerping;
  39415. private _transformYawPitch;
  39416. private _transformYawPitchInv;
  39417. private _firstFrameSkipped;
  39418. private _yawRange;
  39419. private _fowardAxis;
  39420. /**
  39421. * Gets or sets the minimum yaw angle that the bone can look to
  39422. */
  39423. get minYaw(): number;
  39424. set minYaw(value: number);
  39425. /**
  39426. * Gets or sets the maximum yaw angle that the bone can look to
  39427. */
  39428. get maxYaw(): number;
  39429. set maxYaw(value: number);
  39430. /**
  39431. * Gets or sets the minimum pitch angle that the bone can look to
  39432. */
  39433. get minPitch(): number;
  39434. set minPitch(value: number);
  39435. /**
  39436. * Gets or sets the maximum pitch angle that the bone can look to
  39437. */
  39438. get maxPitch(): number;
  39439. set maxPitch(value: number);
  39440. /**
  39441. * Create a BoneLookController
  39442. * @param mesh the mesh that the bone belongs to
  39443. * @param bone the bone that will be looking to the target
  39444. * @param target the target Vector3 to look at
  39445. * @param options optional settings:
  39446. * * maxYaw: the maximum angle the bone will yaw to
  39447. * * minYaw: the minimum angle the bone will yaw to
  39448. * * maxPitch: the maximum angle the bone will pitch to
  39449. * * minPitch: the minimum angle the bone will yaw to
  39450. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39451. * * upAxis: the up axis of the coordinate system
  39452. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39453. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39454. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39455. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39456. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39457. * * adjustRoll: used to make an adjustment to the roll of the bone
  39458. **/
  39459. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39460. maxYaw?: number;
  39461. minYaw?: number;
  39462. maxPitch?: number;
  39463. minPitch?: number;
  39464. slerpAmount?: number;
  39465. upAxis?: Vector3;
  39466. upAxisSpace?: Space;
  39467. yawAxis?: Vector3;
  39468. pitchAxis?: Vector3;
  39469. adjustYaw?: number;
  39470. adjustPitch?: number;
  39471. adjustRoll?: number;
  39472. });
  39473. /**
  39474. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39475. */
  39476. update(): void;
  39477. private _getAngleDiff;
  39478. private _getAngleBetween;
  39479. private _isAngleBetween;
  39480. }
  39481. }
  39482. declare module BABYLON {
  39483. /**
  39484. * Manage the gamepad inputs to control an arc rotate camera.
  39485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39486. */
  39487. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39488. /**
  39489. * Defines the camera the input is attached to.
  39490. */
  39491. camera: ArcRotateCamera;
  39492. /**
  39493. * Defines the gamepad the input is gathering event from.
  39494. */
  39495. gamepad: Nullable<Gamepad>;
  39496. /**
  39497. * Defines the gamepad rotation sensiblity.
  39498. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39499. */
  39500. gamepadRotationSensibility: number;
  39501. /**
  39502. * Defines the gamepad move sensiblity.
  39503. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39504. */
  39505. gamepadMoveSensibility: number;
  39506. private _yAxisScale;
  39507. /**
  39508. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39509. */
  39510. get invertYAxis(): boolean;
  39511. set invertYAxis(value: boolean);
  39512. private _onGamepadConnectedObserver;
  39513. private _onGamepadDisconnectedObserver;
  39514. /**
  39515. * Attach the input controls to a specific dom element to get the input from.
  39516. * @param element Defines the element the controls should be listened from
  39517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39518. */
  39519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39520. /**
  39521. * Detach the current controls from the specified dom element.
  39522. * @param element Defines the element to stop listening the inputs from
  39523. */
  39524. detachControl(element: Nullable<HTMLElement>): void;
  39525. /**
  39526. * Update the current camera state depending on the inputs that have been used this frame.
  39527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39528. */
  39529. checkInputs(): void;
  39530. /**
  39531. * Gets the class name of the current intput.
  39532. * @returns the class name
  39533. */
  39534. getClassName(): string;
  39535. /**
  39536. * Get the friendly name associated with the input class.
  39537. * @returns the input friendly name
  39538. */
  39539. getSimpleName(): string;
  39540. }
  39541. }
  39542. declare module BABYLON {
  39543. interface ArcRotateCameraInputsManager {
  39544. /**
  39545. * Add orientation input support to the input manager.
  39546. * @returns the current input manager
  39547. */
  39548. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39549. }
  39550. /**
  39551. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39553. */
  39554. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39555. /**
  39556. * Defines the camera the input is attached to.
  39557. */
  39558. camera: ArcRotateCamera;
  39559. /**
  39560. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39561. */
  39562. alphaCorrection: number;
  39563. /**
  39564. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39565. */
  39566. gammaCorrection: number;
  39567. private _alpha;
  39568. private _gamma;
  39569. private _dirty;
  39570. private _deviceOrientationHandler;
  39571. /**
  39572. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39573. */
  39574. constructor();
  39575. /**
  39576. * Attach the input controls to a specific dom element to get the input from.
  39577. * @param element Defines the element the controls should be listened from
  39578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39579. */
  39580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39581. /** @hidden */
  39582. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39583. /**
  39584. * Update the current camera state depending on the inputs that have been used this frame.
  39585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39586. */
  39587. checkInputs(): void;
  39588. /**
  39589. * Detach the current controls from the specified dom element.
  39590. * @param element Defines the element to stop listening the inputs from
  39591. */
  39592. detachControl(element: Nullable<HTMLElement>): void;
  39593. /**
  39594. * Gets the class name of the current intput.
  39595. * @returns the class name
  39596. */
  39597. getClassName(): string;
  39598. /**
  39599. * Get the friendly name associated with the input class.
  39600. * @returns the input friendly name
  39601. */
  39602. getSimpleName(): string;
  39603. }
  39604. }
  39605. declare module BABYLON {
  39606. /**
  39607. * Listen to mouse events to control the camera.
  39608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39609. */
  39610. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39611. /**
  39612. * Defines the camera the input is attached to.
  39613. */
  39614. camera: FlyCamera;
  39615. /**
  39616. * Defines if touch is enabled. (Default is true.)
  39617. */
  39618. touchEnabled: boolean;
  39619. /**
  39620. * Defines the buttons associated with the input to handle camera rotation.
  39621. */
  39622. buttons: number[];
  39623. /**
  39624. * Assign buttons for Yaw control.
  39625. */
  39626. buttonsYaw: number[];
  39627. /**
  39628. * Assign buttons for Pitch control.
  39629. */
  39630. buttonsPitch: number[];
  39631. /**
  39632. * Assign buttons for Roll control.
  39633. */
  39634. buttonsRoll: number[];
  39635. /**
  39636. * Detect if any button is being pressed while mouse is moved.
  39637. * -1 = Mouse locked.
  39638. * 0 = Left button.
  39639. * 1 = Middle Button.
  39640. * 2 = Right Button.
  39641. */
  39642. activeButton: number;
  39643. /**
  39644. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39645. * Higher values reduce its sensitivity.
  39646. */
  39647. angularSensibility: number;
  39648. private _mousemoveCallback;
  39649. private _observer;
  39650. private _rollObserver;
  39651. private previousPosition;
  39652. private noPreventDefault;
  39653. private element;
  39654. /**
  39655. * Listen to mouse events to control the camera.
  39656. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39658. */
  39659. constructor(touchEnabled?: boolean);
  39660. /**
  39661. * Attach the mouse control to the HTML DOM element.
  39662. * @param element Defines the element that listens to the input events.
  39663. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39664. */
  39665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39666. /**
  39667. * Detach the current controls from the specified dom element.
  39668. * @param element Defines the element to stop listening the inputs from
  39669. */
  39670. detachControl(element: Nullable<HTMLElement>): void;
  39671. /**
  39672. * Gets the class name of the current input.
  39673. * @returns the class name.
  39674. */
  39675. getClassName(): string;
  39676. /**
  39677. * Get the friendly name associated with the input class.
  39678. * @returns the input's friendly name.
  39679. */
  39680. getSimpleName(): string;
  39681. private _pointerInput;
  39682. private _onMouseMove;
  39683. /**
  39684. * Rotate camera by mouse offset.
  39685. */
  39686. private rotateCamera;
  39687. }
  39688. }
  39689. declare module BABYLON {
  39690. /**
  39691. * Default Inputs manager for the FlyCamera.
  39692. * It groups all the default supported inputs for ease of use.
  39693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39694. */
  39695. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39696. /**
  39697. * Instantiates a new FlyCameraInputsManager.
  39698. * @param camera Defines the camera the inputs belong to.
  39699. */
  39700. constructor(camera: FlyCamera);
  39701. /**
  39702. * Add keyboard input support to the input manager.
  39703. * @returns the new FlyCameraKeyboardMoveInput().
  39704. */
  39705. addKeyboard(): FlyCameraInputsManager;
  39706. /**
  39707. * Add mouse input support to the input manager.
  39708. * @param touchEnabled Enable touch screen support.
  39709. * @returns the new FlyCameraMouseInput().
  39710. */
  39711. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39712. }
  39713. }
  39714. declare module BABYLON {
  39715. /**
  39716. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39717. * such as in a 3D Space Shooter or a Flight Simulator.
  39718. */
  39719. export class FlyCamera extends TargetCamera {
  39720. /**
  39721. * Define the collision ellipsoid of the camera.
  39722. * This is helpful for simulating a camera body, like a player's body.
  39723. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39724. */
  39725. ellipsoid: Vector3;
  39726. /**
  39727. * Define an offset for the position of the ellipsoid around the camera.
  39728. * This can be helpful if the camera is attached away from the player's body center,
  39729. * such as at its head.
  39730. */
  39731. ellipsoidOffset: Vector3;
  39732. /**
  39733. * Enable or disable collisions of the camera with the rest of the scene objects.
  39734. */
  39735. checkCollisions: boolean;
  39736. /**
  39737. * Enable or disable gravity on the camera.
  39738. */
  39739. applyGravity: boolean;
  39740. /**
  39741. * Define the current direction the camera is moving to.
  39742. */
  39743. cameraDirection: Vector3;
  39744. /**
  39745. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39746. * This overrides and empties cameraRotation.
  39747. */
  39748. rotationQuaternion: Quaternion;
  39749. /**
  39750. * Track Roll to maintain the wanted Rolling when looking around.
  39751. */
  39752. _trackRoll: number;
  39753. /**
  39754. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39755. */
  39756. rollCorrect: number;
  39757. /**
  39758. * Mimic a banked turn, Rolling the camera when Yawing.
  39759. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39760. */
  39761. bankedTurn: boolean;
  39762. /**
  39763. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39764. */
  39765. bankedTurnLimit: number;
  39766. /**
  39767. * Value of 0 disables the banked Roll.
  39768. * Value of 1 is equal to the Yaw angle in radians.
  39769. */
  39770. bankedTurnMultiplier: number;
  39771. /**
  39772. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39773. */
  39774. inputs: FlyCameraInputsManager;
  39775. /**
  39776. * Gets the input sensibility for mouse input.
  39777. * Higher values reduce sensitivity.
  39778. */
  39779. get angularSensibility(): number;
  39780. /**
  39781. * Sets the input sensibility for a mouse input.
  39782. * Higher values reduce sensitivity.
  39783. */
  39784. set angularSensibility(value: number);
  39785. /**
  39786. * Get the keys for camera movement forward.
  39787. */
  39788. get keysForward(): number[];
  39789. /**
  39790. * Set the keys for camera movement forward.
  39791. */
  39792. set keysForward(value: number[]);
  39793. /**
  39794. * Get the keys for camera movement backward.
  39795. */
  39796. get keysBackward(): number[];
  39797. set keysBackward(value: number[]);
  39798. /**
  39799. * Get the keys for camera movement up.
  39800. */
  39801. get keysUp(): number[];
  39802. /**
  39803. * Set the keys for camera movement up.
  39804. */
  39805. set keysUp(value: number[]);
  39806. /**
  39807. * Get the keys for camera movement down.
  39808. */
  39809. get keysDown(): number[];
  39810. /**
  39811. * Set the keys for camera movement down.
  39812. */
  39813. set keysDown(value: number[]);
  39814. /**
  39815. * Get the keys for camera movement left.
  39816. */
  39817. get keysLeft(): number[];
  39818. /**
  39819. * Set the keys for camera movement left.
  39820. */
  39821. set keysLeft(value: number[]);
  39822. /**
  39823. * Set the keys for camera movement right.
  39824. */
  39825. get keysRight(): number[];
  39826. /**
  39827. * Set the keys for camera movement right.
  39828. */
  39829. set keysRight(value: number[]);
  39830. /**
  39831. * Event raised when the camera collides with a mesh in the scene.
  39832. */
  39833. onCollide: (collidedMesh: AbstractMesh) => void;
  39834. private _collider;
  39835. private _needMoveForGravity;
  39836. private _oldPosition;
  39837. private _diffPosition;
  39838. private _newPosition;
  39839. /** @hidden */
  39840. _localDirection: Vector3;
  39841. /** @hidden */
  39842. _transformedDirection: Vector3;
  39843. /**
  39844. * Instantiates a FlyCamera.
  39845. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39846. * such as in a 3D Space Shooter or a Flight Simulator.
  39847. * @param name Define the name of the camera in the scene.
  39848. * @param position Define the starting position of the camera in the scene.
  39849. * @param scene Define the scene the camera belongs to.
  39850. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39851. */
  39852. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39853. /**
  39854. * Attach a control to the HTML DOM element.
  39855. * @param element Defines the element that listens to the input events.
  39856. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39857. */
  39858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39859. /**
  39860. * Detach a control from the HTML DOM element.
  39861. * The camera will stop reacting to that input.
  39862. * @param element Defines the element that listens to the input events.
  39863. */
  39864. detachControl(element: HTMLElement): void;
  39865. private _collisionMask;
  39866. /**
  39867. * Get the mask that the camera ignores in collision events.
  39868. */
  39869. get collisionMask(): number;
  39870. /**
  39871. * Set the mask that the camera ignores in collision events.
  39872. */
  39873. set collisionMask(mask: number);
  39874. /** @hidden */
  39875. _collideWithWorld(displacement: Vector3): void;
  39876. /** @hidden */
  39877. private _onCollisionPositionChange;
  39878. /** @hidden */
  39879. _checkInputs(): void;
  39880. /** @hidden */
  39881. _decideIfNeedsToMove(): boolean;
  39882. /** @hidden */
  39883. _updatePosition(): void;
  39884. /**
  39885. * Restore the Roll to its target value at the rate specified.
  39886. * @param rate - Higher means slower restoring.
  39887. * @hidden
  39888. */
  39889. restoreRoll(rate: number): void;
  39890. /**
  39891. * Destroy the camera and release the current resources held by it.
  39892. */
  39893. dispose(): void;
  39894. /**
  39895. * Get the current object class name.
  39896. * @returns the class name.
  39897. */
  39898. getClassName(): string;
  39899. }
  39900. }
  39901. declare module BABYLON {
  39902. /**
  39903. * Listen to keyboard events to control the camera.
  39904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39905. */
  39906. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39907. /**
  39908. * Defines the camera the input is attached to.
  39909. */
  39910. camera: FlyCamera;
  39911. /**
  39912. * The list of keyboard keys used to control the forward move of the camera.
  39913. */
  39914. keysForward: number[];
  39915. /**
  39916. * The list of keyboard keys used to control the backward move of the camera.
  39917. */
  39918. keysBackward: number[];
  39919. /**
  39920. * The list of keyboard keys used to control the forward move of the camera.
  39921. */
  39922. keysUp: number[];
  39923. /**
  39924. * The list of keyboard keys used to control the backward move of the camera.
  39925. */
  39926. keysDown: number[];
  39927. /**
  39928. * The list of keyboard keys used to control the right strafe move of the camera.
  39929. */
  39930. keysRight: number[];
  39931. /**
  39932. * The list of keyboard keys used to control the left strafe move of the camera.
  39933. */
  39934. keysLeft: number[];
  39935. private _keys;
  39936. private _onCanvasBlurObserver;
  39937. private _onKeyboardObserver;
  39938. private _engine;
  39939. private _scene;
  39940. /**
  39941. * Attach the input controls to a specific dom element to get the input from.
  39942. * @param element Defines the element the controls should be listened from
  39943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39944. */
  39945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39946. /**
  39947. * Detach the current controls from the specified dom element.
  39948. * @param element Defines the element to stop listening the inputs from
  39949. */
  39950. detachControl(element: Nullable<HTMLElement>): void;
  39951. /**
  39952. * Gets the class name of the current intput.
  39953. * @returns the class name
  39954. */
  39955. getClassName(): string;
  39956. /** @hidden */
  39957. _onLostFocus(e: FocusEvent): void;
  39958. /**
  39959. * Get the friendly name associated with the input class.
  39960. * @returns the input friendly name
  39961. */
  39962. getSimpleName(): string;
  39963. /**
  39964. * Update the current camera state depending on the inputs that have been used this frame.
  39965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39966. */
  39967. checkInputs(): void;
  39968. }
  39969. }
  39970. declare module BABYLON {
  39971. /**
  39972. * Manage the mouse wheel inputs to control a follow camera.
  39973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39974. */
  39975. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39976. /**
  39977. * Defines the camera the input is attached to.
  39978. */
  39979. camera: FollowCamera;
  39980. /**
  39981. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39982. */
  39983. axisControlRadius: boolean;
  39984. /**
  39985. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39986. */
  39987. axisControlHeight: boolean;
  39988. /**
  39989. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39990. */
  39991. axisControlRotation: boolean;
  39992. /**
  39993. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39994. * relation to mouseWheel events.
  39995. */
  39996. wheelPrecision: number;
  39997. /**
  39998. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39999. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40000. */
  40001. wheelDeltaPercentage: number;
  40002. private _wheel;
  40003. private _observer;
  40004. /**
  40005. * Attach the input controls to a specific dom element to get the input from.
  40006. * @param element Defines the element the controls should be listened from
  40007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40008. */
  40009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40010. /**
  40011. * Detach the current controls from the specified dom element.
  40012. * @param element Defines the element to stop listening the inputs from
  40013. */
  40014. detachControl(element: Nullable<HTMLElement>): void;
  40015. /**
  40016. * Gets the class name of the current intput.
  40017. * @returns the class name
  40018. */
  40019. getClassName(): string;
  40020. /**
  40021. * Get the friendly name associated with the input class.
  40022. * @returns the input friendly name
  40023. */
  40024. getSimpleName(): string;
  40025. }
  40026. }
  40027. declare module BABYLON {
  40028. /**
  40029. * Manage the pointers inputs to control an follow camera.
  40030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40031. */
  40032. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40033. /**
  40034. * Defines the camera the input is attached to.
  40035. */
  40036. camera: FollowCamera;
  40037. /**
  40038. * Gets the class name of the current input.
  40039. * @returns the class name
  40040. */
  40041. getClassName(): string;
  40042. /**
  40043. * Defines the pointer angular sensibility along the X axis or how fast is
  40044. * the camera rotating.
  40045. * A negative number will reverse the axis direction.
  40046. */
  40047. angularSensibilityX: number;
  40048. /**
  40049. * Defines the pointer angular sensibility along the Y axis or how fast is
  40050. * the camera rotating.
  40051. * A negative number will reverse the axis direction.
  40052. */
  40053. angularSensibilityY: number;
  40054. /**
  40055. * Defines the pointer pinch precision or how fast is the camera zooming.
  40056. * A negative number will reverse the axis direction.
  40057. */
  40058. pinchPrecision: number;
  40059. /**
  40060. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40061. * from 0.
  40062. * It defines the percentage of current camera.radius to use as delta when
  40063. * pinch zoom is used.
  40064. */
  40065. pinchDeltaPercentage: number;
  40066. /**
  40067. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40068. */
  40069. axisXControlRadius: boolean;
  40070. /**
  40071. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40072. */
  40073. axisXControlHeight: boolean;
  40074. /**
  40075. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40076. */
  40077. axisXControlRotation: boolean;
  40078. /**
  40079. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40080. */
  40081. axisYControlRadius: boolean;
  40082. /**
  40083. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40084. */
  40085. axisYControlHeight: boolean;
  40086. /**
  40087. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40088. */
  40089. axisYControlRotation: boolean;
  40090. /**
  40091. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40092. */
  40093. axisPinchControlRadius: boolean;
  40094. /**
  40095. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40096. */
  40097. axisPinchControlHeight: boolean;
  40098. /**
  40099. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40100. */
  40101. axisPinchControlRotation: boolean;
  40102. /**
  40103. * Log error messages if basic misconfiguration has occurred.
  40104. */
  40105. warningEnable: boolean;
  40106. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40107. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40108. private _warningCounter;
  40109. private _warning;
  40110. }
  40111. }
  40112. declare module BABYLON {
  40113. /**
  40114. * Default Inputs manager for the FollowCamera.
  40115. * It groups all the default supported inputs for ease of use.
  40116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40117. */
  40118. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40119. /**
  40120. * Instantiates a new FollowCameraInputsManager.
  40121. * @param camera Defines the camera the inputs belong to
  40122. */
  40123. constructor(camera: FollowCamera);
  40124. /**
  40125. * Add keyboard input support to the input manager.
  40126. * @returns the current input manager
  40127. */
  40128. addKeyboard(): FollowCameraInputsManager;
  40129. /**
  40130. * Add mouse wheel input support to the input manager.
  40131. * @returns the current input manager
  40132. */
  40133. addMouseWheel(): FollowCameraInputsManager;
  40134. /**
  40135. * Add pointers input support to the input manager.
  40136. * @returns the current input manager
  40137. */
  40138. addPointers(): FollowCameraInputsManager;
  40139. /**
  40140. * Add orientation input support to the input manager.
  40141. * @returns the current input manager
  40142. */
  40143. addVRDeviceOrientation(): FollowCameraInputsManager;
  40144. }
  40145. }
  40146. declare module BABYLON {
  40147. /**
  40148. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40149. * an arc rotate version arcFollowCamera are available.
  40150. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40151. */
  40152. export class FollowCamera extends TargetCamera {
  40153. /**
  40154. * Distance the follow camera should follow an object at
  40155. */
  40156. radius: number;
  40157. /**
  40158. * Minimum allowed distance of the camera to the axis of rotation
  40159. * (The camera can not get closer).
  40160. * This can help limiting how the Camera is able to move in the scene.
  40161. */
  40162. lowerRadiusLimit: Nullable<number>;
  40163. /**
  40164. * Maximum allowed distance of the camera to the axis of rotation
  40165. * (The camera can not get further).
  40166. * This can help limiting how the Camera is able to move in the scene.
  40167. */
  40168. upperRadiusLimit: Nullable<number>;
  40169. /**
  40170. * Define a rotation offset between the camera and the object it follows
  40171. */
  40172. rotationOffset: number;
  40173. /**
  40174. * Minimum allowed angle to camera position relative to target object.
  40175. * This can help limiting how the Camera is able to move in the scene.
  40176. */
  40177. lowerRotationOffsetLimit: Nullable<number>;
  40178. /**
  40179. * Maximum allowed angle to camera position relative to target object.
  40180. * This can help limiting how the Camera is able to move in the scene.
  40181. */
  40182. upperRotationOffsetLimit: Nullable<number>;
  40183. /**
  40184. * Define a height offset between the camera and the object it follows.
  40185. * It can help following an object from the top (like a car chaing a plane)
  40186. */
  40187. heightOffset: number;
  40188. /**
  40189. * Minimum allowed height of camera position relative to target object.
  40190. * This can help limiting how the Camera is able to move in the scene.
  40191. */
  40192. lowerHeightOffsetLimit: Nullable<number>;
  40193. /**
  40194. * Maximum allowed height of camera position relative to target object.
  40195. * This can help limiting how the Camera is able to move in the scene.
  40196. */
  40197. upperHeightOffsetLimit: Nullable<number>;
  40198. /**
  40199. * Define how fast the camera can accelerate to follow it s target.
  40200. */
  40201. cameraAcceleration: number;
  40202. /**
  40203. * Define the speed limit of the camera following an object.
  40204. */
  40205. maxCameraSpeed: number;
  40206. /**
  40207. * Define the target of the camera.
  40208. */
  40209. lockedTarget: Nullable<AbstractMesh>;
  40210. /**
  40211. * Defines the input associated with the camera.
  40212. */
  40213. inputs: FollowCameraInputsManager;
  40214. /**
  40215. * Instantiates the follow camera.
  40216. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40217. * @param name Define the name of the camera in the scene
  40218. * @param position Define the position of the camera
  40219. * @param scene Define the scene the camera belong to
  40220. * @param lockedTarget Define the target of the camera
  40221. */
  40222. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40223. private _follow;
  40224. /**
  40225. * Attached controls to the current camera.
  40226. * @param element Defines the element the controls should be listened from
  40227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40228. */
  40229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40230. /**
  40231. * Detach the current controls from the camera.
  40232. * The camera will stop reacting to inputs.
  40233. * @param element Defines the element to stop listening the inputs from
  40234. */
  40235. detachControl(element: HTMLElement): void;
  40236. /** @hidden */
  40237. _checkInputs(): void;
  40238. private _checkLimits;
  40239. /**
  40240. * Gets the camera class name.
  40241. * @returns the class name
  40242. */
  40243. getClassName(): string;
  40244. }
  40245. /**
  40246. * Arc Rotate version of the follow camera.
  40247. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40248. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40249. */
  40250. export class ArcFollowCamera extends TargetCamera {
  40251. /** The longitudinal angle of the camera */
  40252. alpha: number;
  40253. /** The latitudinal angle of the camera */
  40254. beta: number;
  40255. /** The radius of the camera from its target */
  40256. radius: number;
  40257. /** Define the camera target (the messh it should follow) */
  40258. target: Nullable<AbstractMesh>;
  40259. private _cartesianCoordinates;
  40260. /**
  40261. * Instantiates a new ArcFollowCamera
  40262. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40263. * @param name Define the name of the camera
  40264. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40265. * @param beta Define the rotation angle of the camera around the elevation axis
  40266. * @param radius Define the radius of the camera from its target point
  40267. * @param target Define the target of the camera
  40268. * @param scene Define the scene the camera belongs to
  40269. */
  40270. constructor(name: string,
  40271. /** The longitudinal angle of the camera */
  40272. alpha: number,
  40273. /** The latitudinal angle of the camera */
  40274. beta: number,
  40275. /** The radius of the camera from its target */
  40276. radius: number,
  40277. /** Define the camera target (the messh it should follow) */
  40278. target: Nullable<AbstractMesh>, scene: Scene);
  40279. private _follow;
  40280. /** @hidden */
  40281. _checkInputs(): void;
  40282. /**
  40283. * Returns the class name of the object.
  40284. * It is mostly used internally for serialization purposes.
  40285. */
  40286. getClassName(): string;
  40287. }
  40288. }
  40289. declare module BABYLON {
  40290. /**
  40291. * Manage the keyboard inputs to control the movement of a follow camera.
  40292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40293. */
  40294. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40295. /**
  40296. * Defines the camera the input is attached to.
  40297. */
  40298. camera: FollowCamera;
  40299. /**
  40300. * Defines the list of key codes associated with the up action (increase heightOffset)
  40301. */
  40302. keysHeightOffsetIncr: number[];
  40303. /**
  40304. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40305. */
  40306. keysHeightOffsetDecr: number[];
  40307. /**
  40308. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40309. */
  40310. keysHeightOffsetModifierAlt: boolean;
  40311. /**
  40312. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40313. */
  40314. keysHeightOffsetModifierCtrl: boolean;
  40315. /**
  40316. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40317. */
  40318. keysHeightOffsetModifierShift: boolean;
  40319. /**
  40320. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40321. */
  40322. keysRotationOffsetIncr: number[];
  40323. /**
  40324. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40325. */
  40326. keysRotationOffsetDecr: number[];
  40327. /**
  40328. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40329. */
  40330. keysRotationOffsetModifierAlt: boolean;
  40331. /**
  40332. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40333. */
  40334. keysRotationOffsetModifierCtrl: boolean;
  40335. /**
  40336. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40337. */
  40338. keysRotationOffsetModifierShift: boolean;
  40339. /**
  40340. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40341. */
  40342. keysRadiusIncr: number[];
  40343. /**
  40344. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40345. */
  40346. keysRadiusDecr: number[];
  40347. /**
  40348. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40349. */
  40350. keysRadiusModifierAlt: boolean;
  40351. /**
  40352. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40353. */
  40354. keysRadiusModifierCtrl: boolean;
  40355. /**
  40356. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40357. */
  40358. keysRadiusModifierShift: boolean;
  40359. /**
  40360. * Defines the rate of change of heightOffset.
  40361. */
  40362. heightSensibility: number;
  40363. /**
  40364. * Defines the rate of change of rotationOffset.
  40365. */
  40366. rotationSensibility: number;
  40367. /**
  40368. * Defines the rate of change of radius.
  40369. */
  40370. radiusSensibility: number;
  40371. private _keys;
  40372. private _ctrlPressed;
  40373. private _altPressed;
  40374. private _shiftPressed;
  40375. private _onCanvasBlurObserver;
  40376. private _onKeyboardObserver;
  40377. private _engine;
  40378. private _scene;
  40379. /**
  40380. * Attach the input controls to a specific dom element to get the input from.
  40381. * @param element Defines the element the controls should be listened from
  40382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40383. */
  40384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40385. /**
  40386. * Detach the current controls from the specified dom element.
  40387. * @param element Defines the element to stop listening the inputs from
  40388. */
  40389. detachControl(element: Nullable<HTMLElement>): void;
  40390. /**
  40391. * Update the current camera state depending on the inputs that have been used this frame.
  40392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40393. */
  40394. checkInputs(): void;
  40395. /**
  40396. * Gets the class name of the current input.
  40397. * @returns the class name
  40398. */
  40399. getClassName(): string;
  40400. /**
  40401. * Get the friendly name associated with the input class.
  40402. * @returns the input friendly name
  40403. */
  40404. getSimpleName(): string;
  40405. /**
  40406. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40407. * allow modification of the heightOffset value.
  40408. */
  40409. private _modifierHeightOffset;
  40410. /**
  40411. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40412. * allow modification of the rotationOffset value.
  40413. */
  40414. private _modifierRotationOffset;
  40415. /**
  40416. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40417. * allow modification of the radius value.
  40418. */
  40419. private _modifierRadius;
  40420. }
  40421. }
  40422. declare module BABYLON {
  40423. interface FreeCameraInputsManager {
  40424. /**
  40425. * @hidden
  40426. */
  40427. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40428. /**
  40429. * Add orientation input support to the input manager.
  40430. * @returns the current input manager
  40431. */
  40432. addDeviceOrientation(): FreeCameraInputsManager;
  40433. }
  40434. /**
  40435. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40436. * Screen rotation is taken into account.
  40437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40438. */
  40439. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40440. private _camera;
  40441. private _screenOrientationAngle;
  40442. private _constantTranform;
  40443. private _screenQuaternion;
  40444. private _alpha;
  40445. private _beta;
  40446. private _gamma;
  40447. /**
  40448. * Can be used to detect if a device orientation sensor is available on a device
  40449. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40450. * @returns a promise that will resolve on orientation change
  40451. */
  40452. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40453. /**
  40454. * @hidden
  40455. */
  40456. _onDeviceOrientationChangedObservable: Observable<void>;
  40457. /**
  40458. * Instantiates a new input
  40459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40460. */
  40461. constructor();
  40462. /**
  40463. * Define the camera controlled by the input.
  40464. */
  40465. get camera(): FreeCamera;
  40466. set camera(camera: FreeCamera);
  40467. /**
  40468. * Attach the input controls to a specific dom element to get the input from.
  40469. * @param element Defines the element the controls should be listened from
  40470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40471. */
  40472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40473. private _orientationChanged;
  40474. private _deviceOrientation;
  40475. /**
  40476. * Detach the current controls from the specified dom element.
  40477. * @param element Defines the element to stop listening the inputs from
  40478. */
  40479. detachControl(element: Nullable<HTMLElement>): void;
  40480. /**
  40481. * Update the current camera state depending on the inputs that have been used this frame.
  40482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40483. */
  40484. checkInputs(): void;
  40485. /**
  40486. * Gets the class name of the current intput.
  40487. * @returns the class name
  40488. */
  40489. getClassName(): string;
  40490. /**
  40491. * Get the friendly name associated with the input class.
  40492. * @returns the input friendly name
  40493. */
  40494. getSimpleName(): string;
  40495. }
  40496. }
  40497. declare module BABYLON {
  40498. /**
  40499. * Manage the gamepad inputs to control a free camera.
  40500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40501. */
  40502. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40503. /**
  40504. * Define the camera the input is attached to.
  40505. */
  40506. camera: FreeCamera;
  40507. /**
  40508. * Define the Gamepad controlling the input
  40509. */
  40510. gamepad: Nullable<Gamepad>;
  40511. /**
  40512. * Defines the gamepad rotation sensiblity.
  40513. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40514. */
  40515. gamepadAngularSensibility: number;
  40516. /**
  40517. * Defines the gamepad move sensiblity.
  40518. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40519. */
  40520. gamepadMoveSensibility: number;
  40521. private _yAxisScale;
  40522. /**
  40523. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40524. */
  40525. get invertYAxis(): boolean;
  40526. set invertYAxis(value: boolean);
  40527. private _onGamepadConnectedObserver;
  40528. private _onGamepadDisconnectedObserver;
  40529. private _cameraTransform;
  40530. private _deltaTransform;
  40531. private _vector3;
  40532. private _vector2;
  40533. /**
  40534. * Attach the input controls to a specific dom element to get the input from.
  40535. * @param element Defines the element the controls should be listened from
  40536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40537. */
  40538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40539. /**
  40540. * Detach the current controls from the specified dom element.
  40541. * @param element Defines the element to stop listening the inputs from
  40542. */
  40543. detachControl(element: Nullable<HTMLElement>): void;
  40544. /**
  40545. * Update the current camera state depending on the inputs that have been used this frame.
  40546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40547. */
  40548. checkInputs(): void;
  40549. /**
  40550. * Gets the class name of the current intput.
  40551. * @returns the class name
  40552. */
  40553. getClassName(): string;
  40554. /**
  40555. * Get the friendly name associated with the input class.
  40556. * @returns the input friendly name
  40557. */
  40558. getSimpleName(): string;
  40559. }
  40560. }
  40561. declare module BABYLON {
  40562. /**
  40563. * Defines the potential axis of a Joystick
  40564. */
  40565. export enum JoystickAxis {
  40566. /** X axis */
  40567. X = 0,
  40568. /** Y axis */
  40569. Y = 1,
  40570. /** Z axis */
  40571. Z = 2
  40572. }
  40573. /**
  40574. * Class used to define virtual joystick (used in touch mode)
  40575. */
  40576. export class VirtualJoystick {
  40577. /**
  40578. * Gets or sets a boolean indicating that left and right values must be inverted
  40579. */
  40580. reverseLeftRight: boolean;
  40581. /**
  40582. * Gets or sets a boolean indicating that up and down values must be inverted
  40583. */
  40584. reverseUpDown: boolean;
  40585. /**
  40586. * Gets the offset value for the position (ie. the change of the position value)
  40587. */
  40588. deltaPosition: Vector3;
  40589. /**
  40590. * Gets a boolean indicating if the virtual joystick was pressed
  40591. */
  40592. pressed: boolean;
  40593. /**
  40594. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40595. */
  40596. static Canvas: Nullable<HTMLCanvasElement>;
  40597. private static _globalJoystickIndex;
  40598. private static vjCanvasContext;
  40599. private static vjCanvasWidth;
  40600. private static vjCanvasHeight;
  40601. private static halfWidth;
  40602. private _action;
  40603. private _axisTargetedByLeftAndRight;
  40604. private _axisTargetedByUpAndDown;
  40605. private _joystickSensibility;
  40606. private _inversedSensibility;
  40607. private _joystickPointerID;
  40608. private _joystickColor;
  40609. private _joystickPointerPos;
  40610. private _joystickPreviousPointerPos;
  40611. private _joystickPointerStartPos;
  40612. private _deltaJoystickVector;
  40613. private _leftJoystick;
  40614. private _touches;
  40615. private _onPointerDownHandlerRef;
  40616. private _onPointerMoveHandlerRef;
  40617. private _onPointerUpHandlerRef;
  40618. private _onResize;
  40619. /**
  40620. * Creates a new virtual joystick
  40621. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40622. */
  40623. constructor(leftJoystick?: boolean);
  40624. /**
  40625. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40626. * @param newJoystickSensibility defines the new sensibility
  40627. */
  40628. setJoystickSensibility(newJoystickSensibility: number): void;
  40629. private _onPointerDown;
  40630. private _onPointerMove;
  40631. private _onPointerUp;
  40632. /**
  40633. * Change the color of the virtual joystick
  40634. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40635. */
  40636. setJoystickColor(newColor: string): void;
  40637. /**
  40638. * Defines a callback to call when the joystick is touched
  40639. * @param action defines the callback
  40640. */
  40641. setActionOnTouch(action: () => any): void;
  40642. /**
  40643. * Defines which axis you'd like to control for left & right
  40644. * @param axis defines the axis to use
  40645. */
  40646. setAxisForLeftRight(axis: JoystickAxis): void;
  40647. /**
  40648. * Defines which axis you'd like to control for up & down
  40649. * @param axis defines the axis to use
  40650. */
  40651. setAxisForUpDown(axis: JoystickAxis): void;
  40652. private _drawVirtualJoystick;
  40653. /**
  40654. * Release internal HTML canvas
  40655. */
  40656. releaseCanvas(): void;
  40657. }
  40658. }
  40659. declare module BABYLON {
  40660. interface FreeCameraInputsManager {
  40661. /**
  40662. * Add virtual joystick input support to the input manager.
  40663. * @returns the current input manager
  40664. */
  40665. addVirtualJoystick(): FreeCameraInputsManager;
  40666. }
  40667. /**
  40668. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40670. */
  40671. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40672. /**
  40673. * Defines the camera the input is attached to.
  40674. */
  40675. camera: FreeCamera;
  40676. private _leftjoystick;
  40677. private _rightjoystick;
  40678. /**
  40679. * Gets the left stick of the virtual joystick.
  40680. * @returns The virtual Joystick
  40681. */
  40682. getLeftJoystick(): VirtualJoystick;
  40683. /**
  40684. * Gets the right stick of the virtual joystick.
  40685. * @returns The virtual Joystick
  40686. */
  40687. getRightJoystick(): VirtualJoystick;
  40688. /**
  40689. * Update the current camera state depending on the inputs that have been used this frame.
  40690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40691. */
  40692. checkInputs(): void;
  40693. /**
  40694. * Attach the input controls to a specific dom element to get the input from.
  40695. * @param element Defines the element the controls should be listened from
  40696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40697. */
  40698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40699. /**
  40700. * Detach the current controls from the specified dom element.
  40701. * @param element Defines the element to stop listening the inputs from
  40702. */
  40703. detachControl(element: Nullable<HTMLElement>): void;
  40704. /**
  40705. * Gets the class name of the current intput.
  40706. * @returns the class name
  40707. */
  40708. getClassName(): string;
  40709. /**
  40710. * Get the friendly name associated with the input class.
  40711. * @returns the input friendly name
  40712. */
  40713. getSimpleName(): string;
  40714. }
  40715. }
  40716. declare module BABYLON {
  40717. /**
  40718. * This represents a FPS type of camera controlled by touch.
  40719. * This is like a universal camera minus the Gamepad controls.
  40720. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40721. */
  40722. export class TouchCamera extends FreeCamera {
  40723. /**
  40724. * Defines the touch sensibility for rotation.
  40725. * The higher the faster.
  40726. */
  40727. get touchAngularSensibility(): number;
  40728. set touchAngularSensibility(value: number);
  40729. /**
  40730. * Defines the touch sensibility for move.
  40731. * The higher the faster.
  40732. */
  40733. get touchMoveSensibility(): number;
  40734. set touchMoveSensibility(value: number);
  40735. /**
  40736. * Instantiates a new touch camera.
  40737. * This represents a FPS type of camera controlled by touch.
  40738. * This is like a universal camera minus the Gamepad controls.
  40739. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40740. * @param name Define the name of the camera in the scene
  40741. * @param position Define the start position of the camera in the scene
  40742. * @param scene Define the scene the camera belongs to
  40743. */
  40744. constructor(name: string, position: Vector3, scene: Scene);
  40745. /**
  40746. * Gets the current object class name.
  40747. * @return the class name
  40748. */
  40749. getClassName(): string;
  40750. /** @hidden */
  40751. _setupInputs(): void;
  40752. }
  40753. }
  40754. declare module BABYLON {
  40755. /**
  40756. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40757. * being tilted forward or back and left or right.
  40758. */
  40759. export class DeviceOrientationCamera extends FreeCamera {
  40760. private _initialQuaternion;
  40761. private _quaternionCache;
  40762. private _tmpDragQuaternion;
  40763. private _disablePointerInputWhenUsingDeviceOrientation;
  40764. /**
  40765. * Creates a new device orientation camera
  40766. * @param name The name of the camera
  40767. * @param position The start position camera
  40768. * @param scene The scene the camera belongs to
  40769. */
  40770. constructor(name: string, position: Vector3, scene: Scene);
  40771. /**
  40772. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40773. */
  40774. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40775. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40776. private _dragFactor;
  40777. /**
  40778. * Enabled turning on the y axis when the orientation sensor is active
  40779. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40780. */
  40781. enableHorizontalDragging(dragFactor?: number): void;
  40782. /**
  40783. * Gets the current instance class name ("DeviceOrientationCamera").
  40784. * This helps avoiding instanceof at run time.
  40785. * @returns the class name
  40786. */
  40787. getClassName(): string;
  40788. /**
  40789. * @hidden
  40790. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40791. */
  40792. _checkInputs(): void;
  40793. /**
  40794. * Reset the camera to its default orientation on the specified axis only.
  40795. * @param axis The axis to reset
  40796. */
  40797. resetToCurrentRotation(axis?: Axis): void;
  40798. }
  40799. }
  40800. declare module BABYLON {
  40801. /**
  40802. * Defines supported buttons for XBox360 compatible gamepads
  40803. */
  40804. export enum Xbox360Button {
  40805. /** A */
  40806. A = 0,
  40807. /** B */
  40808. B = 1,
  40809. /** X */
  40810. X = 2,
  40811. /** Y */
  40812. Y = 3,
  40813. /** Start */
  40814. Start = 4,
  40815. /** Back */
  40816. Back = 5,
  40817. /** Left button */
  40818. LB = 6,
  40819. /** Right button */
  40820. RB = 7,
  40821. /** Left stick */
  40822. LeftStick = 8,
  40823. /** Right stick */
  40824. RightStick = 9
  40825. }
  40826. /** Defines values for XBox360 DPad */
  40827. export enum Xbox360Dpad {
  40828. /** Up */
  40829. Up = 0,
  40830. /** Down */
  40831. Down = 1,
  40832. /** Left */
  40833. Left = 2,
  40834. /** Right */
  40835. Right = 3
  40836. }
  40837. /**
  40838. * Defines a XBox360 gamepad
  40839. */
  40840. export class Xbox360Pad extends Gamepad {
  40841. private _leftTrigger;
  40842. private _rightTrigger;
  40843. private _onlefttriggerchanged;
  40844. private _onrighttriggerchanged;
  40845. private _onbuttondown;
  40846. private _onbuttonup;
  40847. private _ondpaddown;
  40848. private _ondpadup;
  40849. /** Observable raised when a button is pressed */
  40850. onButtonDownObservable: Observable<Xbox360Button>;
  40851. /** Observable raised when a button is released */
  40852. onButtonUpObservable: Observable<Xbox360Button>;
  40853. /** Observable raised when a pad is pressed */
  40854. onPadDownObservable: Observable<Xbox360Dpad>;
  40855. /** Observable raised when a pad is released */
  40856. onPadUpObservable: Observable<Xbox360Dpad>;
  40857. private _buttonA;
  40858. private _buttonB;
  40859. private _buttonX;
  40860. private _buttonY;
  40861. private _buttonBack;
  40862. private _buttonStart;
  40863. private _buttonLB;
  40864. private _buttonRB;
  40865. private _buttonLeftStick;
  40866. private _buttonRightStick;
  40867. private _dPadUp;
  40868. private _dPadDown;
  40869. private _dPadLeft;
  40870. private _dPadRight;
  40871. private _isXboxOnePad;
  40872. /**
  40873. * Creates a new XBox360 gamepad object
  40874. * @param id defines the id of this gamepad
  40875. * @param index defines its index
  40876. * @param gamepad defines the internal HTML gamepad object
  40877. * @param xboxOne defines if it is a XBox One gamepad
  40878. */
  40879. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40880. /**
  40881. * Defines the callback to call when left trigger is pressed
  40882. * @param callback defines the callback to use
  40883. */
  40884. onlefttriggerchanged(callback: (value: number) => void): void;
  40885. /**
  40886. * Defines the callback to call when right trigger is pressed
  40887. * @param callback defines the callback to use
  40888. */
  40889. onrighttriggerchanged(callback: (value: number) => void): void;
  40890. /**
  40891. * Gets the left trigger value
  40892. */
  40893. get leftTrigger(): number;
  40894. /**
  40895. * Sets the left trigger value
  40896. */
  40897. set leftTrigger(newValue: number);
  40898. /**
  40899. * Gets the right trigger value
  40900. */
  40901. get rightTrigger(): number;
  40902. /**
  40903. * Sets the right trigger value
  40904. */
  40905. set rightTrigger(newValue: number);
  40906. /**
  40907. * Defines the callback to call when a button is pressed
  40908. * @param callback defines the callback to use
  40909. */
  40910. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40911. /**
  40912. * Defines the callback to call when a button is released
  40913. * @param callback defines the callback to use
  40914. */
  40915. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40916. /**
  40917. * Defines the callback to call when a pad is pressed
  40918. * @param callback defines the callback to use
  40919. */
  40920. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40921. /**
  40922. * Defines the callback to call when a pad is released
  40923. * @param callback defines the callback to use
  40924. */
  40925. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40926. private _setButtonValue;
  40927. private _setDPadValue;
  40928. /**
  40929. * Gets the value of the `A` button
  40930. */
  40931. get buttonA(): number;
  40932. /**
  40933. * Sets the value of the `A` button
  40934. */
  40935. set buttonA(value: number);
  40936. /**
  40937. * Gets the value of the `B` button
  40938. */
  40939. get buttonB(): number;
  40940. /**
  40941. * Sets the value of the `B` button
  40942. */
  40943. set buttonB(value: number);
  40944. /**
  40945. * Gets the value of the `X` button
  40946. */
  40947. get buttonX(): number;
  40948. /**
  40949. * Sets the value of the `X` button
  40950. */
  40951. set buttonX(value: number);
  40952. /**
  40953. * Gets the value of the `Y` button
  40954. */
  40955. get buttonY(): number;
  40956. /**
  40957. * Sets the value of the `Y` button
  40958. */
  40959. set buttonY(value: number);
  40960. /**
  40961. * Gets the value of the `Start` button
  40962. */
  40963. get buttonStart(): number;
  40964. /**
  40965. * Sets the value of the `Start` button
  40966. */
  40967. set buttonStart(value: number);
  40968. /**
  40969. * Gets the value of the `Back` button
  40970. */
  40971. get buttonBack(): number;
  40972. /**
  40973. * Sets the value of the `Back` button
  40974. */
  40975. set buttonBack(value: number);
  40976. /**
  40977. * Gets the value of the `Left` button
  40978. */
  40979. get buttonLB(): number;
  40980. /**
  40981. * Sets the value of the `Left` button
  40982. */
  40983. set buttonLB(value: number);
  40984. /**
  40985. * Gets the value of the `Right` button
  40986. */
  40987. get buttonRB(): number;
  40988. /**
  40989. * Sets the value of the `Right` button
  40990. */
  40991. set buttonRB(value: number);
  40992. /**
  40993. * Gets the value of the Left joystick
  40994. */
  40995. get buttonLeftStick(): number;
  40996. /**
  40997. * Sets the value of the Left joystick
  40998. */
  40999. set buttonLeftStick(value: number);
  41000. /**
  41001. * Gets the value of the Right joystick
  41002. */
  41003. get buttonRightStick(): number;
  41004. /**
  41005. * Sets the value of the Right joystick
  41006. */
  41007. set buttonRightStick(value: number);
  41008. /**
  41009. * Gets the value of D-pad up
  41010. */
  41011. get dPadUp(): number;
  41012. /**
  41013. * Sets the value of D-pad up
  41014. */
  41015. set dPadUp(value: number);
  41016. /**
  41017. * Gets the value of D-pad down
  41018. */
  41019. get dPadDown(): number;
  41020. /**
  41021. * Sets the value of D-pad down
  41022. */
  41023. set dPadDown(value: number);
  41024. /**
  41025. * Gets the value of D-pad left
  41026. */
  41027. get dPadLeft(): number;
  41028. /**
  41029. * Sets the value of D-pad left
  41030. */
  41031. set dPadLeft(value: number);
  41032. /**
  41033. * Gets the value of D-pad right
  41034. */
  41035. get dPadRight(): number;
  41036. /**
  41037. * Sets the value of D-pad right
  41038. */
  41039. set dPadRight(value: number);
  41040. /**
  41041. * Force the gamepad to synchronize with device values
  41042. */
  41043. update(): void;
  41044. /**
  41045. * Disposes the gamepad
  41046. */
  41047. dispose(): void;
  41048. }
  41049. }
  41050. declare module BABYLON {
  41051. /**
  41052. * Defines supported buttons for DualShock compatible gamepads
  41053. */
  41054. export enum DualShockButton {
  41055. /** Cross */
  41056. Cross = 0,
  41057. /** Circle */
  41058. Circle = 1,
  41059. /** Square */
  41060. Square = 2,
  41061. /** Triangle */
  41062. Triangle = 3,
  41063. /** Options */
  41064. Options = 4,
  41065. /** Share */
  41066. Share = 5,
  41067. /** L1 */
  41068. L1 = 6,
  41069. /** R1 */
  41070. R1 = 7,
  41071. /** Left stick */
  41072. LeftStick = 8,
  41073. /** Right stick */
  41074. RightStick = 9
  41075. }
  41076. /** Defines values for DualShock DPad */
  41077. export enum DualShockDpad {
  41078. /** Up */
  41079. Up = 0,
  41080. /** Down */
  41081. Down = 1,
  41082. /** Left */
  41083. Left = 2,
  41084. /** Right */
  41085. Right = 3
  41086. }
  41087. /**
  41088. * Defines a DualShock gamepad
  41089. */
  41090. export class DualShockPad extends Gamepad {
  41091. private _leftTrigger;
  41092. private _rightTrigger;
  41093. private _onlefttriggerchanged;
  41094. private _onrighttriggerchanged;
  41095. private _onbuttondown;
  41096. private _onbuttonup;
  41097. private _ondpaddown;
  41098. private _ondpadup;
  41099. /** Observable raised when a button is pressed */
  41100. onButtonDownObservable: Observable<DualShockButton>;
  41101. /** Observable raised when a button is released */
  41102. onButtonUpObservable: Observable<DualShockButton>;
  41103. /** Observable raised when a pad is pressed */
  41104. onPadDownObservable: Observable<DualShockDpad>;
  41105. /** Observable raised when a pad is released */
  41106. onPadUpObservable: Observable<DualShockDpad>;
  41107. private _buttonCross;
  41108. private _buttonCircle;
  41109. private _buttonSquare;
  41110. private _buttonTriangle;
  41111. private _buttonShare;
  41112. private _buttonOptions;
  41113. private _buttonL1;
  41114. private _buttonR1;
  41115. private _buttonLeftStick;
  41116. private _buttonRightStick;
  41117. private _dPadUp;
  41118. private _dPadDown;
  41119. private _dPadLeft;
  41120. private _dPadRight;
  41121. /**
  41122. * Creates a new DualShock gamepad object
  41123. * @param id defines the id of this gamepad
  41124. * @param index defines its index
  41125. * @param gamepad defines the internal HTML gamepad object
  41126. */
  41127. constructor(id: string, index: number, gamepad: any);
  41128. /**
  41129. * Defines the callback to call when left trigger is pressed
  41130. * @param callback defines the callback to use
  41131. */
  41132. onlefttriggerchanged(callback: (value: number) => void): void;
  41133. /**
  41134. * Defines the callback to call when right trigger is pressed
  41135. * @param callback defines the callback to use
  41136. */
  41137. onrighttriggerchanged(callback: (value: number) => void): void;
  41138. /**
  41139. * Gets the left trigger value
  41140. */
  41141. get leftTrigger(): number;
  41142. /**
  41143. * Sets the left trigger value
  41144. */
  41145. set leftTrigger(newValue: number);
  41146. /**
  41147. * Gets the right trigger value
  41148. */
  41149. get rightTrigger(): number;
  41150. /**
  41151. * Sets the right trigger value
  41152. */
  41153. set rightTrigger(newValue: number);
  41154. /**
  41155. * Defines the callback to call when a button is pressed
  41156. * @param callback defines the callback to use
  41157. */
  41158. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41159. /**
  41160. * Defines the callback to call when a button is released
  41161. * @param callback defines the callback to use
  41162. */
  41163. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41164. /**
  41165. * Defines the callback to call when a pad is pressed
  41166. * @param callback defines the callback to use
  41167. */
  41168. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41169. /**
  41170. * Defines the callback to call when a pad is released
  41171. * @param callback defines the callback to use
  41172. */
  41173. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41174. private _setButtonValue;
  41175. private _setDPadValue;
  41176. /**
  41177. * Gets the value of the `Cross` button
  41178. */
  41179. get buttonCross(): number;
  41180. /**
  41181. * Sets the value of the `Cross` button
  41182. */
  41183. set buttonCross(value: number);
  41184. /**
  41185. * Gets the value of the `Circle` button
  41186. */
  41187. get buttonCircle(): number;
  41188. /**
  41189. * Sets the value of the `Circle` button
  41190. */
  41191. set buttonCircle(value: number);
  41192. /**
  41193. * Gets the value of the `Square` button
  41194. */
  41195. get buttonSquare(): number;
  41196. /**
  41197. * Sets the value of the `Square` button
  41198. */
  41199. set buttonSquare(value: number);
  41200. /**
  41201. * Gets the value of the `Triangle` button
  41202. */
  41203. get buttonTriangle(): number;
  41204. /**
  41205. * Sets the value of the `Triangle` button
  41206. */
  41207. set buttonTriangle(value: number);
  41208. /**
  41209. * Gets the value of the `Options` button
  41210. */
  41211. get buttonOptions(): number;
  41212. /**
  41213. * Sets the value of the `Options` button
  41214. */
  41215. set buttonOptions(value: number);
  41216. /**
  41217. * Gets the value of the `Share` button
  41218. */
  41219. get buttonShare(): number;
  41220. /**
  41221. * Sets the value of the `Share` button
  41222. */
  41223. set buttonShare(value: number);
  41224. /**
  41225. * Gets the value of the `L1` button
  41226. */
  41227. get buttonL1(): number;
  41228. /**
  41229. * Sets the value of the `L1` button
  41230. */
  41231. set buttonL1(value: number);
  41232. /**
  41233. * Gets the value of the `R1` button
  41234. */
  41235. get buttonR1(): number;
  41236. /**
  41237. * Sets the value of the `R1` button
  41238. */
  41239. set buttonR1(value: number);
  41240. /**
  41241. * Gets the value of the Left joystick
  41242. */
  41243. get buttonLeftStick(): number;
  41244. /**
  41245. * Sets the value of the Left joystick
  41246. */
  41247. set buttonLeftStick(value: number);
  41248. /**
  41249. * Gets the value of the Right joystick
  41250. */
  41251. get buttonRightStick(): number;
  41252. /**
  41253. * Sets the value of the Right joystick
  41254. */
  41255. set buttonRightStick(value: number);
  41256. /**
  41257. * Gets the value of D-pad up
  41258. */
  41259. get dPadUp(): number;
  41260. /**
  41261. * Sets the value of D-pad up
  41262. */
  41263. set dPadUp(value: number);
  41264. /**
  41265. * Gets the value of D-pad down
  41266. */
  41267. get dPadDown(): number;
  41268. /**
  41269. * Sets the value of D-pad down
  41270. */
  41271. set dPadDown(value: number);
  41272. /**
  41273. * Gets the value of D-pad left
  41274. */
  41275. get dPadLeft(): number;
  41276. /**
  41277. * Sets the value of D-pad left
  41278. */
  41279. set dPadLeft(value: number);
  41280. /**
  41281. * Gets the value of D-pad right
  41282. */
  41283. get dPadRight(): number;
  41284. /**
  41285. * Sets the value of D-pad right
  41286. */
  41287. set dPadRight(value: number);
  41288. /**
  41289. * Force the gamepad to synchronize with device values
  41290. */
  41291. update(): void;
  41292. /**
  41293. * Disposes the gamepad
  41294. */
  41295. dispose(): void;
  41296. }
  41297. }
  41298. declare module BABYLON {
  41299. /**
  41300. * Manager for handling gamepads
  41301. */
  41302. export class GamepadManager {
  41303. private _scene?;
  41304. private _babylonGamepads;
  41305. private _oneGamepadConnected;
  41306. /** @hidden */
  41307. _isMonitoring: boolean;
  41308. private _gamepadEventSupported;
  41309. private _gamepadSupport?;
  41310. /**
  41311. * observable to be triggered when the gamepad controller has been connected
  41312. */
  41313. onGamepadConnectedObservable: Observable<Gamepad>;
  41314. /**
  41315. * observable to be triggered when the gamepad controller has been disconnected
  41316. */
  41317. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41318. private _onGamepadConnectedEvent;
  41319. private _onGamepadDisconnectedEvent;
  41320. /**
  41321. * Initializes the gamepad manager
  41322. * @param _scene BabylonJS scene
  41323. */
  41324. constructor(_scene?: Scene | undefined);
  41325. /**
  41326. * The gamepads in the game pad manager
  41327. */
  41328. get gamepads(): Gamepad[];
  41329. /**
  41330. * Get the gamepad controllers based on type
  41331. * @param type The type of gamepad controller
  41332. * @returns Nullable gamepad
  41333. */
  41334. getGamepadByType(type?: number): Nullable<Gamepad>;
  41335. /**
  41336. * Disposes the gamepad manager
  41337. */
  41338. dispose(): void;
  41339. private _addNewGamepad;
  41340. private _startMonitoringGamepads;
  41341. private _stopMonitoringGamepads;
  41342. /** @hidden */
  41343. _checkGamepadsStatus(): void;
  41344. private _updateGamepadObjects;
  41345. }
  41346. }
  41347. declare module BABYLON {
  41348. interface Scene {
  41349. /** @hidden */
  41350. _gamepadManager: Nullable<GamepadManager>;
  41351. /**
  41352. * Gets the gamepad manager associated with the scene
  41353. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41354. */
  41355. gamepadManager: GamepadManager;
  41356. }
  41357. /**
  41358. * Interface representing a free camera inputs manager
  41359. */
  41360. interface FreeCameraInputsManager {
  41361. /**
  41362. * Adds gamepad input support to the FreeCameraInputsManager.
  41363. * @returns the FreeCameraInputsManager
  41364. */
  41365. addGamepad(): FreeCameraInputsManager;
  41366. }
  41367. /**
  41368. * Interface representing an arc rotate camera inputs manager
  41369. */
  41370. interface ArcRotateCameraInputsManager {
  41371. /**
  41372. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41373. * @returns the camera inputs manager
  41374. */
  41375. addGamepad(): ArcRotateCameraInputsManager;
  41376. }
  41377. /**
  41378. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41379. */
  41380. export class GamepadSystemSceneComponent implements ISceneComponent {
  41381. /**
  41382. * The component name helpfull to identify the component in the list of scene components.
  41383. */
  41384. readonly name: string;
  41385. /**
  41386. * The scene the component belongs to.
  41387. */
  41388. scene: Scene;
  41389. /**
  41390. * Creates a new instance of the component for the given scene
  41391. * @param scene Defines the scene to register the component in
  41392. */
  41393. constructor(scene: Scene);
  41394. /**
  41395. * Registers the component in a given scene
  41396. */
  41397. register(): void;
  41398. /**
  41399. * Rebuilds the elements related to this component in case of
  41400. * context lost for instance.
  41401. */
  41402. rebuild(): void;
  41403. /**
  41404. * Disposes the component and the associated ressources
  41405. */
  41406. dispose(): void;
  41407. private _beforeCameraUpdate;
  41408. }
  41409. }
  41410. declare module BABYLON {
  41411. /**
  41412. * 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,
  41413. * which still works and will still be found in many Playgrounds.
  41414. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41415. */
  41416. export class UniversalCamera extends TouchCamera {
  41417. /**
  41418. * Defines the gamepad rotation sensiblity.
  41419. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41420. */
  41421. get gamepadAngularSensibility(): number;
  41422. set gamepadAngularSensibility(value: number);
  41423. /**
  41424. * Defines the gamepad move sensiblity.
  41425. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41426. */
  41427. get gamepadMoveSensibility(): number;
  41428. set gamepadMoveSensibility(value: number);
  41429. /**
  41430. * 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,
  41431. * which still works and will still be found in many Playgrounds.
  41432. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41433. * @param name Define the name of the camera in the scene
  41434. * @param position Define the start position of the camera in the scene
  41435. * @param scene Define the scene the camera belongs to
  41436. */
  41437. constructor(name: string, position: Vector3, scene: Scene);
  41438. /**
  41439. * Gets the current object class name.
  41440. * @return the class name
  41441. */
  41442. getClassName(): string;
  41443. }
  41444. }
  41445. declare module BABYLON {
  41446. /**
  41447. * This represents a FPS type of camera. This is only here for back compat purpose.
  41448. * Please use the UniversalCamera instead as both are identical.
  41449. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41450. */
  41451. export class GamepadCamera extends UniversalCamera {
  41452. /**
  41453. * Instantiates a new Gamepad Camera
  41454. * This represents a FPS type of camera. This is only here for back compat purpose.
  41455. * Please use the UniversalCamera instead as both are identical.
  41456. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41457. * @param name Define the name of the camera in the scene
  41458. * @param position Define the start position of the camera in the scene
  41459. * @param scene Define the scene the camera belongs to
  41460. */
  41461. constructor(name: string, position: Vector3, scene: Scene);
  41462. /**
  41463. * Gets the current object class name.
  41464. * @return the class name
  41465. */
  41466. getClassName(): string;
  41467. }
  41468. }
  41469. declare module BABYLON {
  41470. /** @hidden */
  41471. export var passPixelShader: {
  41472. name: string;
  41473. shader: string;
  41474. };
  41475. }
  41476. declare module BABYLON {
  41477. /** @hidden */
  41478. export var passCubePixelShader: {
  41479. name: string;
  41480. shader: string;
  41481. };
  41482. }
  41483. declare module BABYLON {
  41484. /**
  41485. * PassPostProcess which produces an output the same as it's input
  41486. */
  41487. export class PassPostProcess extends PostProcess {
  41488. /**
  41489. * Creates the PassPostProcess
  41490. * @param name The name of the effect.
  41491. * @param options The required width/height ratio to downsize to before computing the render pass.
  41492. * @param camera The camera to apply the render pass to.
  41493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41494. * @param engine The engine which the post process will be applied. (default: current engine)
  41495. * @param reusable If the post process can be reused on the same frame. (default: false)
  41496. * @param textureType The type of texture to be used when performing the post processing.
  41497. * @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)
  41498. */
  41499. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41500. }
  41501. /**
  41502. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41503. */
  41504. export class PassCubePostProcess extends PostProcess {
  41505. private _face;
  41506. /**
  41507. * Gets or sets the cube face to display.
  41508. * * 0 is +X
  41509. * * 1 is -X
  41510. * * 2 is +Y
  41511. * * 3 is -Y
  41512. * * 4 is +Z
  41513. * * 5 is -Z
  41514. */
  41515. get face(): number;
  41516. set face(value: number);
  41517. /**
  41518. * Creates the PassCubePostProcess
  41519. * @param name The name of the effect.
  41520. * @param options The required width/height ratio to downsize to before computing the render pass.
  41521. * @param camera The camera to apply the render pass to.
  41522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41523. * @param engine The engine which the post process will be applied. (default: current engine)
  41524. * @param reusable If the post process can be reused on the same frame. (default: false)
  41525. * @param textureType The type of texture to be used when performing the post processing.
  41526. * @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)
  41527. */
  41528. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41529. }
  41530. }
  41531. declare module BABYLON {
  41532. /** @hidden */
  41533. export var anaglyphPixelShader: {
  41534. name: string;
  41535. shader: string;
  41536. };
  41537. }
  41538. declare module BABYLON {
  41539. /**
  41540. * Postprocess used to generate anaglyphic rendering
  41541. */
  41542. export class AnaglyphPostProcess extends PostProcess {
  41543. private _passedProcess;
  41544. /**
  41545. * Creates a new AnaglyphPostProcess
  41546. * @param name defines postprocess name
  41547. * @param options defines creation options or target ratio scale
  41548. * @param rigCameras defines cameras using this postprocess
  41549. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41550. * @param engine defines hosting engine
  41551. * @param reusable defines if the postprocess will be reused multiple times per frame
  41552. */
  41553. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /**
  41558. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41559. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41560. */
  41561. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41562. /**
  41563. * Creates a new AnaglyphArcRotateCamera
  41564. * @param name defines camera name
  41565. * @param alpha defines alpha angle (in radians)
  41566. * @param beta defines beta angle (in radians)
  41567. * @param radius defines radius
  41568. * @param target defines camera target
  41569. * @param interaxialDistance defines distance between each color axis
  41570. * @param scene defines the hosting scene
  41571. */
  41572. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41573. /**
  41574. * Gets camera class name
  41575. * @returns AnaglyphArcRotateCamera
  41576. */
  41577. getClassName(): string;
  41578. }
  41579. }
  41580. declare module BABYLON {
  41581. /**
  41582. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41583. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41584. */
  41585. export class AnaglyphFreeCamera extends FreeCamera {
  41586. /**
  41587. * Creates a new AnaglyphFreeCamera
  41588. * @param name defines camera name
  41589. * @param position defines initial position
  41590. * @param interaxialDistance defines distance between each color axis
  41591. * @param scene defines the hosting scene
  41592. */
  41593. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41594. /**
  41595. * Gets camera class name
  41596. * @returns AnaglyphFreeCamera
  41597. */
  41598. getClassName(): string;
  41599. }
  41600. }
  41601. declare module BABYLON {
  41602. /**
  41603. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41604. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41605. */
  41606. export class AnaglyphGamepadCamera extends GamepadCamera {
  41607. /**
  41608. * Creates a new AnaglyphGamepadCamera
  41609. * @param name defines camera name
  41610. * @param position defines initial position
  41611. * @param interaxialDistance defines distance between each color axis
  41612. * @param scene defines the hosting scene
  41613. */
  41614. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41615. /**
  41616. * Gets camera class name
  41617. * @returns AnaglyphGamepadCamera
  41618. */
  41619. getClassName(): string;
  41620. }
  41621. }
  41622. declare module BABYLON {
  41623. /**
  41624. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41625. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41626. */
  41627. export class AnaglyphUniversalCamera extends UniversalCamera {
  41628. /**
  41629. * Creates a new AnaglyphUniversalCamera
  41630. * @param name defines camera name
  41631. * @param position defines initial position
  41632. * @param interaxialDistance defines distance between each color axis
  41633. * @param scene defines the hosting scene
  41634. */
  41635. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41636. /**
  41637. * Gets camera class name
  41638. * @returns AnaglyphUniversalCamera
  41639. */
  41640. getClassName(): string;
  41641. }
  41642. }
  41643. declare module BABYLON {
  41644. /** @hidden */
  41645. export var stereoscopicInterlacePixelShader: {
  41646. name: string;
  41647. shader: string;
  41648. };
  41649. }
  41650. declare module BABYLON {
  41651. /**
  41652. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41653. */
  41654. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41655. private _stepSize;
  41656. private _passedProcess;
  41657. /**
  41658. * Initializes a StereoscopicInterlacePostProcessI
  41659. * @param name The name of the effect.
  41660. * @param rigCameras The rig cameras to be appled to the post process
  41661. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41662. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41664. * @param engine The engine which the post process will be applied. (default: current engine)
  41665. * @param reusable If the post process can be reused on the same frame. (default: false)
  41666. */
  41667. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41668. }
  41669. /**
  41670. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41671. */
  41672. export class StereoscopicInterlacePostProcess extends PostProcess {
  41673. private _stepSize;
  41674. private _passedProcess;
  41675. /**
  41676. * Initializes a StereoscopicInterlacePostProcess
  41677. * @param name The name of the effect.
  41678. * @param rigCameras The rig cameras to be appled to the post process
  41679. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41681. * @param engine The engine which the post process will be applied. (default: current engine)
  41682. * @param reusable If the post process can be reused on the same frame. (default: false)
  41683. */
  41684. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41685. }
  41686. }
  41687. declare module BABYLON {
  41688. /**
  41689. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41690. * @see http://doc.babylonjs.com/features/cameras
  41691. */
  41692. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41693. /**
  41694. * Creates a new StereoscopicArcRotateCamera
  41695. * @param name defines camera name
  41696. * @param alpha defines alpha angle (in radians)
  41697. * @param beta defines beta angle (in radians)
  41698. * @param radius defines radius
  41699. * @param target defines camera target
  41700. * @param interaxialDistance defines distance between each color axis
  41701. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41702. * @param scene defines the hosting scene
  41703. */
  41704. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41705. /**
  41706. * Gets camera class name
  41707. * @returns StereoscopicArcRotateCamera
  41708. */
  41709. getClassName(): string;
  41710. }
  41711. }
  41712. declare module BABYLON {
  41713. /**
  41714. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41715. * @see http://doc.babylonjs.com/features/cameras
  41716. */
  41717. export class StereoscopicFreeCamera extends FreeCamera {
  41718. /**
  41719. * Creates a new StereoscopicFreeCamera
  41720. * @param name defines camera name
  41721. * @param position defines initial position
  41722. * @param interaxialDistance defines distance between each color axis
  41723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41724. * @param scene defines the hosting scene
  41725. */
  41726. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41727. /**
  41728. * Gets camera class name
  41729. * @returns StereoscopicFreeCamera
  41730. */
  41731. getClassName(): string;
  41732. }
  41733. }
  41734. declare module BABYLON {
  41735. /**
  41736. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41737. * @see http://doc.babylonjs.com/features/cameras
  41738. */
  41739. export class StereoscopicGamepadCamera extends GamepadCamera {
  41740. /**
  41741. * Creates a new StereoscopicGamepadCamera
  41742. * @param name defines camera name
  41743. * @param position defines initial position
  41744. * @param interaxialDistance defines distance between each color axis
  41745. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41746. * @param scene defines the hosting scene
  41747. */
  41748. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41749. /**
  41750. * Gets camera class name
  41751. * @returns StereoscopicGamepadCamera
  41752. */
  41753. getClassName(): string;
  41754. }
  41755. }
  41756. declare module BABYLON {
  41757. /**
  41758. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41759. * @see http://doc.babylonjs.com/features/cameras
  41760. */
  41761. export class StereoscopicUniversalCamera extends UniversalCamera {
  41762. /**
  41763. * Creates a new StereoscopicUniversalCamera
  41764. * @param name defines camera name
  41765. * @param position defines initial position
  41766. * @param interaxialDistance defines distance between each color axis
  41767. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41768. * @param scene defines the hosting scene
  41769. */
  41770. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41771. /**
  41772. * Gets camera class name
  41773. * @returns StereoscopicUniversalCamera
  41774. */
  41775. getClassName(): string;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /**
  41780. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41781. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41782. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41783. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41784. */
  41785. export class VirtualJoysticksCamera extends FreeCamera {
  41786. /**
  41787. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41788. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41789. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41790. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41791. * @param name Define the name of the camera in the scene
  41792. * @param position Define the start position of the camera in the scene
  41793. * @param scene Define the scene the camera belongs to
  41794. */
  41795. constructor(name: string, position: Vector3, scene: Scene);
  41796. /**
  41797. * Gets the current object class name.
  41798. * @return the class name
  41799. */
  41800. getClassName(): string;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * This represents all the required metrics to create a VR camera.
  41806. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41807. */
  41808. export class VRCameraMetrics {
  41809. /**
  41810. * Define the horizontal resolution off the screen.
  41811. */
  41812. hResolution: number;
  41813. /**
  41814. * Define the vertical resolution off the screen.
  41815. */
  41816. vResolution: number;
  41817. /**
  41818. * Define the horizontal screen size.
  41819. */
  41820. hScreenSize: number;
  41821. /**
  41822. * Define the vertical screen size.
  41823. */
  41824. vScreenSize: number;
  41825. /**
  41826. * Define the vertical screen center position.
  41827. */
  41828. vScreenCenter: number;
  41829. /**
  41830. * Define the distance of the eyes to the screen.
  41831. */
  41832. eyeToScreenDistance: number;
  41833. /**
  41834. * Define the distance between both lenses
  41835. */
  41836. lensSeparationDistance: number;
  41837. /**
  41838. * Define the distance between both viewer's eyes.
  41839. */
  41840. interpupillaryDistance: number;
  41841. /**
  41842. * Define the distortion factor of the VR postprocess.
  41843. * Please, touch with care.
  41844. */
  41845. distortionK: number[];
  41846. /**
  41847. * Define the chromatic aberration correction factors for the VR post process.
  41848. */
  41849. chromaAbCorrection: number[];
  41850. /**
  41851. * Define the scale factor of the post process.
  41852. * The smaller the better but the slower.
  41853. */
  41854. postProcessScaleFactor: number;
  41855. /**
  41856. * Define an offset for the lens center.
  41857. */
  41858. lensCenterOffset: number;
  41859. /**
  41860. * Define if the current vr camera should compensate the distortion of the lense or not.
  41861. */
  41862. compensateDistortion: boolean;
  41863. /**
  41864. * Defines if multiview should be enabled when rendering (Default: false)
  41865. */
  41866. multiviewEnabled: boolean;
  41867. /**
  41868. * Gets the rendering aspect ratio based on the provided resolutions.
  41869. */
  41870. get aspectRatio(): number;
  41871. /**
  41872. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41873. */
  41874. get aspectRatioFov(): number;
  41875. /**
  41876. * @hidden
  41877. */
  41878. get leftHMatrix(): Matrix;
  41879. /**
  41880. * @hidden
  41881. */
  41882. get rightHMatrix(): Matrix;
  41883. /**
  41884. * @hidden
  41885. */
  41886. get leftPreViewMatrix(): Matrix;
  41887. /**
  41888. * @hidden
  41889. */
  41890. get rightPreViewMatrix(): Matrix;
  41891. /**
  41892. * Get the default VRMetrics based on the most generic setup.
  41893. * @returns the default vr metrics
  41894. */
  41895. static GetDefault(): VRCameraMetrics;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. /** @hidden */
  41900. export var vrDistortionCorrectionPixelShader: {
  41901. name: string;
  41902. shader: string;
  41903. };
  41904. }
  41905. declare module BABYLON {
  41906. /**
  41907. * VRDistortionCorrectionPostProcess used for mobile VR
  41908. */
  41909. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41910. private _isRightEye;
  41911. private _distortionFactors;
  41912. private _postProcessScaleFactor;
  41913. private _lensCenterOffset;
  41914. private _scaleIn;
  41915. private _scaleFactor;
  41916. private _lensCenter;
  41917. /**
  41918. * Initializes the VRDistortionCorrectionPostProcess
  41919. * @param name The name of the effect.
  41920. * @param camera The camera to apply the render pass to.
  41921. * @param isRightEye If this is for the right eye distortion
  41922. * @param vrMetrics All the required metrics for the VR camera
  41923. */
  41924. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41930. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41931. */
  41932. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41933. /**
  41934. * Creates a new VRDeviceOrientationArcRotateCamera
  41935. * @param name defines camera name
  41936. * @param alpha defines the camera rotation along the logitudinal axis
  41937. * @param beta defines the camera rotation along the latitudinal axis
  41938. * @param radius defines the camera distance from its target
  41939. * @param target defines the camera target
  41940. * @param scene defines the scene the camera belongs to
  41941. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41942. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41943. */
  41944. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41945. /**
  41946. * Gets camera class name
  41947. * @returns VRDeviceOrientationArcRotateCamera
  41948. */
  41949. getClassName(): string;
  41950. }
  41951. }
  41952. declare module BABYLON {
  41953. /**
  41954. * Camera used to simulate VR rendering (based on FreeCamera)
  41955. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41956. */
  41957. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41958. /**
  41959. * Creates a new VRDeviceOrientationFreeCamera
  41960. * @param name defines camera name
  41961. * @param position defines the start position of the camera
  41962. * @param scene defines the scene the camera belongs to
  41963. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41964. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41965. */
  41966. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41967. /**
  41968. * Gets camera class name
  41969. * @returns VRDeviceOrientationFreeCamera
  41970. */
  41971. getClassName(): string;
  41972. }
  41973. }
  41974. declare module BABYLON {
  41975. /**
  41976. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41978. */
  41979. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41980. /**
  41981. * Creates a new VRDeviceOrientationGamepadCamera
  41982. * @param name defines camera name
  41983. * @param position defines the start position of the camera
  41984. * @param scene defines the scene the camera belongs to
  41985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41987. */
  41988. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41989. /**
  41990. * Gets camera class name
  41991. * @returns VRDeviceOrientationGamepadCamera
  41992. */
  41993. getClassName(): string;
  41994. }
  41995. }
  41996. declare module BABYLON {
  41997. /** @hidden */
  41998. export var imageProcessingPixelShader: {
  41999. name: string;
  42000. shader: string;
  42001. };
  42002. }
  42003. declare module BABYLON {
  42004. /**
  42005. * ImageProcessingPostProcess
  42006. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42007. */
  42008. export class ImageProcessingPostProcess extends PostProcess {
  42009. /**
  42010. * Default configuration related to image processing available in the PBR Material.
  42011. */
  42012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42013. /**
  42014. * Gets the image processing configuration used either in this material.
  42015. */
  42016. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42017. /**
  42018. * Sets the Default image processing configuration used either in the this material.
  42019. *
  42020. * If sets to null, the scene one is in use.
  42021. */
  42022. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42023. /**
  42024. * Keep track of the image processing observer to allow dispose and replace.
  42025. */
  42026. private _imageProcessingObserver;
  42027. /**
  42028. * Attaches a new image processing configuration to the PBR Material.
  42029. * @param configuration
  42030. */
  42031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42032. /**
  42033. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42034. */
  42035. get colorCurves(): Nullable<ColorCurves>;
  42036. /**
  42037. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42038. */
  42039. set colorCurves(value: Nullable<ColorCurves>);
  42040. /**
  42041. * Gets wether the color curves effect is enabled.
  42042. */
  42043. get colorCurvesEnabled(): boolean;
  42044. /**
  42045. * Sets wether the color curves effect is enabled.
  42046. */
  42047. set colorCurvesEnabled(value: boolean);
  42048. /**
  42049. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42050. */
  42051. get colorGradingTexture(): Nullable<BaseTexture>;
  42052. /**
  42053. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42054. */
  42055. set colorGradingTexture(value: Nullable<BaseTexture>);
  42056. /**
  42057. * Gets wether the color grading effect is enabled.
  42058. */
  42059. get colorGradingEnabled(): boolean;
  42060. /**
  42061. * Gets wether the color grading effect is enabled.
  42062. */
  42063. set colorGradingEnabled(value: boolean);
  42064. /**
  42065. * Gets exposure used in the effect.
  42066. */
  42067. get exposure(): number;
  42068. /**
  42069. * Sets exposure used in the effect.
  42070. */
  42071. set exposure(value: number);
  42072. /**
  42073. * Gets wether tonemapping is enabled or not.
  42074. */
  42075. get toneMappingEnabled(): boolean;
  42076. /**
  42077. * Sets wether tonemapping is enabled or not
  42078. */
  42079. set toneMappingEnabled(value: boolean);
  42080. /**
  42081. * Gets the type of tone mapping effect.
  42082. */
  42083. get toneMappingType(): number;
  42084. /**
  42085. * Sets the type of tone mapping effect.
  42086. */
  42087. set toneMappingType(value: number);
  42088. /**
  42089. * Gets contrast used in the effect.
  42090. */
  42091. get contrast(): number;
  42092. /**
  42093. * Sets contrast used in the effect.
  42094. */
  42095. set contrast(value: number);
  42096. /**
  42097. * Gets Vignette stretch size.
  42098. */
  42099. get vignetteStretch(): number;
  42100. /**
  42101. * Sets Vignette stretch size.
  42102. */
  42103. set vignetteStretch(value: number);
  42104. /**
  42105. * Gets Vignette centre X Offset.
  42106. */
  42107. get vignetteCentreX(): number;
  42108. /**
  42109. * Sets Vignette centre X Offset.
  42110. */
  42111. set vignetteCentreX(value: number);
  42112. /**
  42113. * Gets Vignette centre Y Offset.
  42114. */
  42115. get vignetteCentreY(): number;
  42116. /**
  42117. * Sets Vignette centre Y Offset.
  42118. */
  42119. set vignetteCentreY(value: number);
  42120. /**
  42121. * Gets Vignette weight or intensity of the vignette effect.
  42122. */
  42123. get vignetteWeight(): number;
  42124. /**
  42125. * Sets Vignette weight or intensity of the vignette effect.
  42126. */
  42127. set vignetteWeight(value: number);
  42128. /**
  42129. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42130. * if vignetteEnabled is set to true.
  42131. */
  42132. get vignetteColor(): Color4;
  42133. /**
  42134. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42135. * if vignetteEnabled is set to true.
  42136. */
  42137. set vignetteColor(value: Color4);
  42138. /**
  42139. * Gets Camera field of view used by the Vignette effect.
  42140. */
  42141. get vignetteCameraFov(): number;
  42142. /**
  42143. * Sets Camera field of view used by the Vignette effect.
  42144. */
  42145. set vignetteCameraFov(value: number);
  42146. /**
  42147. * Gets the vignette blend mode allowing different kind of effect.
  42148. */
  42149. get vignetteBlendMode(): number;
  42150. /**
  42151. * Sets the vignette blend mode allowing different kind of effect.
  42152. */
  42153. set vignetteBlendMode(value: number);
  42154. /**
  42155. * Gets wether the vignette effect is enabled.
  42156. */
  42157. get vignetteEnabled(): boolean;
  42158. /**
  42159. * Sets wether the vignette effect is enabled.
  42160. */
  42161. set vignetteEnabled(value: boolean);
  42162. private _fromLinearSpace;
  42163. /**
  42164. * Gets wether the input of the processing is in Gamma or Linear Space.
  42165. */
  42166. get fromLinearSpace(): boolean;
  42167. /**
  42168. * Sets wether the input of the processing is in Gamma or Linear Space.
  42169. */
  42170. set fromLinearSpace(value: boolean);
  42171. /**
  42172. * Defines cache preventing GC.
  42173. */
  42174. private _defines;
  42175. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42176. /**
  42177. * "ImageProcessingPostProcess"
  42178. * @returns "ImageProcessingPostProcess"
  42179. */
  42180. getClassName(): string;
  42181. protected _updateParameters(): void;
  42182. dispose(camera?: Camera): void;
  42183. }
  42184. }
  42185. declare module BABYLON {
  42186. /**
  42187. * Class containing static functions to help procedurally build meshes
  42188. */
  42189. export class GroundBuilder {
  42190. /**
  42191. * Creates a ground mesh
  42192. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42193. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42195. * @param name defines the name of the mesh
  42196. * @param options defines the options used to create the mesh
  42197. * @param scene defines the hosting scene
  42198. * @returns the ground mesh
  42199. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42200. */
  42201. static CreateGround(name: string, options: {
  42202. width?: number;
  42203. height?: number;
  42204. subdivisions?: number;
  42205. subdivisionsX?: number;
  42206. subdivisionsY?: number;
  42207. updatable?: boolean;
  42208. }, scene: any): Mesh;
  42209. /**
  42210. * Creates a tiled ground mesh
  42211. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42212. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42213. * * 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
  42214. * * 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
  42215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42216. * @param name defines the name of the mesh
  42217. * @param options defines the options used to create the mesh
  42218. * @param scene defines the hosting scene
  42219. * @returns the tiled ground mesh
  42220. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42221. */
  42222. static CreateTiledGround(name: string, options: {
  42223. xmin: number;
  42224. zmin: number;
  42225. xmax: number;
  42226. zmax: number;
  42227. subdivisions?: {
  42228. w: number;
  42229. h: number;
  42230. };
  42231. precision?: {
  42232. w: number;
  42233. h: number;
  42234. };
  42235. updatable?: boolean;
  42236. }, scene?: Nullable<Scene>): Mesh;
  42237. /**
  42238. * Creates a ground mesh from a height map
  42239. * * The parameter `url` sets the URL of the height map image resource.
  42240. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42241. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42242. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42243. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42244. * * 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.
  42245. * * 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).
  42246. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42248. * @param name defines the name of the mesh
  42249. * @param url defines the url to the height map
  42250. * @param options defines the options used to create the mesh
  42251. * @param scene defines the hosting scene
  42252. * @returns the ground mesh
  42253. * @see https://doc.babylonjs.com/babylon101/height_map
  42254. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42255. */
  42256. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42257. width?: number;
  42258. height?: number;
  42259. subdivisions?: number;
  42260. minHeight?: number;
  42261. maxHeight?: number;
  42262. colorFilter?: Color3;
  42263. alphaFilter?: number;
  42264. updatable?: boolean;
  42265. onReady?: (mesh: GroundMesh) => void;
  42266. }, scene?: Nullable<Scene>): GroundMesh;
  42267. }
  42268. }
  42269. declare module BABYLON {
  42270. /**
  42271. * Class containing static functions to help procedurally build meshes
  42272. */
  42273. export class TorusBuilder {
  42274. /**
  42275. * Creates a torus mesh
  42276. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42277. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42278. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42280. * * 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
  42281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42282. * @param name defines the name of the mesh
  42283. * @param options defines the options used to create the mesh
  42284. * @param scene defines the hosting scene
  42285. * @returns the torus mesh
  42286. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42287. */
  42288. static CreateTorus(name: string, options: {
  42289. diameter?: number;
  42290. thickness?: number;
  42291. tessellation?: number;
  42292. updatable?: boolean;
  42293. sideOrientation?: number;
  42294. frontUVs?: Vector4;
  42295. backUVs?: Vector4;
  42296. }, scene: any): Mesh;
  42297. }
  42298. }
  42299. declare module BABYLON {
  42300. /**
  42301. * Class containing static functions to help procedurally build meshes
  42302. */
  42303. export class CylinderBuilder {
  42304. /**
  42305. * Creates a cylinder or a cone mesh
  42306. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42307. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42308. * * 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.
  42309. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42310. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42311. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42312. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42313. * * 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).
  42314. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42315. * * 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).
  42316. * * 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
  42317. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42318. * * 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
  42319. * * 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.
  42320. * * If `enclose` is false, a ring surface is one element.
  42321. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42322. * * 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
  42323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42324. * * 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
  42325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42326. * @param name defines the name of the mesh
  42327. * @param options defines the options used to create the mesh
  42328. * @param scene defines the hosting scene
  42329. * @returns the cylinder mesh
  42330. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42331. */
  42332. static CreateCylinder(name: string, options: {
  42333. height?: number;
  42334. diameterTop?: number;
  42335. diameterBottom?: number;
  42336. diameter?: number;
  42337. tessellation?: number;
  42338. subdivisions?: number;
  42339. arc?: number;
  42340. faceColors?: Color4[];
  42341. faceUV?: Vector4[];
  42342. updatable?: boolean;
  42343. hasRings?: boolean;
  42344. enclose?: boolean;
  42345. cap?: number;
  42346. sideOrientation?: number;
  42347. frontUVs?: Vector4;
  42348. backUVs?: Vector4;
  42349. }, scene: any): Mesh;
  42350. }
  42351. }
  42352. declare module BABYLON {
  42353. /**
  42354. * States of the webXR experience
  42355. */
  42356. export enum WebXRState {
  42357. /**
  42358. * Transitioning to being in XR mode
  42359. */
  42360. ENTERING_XR = 0,
  42361. /**
  42362. * Transitioning to non XR mode
  42363. */
  42364. EXITING_XR = 1,
  42365. /**
  42366. * In XR mode and presenting
  42367. */
  42368. IN_XR = 2,
  42369. /**
  42370. * Not entered XR mode
  42371. */
  42372. NOT_IN_XR = 3
  42373. }
  42374. /**
  42375. * Abstraction of the XR render target
  42376. */
  42377. export interface WebXRRenderTarget extends IDisposable {
  42378. /**
  42379. * xrpresent context of the canvas which can be used to display/mirror xr content
  42380. */
  42381. canvasContext: WebGLRenderingContext;
  42382. /**
  42383. * xr layer for the canvas
  42384. */
  42385. xrLayer: Nullable<XRWebGLLayer>;
  42386. /**
  42387. * Initializes the xr layer for the session
  42388. * @param xrSession xr session
  42389. * @returns a promise that will resolve once the XR Layer has been created
  42390. */
  42391. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42392. }
  42393. }
  42394. declare module BABYLON {
  42395. /**
  42396. * COnfiguration object for WebXR output canvas
  42397. */
  42398. export class WebXRManagedOutputCanvasOptions {
  42399. /**
  42400. * Options for this XR Layer output
  42401. */
  42402. canvasOptions?: XRWebGLLayerOptions;
  42403. /**
  42404. * CSS styling for a newly created canvas (if not provided)
  42405. */
  42406. newCanvasCssStyle?: string;
  42407. /**
  42408. * An optional canvas in case you wish to create it yourself and provide it here.
  42409. * If not provided, a new canvas will be created
  42410. */
  42411. canvasElement?: HTMLCanvasElement;
  42412. /**
  42413. * Get the default values of the configuration object
  42414. * @returns default values of this configuration object
  42415. */
  42416. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42417. }
  42418. /**
  42419. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42420. */
  42421. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42422. private _options;
  42423. private _engine;
  42424. private _canvas;
  42425. /**
  42426. * Rendering context of the canvas which can be used to display/mirror xr content
  42427. */
  42428. canvasContext: WebGLRenderingContext;
  42429. /**
  42430. * xr layer for the canvas
  42431. */
  42432. xrLayer: Nullable<XRWebGLLayer>;
  42433. /**
  42434. * Initializes the xr layer for the session
  42435. * @param xrSession xr session
  42436. * @returns a promise that will resolve once the XR Layer has been created
  42437. */
  42438. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42439. /**
  42440. * Initializes the canvas to be added/removed upon entering/exiting xr
  42441. * @param _xrSessionManager The XR Session manager
  42442. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42443. */
  42444. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42445. /**
  42446. * Disposes of the object
  42447. */
  42448. dispose(): void;
  42449. private _setManagedOutputCanvas;
  42450. private _addCanvas;
  42451. private _removeCanvas;
  42452. }
  42453. }
  42454. declare module BABYLON {
  42455. /**
  42456. * Manages an XRSession to work with Babylon's engine
  42457. * @see https://doc.babylonjs.com/how_to/webxr
  42458. */
  42459. export class WebXRSessionManager implements IDisposable {
  42460. /** The scene which the session should be created for */
  42461. scene: Scene;
  42462. /**
  42463. * Fires every time a new xrFrame arrives which can be used to update the camera
  42464. */
  42465. onXRFrameObservable: Observable<XRFrame>;
  42466. /**
  42467. * Fires when the xr session is ended either by the device or manually done
  42468. */
  42469. onXRSessionEnded: Observable<any>;
  42470. /**
  42471. * Fires when the xr session is ended either by the device or manually done
  42472. */
  42473. onXRSessionInit: Observable<XRSession>;
  42474. /**
  42475. * Fires when the reference space changed
  42476. */
  42477. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42478. /**
  42479. * Underlying xr session
  42480. */
  42481. session: XRSession;
  42482. /**
  42483. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42484. * or get the offset the player is currently at.
  42485. */
  42486. viewerReferenceSpace: XRReferenceSpace;
  42487. private _referenceSpace;
  42488. /**
  42489. * The current reference space used in this session. This reference space can constantly change!
  42490. * It is mainly used to offset the camera's position.
  42491. */
  42492. get referenceSpace(): XRReferenceSpace;
  42493. /**
  42494. * Set a new reference space and triggers the observable
  42495. */
  42496. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42497. /**
  42498. * The base reference space from which the session started. good if you want to reset your
  42499. * reference space
  42500. */
  42501. baseReferenceSpace: XRReferenceSpace;
  42502. /**
  42503. * Used just in case of a failure to initialize an immersive session.
  42504. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42505. */
  42506. defaultHeightCompensation: number;
  42507. /**
  42508. * Current XR frame
  42509. */
  42510. currentFrame: Nullable<XRFrame>;
  42511. /** WebXR timestamp updated every frame */
  42512. currentTimestamp: number;
  42513. private _xrNavigator;
  42514. private baseLayer;
  42515. private _rttProvider;
  42516. private _sessionEnded;
  42517. /**
  42518. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42519. * @param scene The scene which the session should be created for
  42520. */
  42521. constructor(
  42522. /** The scene which the session should be created for */
  42523. scene: Scene);
  42524. /**
  42525. * Initializes the manager
  42526. * After initialization enterXR can be called to start an XR session
  42527. * @returns Promise which resolves after it is initialized
  42528. */
  42529. initializeAsync(): Promise<void>;
  42530. /**
  42531. * Initializes an xr session
  42532. * @param xrSessionMode mode to initialize
  42533. * @param xrSessionInit defines optional and required values to pass to the session builder
  42534. * @returns a promise which will resolve once the session has been initialized
  42535. */
  42536. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42537. /**
  42538. * Sets the reference space on the xr session
  42539. * @param referenceSpace space to set
  42540. * @returns a promise that will resolve once the reference space has been set
  42541. */
  42542. setReferenceSpaceAsync(referenceSpace?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42543. /**
  42544. * Resets the reference space to the one started the session
  42545. */
  42546. resetReferenceSpace(): void;
  42547. /**
  42548. * Updates the render state of the session
  42549. * @param state state to set
  42550. * @returns a promise that resolves once the render state has been updated
  42551. */
  42552. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42553. /**
  42554. * Starts rendering to the xr layer
  42555. */
  42556. runXRRenderLoop(): void;
  42557. /**
  42558. * Gets the correct render target texture to be rendered this frame for this eye
  42559. * @param eye the eye for which to get the render target
  42560. * @returns the render target for the specified eye
  42561. */
  42562. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42563. /**
  42564. * Stops the xrSession and restores the renderloop
  42565. * @returns Promise which resolves after it exits XR
  42566. */
  42567. exitXRAsync(): Promise<void>;
  42568. /**
  42569. * Checks if a session would be supported for the creation options specified
  42570. * @param sessionMode session mode to check if supported eg. immersive-vr
  42571. * @returns true if supported
  42572. */
  42573. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42574. /**
  42575. * Creates a WebXRRenderTarget object for the XR session
  42576. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42577. * @param options optional options to provide when creating a new render target
  42578. * @returns a WebXR render target to which the session can render
  42579. */
  42580. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42581. /**
  42582. * @hidden
  42583. * Converts the render layer of xrSession to a render target
  42584. * @param session session to create render target for
  42585. * @param scene scene the new render target should be created for
  42586. * @param baseLayer the webgl layer to create the render target for
  42587. */
  42588. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42589. /**
  42590. * Disposes of the session manager
  42591. */
  42592. dispose(): void;
  42593. /**
  42594. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42595. * @param sessionMode defines the session to test
  42596. * @returns a promise with boolean as final value
  42597. */
  42598. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * WebXR Camera which holds the views for the xrSession
  42604. * @see https://doc.babylonjs.com/how_to/webxr
  42605. */
  42606. export class WebXRCamera extends FreeCamera {
  42607. private _xrSessionManager;
  42608. /**
  42609. * Is the camera in debug mode. Used when using an emulator
  42610. */
  42611. debugMode: boolean;
  42612. private _firstFrame;
  42613. private _referencedPosition;
  42614. private _referenceQuaternion;
  42615. private _xrInvPositionCache;
  42616. private _xrInvQuaternionCache;
  42617. /**
  42618. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42619. * @param name the name of the camera
  42620. * @param scene the scene to add the camera to
  42621. */
  42622. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42623. private _updateNumberOfRigCameras;
  42624. /**
  42625. * Sets this camera's transformation based on a non-vr camera
  42626. * @param otherCamera the non-vr camera to copy the transformation from
  42627. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42628. */
  42629. setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace?: boolean): void;
  42630. /** @hidden */
  42631. _updateForDualEyeDebugging(): void;
  42632. private _updateReferenceSpace;
  42633. private _updateReferenceSpaceOffset;
  42634. private _updateFromXRSession;
  42635. }
  42636. }
  42637. declare module BABYLON {
  42638. /**
  42639. * Defining the interface required for a (webxr) feature
  42640. */
  42641. export interface IWebXRFeature extends IDisposable {
  42642. /**
  42643. * Is this feature attached
  42644. */
  42645. attached: boolean;
  42646. /**
  42647. * Attach the feature to the session
  42648. * Will usually be called by the features manager
  42649. *
  42650. * @returns true if successful.
  42651. */
  42652. attach(): boolean;
  42653. /**
  42654. * Detach the feature from the session
  42655. * Will usually be called by the features manager
  42656. *
  42657. * @returns true if successful.
  42658. */
  42659. detach(): boolean;
  42660. }
  42661. /**
  42662. * Defining the constructor of a feature. Used to register the modules.
  42663. */
  42664. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42665. /**
  42666. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42667. * It is mainly used in AR sessions.
  42668. *
  42669. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42670. */
  42671. export class WebXRFeaturesManager implements IDisposable {
  42672. private _xrSessionManager;
  42673. private static readonly _AvailableFeatures;
  42674. /**
  42675. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42676. * Mainly used internally.
  42677. *
  42678. * @param featureName the name of the feature to register
  42679. * @param constructorFunction the function used to construct the module
  42680. * @param version the (babylon) version of the module
  42681. * @param stable is that a stable version of this module
  42682. */
  42683. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42684. /**
  42685. * Returns a constructor of a specific feature.
  42686. *
  42687. * @param featureName the name of the feature to construct
  42688. * @param version the version of the feature to load
  42689. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42690. * @param options optional options provided to the module.
  42691. * @returns a function that, when called, will return a new instance of this feature
  42692. */
  42693. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42694. /**
  42695. * Return the latest unstable version of this feature
  42696. * @param featureName the name of the feature to search
  42697. * @returns the version number. if not found will return -1
  42698. */
  42699. static GetLatestVersionOfFeature(featureName: string): number;
  42700. /**
  42701. * Return the latest stable version of this feature
  42702. * @param featureName the name of the feature to search
  42703. * @returns the version number. if not found will return -1
  42704. */
  42705. static GetStableVersionOfFeature(featureName: string): number;
  42706. /**
  42707. * Can be used to return the list of features currently registered
  42708. *
  42709. * @returns an Array of available features
  42710. */
  42711. static GetAvailableFeatures(): string[];
  42712. /**
  42713. * Gets the versions available for a specific feature
  42714. * @param featureName the name of the feature
  42715. * @returns an array with the available versions
  42716. */
  42717. static GetAvailableVersions(featureName: string): string[];
  42718. private _features;
  42719. /**
  42720. * constructs a new features manages.
  42721. *
  42722. * @param _xrSessionManager an instance of WebXRSessionManager
  42723. */
  42724. constructor(_xrSessionManager: WebXRSessionManager);
  42725. /**
  42726. * 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.
  42727. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  42728. *
  42729. * @param featureName the name of the feature to load or the class of the feature
  42730. * @param version optional version to load. if not provided the latest version will be enabled
  42731. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42732. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42733. * @returns a new constructed feature or throws an error if feature not found.
  42734. */
  42735. enableFeature(featureName: string | {
  42736. Name: string;
  42737. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42738. /**
  42739. * Used to disable an already-enabled feature
  42740. * The feature will be disposed and will be recreated once enabled.
  42741. * @param featureName the feature to disable
  42742. * @returns true if disable was successful
  42743. */
  42744. disableFeature(featureName: string | {
  42745. Name: string;
  42746. }): boolean;
  42747. /**
  42748. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42749. * Can be used during a session to start a feature
  42750. * @param featureName the name of feature to attach
  42751. */
  42752. attachFeature(featureName: string): void;
  42753. /**
  42754. * Can be used inside a session or when the session ends to detach a specific feature
  42755. * @param featureName the name of the feature to detach
  42756. */
  42757. detachFeature(featureName: string): void;
  42758. /**
  42759. * Get the list of enabled features
  42760. * @returns an array of enabled features
  42761. */
  42762. getEnabledFeatures(): string[];
  42763. /**
  42764. * get the implementation of an enabled feature.
  42765. * @param featureName the name of the feature to load
  42766. * @returns the feature class, if found
  42767. */
  42768. getEnabledFeature(featureName: string): IWebXRFeature;
  42769. /**
  42770. * dispose this features manager
  42771. */
  42772. dispose(): void;
  42773. }
  42774. }
  42775. declare module BABYLON {
  42776. /**
  42777. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42778. * @see https://doc.babylonjs.com/how_to/webxr
  42779. */
  42780. export class WebXRExperienceHelper implements IDisposable {
  42781. private scene;
  42782. /**
  42783. * Camera used to render xr content
  42784. */
  42785. camera: WebXRCamera;
  42786. /**
  42787. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42788. */
  42789. state: WebXRState;
  42790. private _setState;
  42791. /**
  42792. * Fires when the state of the experience helper has changed
  42793. */
  42794. onStateChangedObservable: Observable<WebXRState>;
  42795. /**
  42796. * Observers registered here will be triggered after the camera's initial transformation is set
  42797. * This can be used to set a different ground level or an extra rotation.
  42798. *
  42799. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42800. * to the position set after this observable is done executing.
  42801. */
  42802. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42803. /** Session manager used to keep track of xr session */
  42804. sessionManager: WebXRSessionManager;
  42805. /** A features manager for this xr session */
  42806. featuresManager: WebXRFeaturesManager;
  42807. private _nonVRCamera;
  42808. private _originalSceneAutoClear;
  42809. private _supported;
  42810. /**
  42811. * Creates the experience helper
  42812. * @param scene the scene to attach the experience helper to
  42813. * @returns a promise for the experience helper
  42814. */
  42815. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42816. /**
  42817. * Creates a WebXRExperienceHelper
  42818. * @param scene The scene the helper should be created in
  42819. */
  42820. private constructor();
  42821. /**
  42822. * Exits XR mode and returns the scene to its original state
  42823. * @returns promise that resolves after xr mode has exited
  42824. */
  42825. exitXRAsync(): Promise<void>;
  42826. /**
  42827. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42828. * @param sessionMode options for the XR session
  42829. * @param referenceSpaceType frame of reference of the XR session
  42830. * @param renderTarget the output canvas that will be used to enter XR mode
  42831. * @returns promise that resolves after xr mode has entered
  42832. */
  42833. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42834. /**
  42835. * Disposes of the experience helper
  42836. */
  42837. dispose(): void;
  42838. private _nonXRToXRCamera;
  42839. }
  42840. }
  42841. declare module BABYLON {
  42842. /**
  42843. * X-Y values for axes in WebXR
  42844. */
  42845. export interface IWebXRMotionControllerAxesValue {
  42846. /**
  42847. * The value of the x axis
  42848. */
  42849. x: number;
  42850. /**
  42851. * The value of the y-axis
  42852. */
  42853. y: number;
  42854. }
  42855. /**
  42856. * changed / previous values for the values of this component
  42857. */
  42858. export interface IWebXRMotionControllerComponentChangesValues<T> {
  42859. /**
  42860. * current (this frame) value
  42861. */
  42862. current: T;
  42863. /**
  42864. * previous (last change) value
  42865. */
  42866. previous: T;
  42867. }
  42868. /**
  42869. * Represents changes in the component between current frame and last values recorded
  42870. */
  42871. export interface IWebXRMotionControllerComponentChanges {
  42872. /**
  42873. * will be populated with previous and current values if touched changed
  42874. */
  42875. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42876. /**
  42877. * will be populated with previous and current values if pressed changed
  42878. */
  42879. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42880. /**
  42881. * will be populated with previous and current values if value changed
  42882. */
  42883. value?: IWebXRMotionControllerComponentChangesValues<number>;
  42884. /**
  42885. * will be populated with previous and current values if axes changed
  42886. */
  42887. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  42888. }
  42889. /**
  42890. * This class represents a single component (for example button or thumbstick) of a motion controller
  42891. */
  42892. export class WebXRControllerComponent implements IDisposable {
  42893. /**
  42894. * the id of this component
  42895. */
  42896. id: string;
  42897. /**
  42898. * the type of the component
  42899. */
  42900. type: MotionControllerComponentType;
  42901. private _buttonIndex;
  42902. private _axesIndices;
  42903. /**
  42904. * Thumbstick component type
  42905. */
  42906. static THUMBSTICK: string;
  42907. /**
  42908. * Touchpad component type
  42909. */
  42910. static TOUCHPAD: string;
  42911. /**
  42912. * trigger component type
  42913. */
  42914. static TRIGGER: string;
  42915. /**
  42916. * squeeze component type
  42917. */
  42918. static SQUEEZE: string;
  42919. /**
  42920. * Observers registered here will be triggered when the state of a button changes
  42921. * State change is either pressed / touched / value
  42922. */
  42923. onButtonStateChanged: Observable<WebXRControllerComponent>;
  42924. /**
  42925. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  42926. * the axes data changes
  42927. */
  42928. onAxisValueChanged: Observable<{
  42929. x: number;
  42930. y: number;
  42931. }>;
  42932. private _currentValue;
  42933. private _touched;
  42934. private _pressed;
  42935. private _axes;
  42936. private _changes;
  42937. /**
  42938. * Creates a new component for a motion controller.
  42939. * It is created by the motion controller itself
  42940. *
  42941. * @param id the id of this component
  42942. * @param type the type of the component
  42943. * @param _buttonIndex index in the buttons array of the gamepad
  42944. * @param _axesIndices indices of the values in the axes array of the gamepad
  42945. */
  42946. constructor(
  42947. /**
  42948. * the id of this component
  42949. */
  42950. id: string,
  42951. /**
  42952. * the type of the component
  42953. */
  42954. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  42955. /**
  42956. * Get the current value of this component
  42957. */
  42958. get value(): number;
  42959. /**
  42960. * is the button currently pressed
  42961. */
  42962. get pressed(): boolean;
  42963. /**
  42964. * is the button currently touched
  42965. */
  42966. get touched(): boolean;
  42967. /**
  42968. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  42969. */
  42970. get axes(): IWebXRMotionControllerAxesValue;
  42971. /**
  42972. * Get the changes. Elements will be populated only if they changed with their previous and current value
  42973. */
  42974. get changes(): IWebXRMotionControllerComponentChanges;
  42975. /**
  42976. * Is this component a button (hence - pressable)
  42977. * @returns true if can be pressed
  42978. */
  42979. isButton(): boolean;
  42980. /**
  42981. * Are there axes correlating to this component
  42982. * @return true is axes data is available
  42983. */
  42984. isAxes(): boolean;
  42985. /**
  42986. * update this component using the gamepad object it is in. Called on every frame
  42987. * @param nativeController the native gamepad controller object
  42988. */
  42989. update(nativeController: IMinimalMotionControllerObject): void;
  42990. /**
  42991. * Dispose this component
  42992. */
  42993. dispose(): void;
  42994. }
  42995. }
  42996. declare module BABYLON {
  42997. /**
  42998. * Class used to represent data loading progression
  42999. */
  43000. export class SceneLoaderProgressEvent {
  43001. /** defines if data length to load can be evaluated */
  43002. readonly lengthComputable: boolean;
  43003. /** defines the loaded data length */
  43004. readonly loaded: number;
  43005. /** defines the data length to load */
  43006. readonly total: number;
  43007. /**
  43008. * Create a new progress event
  43009. * @param lengthComputable defines if data length to load can be evaluated
  43010. * @param loaded defines the loaded data length
  43011. * @param total defines the data length to load
  43012. */
  43013. constructor(
  43014. /** defines if data length to load can be evaluated */
  43015. lengthComputable: boolean,
  43016. /** defines the loaded data length */
  43017. loaded: number,
  43018. /** defines the data length to load */
  43019. total: number);
  43020. /**
  43021. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43022. * @param event defines the source event
  43023. * @returns a new SceneLoaderProgressEvent
  43024. */
  43025. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43026. }
  43027. /**
  43028. * Interface used by SceneLoader plugins to define supported file extensions
  43029. */
  43030. export interface ISceneLoaderPluginExtensions {
  43031. /**
  43032. * Defines the list of supported extensions
  43033. */
  43034. [extension: string]: {
  43035. isBinary: boolean;
  43036. };
  43037. }
  43038. /**
  43039. * Interface used by SceneLoader plugin factory
  43040. */
  43041. export interface ISceneLoaderPluginFactory {
  43042. /**
  43043. * Defines the name of the factory
  43044. */
  43045. name: string;
  43046. /**
  43047. * Function called to create a new plugin
  43048. * @return the new plugin
  43049. */
  43050. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43051. /**
  43052. * The callback that returns true if the data can be directly loaded.
  43053. * @param data string containing the file data
  43054. * @returns if the data can be loaded directly
  43055. */
  43056. canDirectLoad?(data: string): boolean;
  43057. }
  43058. /**
  43059. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43060. */
  43061. export interface ISceneLoaderPluginBase {
  43062. /**
  43063. * The friendly name of this plugin.
  43064. */
  43065. name: string;
  43066. /**
  43067. * The file extensions supported by this plugin.
  43068. */
  43069. extensions: string | ISceneLoaderPluginExtensions;
  43070. /**
  43071. * The callback called when loading from a url.
  43072. * @param scene scene loading this url
  43073. * @param url url to load
  43074. * @param onSuccess callback called when the file successfully loads
  43075. * @param onProgress callback called while file is loading (if the server supports this mode)
  43076. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43077. * @param onError callback called when the file fails to load
  43078. * @returns a file request object
  43079. */
  43080. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43081. /**
  43082. * The callback called when loading from a file object.
  43083. * @param scene scene loading this file
  43084. * @param file defines the file to load
  43085. * @param onSuccess defines the callback to call when data is loaded
  43086. * @param onProgress defines the callback to call during loading process
  43087. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43088. * @param onError defines the callback to call when an error occurs
  43089. * @returns a file request object
  43090. */
  43091. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43092. /**
  43093. * The callback that returns true if the data can be directly loaded.
  43094. * @param data string containing the file data
  43095. * @returns if the data can be loaded directly
  43096. */
  43097. canDirectLoad?(data: string): boolean;
  43098. /**
  43099. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43100. * @param scene scene loading this data
  43101. * @param data string containing the data
  43102. * @returns data to pass to the plugin
  43103. */
  43104. directLoad?(scene: Scene, data: string): any;
  43105. /**
  43106. * The callback that allows custom handling of the root url based on the response url.
  43107. * @param rootUrl the original root url
  43108. * @param responseURL the response url if available
  43109. * @returns the new root url
  43110. */
  43111. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43112. }
  43113. /**
  43114. * Interface used to define a SceneLoader plugin
  43115. */
  43116. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43117. /**
  43118. * Import meshes into a scene.
  43119. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43120. * @param scene The scene to import into
  43121. * @param data The data to import
  43122. * @param rootUrl The root url for scene and resources
  43123. * @param meshes The meshes array to import into
  43124. * @param particleSystems The particle systems array to import into
  43125. * @param skeletons The skeletons array to import into
  43126. * @param onError The callback when import fails
  43127. * @returns True if successful or false otherwise
  43128. */
  43129. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43130. /**
  43131. * Load into a scene.
  43132. * @param scene The scene to load into
  43133. * @param data The data to import
  43134. * @param rootUrl The root url for scene and resources
  43135. * @param onError The callback when import fails
  43136. * @returns True if successful or false otherwise
  43137. */
  43138. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43139. /**
  43140. * Load into an asset container.
  43141. * @param scene The scene to load into
  43142. * @param data The data to import
  43143. * @param rootUrl The root url for scene and resources
  43144. * @param onError The callback when import fails
  43145. * @returns The loaded asset container
  43146. */
  43147. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43148. }
  43149. /**
  43150. * Interface used to define an async SceneLoader plugin
  43151. */
  43152. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43153. /**
  43154. * Import meshes into a scene.
  43155. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43156. * @param scene The scene to import into
  43157. * @param data The data to import
  43158. * @param rootUrl The root url for scene and resources
  43159. * @param onProgress The callback when the load progresses
  43160. * @param fileName Defines the name of the file to load
  43161. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43162. */
  43163. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43164. meshes: AbstractMesh[];
  43165. particleSystems: IParticleSystem[];
  43166. skeletons: Skeleton[];
  43167. animationGroups: AnimationGroup[];
  43168. }>;
  43169. /**
  43170. * Load into a scene.
  43171. * @param scene The scene to load into
  43172. * @param data The data to import
  43173. * @param rootUrl The root url for scene and resources
  43174. * @param onProgress The callback when the load progresses
  43175. * @param fileName Defines the name of the file to load
  43176. * @returns Nothing
  43177. */
  43178. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43179. /**
  43180. * Load into an asset container.
  43181. * @param scene The scene to load into
  43182. * @param data The data to import
  43183. * @param rootUrl The root url for scene and resources
  43184. * @param onProgress The callback when the load progresses
  43185. * @param fileName Defines the name of the file to load
  43186. * @returns The loaded asset container
  43187. */
  43188. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43189. }
  43190. /**
  43191. * Mode that determines how to handle old animation groups before loading new ones.
  43192. */
  43193. export enum SceneLoaderAnimationGroupLoadingMode {
  43194. /**
  43195. * Reset all old animations to initial state then dispose them.
  43196. */
  43197. Clean = 0,
  43198. /**
  43199. * Stop all old animations.
  43200. */
  43201. Stop = 1,
  43202. /**
  43203. * Restart old animations from first frame.
  43204. */
  43205. Sync = 2,
  43206. /**
  43207. * Old animations remains untouched.
  43208. */
  43209. NoSync = 3
  43210. }
  43211. /**
  43212. * Class used to load scene from various file formats using registered plugins
  43213. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43214. */
  43215. export class SceneLoader {
  43216. /**
  43217. * No logging while loading
  43218. */
  43219. static readonly NO_LOGGING: number;
  43220. /**
  43221. * Minimal logging while loading
  43222. */
  43223. static readonly MINIMAL_LOGGING: number;
  43224. /**
  43225. * Summary logging while loading
  43226. */
  43227. static readonly SUMMARY_LOGGING: number;
  43228. /**
  43229. * Detailled logging while loading
  43230. */
  43231. static readonly DETAILED_LOGGING: number;
  43232. /**
  43233. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43234. */
  43235. static get ForceFullSceneLoadingForIncremental(): boolean;
  43236. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43237. /**
  43238. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43239. */
  43240. static get ShowLoadingScreen(): boolean;
  43241. static set ShowLoadingScreen(value: boolean);
  43242. /**
  43243. * Defines the current logging level (while loading the scene)
  43244. * @ignorenaming
  43245. */
  43246. static get loggingLevel(): number;
  43247. static set loggingLevel(value: number);
  43248. /**
  43249. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43250. */
  43251. static get CleanBoneMatrixWeights(): boolean;
  43252. static set CleanBoneMatrixWeights(value: boolean);
  43253. /**
  43254. * Event raised when a plugin is used to load a scene
  43255. */
  43256. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43257. private static _registeredPlugins;
  43258. private static _getDefaultPlugin;
  43259. private static _getPluginForExtension;
  43260. private static _getPluginForDirectLoad;
  43261. private static _getPluginForFilename;
  43262. private static _getDirectLoad;
  43263. private static _loadData;
  43264. private static _getFileInfo;
  43265. /**
  43266. * Gets a plugin that can load the given extension
  43267. * @param extension defines the extension to load
  43268. * @returns a plugin or null if none works
  43269. */
  43270. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43271. /**
  43272. * Gets a boolean indicating that the given extension can be loaded
  43273. * @param extension defines the extension to load
  43274. * @returns true if the extension is supported
  43275. */
  43276. static IsPluginForExtensionAvailable(extension: string): boolean;
  43277. /**
  43278. * Adds a new plugin to the list of registered plugins
  43279. * @param plugin defines the plugin to add
  43280. */
  43281. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43282. /**
  43283. * Import meshes into a scene
  43284. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43285. * @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)
  43286. * @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)
  43287. * @param scene the instance of BABYLON.Scene to append to
  43288. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43289. * @param onProgress a callback with a progress event for each file being loaded
  43290. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43291. * @param pluginExtension the extension used to determine the plugin
  43292. * @returns The loaded plugin
  43293. */
  43294. 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>;
  43295. /**
  43296. * Import meshes into a scene
  43297. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43298. * @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)
  43299. * @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)
  43300. * @param scene the instance of BABYLON.Scene to append to
  43301. * @param onProgress a callback with a progress event for each file being loaded
  43302. * @param pluginExtension the extension used to determine the plugin
  43303. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43304. */
  43305. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43306. meshes: AbstractMesh[];
  43307. particleSystems: IParticleSystem[];
  43308. skeletons: Skeleton[];
  43309. animationGroups: AnimationGroup[];
  43310. }>;
  43311. /**
  43312. * Load a scene
  43313. * @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)
  43314. * @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)
  43315. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43316. * @param onSuccess a callback with the scene when import succeeds
  43317. * @param onProgress a callback with a progress event for each file being loaded
  43318. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43319. * @param pluginExtension the extension used to determine the plugin
  43320. * @returns The loaded plugin
  43321. */
  43322. 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>;
  43323. /**
  43324. * Load a scene
  43325. * @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)
  43326. * @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)
  43327. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43328. * @param onProgress a callback with a progress event for each file being loaded
  43329. * @param pluginExtension the extension used to determine the plugin
  43330. * @returns The loaded scene
  43331. */
  43332. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43333. /**
  43334. * Append a scene
  43335. * @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)
  43336. * @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)
  43337. * @param scene is the instance of BABYLON.Scene to append to
  43338. * @param onSuccess a callback with the scene when import succeeds
  43339. * @param onProgress a callback with a progress event for each file being loaded
  43340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43341. * @param pluginExtension the extension used to determine the plugin
  43342. * @returns The loaded plugin
  43343. */
  43344. 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>;
  43345. /**
  43346. * Append a scene
  43347. * @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)
  43348. * @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)
  43349. * @param scene is the instance of BABYLON.Scene to append to
  43350. * @param onProgress a callback with a progress event for each file being loaded
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The given scene
  43353. */
  43354. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43355. /**
  43356. * Load a scene into an asset container
  43357. * @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)
  43358. * @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)
  43359. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43360. * @param onSuccess a callback with the scene when import succeeds
  43361. * @param onProgress a callback with a progress event for each file being loaded
  43362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43363. * @param pluginExtension the extension used to determine the plugin
  43364. * @returns The loaded plugin
  43365. */
  43366. 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>;
  43367. /**
  43368. * Load a scene into an asset container
  43369. * @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)
  43370. * @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)
  43371. * @param scene is the instance of Scene to append to
  43372. * @param onProgress a callback with a progress event for each file being loaded
  43373. * @param pluginExtension the extension used to determine the plugin
  43374. * @returns The loaded asset container
  43375. */
  43376. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43377. /**
  43378. * Import animations from a file into a scene
  43379. * @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)
  43380. * @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)
  43381. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43382. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43383. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43384. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43385. * @param onSuccess a callback with the scene when import succeeds
  43386. * @param onProgress a callback with a progress event for each file being loaded
  43387. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43388. */
  43389. 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;
  43390. /**
  43391. * Import animations from a file into a scene
  43392. * @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)
  43393. * @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)
  43394. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43395. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43396. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43397. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43398. * @param onSuccess a callback with the scene when import succeeds
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43401. * @returns the updated scene with imported animations
  43402. */
  43403. 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>;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43409. */
  43410. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  43411. /**
  43412. * The type of components available in motion controllers.
  43413. * This is not the name of the component.
  43414. */
  43415. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43416. /**
  43417. * The schema of motion controller layout.
  43418. * No object will be initialized using this interface
  43419. * This is used just to define the profile.
  43420. */
  43421. export interface IMotionControllerLayout {
  43422. /**
  43423. * Defines the main button component id
  43424. */
  43425. selectComponentId: string;
  43426. /**
  43427. * Available components (unsorted)
  43428. */
  43429. components: {
  43430. /**
  43431. * A map of component Ids
  43432. */
  43433. [componentId: string]: {
  43434. /**
  43435. * The type of input the component outputs
  43436. */
  43437. type: MotionControllerComponentType;
  43438. };
  43439. };
  43440. /**
  43441. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  43442. */
  43443. gamepad?: {
  43444. /**
  43445. * Is the mapping based on the xr-standard defined here:
  43446. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  43447. */
  43448. mapping: "" | "xr-standard";
  43449. /**
  43450. * The buttons available in this input in the right order
  43451. * index of this button will be the index in the gamepadObject.buttons array
  43452. * correlates to the componentId in components
  43453. */
  43454. buttons: Array<string | null>;
  43455. /**
  43456. * Definition of the axes of the gamepad input, sorted
  43457. * Correlates to componentIds in the components map
  43458. */
  43459. axes: Array<{
  43460. /**
  43461. * The component id that the axis correlates to
  43462. */
  43463. componentId: string;
  43464. /**
  43465. * X or Y Axis
  43466. */
  43467. axis: "x-axis" | "y-axis";
  43468. } | null>;
  43469. };
  43470. }
  43471. /**
  43472. * A definition for the layout map in the input profile
  43473. */
  43474. export interface IMotionControllerLayoutMap {
  43475. /**
  43476. * Layouts with handness type as a key
  43477. */
  43478. [handness: string]: IMotionControllerLayout;
  43479. }
  43480. /**
  43481. * The XR Input profile schema
  43482. * Profiles can be found here:
  43483. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43484. */
  43485. export interface IMotionControllerProfile {
  43486. /**
  43487. * The id of this profile
  43488. * correlates to the profile(s) in the xrInput.profiles array
  43489. */
  43490. profileId: string;
  43491. /**
  43492. * fallback profiles for this profileId
  43493. */
  43494. fallbackProfileIds: string[];
  43495. /**
  43496. * The layout map, with handness as key
  43497. */
  43498. layouts: IMotionControllerLayoutMap;
  43499. }
  43500. /**
  43501. * A helper-interface for the 3 meshes needed for controller button animation
  43502. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43503. */
  43504. export interface IMotionControllerButtonMeshMap {
  43505. /**
  43506. * The mesh that will be changed when value changes
  43507. */
  43508. valueMesh: AbstractMesh;
  43509. /**
  43510. * the mesh that defines the pressed value mesh position.
  43511. * This is used to find the max-position of this button
  43512. */
  43513. pressedMesh: AbstractMesh;
  43514. /**
  43515. * the mesh that defines the unpressed value mesh position.
  43516. * This is used to find the min (or initial) position of this button
  43517. */
  43518. unpressedMesh: AbstractMesh;
  43519. }
  43520. /**
  43521. * A helper-interface for the 3 meshes needed for controller axis animation.
  43522. * This will be expanded when touchpad animations are fully supported
  43523. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43524. */
  43525. export interface IMotionControllerAxisMeshMap {
  43526. /**
  43527. * The mesh that will be changed when axis value changes
  43528. */
  43529. valueMesh: AbstractMesh;
  43530. /**
  43531. * the mesh that defines the minimum value mesh position.
  43532. */
  43533. minMesh: AbstractMesh;
  43534. /**
  43535. * the mesh that defines the maximum value mesh position.
  43536. */
  43537. maxMesh: AbstractMesh;
  43538. }
  43539. /**
  43540. * The elements needed for change-detection of the gamepad objects in motion controllers
  43541. */
  43542. export interface IMinimalMotionControllerObject {
  43543. /**
  43544. * An array of available buttons
  43545. */
  43546. buttons: Array<{
  43547. /**
  43548. * Value of the button/trigger
  43549. */
  43550. value: number;
  43551. /**
  43552. * If the button/trigger is currently touched
  43553. */
  43554. touched: boolean;
  43555. /**
  43556. * If the button/trigger is currently pressed
  43557. */
  43558. pressed: boolean;
  43559. }>;
  43560. /**
  43561. * Available axes of this controller
  43562. */
  43563. axes: number[];
  43564. }
  43565. /**
  43566. * An Abstract Motion controller
  43567. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43568. * Each component has an observable to check for changes in value and state
  43569. */
  43570. export abstract class WebXRAbstractMotionController implements IDisposable {
  43571. protected scene: Scene;
  43572. protected layout: IMotionControllerLayout;
  43573. /**
  43574. * The gamepad object correlating to this controller
  43575. */
  43576. gamepadObject: IMinimalMotionControllerObject;
  43577. /**
  43578. * handness (left/right/none) of this controller
  43579. */
  43580. handness: MotionControllerHandness;
  43581. /**
  43582. * Component type map
  43583. */
  43584. static ComponentType: {
  43585. TRIGGER: string;
  43586. SQUEEZE: string;
  43587. TOUCHPAD: string;
  43588. THUMBSTICK: string;
  43589. BUTTON: string;
  43590. };
  43591. /**
  43592. * The profile id of this motion controller
  43593. */
  43594. abstract profileId: string;
  43595. /**
  43596. * A map of components (WebXRControllerComponent) in this motion controller
  43597. * Components have a ComponentType and can also have both button and axis definitions
  43598. */
  43599. readonly components: {
  43600. [id: string]: WebXRControllerComponent;
  43601. };
  43602. /**
  43603. * Observers registered here will be triggered when the model of this controller is done loading
  43604. */
  43605. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43606. /**
  43607. * The root mesh of the model. It is null if the model was not yet initialized
  43608. */
  43609. rootMesh: Nullable<AbstractMesh>;
  43610. private _modelReady;
  43611. /**
  43612. * constructs a new abstract motion controller
  43613. * @param scene the scene to which the model of the controller will be added
  43614. * @param layout The profile layout to load
  43615. * @param gamepadObject The gamepad object correlating to this controller
  43616. * @param handness handness (left/right/none) of this controller
  43617. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43618. */
  43619. constructor(scene: Scene, layout: IMotionControllerLayout,
  43620. /**
  43621. * The gamepad object correlating to this controller
  43622. */
  43623. gamepadObject: IMinimalMotionControllerObject,
  43624. /**
  43625. * handness (left/right/none) of this controller
  43626. */
  43627. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43628. private _initComponent;
  43629. /**
  43630. * Update this model using the current XRFrame
  43631. * @param xrFrame the current xr frame to use and update the model
  43632. */
  43633. updateFromXRFrame(xrFrame: XRFrame): void;
  43634. /**
  43635. * Get the list of components available in this motion controller
  43636. * @returns an array of strings correlating to available components
  43637. */
  43638. getComponentTypes(): string[];
  43639. /**
  43640. * Get the main (Select) component of this controller as defined in the layout
  43641. * @returns the main component of this controller
  43642. */
  43643. getMainComponent(): WebXRControllerComponent;
  43644. /**
  43645. * get a component based an its component id as defined in layout.components
  43646. * @param id the id of the component
  43647. * @returns the component correlates to the id or undefined if not found
  43648. */
  43649. getComponent(id: string): WebXRControllerComponent;
  43650. /**
  43651. * Loads the model correlating to this controller
  43652. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43653. * @returns A promise fulfilled with the result of the model loading
  43654. */
  43655. loadModel(): Promise<boolean>;
  43656. /**
  43657. * Update the model itself with the current frame data
  43658. * @param xrFrame the frame to use for updating the model mesh
  43659. */
  43660. protected updateModel(xrFrame: XRFrame): void;
  43661. /**
  43662. * Moves the axis on the controller mesh based on its current state
  43663. * @param axis the index of the axis
  43664. * @param axisValue the value of the axis which determines the meshes new position
  43665. * @hidden
  43666. */
  43667. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  43668. /**
  43669. * Moves the buttons on the controller mesh based on their current state
  43670. * @param buttonName the name of the button to move
  43671. * @param buttonValue the value of the button which determines the buttons new position
  43672. */
  43673. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  43674. private _getGenericFilenameAndPath;
  43675. private _getGenericParentMesh;
  43676. /**
  43677. * Get the filename and path for this controller's model
  43678. * @returns a map of filename and path
  43679. */
  43680. protected abstract _getFilenameAndPath(): {
  43681. filename: string;
  43682. path: string;
  43683. };
  43684. /**
  43685. * This function will be called after the model was successfully loaded and can be used
  43686. * for mesh transformations before it is available for the user
  43687. * @param meshes the loaded meshes
  43688. */
  43689. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43690. /**
  43691. * Set the root mesh for this controller. Important for the WebXR controller class
  43692. * @param meshes the loaded meshes
  43693. */
  43694. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43695. /**
  43696. * A function executed each frame that updates the mesh (if needed)
  43697. * @param xrFrame the current xrFrame
  43698. */
  43699. protected abstract _updateModel(xrFrame: XRFrame): void;
  43700. /**
  43701. * This function is called before the mesh is loaded. It checks for loading constraints.
  43702. * For example, this function can check if the GLB loader is available
  43703. * If this function returns false, the generic controller will be loaded instead
  43704. * @returns Is the client ready to load the mesh
  43705. */
  43706. protected abstract _getModelLoadingConstraints(): boolean;
  43707. /**
  43708. * Dispose this controller, the model mesh and all its components
  43709. */
  43710. dispose(): void;
  43711. }
  43712. }
  43713. declare module BABYLON {
  43714. /**
  43715. * A generic trigger-only motion controller for WebXR
  43716. */
  43717. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43718. /**
  43719. * Static version of the profile id of this controller
  43720. */
  43721. static ProfileId: string;
  43722. profileId: string;
  43723. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43724. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43725. protected _updateModel(): void;
  43726. protected _getFilenameAndPath(): {
  43727. filename: string;
  43728. path: string;
  43729. };
  43730. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43731. protected _getModelLoadingConstraints(): boolean;
  43732. }
  43733. }
  43734. declare module BABYLON {
  43735. /**
  43736. * A construction function type to create a new controller based on an xrInput object
  43737. */
  43738. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  43739. /**
  43740. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  43741. *
  43742. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  43743. * it should be replaced with auto-loaded controllers.
  43744. *
  43745. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  43746. */
  43747. export class WebXRMotionControllerManager {
  43748. private static _AvailableControllers;
  43749. private static _Fallbacks;
  43750. /**
  43751. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  43752. *
  43753. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  43754. *
  43755. * @param type the profile type to register
  43756. * @param constructFunction the function to be called when loading this profile
  43757. */
  43758. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  43759. /**
  43760. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  43761. * The order of search:
  43762. *
  43763. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  43764. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  43765. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  43766. * 4) return the generic trigger controller if none were found
  43767. *
  43768. * @param xrInput the xrInput to which a new controller is initialized
  43769. * @param scene the scene to which the model will be added
  43770. * @param forceProfile force a certain profile for this controller
  43771. * @return the motion controller class for this profile id or the generic standard class if none was found
  43772. */
  43773. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  43774. /**
  43775. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  43776. * @param profileId the profile to which a fallback needs to be found
  43777. * @return an array with corresponding fallback profiles
  43778. */
  43779. static FindFallbackWithProfileId(profileId: string): string[];
  43780. /**
  43781. * Register a fallback to a specific profile.
  43782. * @param profileId the profileId that will receive the fallbacks
  43783. * @param fallbacks A list of fallback profiles
  43784. */
  43785. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  43786. /**
  43787. * Register the default fallbacks.
  43788. * This function is called automatically when this file is imported.
  43789. */
  43790. static DefaultFallbacks(): void;
  43791. }
  43792. }
  43793. declare module BABYLON {
  43794. /**
  43795. * Configuration options for the WebXR controller creation
  43796. */
  43797. export interface IWebXRControllerOptions {
  43798. /**
  43799. * Force a specific controller type for this controller.
  43800. * This can be used when creating your own profile or when testing different controllers
  43801. */
  43802. forceControllerProfile?: string;
  43803. }
  43804. /**
  43805. * Represents an XR controller
  43806. */
  43807. export class WebXRController {
  43808. private _scene;
  43809. /** The underlying input source for the controller */
  43810. inputSource: XRInputSource;
  43811. private _options;
  43812. /**
  43813. * 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
  43814. */
  43815. grip?: AbstractMesh;
  43816. /**
  43817. * Pointer which can be used to select objects or attach a visible laser to
  43818. */
  43819. pointer: AbstractMesh;
  43820. /**
  43821. * If available, this is the gamepad object related to this controller.
  43822. * Using this object it is possible to get click events and trackpad changes of the
  43823. * webxr controller that is currently being used.
  43824. */
  43825. motionController?: WebXRAbstractMotionController;
  43826. /**
  43827. * Event that fires when the controller is removed/disposed
  43828. */
  43829. onDisposeObservable: Observable<{}>;
  43830. private _tmpQuaternion;
  43831. private _tmpVector;
  43832. private _uniqueId;
  43833. /**
  43834. * Creates the controller
  43835. * @see https://doc.babylonjs.com/how_to/webxr
  43836. * @param _scene the scene which the controller should be associated to
  43837. * @param inputSource the underlying input source for the controller
  43838. * @param _options options for this controller creation
  43839. */
  43840. constructor(_scene: Scene,
  43841. /** The underlying input source for the controller */
  43842. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  43843. /**
  43844. * Get this controllers unique id
  43845. */
  43846. get uniqueId(): string;
  43847. /**
  43848. * Updates the controller pose based on the given XRFrame
  43849. * @param xrFrame xr frame to update the pose with
  43850. * @param referenceSpace reference space to use
  43851. */
  43852. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43853. /**
  43854. * Gets a world space ray coming from the controller
  43855. * @param result the resulting ray
  43856. */
  43857. getWorldPointerRayToRef(result: Ray): void;
  43858. /**
  43859. * Disposes of the object
  43860. */
  43861. dispose(): void;
  43862. }
  43863. }
  43864. declare module BABYLON {
  43865. /**
  43866. * The schema for initialization options of the XR Input class
  43867. */
  43868. export interface IWebXRInputOptions {
  43869. /**
  43870. * If set to true no model will be automatically loaded
  43871. */
  43872. doNotLoadControllerMeshes?: boolean;
  43873. /**
  43874. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  43875. * If not found, the xr input profile data will be used.
  43876. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  43877. */
  43878. forceInputProfile?: string;
  43879. }
  43880. /**
  43881. * XR input used to track XR inputs such as controllers/rays
  43882. */
  43883. export class WebXRInput implements IDisposable {
  43884. /**
  43885. * the xr session manager for this session
  43886. */
  43887. xrSessionManager: WebXRSessionManager;
  43888. /**
  43889. * the WebXR camera for this session. Mainly used for teleportation
  43890. */
  43891. xrCamera: WebXRCamera;
  43892. private readonly options;
  43893. /**
  43894. * XR controllers being tracked
  43895. */
  43896. controllers: Array<WebXRController>;
  43897. private _frameObserver;
  43898. private _sessionEndedObserver;
  43899. private _sessionInitObserver;
  43900. /**
  43901. * Event when a controller has been connected/added
  43902. */
  43903. onControllerAddedObservable: Observable<WebXRController>;
  43904. /**
  43905. * Event when a controller has been removed/disconnected
  43906. */
  43907. onControllerRemovedObservable: Observable<WebXRController>;
  43908. /**
  43909. * Initializes the WebXRInput
  43910. * @param xrSessionManager the xr session manager for this session
  43911. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  43912. * @param options = initialization options for this xr input
  43913. */
  43914. constructor(
  43915. /**
  43916. * the xr session manager for this session
  43917. */
  43918. xrSessionManager: WebXRSessionManager,
  43919. /**
  43920. * the WebXR camera for this session. Mainly used for teleportation
  43921. */
  43922. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  43923. private _onInputSourcesChange;
  43924. private _addAndRemoveControllers;
  43925. /**
  43926. * Disposes of the object
  43927. */
  43928. dispose(): void;
  43929. }
  43930. }
  43931. declare module BABYLON {
  43932. /**
  43933. * This is the base class for all WebXR features.
  43934. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  43935. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  43936. */
  43937. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  43938. protected _xrSessionManager: WebXRSessionManager;
  43939. /**
  43940. * Construct a new (abstract) webxr feature
  43941. * @param _xrSessionManager the xr session manager for this feature
  43942. */
  43943. constructor(_xrSessionManager: WebXRSessionManager);
  43944. private _attached;
  43945. private _removeOnDetach;
  43946. /**
  43947. * Is this feature attached
  43948. */
  43949. get attached(): boolean;
  43950. /**
  43951. * attach this feature
  43952. *
  43953. * @returns true if successful, false is failed or already attached
  43954. */
  43955. attach(): boolean;
  43956. /**
  43957. * detach this feature.
  43958. *
  43959. * @returns true if successful, false if failed or already detached
  43960. */
  43961. detach(): boolean;
  43962. /**
  43963. * Dispose this feature and all of the resources attached
  43964. */
  43965. dispose(): void;
  43966. /**
  43967. * Code in this function will be executed on each xrFrame received from the browser.
  43968. * This function will not execute after the feature is detached.
  43969. * @param _xrFrame the current frame
  43970. */
  43971. protected _onXRFrame(_xrFrame: XRFrame): void;
  43972. /**
  43973. * This is used to register callbacks that will automatically be removed when detach is called.
  43974. * @param observable the observable to which the observer will be attached
  43975. * @param callback the callback to register
  43976. */
  43977. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  43978. }
  43979. }
  43980. declare module BABYLON {
  43981. /**
  43982. * Options interface for the pointer selection module
  43983. */
  43984. export interface IWebXRControllerPointerSelectionOptions {
  43985. /**
  43986. * the xr input to use with this pointer selection
  43987. */
  43988. xrInput: WebXRInput;
  43989. /**
  43990. * Different button type to use instead of the main component
  43991. */
  43992. overrideButtonId?: string;
  43993. /**
  43994. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  43995. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  43996. * 3000 means 3 seconds between pointing at something and selecting it
  43997. */
  43998. timeToSelect?: number;
  43999. /**
  44000. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44001. * If not disabled, the last picked point will be used to execute a pointer up event
  44002. * If disabled, pointer up event will be triggered right after the pointer down event.
  44003. * Used in screen and gaze target ray mode only
  44004. */
  44005. disablePointerUpOnTouchOut: boolean;
  44006. /**
  44007. * For gaze mode (time to select instead of press)
  44008. */
  44009. forceGazeMode: boolean;
  44010. /**
  44011. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44012. * to start a new countdown to the pointer down event.
  44013. * Defaults to 1.
  44014. */
  44015. gazeModePointerMovedFactor?: number;
  44016. }
  44017. /**
  44018. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44019. */
  44020. export class WebXRControllerPointerSelection extends WebXRAbstractFeature implements IWebXRFeature {
  44021. private readonly _options;
  44022. /**
  44023. * The module's name
  44024. */
  44025. static readonly Name: string;
  44026. /**
  44027. * The (Babylon) version of this module.
  44028. * This is an integer representing the implementation version.
  44029. * This number does not correspond to the webxr specs version
  44030. */
  44031. static readonly Version: number;
  44032. /**
  44033. * This color will be set to the laser pointer when selection is triggered
  44034. */
  44035. laserPointerPickedColor: Color3;
  44036. /**
  44037. * This color will be applied to the selection ring when selection is triggered
  44038. */
  44039. selectionMeshPickedColor: Color3;
  44040. /**
  44041. * default color of the selection ring
  44042. */
  44043. selectionMeshDefaultColor: Color3;
  44044. /**
  44045. * Default color of the laser pointer
  44046. */
  44047. lasterPointerDefaultColor: Color3;
  44048. /**
  44049. * Should the laser pointer be displayed
  44050. */
  44051. displayLaserPointer: boolean;
  44052. /**
  44053. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44054. */
  44055. displaySelectionMesh: boolean;
  44056. /**
  44057. * Disable lighting on the laser pointer (so it will always be visible)
  44058. */
  44059. disablePointerLighting: boolean;
  44060. /**
  44061. * Disable lighting on the selection mesh (so it will always be visible)
  44062. */
  44063. disableSelectionMeshLighting: boolean;
  44064. private static _idCounter;
  44065. private _tmpRay;
  44066. private _controllers;
  44067. private _scene;
  44068. /**
  44069. * constructs a new background remover module
  44070. * @param _xrSessionManager the session manager for this module
  44071. * @param _options read-only options to be used in this module
  44072. */
  44073. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44074. /**
  44075. * attach this feature
  44076. * Will usually be called by the features manager
  44077. *
  44078. * @returns true if successful.
  44079. */
  44080. attach(): boolean;
  44081. /**
  44082. * detach this feature.
  44083. * Will usually be called by the features manager
  44084. *
  44085. * @returns true if successful.
  44086. */
  44087. detach(): boolean;
  44088. /**
  44089. * Get the xr controller that correlates to the pointer id in the pointer event
  44090. *
  44091. * @param id the pointer id to search for
  44092. * @returns the controller that correlates to this id or null if not found
  44093. */
  44094. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  44095. protected _onXRFrame(_xrFrame: XRFrame): void;
  44096. private _attachController;
  44097. private _attachScreenRayMode;
  44098. private _attachGazeMode;
  44099. private _tmpVectorForPickCompare;
  44100. private _pickingMoved;
  44101. private _attachTrackedPointerRayMode;
  44102. private _detachController;
  44103. private _generateNewMeshPair;
  44104. private _convertNormalToDirectionOfRay;
  44105. private _updatePointerDistance;
  44106. }
  44107. }
  44108. declare module BABYLON {
  44109. /**
  44110. * Button which can be used to enter a different mode of XR
  44111. */
  44112. export class WebXREnterExitUIButton {
  44113. /** button element */
  44114. element: HTMLElement;
  44115. /** XR initialization options for the button */
  44116. sessionMode: XRSessionMode;
  44117. /** Reference space type */
  44118. referenceSpaceType: XRReferenceSpaceType;
  44119. /**
  44120. * Creates a WebXREnterExitUIButton
  44121. * @param element button element
  44122. * @param sessionMode XR initialization session mode
  44123. * @param referenceSpaceType the type of reference space to be used
  44124. */
  44125. constructor(
  44126. /** button element */
  44127. element: HTMLElement,
  44128. /** XR initialization options for the button */
  44129. sessionMode: XRSessionMode,
  44130. /** Reference space type */
  44131. referenceSpaceType: XRReferenceSpaceType);
  44132. /**
  44133. * Overwritable function which can be used to update the button's visuals when the state changes
  44134. * @param activeButton the current active button in the UI
  44135. */
  44136. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44137. }
  44138. /**
  44139. * Options to create the webXR UI
  44140. */
  44141. export class WebXREnterExitUIOptions {
  44142. /**
  44143. * Context to enter xr with
  44144. */
  44145. renderTarget?: Nullable<WebXRRenderTarget>;
  44146. /**
  44147. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44148. */
  44149. customButtons?: Array<WebXREnterExitUIButton>;
  44150. /**
  44151. * A session mode to use when creating the default button.
  44152. * Default is immersive-vr
  44153. */
  44154. sessionMode?: XRSessionMode;
  44155. /**
  44156. * A reference space type to use when creating the default button.
  44157. * Default is local-floor
  44158. */
  44159. referenceSpaceType?: XRReferenceSpaceType;
  44160. }
  44161. /**
  44162. * UI to allow the user to enter/exit XR mode
  44163. */
  44164. export class WebXREnterExitUI implements IDisposable {
  44165. private scene;
  44166. /** version of the options passed to this UI */
  44167. options: WebXREnterExitUIOptions;
  44168. private _overlay;
  44169. private _buttons;
  44170. private _activeButton;
  44171. /**
  44172. * Fired every time the active button is changed.
  44173. *
  44174. * When xr is entered via a button that launches xr that button will be the callback parameter
  44175. *
  44176. * When exiting xr the callback parameter will be null)
  44177. */
  44178. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44179. /**
  44180. * Creates UI to allow the user to enter/exit XR mode
  44181. * @param scene the scene to add the ui to
  44182. * @param helper the xr experience helper to enter/exit xr with
  44183. * @param options options to configure the UI
  44184. * @returns the created ui
  44185. */
  44186. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44187. /**
  44188. *
  44189. * @param scene babylon scene object to use
  44190. * @param options (read-only) version of the options passed to this UI
  44191. */
  44192. private constructor();
  44193. private _updateButtons;
  44194. /**
  44195. * Disposes of the object
  44196. */
  44197. dispose(): void;
  44198. }
  44199. }
  44200. declare module BABYLON {
  44201. /**
  44202. * Class containing static functions to help procedurally build meshes
  44203. */
  44204. export class LinesBuilder {
  44205. /**
  44206. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44207. * * 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
  44208. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44209. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44210. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44211. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44212. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44213. * * 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
  44214. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44217. * @param name defines the name of the new line system
  44218. * @param options defines the options used to create the line system
  44219. * @param scene defines the hosting scene
  44220. * @returns a new line system mesh
  44221. */
  44222. static CreateLineSystem(name: string, options: {
  44223. lines: Vector3[][];
  44224. updatable?: boolean;
  44225. instance?: Nullable<LinesMesh>;
  44226. colors?: Nullable<Color4[][]>;
  44227. useVertexAlpha?: boolean;
  44228. }, scene: Nullable<Scene>): LinesMesh;
  44229. /**
  44230. * Creates a line mesh
  44231. * 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
  44232. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44233. * * The parameter `points` is an array successive Vector3
  44234. * * 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
  44235. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44236. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44237. * * When updating an instance, remember that only point positions can change, not the number of points
  44238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44240. * @param name defines the name of the new line system
  44241. * @param options defines the options used to create the line system
  44242. * @param scene defines the hosting scene
  44243. * @returns a new line mesh
  44244. */
  44245. static CreateLines(name: string, options: {
  44246. points: Vector3[];
  44247. updatable?: boolean;
  44248. instance?: Nullable<LinesMesh>;
  44249. colors?: Color4[];
  44250. useVertexAlpha?: boolean;
  44251. }, scene?: Nullable<Scene>): LinesMesh;
  44252. /**
  44253. * Creates a dashed line mesh
  44254. * * 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
  44255. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44256. * * The parameter `points` is an array successive Vector3
  44257. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44258. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44259. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44260. * * 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
  44261. * * When updating an instance, remember that only point positions can change, not the number of points
  44262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44263. * @param name defines the name of the mesh
  44264. * @param options defines the options used to create the mesh
  44265. * @param scene defines the hosting scene
  44266. * @returns the dashed line mesh
  44267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44268. */
  44269. static CreateDashedLines(name: string, options: {
  44270. points: Vector3[];
  44271. dashSize?: number;
  44272. gapSize?: number;
  44273. dashNb?: number;
  44274. updatable?: boolean;
  44275. instance?: LinesMesh;
  44276. }, scene?: Nullable<Scene>): LinesMesh;
  44277. }
  44278. }
  44279. declare module BABYLON {
  44280. /**
  44281. * The options container for the teleportation module
  44282. */
  44283. export interface IWebXRTeleportationOptions {
  44284. /**
  44285. * Babylon XR Input class for controller
  44286. */
  44287. xrInput: WebXRInput;
  44288. /**
  44289. * A list of meshes to use as floor meshes.
  44290. * Meshes can be added and removed after initializing the feature using the
  44291. * addFloorMesh and removeFloorMesh functions
  44292. * If empty, rotation will still work
  44293. */
  44294. floorMeshes?: AbstractMesh[];
  44295. /**
  44296. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44297. * If you want to support rotation, make sure your mesh has a direction indicator.
  44298. *
  44299. * When left untouched, the default mesh will be initialized.
  44300. */
  44301. teleportationTargetMesh?: AbstractMesh;
  44302. /**
  44303. * Values to configure the default target mesh
  44304. */
  44305. defaultTargetMeshOptions?: {
  44306. /**
  44307. * Fill color of the teleportation area
  44308. */
  44309. teleportationFillColor?: string;
  44310. /**
  44311. * Border color for the teleportation area
  44312. */
  44313. teleportationBorderColor?: string;
  44314. /**
  44315. * Override the default material of the torus and arrow
  44316. */
  44317. torusArrowMaterial?: Material;
  44318. /**
  44319. * Disable the mesh's animation sequence
  44320. */
  44321. disableAnimation?: boolean;
  44322. };
  44323. /**
  44324. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44325. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44326. */
  44327. useMainComponentOnly?: boolean;
  44328. /**
  44329. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44330. */
  44331. timeToTeleport?: number;
  44332. }
  44333. /**
  44334. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44335. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44336. * the input of the attached controllers.
  44337. */
  44338. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature implements IWebXRFeature {
  44339. private _options;
  44340. /**
  44341. * The module's name
  44342. */
  44343. static readonly Name: string;
  44344. /**
  44345. * The (Babylon) version of this module.
  44346. * This is an integer representing the implementation version.
  44347. * This number does not correspond to the webxr specs version
  44348. */
  44349. static readonly Version: number;
  44350. /**
  44351. * Is rotation enabled when moving forward?
  44352. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44353. */
  44354. rotationEnabled: boolean;
  44355. /**
  44356. * Should the module support parabolic ray on top of direct ray
  44357. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44358. * Very helpful when moving between floors / different heights
  44359. */
  44360. parabolicRayEnabled: boolean;
  44361. /**
  44362. * The distance from the user to the inspection point in the direction of the controller
  44363. * A higher number will allow the user to move further
  44364. * defaults to 5 (meters, in xr units)
  44365. */
  44366. parabolicCheckRadius: number;
  44367. /**
  44368. * How much rotation should be applied when rotating right and left
  44369. */
  44370. rotationAngle: number;
  44371. /**
  44372. * Distance to travel when moving backwards
  44373. */
  44374. backwardsTeleportationDistance: number;
  44375. /**
  44376. * Add a new mesh to the floor meshes array
  44377. * @param mesh the mesh to use as floor mesh
  44378. */
  44379. addFloorMesh(mesh: AbstractMesh): void;
  44380. /**
  44381. * Remove a mesh from the floor meshes array
  44382. * @param mesh the mesh to remove
  44383. */
  44384. removeFloorMesh(mesh: AbstractMesh): void;
  44385. /**
  44386. * Remove a mesh from the floor meshes array using its name
  44387. * @param name the mesh name to remove
  44388. */
  44389. removeFloorMeshByName(name: string): void;
  44390. private _tmpRay;
  44391. private _tmpVector;
  44392. private _floorMeshes;
  44393. private _controllers;
  44394. /**
  44395. * constructs a new anchor system
  44396. * @param _xrSessionManager an instance of WebXRSessionManager
  44397. * @param _options configuration object for this feature
  44398. */
  44399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44400. private _selectionFeature;
  44401. /**
  44402. * This function sets a selection feature that will be disabled when
  44403. * the forward ray is shown and will be reattached when hidden.
  44404. * This is used to remove the selection rays when moving.
  44405. * @param selectionFeature the feature to disable when forward movement is enabled
  44406. */
  44407. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44408. attach(): boolean;
  44409. detach(): boolean;
  44410. dispose(): void;
  44411. protected _onXRFrame(_xrFrame: XRFrame): void;
  44412. private _currentTeleportationControllerId;
  44413. private _attachController;
  44414. private _teleportForward;
  44415. private _detachController;
  44416. private createDefaultTargetMesh;
  44417. private setTargetMeshVisibility;
  44418. private setTargetMeshPosition;
  44419. private _quadraticBezierCurve;
  44420. private showParabolicPath;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * Options for the default xr helper
  44426. */
  44427. export class WebXRDefaultExperienceOptions {
  44428. /**
  44429. * Floor meshes that will be used for teleporting
  44430. */
  44431. floorMeshes?: Array<AbstractMesh>;
  44432. /**
  44433. * Enable or disable default UI to enter XR
  44434. */
  44435. disableDefaultUI?: boolean;
  44436. /**
  44437. * optional configuration for the output canvas
  44438. */
  44439. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44440. /**
  44441. * optional UI options. This can be used among other to change session mode and reference space type
  44442. */
  44443. uiOptions?: WebXREnterExitUIOptions;
  44444. /**
  44445. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44446. */
  44447. inputOptions?: IWebXRInputOptions;
  44448. /**
  44449. * Should teleportation not initialize. defaults to false.
  44450. */
  44451. disableTeleportation?: boolean;
  44452. }
  44453. /**
  44454. * Default experience which provides a similar setup to the previous webVRExperience
  44455. */
  44456. export class WebXRDefaultExperience {
  44457. /**
  44458. * Base experience
  44459. */
  44460. baseExperience: WebXRExperienceHelper;
  44461. /**
  44462. * Input experience extension
  44463. */
  44464. input: WebXRInput;
  44465. /**
  44466. * Enables laser pointer and selection
  44467. */
  44468. pointerSelection: WebXRControllerPointerSelection;
  44469. /**
  44470. * Enables teleportation
  44471. */
  44472. teleportation: WebXRMotionControllerTeleportation;
  44473. /**
  44474. * Enables ui for entering/exiting xr
  44475. */
  44476. enterExitUI: WebXREnterExitUI;
  44477. /**
  44478. * Default target xr should render to
  44479. */
  44480. renderTarget: WebXRRenderTarget;
  44481. /**
  44482. * Creates the default xr experience
  44483. * @param scene scene
  44484. * @param options options for basic configuration
  44485. * @returns resulting WebXRDefaultExperience
  44486. */
  44487. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44488. private constructor();
  44489. /**
  44490. * DIsposes of the experience helper
  44491. */
  44492. dispose(): void;
  44493. }
  44494. }
  44495. declare module BABYLON {
  44496. /**
  44497. * Options to modify the vr teleportation behavior.
  44498. */
  44499. export interface VRTeleportationOptions {
  44500. /**
  44501. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44502. */
  44503. floorMeshName?: string;
  44504. /**
  44505. * A list of meshes to be used as the teleportation floor. (default: empty)
  44506. */
  44507. floorMeshes?: Mesh[];
  44508. /**
  44509. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44510. */
  44511. teleportationMode?: number;
  44512. /**
  44513. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44514. */
  44515. teleportationTime?: number;
  44516. /**
  44517. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44518. */
  44519. teleportationSpeed?: number;
  44520. /**
  44521. * The easing function used in the animation or null for Linear. (default CircleEase)
  44522. */
  44523. easingFunction?: EasingFunction;
  44524. }
  44525. /**
  44526. * Options to modify the vr experience helper's behavior.
  44527. */
  44528. export interface VRExperienceHelperOptions extends WebVROptions {
  44529. /**
  44530. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44531. */
  44532. createDeviceOrientationCamera?: boolean;
  44533. /**
  44534. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44535. */
  44536. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44537. /**
  44538. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44539. */
  44540. laserToggle?: boolean;
  44541. /**
  44542. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44543. */
  44544. floorMeshes?: Mesh[];
  44545. /**
  44546. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44547. */
  44548. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44549. /**
  44550. * Defines if WebXR should be used instead of WebVR (if available)
  44551. */
  44552. useXR?: boolean;
  44553. }
  44554. /**
  44555. * Event containing information after VR has been entered
  44556. */
  44557. export class OnAfterEnteringVRObservableEvent {
  44558. /**
  44559. * If entering vr was successful
  44560. */
  44561. success: boolean;
  44562. }
  44563. /**
  44564. * Helps to quickly add VR support to an existing scene.
  44565. * See http://doc.babylonjs.com/how_to/webvr_helper
  44566. */
  44567. export class VRExperienceHelper {
  44568. /** Options to modify the vr experience helper's behavior. */
  44569. webVROptions: VRExperienceHelperOptions;
  44570. private _scene;
  44571. private _position;
  44572. private _btnVR;
  44573. private _btnVRDisplayed;
  44574. private _webVRsupported;
  44575. private _webVRready;
  44576. private _webVRrequesting;
  44577. private _webVRpresenting;
  44578. private _hasEnteredVR;
  44579. private _fullscreenVRpresenting;
  44580. private _inputElement;
  44581. private _webVRCamera;
  44582. private _vrDeviceOrientationCamera;
  44583. private _deviceOrientationCamera;
  44584. private _existingCamera;
  44585. private _onKeyDown;
  44586. private _onVrDisplayPresentChange;
  44587. private _onVRDisplayChanged;
  44588. private _onVRRequestPresentStart;
  44589. private _onVRRequestPresentComplete;
  44590. /**
  44591. * 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)
  44592. */
  44593. enableGazeEvenWhenNoPointerLock: boolean;
  44594. /**
  44595. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44596. */
  44597. exitVROnDoubleTap: boolean;
  44598. /**
  44599. * Observable raised right before entering VR.
  44600. */
  44601. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44602. /**
  44603. * Observable raised when entering VR has completed.
  44604. */
  44605. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44606. /**
  44607. * Observable raised when exiting VR.
  44608. */
  44609. onExitingVRObservable: Observable<VRExperienceHelper>;
  44610. /**
  44611. * Observable raised when controller mesh is loaded.
  44612. */
  44613. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44614. /** Return this.onEnteringVRObservable
  44615. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44616. */
  44617. get onEnteringVR(): Observable<VRExperienceHelper>;
  44618. /** Return this.onExitingVRObservable
  44619. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44620. */
  44621. get onExitingVR(): Observable<VRExperienceHelper>;
  44622. /** Return this.onControllerMeshLoadedObservable
  44623. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44624. */
  44625. get onControllerMeshLoaded(): Observable<WebVRController>;
  44626. private _rayLength;
  44627. private _useCustomVRButton;
  44628. private _teleportationRequested;
  44629. private _teleportActive;
  44630. private _floorMeshName;
  44631. private _floorMeshesCollection;
  44632. private _teleportationMode;
  44633. private _teleportationTime;
  44634. private _teleportationSpeed;
  44635. private _teleportationEasing;
  44636. private _rotationAllowed;
  44637. private _teleportBackwardsVector;
  44638. private _teleportationTarget;
  44639. private _isDefaultTeleportationTarget;
  44640. private _postProcessMove;
  44641. private _teleportationFillColor;
  44642. private _teleportationBorderColor;
  44643. private _rotationAngle;
  44644. private _haloCenter;
  44645. private _cameraGazer;
  44646. private _padSensibilityUp;
  44647. private _padSensibilityDown;
  44648. private _leftController;
  44649. private _rightController;
  44650. private _gazeColor;
  44651. private _laserColor;
  44652. private _pickedLaserColor;
  44653. private _pickedGazeColor;
  44654. /**
  44655. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44656. */
  44657. onNewMeshSelected: Observable<AbstractMesh>;
  44658. /**
  44659. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44660. * This observable will provide the mesh and the controller used to select the mesh
  44661. */
  44662. onMeshSelectedWithController: Observable<{
  44663. mesh: AbstractMesh;
  44664. controller: WebVRController;
  44665. }>;
  44666. /**
  44667. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44668. */
  44669. onNewMeshPicked: Observable<PickingInfo>;
  44670. private _circleEase;
  44671. /**
  44672. * Observable raised before camera teleportation
  44673. */
  44674. onBeforeCameraTeleport: Observable<Vector3>;
  44675. /**
  44676. * Observable raised after camera teleportation
  44677. */
  44678. onAfterCameraTeleport: Observable<Vector3>;
  44679. /**
  44680. * Observable raised when current selected mesh gets unselected
  44681. */
  44682. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44683. private _raySelectionPredicate;
  44684. /**
  44685. * To be optionaly changed by user to define custom ray selection
  44686. */
  44687. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44688. /**
  44689. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44690. */
  44691. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44692. /**
  44693. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44694. */
  44695. teleportationEnabled: boolean;
  44696. private _defaultHeight;
  44697. private _teleportationInitialized;
  44698. private _interactionsEnabled;
  44699. private _interactionsRequested;
  44700. private _displayGaze;
  44701. private _displayLaserPointer;
  44702. /**
  44703. * The mesh used to display where the user is going to teleport.
  44704. */
  44705. get teleportationTarget(): Mesh;
  44706. /**
  44707. * Sets the mesh to be used to display where the user is going to teleport.
  44708. */
  44709. set teleportationTarget(value: Mesh);
  44710. /**
  44711. * 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
  44712. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44713. * See http://doc.babylonjs.com/resources/baking_transformations
  44714. */
  44715. get gazeTrackerMesh(): Mesh;
  44716. set gazeTrackerMesh(value: Mesh);
  44717. /**
  44718. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44719. */
  44720. updateGazeTrackerScale: boolean;
  44721. /**
  44722. * If the gaze trackers color should be updated when selecting meshes
  44723. */
  44724. updateGazeTrackerColor: boolean;
  44725. /**
  44726. * If the controller laser color should be updated when selecting meshes
  44727. */
  44728. updateControllerLaserColor: boolean;
  44729. /**
  44730. * The gaze tracking mesh corresponding to the left controller
  44731. */
  44732. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44733. /**
  44734. * The gaze tracking mesh corresponding to the right controller
  44735. */
  44736. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44737. /**
  44738. * If the ray of the gaze should be displayed.
  44739. */
  44740. get displayGaze(): boolean;
  44741. /**
  44742. * Sets if the ray of the gaze should be displayed.
  44743. */
  44744. set displayGaze(value: boolean);
  44745. /**
  44746. * If the ray of the LaserPointer should be displayed.
  44747. */
  44748. get displayLaserPointer(): boolean;
  44749. /**
  44750. * Sets if the ray of the LaserPointer should be displayed.
  44751. */
  44752. set displayLaserPointer(value: boolean);
  44753. /**
  44754. * The deviceOrientationCamera used as the camera when not in VR.
  44755. */
  44756. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44757. /**
  44758. * Based on the current WebVR support, returns the current VR camera used.
  44759. */
  44760. get currentVRCamera(): Nullable<Camera>;
  44761. /**
  44762. * The webVRCamera which is used when in VR.
  44763. */
  44764. get webVRCamera(): WebVRFreeCamera;
  44765. /**
  44766. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44767. */
  44768. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44769. /**
  44770. * The html button that is used to trigger entering into VR.
  44771. */
  44772. get vrButton(): Nullable<HTMLButtonElement>;
  44773. private get _teleportationRequestInitiated();
  44774. /**
  44775. * Defines wether or not Pointer lock should be requested when switching to
  44776. * full screen.
  44777. */
  44778. requestPointerLockOnFullScreen: boolean;
  44779. /**
  44780. * If asking to force XR, this will be populated with the default xr experience
  44781. */
  44782. xr: WebXRDefaultExperience;
  44783. /**
  44784. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44785. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44786. */
  44787. xrTestDone: boolean;
  44788. /**
  44789. * Instantiates a VRExperienceHelper.
  44790. * Helps to quickly add VR support to an existing scene.
  44791. * @param scene The scene the VRExperienceHelper belongs to.
  44792. * @param webVROptions Options to modify the vr experience helper's behavior.
  44793. */
  44794. constructor(scene: Scene,
  44795. /** Options to modify the vr experience helper's behavior. */
  44796. webVROptions?: VRExperienceHelperOptions);
  44797. private completeVRInit;
  44798. private _onDefaultMeshLoaded;
  44799. private _onResize;
  44800. private _onFullscreenChange;
  44801. /**
  44802. * Gets a value indicating if we are currently in VR mode.
  44803. */
  44804. get isInVRMode(): boolean;
  44805. private onVrDisplayPresentChange;
  44806. private onVRDisplayChanged;
  44807. private moveButtonToBottomRight;
  44808. private displayVRButton;
  44809. private updateButtonVisibility;
  44810. private _cachedAngularSensibility;
  44811. /**
  44812. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44813. * Otherwise, will use the fullscreen API.
  44814. */
  44815. enterVR(): void;
  44816. /**
  44817. * Attempt to exit VR, or fullscreen.
  44818. */
  44819. exitVR(): void;
  44820. /**
  44821. * The position of the vr experience helper.
  44822. */
  44823. get position(): Vector3;
  44824. /**
  44825. * Sets the position of the vr experience helper.
  44826. */
  44827. set position(value: Vector3);
  44828. /**
  44829. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44830. */
  44831. enableInteractions(): void;
  44832. private get _noControllerIsActive();
  44833. private beforeRender;
  44834. private _isTeleportationFloor;
  44835. /**
  44836. * Adds a floor mesh to be used for teleportation.
  44837. * @param floorMesh the mesh to be used for teleportation.
  44838. */
  44839. addFloorMesh(floorMesh: Mesh): void;
  44840. /**
  44841. * Removes a floor mesh from being used for teleportation.
  44842. * @param floorMesh the mesh to be removed.
  44843. */
  44844. removeFloorMesh(floorMesh: Mesh): void;
  44845. /**
  44846. * Enables interactions and teleportation using the VR controllers and gaze.
  44847. * @param vrTeleportationOptions options to modify teleportation behavior.
  44848. */
  44849. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44850. private _onNewGamepadConnected;
  44851. private _tryEnableInteractionOnController;
  44852. private _onNewGamepadDisconnected;
  44853. private _enableInteractionOnController;
  44854. private _checkTeleportWithRay;
  44855. private _checkRotate;
  44856. private _checkTeleportBackwards;
  44857. private _enableTeleportationOnController;
  44858. private _createTeleportationCircles;
  44859. private _displayTeleportationTarget;
  44860. private _hideTeleportationTarget;
  44861. private _rotateCamera;
  44862. private _moveTeleportationSelectorTo;
  44863. private _workingVector;
  44864. private _workingQuaternion;
  44865. private _workingMatrix;
  44866. /**
  44867. * Time Constant Teleportation Mode
  44868. */
  44869. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44870. /**
  44871. * Speed Constant Teleportation Mode
  44872. */
  44873. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44874. /**
  44875. * Teleports the users feet to the desired location
  44876. * @param location The location where the user's feet should be placed
  44877. */
  44878. teleportCamera(location: Vector3): void;
  44879. private _convertNormalToDirectionOfRay;
  44880. private _castRayAndSelectObject;
  44881. private _notifySelectedMeshUnselected;
  44882. /**
  44883. * Permanently set new colors for the laser pointer
  44884. * @param color the new laser color
  44885. * @param pickedColor the new laser color when picked mesh detected
  44886. */
  44887. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44888. /**
  44889. * Set lighting enabled / disabled on the laser pointer of both controllers
  44890. * @param enabled should the lighting be enabled on the laser pointer
  44891. */
  44892. setLaserLightingState(enabled?: boolean): void;
  44893. /**
  44894. * Permanently set new colors for the gaze pointer
  44895. * @param color the new gaze color
  44896. * @param pickedColor the new gaze color when picked mesh detected
  44897. */
  44898. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44899. /**
  44900. * Sets the color of the laser ray from the vr controllers.
  44901. * @param color new color for the ray.
  44902. */
  44903. changeLaserColor(color: Color3): void;
  44904. /**
  44905. * Sets the color of the ray from the vr headsets gaze.
  44906. * @param color new color for the ray.
  44907. */
  44908. changeGazeColor(color: Color3): void;
  44909. /**
  44910. * Exits VR and disposes of the vr experience helper
  44911. */
  44912. dispose(): void;
  44913. /**
  44914. * Gets the name of the VRExperienceHelper class
  44915. * @returns "VRExperienceHelper"
  44916. */
  44917. getClassName(): string;
  44918. }
  44919. }
  44920. declare module BABYLON {
  44921. /**
  44922. * Options used for hit testing
  44923. */
  44924. export interface IWebXRHitTestOptions {
  44925. /**
  44926. * Only test when user interacted with the scene. Default - hit test every frame
  44927. */
  44928. testOnPointerDownOnly?: boolean;
  44929. /**
  44930. * The node to use to transform the local results to world coordinates
  44931. */
  44932. worldParentNode?: TransformNode;
  44933. }
  44934. /**
  44935. * Interface defining the babylon result of raycasting/hit-test
  44936. */
  44937. export interface IWebXRHitResult {
  44938. /**
  44939. * The native hit test result
  44940. */
  44941. xrHitResult: XRHitResult;
  44942. /**
  44943. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44944. */
  44945. transformationMatrix: Matrix;
  44946. }
  44947. /**
  44948. * The currently-working hit-test module.
  44949. * Hit test (or raycasting) is used to interact with the real world.
  44950. * For further information read here - https://github.com/immersive-web/hit-test
  44951. */
  44952. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFeature {
  44953. /**
  44954. * options to use when constructing this feature
  44955. */
  44956. readonly options: IWebXRHitTestOptions;
  44957. /**
  44958. * The module's name
  44959. */
  44960. static readonly Name: string;
  44961. /**
  44962. * The (Babylon) version of this module.
  44963. * This is an integer representing the implementation version.
  44964. * This number does not correspond to the webxr specs version
  44965. */
  44966. static readonly Version: number;
  44967. /**
  44968. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44969. * @param event the (select) event to use to select with
  44970. * @param referenceSpace the reference space to use for this hit test
  44971. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44972. */
  44973. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44974. /**
  44975. * execute a hit test with an XR Ray
  44976. *
  44977. * @param xrSession a native xrSession that will execute this hit test
  44978. * @param xrRay the ray (position and direction) to use for raycasting
  44979. * @param referenceSpace native XR reference space to use for the hit-test
  44980. * @param filter filter function that will filter the results
  44981. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44982. */
  44983. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44984. /**
  44985. * Triggered when new babylon (transformed) hit test results are available
  44986. */
  44987. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44988. private _onSelectEnabled;
  44989. /**
  44990. * Creates a new instance of the (legacy version) hit test feature
  44991. * @param _xrSessionManager an instance of WebXRSessionManager
  44992. * @param options options to use when constructing this feature
  44993. */
  44994. constructor(_xrSessionManager: WebXRSessionManager,
  44995. /**
  44996. * options to use when constructing this feature
  44997. */
  44998. options?: IWebXRHitTestOptions);
  44999. /**
  45000. * Populated with the last native XR Hit Results
  45001. */
  45002. lastNativeXRHitResults: XRHitResult[];
  45003. /**
  45004. * attach this feature
  45005. * Will usually be called by the features manager
  45006. *
  45007. * @returns true if successful.
  45008. */
  45009. attach(): boolean;
  45010. /**
  45011. * detach this feature.
  45012. * Will usually be called by the features manager
  45013. *
  45014. * @returns true if successful.
  45015. */
  45016. detach(): boolean;
  45017. private _onHitTestResults;
  45018. private _origin;
  45019. private _direction;
  45020. private _mat;
  45021. protected _onXRFrame(frame: XRFrame): void;
  45022. private _onSelect;
  45023. /**
  45024. * Dispose this feature and all of the resources attached
  45025. */
  45026. dispose(): void;
  45027. }
  45028. }
  45029. declare module BABYLON {
  45030. /**
  45031. * Options used in the plane detector module
  45032. */
  45033. export interface IWebXRPlaneDetectorOptions {
  45034. /**
  45035. * The node to use to transform the local results to world coordinates
  45036. */
  45037. worldParentNode?: TransformNode;
  45038. }
  45039. /**
  45040. * A babylon interface for a webxr plane.
  45041. * A Plane is actually a polygon, built from N points in space
  45042. */
  45043. export interface IWebXRPlane {
  45044. /**
  45045. * a babylon-assigned ID for this polygon
  45046. */
  45047. id: number;
  45048. /**
  45049. * the native xr-plane object
  45050. */
  45051. xrPlane: XRPlane;
  45052. /**
  45053. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45054. */
  45055. polygonDefinition: Array<Vector3>;
  45056. /**
  45057. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45058. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45059. */
  45060. transformationMatrix: Matrix;
  45061. }
  45062. /**
  45063. * The plane detector is used to detect planes in the real world when in AR
  45064. * For more information see https://github.com/immersive-web/real-world-geometry/
  45065. */
  45066. export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFeature {
  45067. private _options;
  45068. /**
  45069. * The module's name
  45070. */
  45071. static readonly Name: string;
  45072. /**
  45073. * The (Babylon) version of this module.
  45074. * This is an integer representing the implementation version.
  45075. * This number does not correspond to the webxr specs version
  45076. */
  45077. static readonly Version: number;
  45078. /**
  45079. * Observers registered here will be executed when a new plane was added to the session
  45080. */
  45081. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45082. /**
  45083. * Observers registered here will be executed when a plane is no longer detected in the session
  45084. */
  45085. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45086. /**
  45087. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45088. * This can execute N times every frame
  45089. */
  45090. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45091. private _enabled;
  45092. private _detectedPlanes;
  45093. private _lastFrameDetected;
  45094. /**
  45095. * construct a new Plane Detector
  45096. * @param _xrSessionManager an instance of xr Session manager
  45097. * @param _options configuration to use when constructing this feature
  45098. */
  45099. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45100. protected _onXRFrame(frame: XRFrame): void;
  45101. /**
  45102. * Dispose this feature and all of the resources attached
  45103. */
  45104. dispose(): void;
  45105. private _updatePlaneWithXRPlane;
  45106. /**
  45107. * avoiding using Array.find for global support.
  45108. * @param xrPlane the plane to find in the array
  45109. */
  45110. private findIndexInPlaneArray;
  45111. }
  45112. }
  45113. declare module BABYLON {
  45114. /**
  45115. * Configuration options of the anchor system
  45116. */
  45117. export interface IWebXRAnchorSystemOptions {
  45118. /**
  45119. * a node that will be used to convert local to world coordinates
  45120. */
  45121. worldParentNode?: TransformNode;
  45122. /**
  45123. * should the anchor system use plane detection.
  45124. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45125. */
  45126. usePlaneDetection?: boolean;
  45127. /**
  45128. * Should a new anchor be added every time a select event is triggered
  45129. */
  45130. addAnchorOnSelect?: boolean;
  45131. }
  45132. /**
  45133. * A babylon container for an XR Anchor
  45134. */
  45135. export interface IWebXRAnchor {
  45136. /**
  45137. * A babylon-assigned ID for this anchor
  45138. */
  45139. id: number;
  45140. /**
  45141. * The native anchor object
  45142. */
  45143. xrAnchor: XRAnchor;
  45144. /**
  45145. * Transformation matrix to apply to an object attached to this anchor
  45146. */
  45147. transformationMatrix: Matrix;
  45148. }
  45149. /**
  45150. * An implementation of the anchor system of WebXR.
  45151. * Note that the current documented implementation is not available in any browser. Future implementations
  45152. * will use the frame to create an anchor and not the session or a detected plane
  45153. * For further information see https://github.com/immersive-web/anchors/
  45154. */
  45155. export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFeature {
  45156. private _options;
  45157. /**
  45158. * The module's name
  45159. */
  45160. static readonly Name: string;
  45161. /**
  45162. * The (Babylon) version of this module.
  45163. * This is an integer representing the implementation version.
  45164. * This number does not correspond to the webxr specs version
  45165. */
  45166. static readonly Version: number;
  45167. /**
  45168. * Observers registered here will be executed when a new anchor was added to the session
  45169. */
  45170. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45171. /**
  45172. * Observers registered here will be executed when an existing anchor updates
  45173. * This can execute N times every frame
  45174. */
  45175. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45176. /**
  45177. * Observers registered here will be executed when an anchor was removed from the session
  45178. */
  45179. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45180. private _planeDetector;
  45181. private _hitTestModule;
  45182. private _enabled;
  45183. private _trackedAnchors;
  45184. private _lastFrameDetected;
  45185. /**
  45186. * constructs a new anchor system
  45187. * @param _xrSessionManager an instance of WebXRSessionManager
  45188. * @param _options configuration object for this feature
  45189. */
  45190. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45191. /**
  45192. * set the plane detector to use in order to create anchors from frames
  45193. * @param planeDetector the plane-detector module to use
  45194. * @param enable enable plane-anchors. default is true
  45195. */
  45196. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45197. /**
  45198. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  45199. * @param hitTestModule the hit-test module to use.
  45200. */
  45201. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  45202. /**
  45203. * attach this feature
  45204. * Will usually be called by the features manager
  45205. *
  45206. * @returns true if successful.
  45207. */
  45208. attach(): boolean;
  45209. /**
  45210. * detach this feature.
  45211. * Will usually be called by the features manager
  45212. *
  45213. * @returns true if successful.
  45214. */
  45215. detach(): boolean;
  45216. /**
  45217. * Dispose this feature and all of the resources attached
  45218. */
  45219. dispose(): void;
  45220. protected _onXRFrame(frame: XRFrame): void;
  45221. private _onSelect;
  45222. /**
  45223. * Add anchor at a specific XR point.
  45224. *
  45225. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  45226. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  45227. * @returns a promise the fulfills when the anchor was created
  45228. */
  45229. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  45230. private _updateAnchorWithXRFrame;
  45231. /**
  45232. * avoiding using Array.find for global support.
  45233. * @param xrAnchor the plane to find in the array
  45234. */
  45235. private _findIndexInAnchorArray;
  45236. }
  45237. }
  45238. declare module BABYLON {
  45239. /**
  45240. * Options interface for the background remover plugin
  45241. */
  45242. export interface IWebXRBackgroundRemoverOptions {
  45243. /**
  45244. * don't disable the environment helper
  45245. */
  45246. ignoreEnvironmentHelper?: boolean;
  45247. /**
  45248. * flags to configure the removal of the environment helper.
  45249. * If not set, the entire background will be removed. If set, flags should be set as well.
  45250. */
  45251. environmentHelperRemovalFlags?: {
  45252. /**
  45253. * Should the skybox be removed (default false)
  45254. */
  45255. skyBox?: boolean;
  45256. /**
  45257. * Should the ground be removed (default false)
  45258. */
  45259. ground?: boolean;
  45260. };
  45261. /**
  45262. * Further background meshes to disable when entering AR
  45263. */
  45264. backgroundMeshes?: AbstractMesh[];
  45265. }
  45266. /**
  45267. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  45268. */
  45269. export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWebXRFeature {
  45270. /**
  45271. * read-only options to be used in this module
  45272. */
  45273. readonly options: IWebXRBackgroundRemoverOptions;
  45274. /**
  45275. * The module's name
  45276. */
  45277. static readonly Name: string;
  45278. /**
  45279. * The (Babylon) version of this module.
  45280. * This is an integer representing the implementation version.
  45281. * This number does not correspond to the webxr specs version
  45282. */
  45283. static readonly Version: number;
  45284. /**
  45285. * registered observers will be triggered when the background state changes
  45286. */
  45287. onBackgroundStateChangedObservable: Observable<boolean>;
  45288. /**
  45289. * constructs a new background remover module
  45290. * @param _xrSessionManager the session manager for this module
  45291. * @param options read-only options to be used in this module
  45292. */
  45293. constructor(_xrSessionManager: WebXRSessionManager,
  45294. /**
  45295. * read-only options to be used in this module
  45296. */
  45297. options?: IWebXRBackgroundRemoverOptions);
  45298. /**
  45299. * attach this feature
  45300. * Will usually be called by the features manager
  45301. *
  45302. * @returns true if successful.
  45303. */
  45304. attach(): boolean;
  45305. /**
  45306. * detach this feature.
  45307. * Will usually be called by the features manager
  45308. *
  45309. * @returns true if successful.
  45310. */
  45311. detach(): boolean;
  45312. private _setBackgroundState;
  45313. /**
  45314. * Dispose this feature and all of the resources attached
  45315. */
  45316. dispose(): void;
  45317. }
  45318. }
  45319. declare module BABYLON {
  45320. /**
  45321. * The motion controller class for all microsoft mixed reality controllers
  45322. */
  45323. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  45324. /**
  45325. * The base url used to load the left and right controller models
  45326. */
  45327. static MODEL_BASE_URL: string;
  45328. /**
  45329. * The name of the left controller model file
  45330. */
  45331. static MODEL_LEFT_FILENAME: string;
  45332. /**
  45333. * The name of the right controller model file
  45334. */
  45335. static MODEL_RIGHT_FILENAME: string;
  45336. profileId: string;
  45337. protected readonly _mapping: {
  45338. defaultButton: {
  45339. "valueNodeName": string;
  45340. "unpressedNodeName": string;
  45341. "pressedNodeName": string;
  45342. };
  45343. defaultAxis: {
  45344. "valueNodeName": string;
  45345. "minNodeName": string;
  45346. "maxNodeName": string;
  45347. };
  45348. buttons: {
  45349. "xr-standard-trigger": {
  45350. "rootNodeName": string;
  45351. "componentProperty": string;
  45352. "states": string[];
  45353. };
  45354. "xr-standard-squeeze": {
  45355. "rootNodeName": string;
  45356. "componentProperty": string;
  45357. "states": string[];
  45358. };
  45359. "xr-standard-touchpad": {
  45360. "rootNodeName": string;
  45361. "labelAnchorNodeName": string;
  45362. "touchPointNodeName": string;
  45363. };
  45364. "xr-standard-thumbstick": {
  45365. "rootNodeName": string;
  45366. "componentProperty": string;
  45367. "states": string[];
  45368. };
  45369. };
  45370. axes: {
  45371. "xr-standard-touchpad": {
  45372. "x-axis": {
  45373. "rootNodeName": string;
  45374. };
  45375. "y-axis": {
  45376. "rootNodeName": string;
  45377. };
  45378. };
  45379. "xr-standard-thumbstick": {
  45380. "x-axis": {
  45381. "rootNodeName": string;
  45382. };
  45383. "y-axis": {
  45384. "rootNodeName": string;
  45385. };
  45386. };
  45387. };
  45388. };
  45389. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45390. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45391. private _getChildByName;
  45392. private _getImmediateChildByName;
  45393. protected _getFilenameAndPath(): {
  45394. filename: string;
  45395. path: string;
  45396. };
  45397. protected _updateModel(): void;
  45398. protected _getModelLoadingConstraints(): boolean;
  45399. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45400. }
  45401. }
  45402. declare module BABYLON {
  45403. /**
  45404. * The motion controller class for oculus touch (quest, rift).
  45405. * This class supports legacy mapping as well the standard xr mapping
  45406. */
  45407. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  45408. private _forceLegacyControllers;
  45409. /**
  45410. * The base url used to load the left and right controller models
  45411. */
  45412. static MODEL_BASE_URL: string;
  45413. /**
  45414. * The name of the left controller model file
  45415. */
  45416. static MODEL_LEFT_FILENAME: string;
  45417. /**
  45418. * The name of the right controller model file
  45419. */
  45420. static MODEL_RIGHT_FILENAME: string;
  45421. /**
  45422. * Base Url for the Quest controller model.
  45423. */
  45424. static QUEST_MODEL_BASE_URL: string;
  45425. profileId: string;
  45426. private _modelRootNode;
  45427. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  45428. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45429. protected _getFilenameAndPath(): {
  45430. filename: string;
  45431. path: string;
  45432. };
  45433. /**
  45434. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  45435. * between the touch and touch 2.
  45436. */
  45437. private _isQuest;
  45438. protected _updateModel(): void;
  45439. protected _getModelLoadingConstraints(): boolean;
  45440. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45441. }
  45442. }
  45443. declare module BABYLON {
  45444. /**
  45445. * The motion controller class for the standard HTC-Vive controllers
  45446. */
  45447. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  45448. /**
  45449. * The base url used to load the left and right controller models
  45450. */
  45451. static MODEL_BASE_URL: string;
  45452. /**
  45453. * File name for the controller model.
  45454. */
  45455. static MODEL_FILENAME: string;
  45456. profileId: string;
  45457. private _modelRootNode;
  45458. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  45459. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45460. protected _getFilenameAndPath(): {
  45461. filename: string;
  45462. path: string;
  45463. };
  45464. protected _updateModel(): void;
  45465. protected _getModelLoadingConstraints(): boolean;
  45466. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45467. }
  45468. }
  45469. declare module BABYLON {
  45470. /**
  45471. * Contains an array of blocks representing the octree
  45472. */
  45473. export interface IOctreeContainer<T> {
  45474. /**
  45475. * Blocks within the octree
  45476. */
  45477. blocks: Array<OctreeBlock<T>>;
  45478. }
  45479. /**
  45480. * Class used to store a cell in an octree
  45481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45482. */
  45483. export class OctreeBlock<T> {
  45484. /**
  45485. * Gets the content of the current block
  45486. */
  45487. entries: T[];
  45488. /**
  45489. * Gets the list of block children
  45490. */
  45491. blocks: Array<OctreeBlock<T>>;
  45492. private _depth;
  45493. private _maxDepth;
  45494. private _capacity;
  45495. private _minPoint;
  45496. private _maxPoint;
  45497. private _boundingVectors;
  45498. private _creationFunc;
  45499. /**
  45500. * Creates a new block
  45501. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45502. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45503. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45504. * @param depth defines the current depth of this block in the octree
  45505. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45506. * @param creationFunc defines a callback to call when an element is added to the block
  45507. */
  45508. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45509. /**
  45510. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45511. */
  45512. get capacity(): number;
  45513. /**
  45514. * Gets the minimum vector (in world space) of the block's bounding box
  45515. */
  45516. get minPoint(): Vector3;
  45517. /**
  45518. * Gets the maximum vector (in world space) of the block's bounding box
  45519. */
  45520. get maxPoint(): Vector3;
  45521. /**
  45522. * Add a new element to this block
  45523. * @param entry defines the element to add
  45524. */
  45525. addEntry(entry: T): void;
  45526. /**
  45527. * Remove an element from this block
  45528. * @param entry defines the element to remove
  45529. */
  45530. removeEntry(entry: T): void;
  45531. /**
  45532. * Add an array of elements to this block
  45533. * @param entries defines the array of elements to add
  45534. */
  45535. addEntries(entries: T[]): void;
  45536. /**
  45537. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45538. * @param frustumPlanes defines the frustum planes to test
  45539. * @param selection defines the array to store current content if selection is positive
  45540. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45541. */
  45542. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45543. /**
  45544. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45545. * @param sphereCenter defines the bounding sphere center
  45546. * @param sphereRadius defines the bounding sphere radius
  45547. * @param selection defines the array to store current content if selection is positive
  45548. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45549. */
  45550. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45551. /**
  45552. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45553. * @param ray defines the ray to test with
  45554. * @param selection defines the array to store current content if selection is positive
  45555. */
  45556. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45557. /**
  45558. * Subdivide the content into child blocks (this block will then be empty)
  45559. */
  45560. createInnerBlocks(): void;
  45561. /**
  45562. * @hidden
  45563. */
  45564. 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;
  45565. }
  45566. }
  45567. declare module BABYLON {
  45568. /**
  45569. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45570. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45571. */
  45572. export class Octree<T> {
  45573. /** 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.) */
  45574. maxDepth: number;
  45575. /**
  45576. * Blocks within the octree containing objects
  45577. */
  45578. blocks: Array<OctreeBlock<T>>;
  45579. /**
  45580. * Content stored in the octree
  45581. */
  45582. dynamicContent: T[];
  45583. private _maxBlockCapacity;
  45584. private _selectionContent;
  45585. private _creationFunc;
  45586. /**
  45587. * Creates a octree
  45588. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45589. * @param creationFunc function to be used to instatiate the octree
  45590. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45591. * @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.)
  45592. */
  45593. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45594. /** 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.) */
  45595. maxDepth?: number);
  45596. /**
  45597. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45598. * @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);
  45599. * @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);
  45600. * @param entries meshes to be added to the octree blocks
  45601. */
  45602. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45603. /**
  45604. * Adds a mesh to the octree
  45605. * @param entry Mesh to add to the octree
  45606. */
  45607. addMesh(entry: T): void;
  45608. /**
  45609. * Remove an element from the octree
  45610. * @param entry defines the element to remove
  45611. */
  45612. removeMesh(entry: T): void;
  45613. /**
  45614. * Selects an array of meshes within the frustum
  45615. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45616. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45617. * @returns array of meshes within the frustum
  45618. */
  45619. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45620. /**
  45621. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45622. * @param sphereCenter defines the bounding sphere center
  45623. * @param sphereRadius defines the bounding sphere radius
  45624. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45625. * @returns an array of objects that intersect the sphere
  45626. */
  45627. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45628. /**
  45629. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45630. * @param ray defines the ray to test with
  45631. * @returns array of intersected objects
  45632. */
  45633. intersectsRay(ray: Ray): SmartArray<T>;
  45634. /**
  45635. * Adds a mesh into the octree block if it intersects the block
  45636. */
  45637. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45638. /**
  45639. * Adds a submesh into the octree block if it intersects the block
  45640. */
  45641. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45642. }
  45643. }
  45644. declare module BABYLON {
  45645. interface Scene {
  45646. /**
  45647. * @hidden
  45648. * Backing Filed
  45649. */
  45650. _selectionOctree: Octree<AbstractMesh>;
  45651. /**
  45652. * Gets the octree used to boost mesh selection (picking)
  45653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45654. */
  45655. selectionOctree: Octree<AbstractMesh>;
  45656. /**
  45657. * Creates or updates the octree used to boost selection (picking)
  45658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45659. * @param maxCapacity defines the maximum capacity per leaf
  45660. * @param maxDepth defines the maximum depth of the octree
  45661. * @returns an octree of AbstractMesh
  45662. */
  45663. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45664. }
  45665. interface AbstractMesh {
  45666. /**
  45667. * @hidden
  45668. * Backing Field
  45669. */
  45670. _submeshesOctree: Octree<SubMesh>;
  45671. /**
  45672. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45673. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45674. * @param maxCapacity defines the maximum size of each block (64 by default)
  45675. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45676. * @returns the new octree
  45677. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45679. */
  45680. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45681. }
  45682. /**
  45683. * Defines the octree scene component responsible to manage any octrees
  45684. * in a given scene.
  45685. */
  45686. export class OctreeSceneComponent {
  45687. /**
  45688. * The component name help to identify the component in the list of scene components.
  45689. */
  45690. readonly name: string;
  45691. /**
  45692. * The scene the component belongs to.
  45693. */
  45694. scene: Scene;
  45695. /**
  45696. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45697. */
  45698. readonly checksIsEnabled: boolean;
  45699. /**
  45700. * Creates a new instance of the component for the given scene
  45701. * @param scene Defines the scene to register the component in
  45702. */
  45703. constructor(scene: Scene);
  45704. /**
  45705. * Registers the component in a given scene
  45706. */
  45707. register(): void;
  45708. /**
  45709. * Return the list of active meshes
  45710. * @returns the list of active meshes
  45711. */
  45712. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45713. /**
  45714. * Return the list of active sub meshes
  45715. * @param mesh The mesh to get the candidates sub meshes from
  45716. * @returns the list of active sub meshes
  45717. */
  45718. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45719. private _tempRay;
  45720. /**
  45721. * Return the list of sub meshes intersecting with a given local ray
  45722. * @param mesh defines the mesh to find the submesh for
  45723. * @param localRay defines the ray in local space
  45724. * @returns the list of intersecting sub meshes
  45725. */
  45726. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45727. /**
  45728. * Return the list of sub meshes colliding with a collider
  45729. * @param mesh defines the mesh to find the submesh for
  45730. * @param collider defines the collider to evaluate the collision against
  45731. * @returns the list of colliding sub meshes
  45732. */
  45733. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45734. /**
  45735. * Rebuilds the elements related to this component in case of
  45736. * context lost for instance.
  45737. */
  45738. rebuild(): void;
  45739. /**
  45740. * Disposes the component and the associated ressources.
  45741. */
  45742. dispose(): void;
  45743. }
  45744. }
  45745. declare module BABYLON {
  45746. /**
  45747. * Renders a layer on top of an existing scene
  45748. */
  45749. export class UtilityLayerRenderer implements IDisposable {
  45750. /** the original scene that will be rendered on top of */
  45751. originalScene: Scene;
  45752. private _pointerCaptures;
  45753. private _lastPointerEvents;
  45754. private static _DefaultUtilityLayer;
  45755. private static _DefaultKeepDepthUtilityLayer;
  45756. private _sharedGizmoLight;
  45757. private _renderCamera;
  45758. /**
  45759. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45760. * @returns the camera that is used when rendering the utility layer
  45761. */
  45762. getRenderCamera(): Nullable<Camera>;
  45763. /**
  45764. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45765. * @param cam the camera that should be used when rendering the utility layer
  45766. */
  45767. setRenderCamera(cam: Nullable<Camera>): void;
  45768. /**
  45769. * @hidden
  45770. * Light which used by gizmos to get light shading
  45771. */
  45772. _getSharedGizmoLight(): HemisphericLight;
  45773. /**
  45774. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45775. */
  45776. pickUtilitySceneFirst: boolean;
  45777. /**
  45778. * 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)
  45779. */
  45780. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45781. /**
  45782. * 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)
  45783. */
  45784. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45785. /**
  45786. * The scene that is rendered on top of the original scene
  45787. */
  45788. utilityLayerScene: Scene;
  45789. /**
  45790. * If the utility layer should automatically be rendered on top of existing scene
  45791. */
  45792. shouldRender: boolean;
  45793. /**
  45794. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45795. */
  45796. onlyCheckPointerDownEvents: boolean;
  45797. /**
  45798. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45799. */
  45800. processAllEvents: boolean;
  45801. /**
  45802. * Observable raised when the pointer move from the utility layer scene to the main scene
  45803. */
  45804. onPointerOutObservable: Observable<number>;
  45805. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45806. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45807. private _afterRenderObserver;
  45808. private _sceneDisposeObserver;
  45809. private _originalPointerObserver;
  45810. /**
  45811. * Instantiates a UtilityLayerRenderer
  45812. * @param originalScene the original scene that will be rendered on top of
  45813. * @param handleEvents boolean indicating if the utility layer should handle events
  45814. */
  45815. constructor(
  45816. /** the original scene that will be rendered on top of */
  45817. originalScene: Scene, handleEvents?: boolean);
  45818. private _notifyObservers;
  45819. /**
  45820. * Renders the utility layers scene on top of the original scene
  45821. */
  45822. render(): void;
  45823. /**
  45824. * Disposes of the renderer
  45825. */
  45826. dispose(): void;
  45827. private _updateCamera;
  45828. }
  45829. }
  45830. declare module BABYLON {
  45831. /**
  45832. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45833. */
  45834. export class Gizmo implements IDisposable {
  45835. /** The utility layer the gizmo will be added to */
  45836. gizmoLayer: UtilityLayerRenderer;
  45837. /**
  45838. * The root mesh of the gizmo
  45839. */
  45840. _rootMesh: Mesh;
  45841. private _attachedMesh;
  45842. /**
  45843. * Ratio for the scale of the gizmo (Default: 1)
  45844. */
  45845. scaleRatio: number;
  45846. /**
  45847. * If a custom mesh has been set (Default: false)
  45848. */
  45849. protected _customMeshSet: boolean;
  45850. /**
  45851. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45852. * * When set, interactions will be enabled
  45853. */
  45854. get attachedMesh(): Nullable<AbstractMesh>;
  45855. set attachedMesh(value: Nullable<AbstractMesh>);
  45856. /**
  45857. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45858. * @param mesh The mesh to replace the default mesh of the gizmo
  45859. */
  45860. setCustomMesh(mesh: Mesh): void;
  45861. /**
  45862. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45863. */
  45864. updateGizmoRotationToMatchAttachedMesh: boolean;
  45865. /**
  45866. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45867. */
  45868. updateGizmoPositionToMatchAttachedMesh: boolean;
  45869. /**
  45870. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45871. */
  45872. updateScale: boolean;
  45873. protected _interactionsEnabled: boolean;
  45874. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45875. private _beforeRenderObserver;
  45876. private _tempVector;
  45877. /**
  45878. * Creates a gizmo
  45879. * @param gizmoLayer The utility layer the gizmo will be added to
  45880. */
  45881. constructor(
  45882. /** The utility layer the gizmo will be added to */
  45883. gizmoLayer?: UtilityLayerRenderer);
  45884. /**
  45885. * Updates the gizmo to match the attached mesh's position/rotation
  45886. */
  45887. protected _update(): void;
  45888. /**
  45889. * Disposes of the gizmo
  45890. */
  45891. dispose(): void;
  45892. }
  45893. }
  45894. declare module BABYLON {
  45895. /**
  45896. * Single plane drag gizmo
  45897. */
  45898. export class PlaneDragGizmo extends Gizmo {
  45899. /**
  45900. * Drag behavior responsible for the gizmos dragging interactions
  45901. */
  45902. dragBehavior: PointerDragBehavior;
  45903. private _pointerObserver;
  45904. /**
  45905. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45906. */
  45907. snapDistance: number;
  45908. /**
  45909. * Event that fires each time the gizmo snaps to a new location.
  45910. * * snapDistance is the the change in distance
  45911. */
  45912. onSnapObservable: Observable<{
  45913. snapDistance: number;
  45914. }>;
  45915. private _plane;
  45916. private _coloredMaterial;
  45917. private _hoverMaterial;
  45918. private _isEnabled;
  45919. private _parent;
  45920. /** @hidden */
  45921. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45922. /** @hidden */
  45923. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45924. /**
  45925. * Creates a PlaneDragGizmo
  45926. * @param gizmoLayer The utility layer the gizmo will be added to
  45927. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45928. * @param color The color of the gizmo
  45929. */
  45930. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45932. /**
  45933. * If the gizmo is enabled
  45934. */
  45935. set isEnabled(value: boolean);
  45936. get isEnabled(): boolean;
  45937. /**
  45938. * Disposes of the gizmo
  45939. */
  45940. dispose(): void;
  45941. }
  45942. }
  45943. declare module BABYLON {
  45944. /**
  45945. * Gizmo that enables dragging a mesh along 3 axis
  45946. */
  45947. export class PositionGizmo extends Gizmo {
  45948. /**
  45949. * Internal gizmo used for interactions on the x axis
  45950. */
  45951. xGizmo: AxisDragGizmo;
  45952. /**
  45953. * Internal gizmo used for interactions on the y axis
  45954. */
  45955. yGizmo: AxisDragGizmo;
  45956. /**
  45957. * Internal gizmo used for interactions on the z axis
  45958. */
  45959. zGizmo: AxisDragGizmo;
  45960. /**
  45961. * Internal gizmo used for interactions on the yz plane
  45962. */
  45963. xPlaneGizmo: PlaneDragGizmo;
  45964. /**
  45965. * Internal gizmo used for interactions on the xz plane
  45966. */
  45967. yPlaneGizmo: PlaneDragGizmo;
  45968. /**
  45969. * Internal gizmo used for interactions on the xy plane
  45970. */
  45971. zPlaneGizmo: PlaneDragGizmo;
  45972. /**
  45973. * private variables
  45974. */
  45975. private _meshAttached;
  45976. private _updateGizmoRotationToMatchAttachedMesh;
  45977. private _snapDistance;
  45978. private _scaleRatio;
  45979. /** Fires an event when any of it's sub gizmos are dragged */
  45980. onDragStartObservable: Observable<unknown>;
  45981. /** Fires an event when any of it's sub gizmos are released from dragging */
  45982. onDragEndObservable: Observable<unknown>;
  45983. /**
  45984. * If set to true, planar drag is enabled
  45985. */
  45986. private _planarGizmoEnabled;
  45987. get attachedMesh(): Nullable<AbstractMesh>;
  45988. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45989. /**
  45990. * Creates a PositionGizmo
  45991. * @param gizmoLayer The utility layer the gizmo will be added to
  45992. */
  45993. constructor(gizmoLayer?: UtilityLayerRenderer);
  45994. /**
  45995. * If the planar drag gizmo is enabled
  45996. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45997. */
  45998. set planarGizmoEnabled(value: boolean);
  45999. get planarGizmoEnabled(): boolean;
  46000. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46001. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46002. /**
  46003. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46004. */
  46005. set snapDistance(value: number);
  46006. get snapDistance(): number;
  46007. /**
  46008. * Ratio for the scale of the gizmo (Default: 1)
  46009. */
  46010. set scaleRatio(value: number);
  46011. get scaleRatio(): number;
  46012. /**
  46013. * Disposes of the gizmo
  46014. */
  46015. dispose(): void;
  46016. /**
  46017. * CustomMeshes are not supported by this gizmo
  46018. * @param mesh The mesh to replace the default mesh of the gizmo
  46019. */
  46020. setCustomMesh(mesh: Mesh): void;
  46021. }
  46022. }
  46023. declare module BABYLON {
  46024. /**
  46025. * Single axis drag gizmo
  46026. */
  46027. export class AxisDragGizmo extends Gizmo {
  46028. /**
  46029. * Drag behavior responsible for the gizmos dragging interactions
  46030. */
  46031. dragBehavior: PointerDragBehavior;
  46032. private _pointerObserver;
  46033. /**
  46034. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46035. */
  46036. snapDistance: number;
  46037. /**
  46038. * Event that fires each time the gizmo snaps to a new location.
  46039. * * snapDistance is the the change in distance
  46040. */
  46041. onSnapObservable: Observable<{
  46042. snapDistance: number;
  46043. }>;
  46044. private _isEnabled;
  46045. private _parent;
  46046. private _arrow;
  46047. private _coloredMaterial;
  46048. private _hoverMaterial;
  46049. /** @hidden */
  46050. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46051. /** @hidden */
  46052. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46053. /**
  46054. * Creates an AxisDragGizmo
  46055. * @param gizmoLayer The utility layer the gizmo will be added to
  46056. * @param dragAxis The axis which the gizmo will be able to drag on
  46057. * @param color The color of the gizmo
  46058. */
  46059. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46060. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46061. /**
  46062. * If the gizmo is enabled
  46063. */
  46064. set isEnabled(value: boolean);
  46065. get isEnabled(): boolean;
  46066. /**
  46067. * Disposes of the gizmo
  46068. */
  46069. dispose(): void;
  46070. }
  46071. }
  46072. declare module BABYLON.Debug {
  46073. /**
  46074. * The Axes viewer will show 3 axes in a specific point in space
  46075. */
  46076. export class AxesViewer {
  46077. private _xAxis;
  46078. private _yAxis;
  46079. private _zAxis;
  46080. private _scaleLinesFactor;
  46081. private _instanced;
  46082. /**
  46083. * Gets the hosting scene
  46084. */
  46085. scene: Scene;
  46086. /**
  46087. * Gets or sets a number used to scale line length
  46088. */
  46089. scaleLines: number;
  46090. /** Gets the node hierarchy used to render x-axis */
  46091. get xAxis(): TransformNode;
  46092. /** Gets the node hierarchy used to render y-axis */
  46093. get yAxis(): TransformNode;
  46094. /** Gets the node hierarchy used to render z-axis */
  46095. get zAxis(): TransformNode;
  46096. /**
  46097. * Creates a new AxesViewer
  46098. * @param scene defines the hosting scene
  46099. * @param scaleLines defines a number used to scale line length (1 by default)
  46100. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46101. * @param xAxis defines the node hierarchy used to render the x-axis
  46102. * @param yAxis defines the node hierarchy used to render the y-axis
  46103. * @param zAxis defines the node hierarchy used to render the z-axis
  46104. */
  46105. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46106. /**
  46107. * Force the viewer to update
  46108. * @param position defines the position of the viewer
  46109. * @param xaxis defines the x axis of the viewer
  46110. * @param yaxis defines the y axis of the viewer
  46111. * @param zaxis defines the z axis of the viewer
  46112. */
  46113. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46114. /**
  46115. * Creates an instance of this axes viewer.
  46116. * @returns a new axes viewer with instanced meshes
  46117. */
  46118. createInstance(): AxesViewer;
  46119. /** Releases resources */
  46120. dispose(): void;
  46121. private static _SetRenderingGroupId;
  46122. }
  46123. }
  46124. declare module BABYLON.Debug {
  46125. /**
  46126. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46127. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46128. */
  46129. export class BoneAxesViewer extends AxesViewer {
  46130. /**
  46131. * Gets or sets the target mesh where to display the axes viewer
  46132. */
  46133. mesh: Nullable<Mesh>;
  46134. /**
  46135. * Gets or sets the target bone where to display the axes viewer
  46136. */
  46137. bone: Nullable<Bone>;
  46138. /** Gets current position */
  46139. pos: Vector3;
  46140. /** Gets direction of X axis */
  46141. xaxis: Vector3;
  46142. /** Gets direction of Y axis */
  46143. yaxis: Vector3;
  46144. /** Gets direction of Z axis */
  46145. zaxis: Vector3;
  46146. /**
  46147. * Creates a new BoneAxesViewer
  46148. * @param scene defines the hosting scene
  46149. * @param bone defines the target bone
  46150. * @param mesh defines the target mesh
  46151. * @param scaleLines defines a scaling factor for line length (1 by default)
  46152. */
  46153. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46154. /**
  46155. * Force the viewer to update
  46156. */
  46157. update(): void;
  46158. /** Releases resources */
  46159. dispose(): void;
  46160. }
  46161. }
  46162. declare module BABYLON {
  46163. /**
  46164. * Interface used to define scene explorer extensibility option
  46165. */
  46166. export interface IExplorerExtensibilityOption {
  46167. /**
  46168. * Define the option label
  46169. */
  46170. label: string;
  46171. /**
  46172. * Defines the action to execute on click
  46173. */
  46174. action: (entity: any) => void;
  46175. }
  46176. /**
  46177. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46178. */
  46179. export interface IExplorerExtensibilityGroup {
  46180. /**
  46181. * Defines a predicate to test if a given type mut be extended
  46182. */
  46183. predicate: (entity: any) => boolean;
  46184. /**
  46185. * Gets the list of options added to a type
  46186. */
  46187. entries: IExplorerExtensibilityOption[];
  46188. }
  46189. /**
  46190. * Interface used to define the options to use to create the Inspector
  46191. */
  46192. export interface IInspectorOptions {
  46193. /**
  46194. * Display in overlay mode (default: false)
  46195. */
  46196. overlay?: boolean;
  46197. /**
  46198. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46199. */
  46200. globalRoot?: HTMLElement;
  46201. /**
  46202. * Display the Scene explorer
  46203. */
  46204. showExplorer?: boolean;
  46205. /**
  46206. * Display the property inspector
  46207. */
  46208. showInspector?: boolean;
  46209. /**
  46210. * Display in embed mode (both panes on the right)
  46211. */
  46212. embedMode?: boolean;
  46213. /**
  46214. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46215. */
  46216. handleResize?: boolean;
  46217. /**
  46218. * Allow the panes to popup (default: true)
  46219. */
  46220. enablePopup?: boolean;
  46221. /**
  46222. * Allow the panes to be closed by users (default: true)
  46223. */
  46224. enableClose?: boolean;
  46225. /**
  46226. * Optional list of extensibility entries
  46227. */
  46228. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46229. /**
  46230. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46231. */
  46232. inspectorURL?: string;
  46233. /**
  46234. * Optional initial tab (default to DebugLayerTab.Properties)
  46235. */
  46236. initialTab?: DebugLayerTab;
  46237. }
  46238. interface Scene {
  46239. /**
  46240. * @hidden
  46241. * Backing field
  46242. */
  46243. _debugLayer: DebugLayer;
  46244. /**
  46245. * Gets the debug layer (aka Inspector) associated with the scene
  46246. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46247. */
  46248. debugLayer: DebugLayer;
  46249. }
  46250. /**
  46251. * Enum of inspector action tab
  46252. */
  46253. export enum DebugLayerTab {
  46254. /**
  46255. * Properties tag (default)
  46256. */
  46257. Properties = 0,
  46258. /**
  46259. * Debug tab
  46260. */
  46261. Debug = 1,
  46262. /**
  46263. * Statistics tab
  46264. */
  46265. Statistics = 2,
  46266. /**
  46267. * Tools tab
  46268. */
  46269. Tools = 3,
  46270. /**
  46271. * Settings tab
  46272. */
  46273. Settings = 4
  46274. }
  46275. /**
  46276. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46277. * what is happening in your scene
  46278. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46279. */
  46280. export class DebugLayer {
  46281. /**
  46282. * Define the url to get the inspector script from.
  46283. * By default it uses the babylonjs CDN.
  46284. * @ignoreNaming
  46285. */
  46286. static InspectorURL: string;
  46287. private _scene;
  46288. private BJSINSPECTOR;
  46289. private _onPropertyChangedObservable?;
  46290. /**
  46291. * Observable triggered when a property is changed through the inspector.
  46292. */
  46293. get onPropertyChangedObservable(): any;
  46294. /**
  46295. * Instantiates a new debug layer.
  46296. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46297. * what is happening in your scene
  46298. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46299. * @param scene Defines the scene to inspect
  46300. */
  46301. constructor(scene: Scene);
  46302. /** Creates the inspector window. */
  46303. private _createInspector;
  46304. /**
  46305. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46306. * @param entity defines the entity to select
  46307. * @param lineContainerTitle defines the specific block to highlight
  46308. */
  46309. select(entity: any, lineContainerTitle?: string): void;
  46310. /** Get the inspector from bundle or global */
  46311. private _getGlobalInspector;
  46312. /**
  46313. * Get if the inspector is visible or not.
  46314. * @returns true if visible otherwise, false
  46315. */
  46316. isVisible(): boolean;
  46317. /**
  46318. * Hide the inspector and close its window.
  46319. */
  46320. hide(): void;
  46321. /**
  46322. * Launch the debugLayer.
  46323. * @param config Define the configuration of the inspector
  46324. * @return a promise fulfilled when the debug layer is visible
  46325. */
  46326. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46327. }
  46328. }
  46329. declare module BABYLON {
  46330. /**
  46331. * Class containing static functions to help procedurally build meshes
  46332. */
  46333. export class BoxBuilder {
  46334. /**
  46335. * Creates a box mesh
  46336. * * The parameter `size` sets the size (float) of each box side (default 1)
  46337. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46338. * * 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)
  46339. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46341. * * 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
  46342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46343. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46344. * @param name defines the name of the mesh
  46345. * @param options defines the options used to create the mesh
  46346. * @param scene defines the hosting scene
  46347. * @returns the box mesh
  46348. */
  46349. static CreateBox(name: string, options: {
  46350. size?: number;
  46351. width?: number;
  46352. height?: number;
  46353. depth?: number;
  46354. faceUV?: Vector4[];
  46355. faceColors?: Color4[];
  46356. sideOrientation?: number;
  46357. frontUVs?: Vector4;
  46358. backUVs?: Vector4;
  46359. wrap?: boolean;
  46360. topBaseAt?: number;
  46361. bottomBaseAt?: number;
  46362. updatable?: boolean;
  46363. }, scene?: Nullable<Scene>): Mesh;
  46364. }
  46365. }
  46366. declare module BABYLON {
  46367. /**
  46368. * Class containing static functions to help procedurally build meshes
  46369. */
  46370. export class SphereBuilder {
  46371. /**
  46372. * Creates a sphere mesh
  46373. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46374. * * 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`)
  46375. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46376. * * 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
  46377. * * 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)
  46378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46379. * * 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
  46380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46381. * @param name defines the name of the mesh
  46382. * @param options defines the options used to create the mesh
  46383. * @param scene defines the hosting scene
  46384. * @returns the sphere mesh
  46385. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46386. */
  46387. static CreateSphere(name: string, options: {
  46388. segments?: number;
  46389. diameter?: number;
  46390. diameterX?: number;
  46391. diameterY?: number;
  46392. diameterZ?: number;
  46393. arc?: number;
  46394. slice?: number;
  46395. sideOrientation?: number;
  46396. frontUVs?: Vector4;
  46397. backUVs?: Vector4;
  46398. updatable?: boolean;
  46399. }, scene?: Nullable<Scene>): Mesh;
  46400. }
  46401. }
  46402. declare module BABYLON.Debug {
  46403. /**
  46404. * Used to show the physics impostor around the specific mesh
  46405. */
  46406. export class PhysicsViewer {
  46407. /** @hidden */
  46408. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46409. /** @hidden */
  46410. protected _meshes: Array<Nullable<AbstractMesh>>;
  46411. /** @hidden */
  46412. protected _scene: Nullable<Scene>;
  46413. /** @hidden */
  46414. protected _numMeshes: number;
  46415. /** @hidden */
  46416. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46417. private _renderFunction;
  46418. private _utilityLayer;
  46419. private _debugBoxMesh;
  46420. private _debugSphereMesh;
  46421. private _debugCylinderMesh;
  46422. private _debugMaterial;
  46423. private _debugMeshMeshes;
  46424. /**
  46425. * Creates a new PhysicsViewer
  46426. * @param scene defines the hosting scene
  46427. */
  46428. constructor(scene: Scene);
  46429. /** @hidden */
  46430. protected _updateDebugMeshes(): void;
  46431. /**
  46432. * Renders a specified physic impostor
  46433. * @param impostor defines the impostor to render
  46434. * @param targetMesh defines the mesh represented by the impostor
  46435. * @returns the new debug mesh used to render the impostor
  46436. */
  46437. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46438. /**
  46439. * Hides a specified physic impostor
  46440. * @param impostor defines the impostor to hide
  46441. */
  46442. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46443. private _getDebugMaterial;
  46444. private _getDebugBoxMesh;
  46445. private _getDebugSphereMesh;
  46446. private _getDebugCylinderMesh;
  46447. private _getDebugMeshMesh;
  46448. private _getDebugMesh;
  46449. /** Releases all resources */
  46450. dispose(): void;
  46451. }
  46452. }
  46453. declare module BABYLON {
  46454. /**
  46455. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46456. * in order to better appreciate the issue one might have.
  46457. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46458. */
  46459. export class RayHelper {
  46460. /**
  46461. * Defines the ray we are currently tryin to visualize.
  46462. */
  46463. ray: Nullable<Ray>;
  46464. private _renderPoints;
  46465. private _renderLine;
  46466. private _renderFunction;
  46467. private _scene;
  46468. private _updateToMeshFunction;
  46469. private _attachedToMesh;
  46470. private _meshSpaceDirection;
  46471. private _meshSpaceOrigin;
  46472. /**
  46473. * Helper function to create a colored helper in a scene in one line.
  46474. * @param ray Defines the ray we are currently tryin to visualize
  46475. * @param scene Defines the scene the ray is used in
  46476. * @param color Defines the color we want to see the ray in
  46477. * @returns The newly created ray helper.
  46478. */
  46479. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46480. /**
  46481. * Instantiate a new ray helper.
  46482. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46483. * in order to better appreciate the issue one might have.
  46484. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46485. * @param ray Defines the ray we are currently tryin to visualize
  46486. */
  46487. constructor(ray: Ray);
  46488. /**
  46489. * Shows the ray we are willing to debug.
  46490. * @param scene Defines the scene the ray needs to be rendered in
  46491. * @param color Defines the color the ray needs to be rendered in
  46492. */
  46493. show(scene: Scene, color?: Color3): void;
  46494. /**
  46495. * Hides the ray we are debugging.
  46496. */
  46497. hide(): void;
  46498. private _render;
  46499. /**
  46500. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46501. * @param mesh Defines the mesh we want the helper attached to
  46502. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46503. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46504. * @param length Defines the length of the ray
  46505. */
  46506. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46507. /**
  46508. * Detach the ray helper from the mesh it has previously been attached to.
  46509. */
  46510. detachFromMesh(): void;
  46511. private _updateToMesh;
  46512. /**
  46513. * Dispose the helper and release its associated resources.
  46514. */
  46515. dispose(): void;
  46516. }
  46517. }
  46518. declare module BABYLON.Debug {
  46519. /**
  46520. * Class used to render a debug view of a given skeleton
  46521. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46522. */
  46523. export class SkeletonViewer {
  46524. /** defines the skeleton to render */
  46525. skeleton: Skeleton;
  46526. /** defines the mesh attached to the skeleton */
  46527. mesh: AbstractMesh;
  46528. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46529. autoUpdateBonesMatrices: boolean;
  46530. /** defines the rendering group id to use with the viewer */
  46531. renderingGroupId: number;
  46532. /** Gets or sets the color used to render the skeleton */
  46533. color: Color3;
  46534. private _scene;
  46535. private _debugLines;
  46536. private _debugMesh;
  46537. private _isEnabled;
  46538. private _renderFunction;
  46539. private _utilityLayer;
  46540. /**
  46541. * Returns the mesh used to render the bones
  46542. */
  46543. get debugMesh(): Nullable<LinesMesh>;
  46544. /**
  46545. * Creates a new SkeletonViewer
  46546. * @param skeleton defines the skeleton to render
  46547. * @param mesh defines the mesh attached to the skeleton
  46548. * @param scene defines the hosting scene
  46549. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46550. * @param renderingGroupId defines the rendering group id to use with the viewer
  46551. */
  46552. constructor(
  46553. /** defines the skeleton to render */
  46554. skeleton: Skeleton,
  46555. /** defines the mesh attached to the skeleton */
  46556. mesh: AbstractMesh, scene: Scene,
  46557. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46558. autoUpdateBonesMatrices?: boolean,
  46559. /** defines the rendering group id to use with the viewer */
  46560. renderingGroupId?: number);
  46561. /** Gets or sets a boolean indicating if the viewer is enabled */
  46562. set isEnabled(value: boolean);
  46563. get isEnabled(): boolean;
  46564. private _getBonePosition;
  46565. private _getLinesForBonesWithLength;
  46566. private _getLinesForBonesNoLength;
  46567. /** Update the viewer to sync with current skeleton state */
  46568. update(): void;
  46569. /** Release associated resources */
  46570. dispose(): void;
  46571. }
  46572. }
  46573. declare module BABYLON {
  46574. /**
  46575. * Options to create the null engine
  46576. */
  46577. export class NullEngineOptions {
  46578. /**
  46579. * Render width (Default: 512)
  46580. */
  46581. renderWidth: number;
  46582. /**
  46583. * Render height (Default: 256)
  46584. */
  46585. renderHeight: number;
  46586. /**
  46587. * Texture size (Default: 512)
  46588. */
  46589. textureSize: number;
  46590. /**
  46591. * If delta time between frames should be constant
  46592. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46593. */
  46594. deterministicLockstep: boolean;
  46595. /**
  46596. * Maximum about of steps between frames (Default: 4)
  46597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46598. */
  46599. lockstepMaxSteps: number;
  46600. }
  46601. /**
  46602. * The null engine class provides support for headless version of babylon.js.
  46603. * This can be used in server side scenario or for testing purposes
  46604. */
  46605. export class NullEngine extends Engine {
  46606. private _options;
  46607. /**
  46608. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46610. * @returns true if engine is in deterministic lock step mode
  46611. */
  46612. isDeterministicLockStep(): boolean;
  46613. /**
  46614. * Gets the max steps when engine is running in deterministic lock step
  46615. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46616. * @returns the max steps
  46617. */
  46618. getLockstepMaxSteps(): number;
  46619. /**
  46620. * Gets the current hardware scaling level.
  46621. * By default the hardware scaling level is computed from the window device ratio.
  46622. * 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.
  46623. * @returns a number indicating the current hardware scaling level
  46624. */
  46625. getHardwareScalingLevel(): number;
  46626. constructor(options?: NullEngineOptions);
  46627. /**
  46628. * Creates a vertex buffer
  46629. * @param vertices the data for the vertex buffer
  46630. * @returns the new WebGL static buffer
  46631. */
  46632. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46633. /**
  46634. * Creates a new index buffer
  46635. * @param indices defines the content of the index buffer
  46636. * @param updatable defines if the index buffer must be updatable
  46637. * @returns a new webGL buffer
  46638. */
  46639. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46640. /**
  46641. * Clear the current render buffer or the current render target (if any is set up)
  46642. * @param color defines the color to use
  46643. * @param backBuffer defines if the back buffer must be cleared
  46644. * @param depth defines if the depth buffer must be cleared
  46645. * @param stencil defines if the stencil buffer must be cleared
  46646. */
  46647. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46648. /**
  46649. * Gets the current render width
  46650. * @param useScreen defines if screen size must be used (or the current render target if any)
  46651. * @returns a number defining the current render width
  46652. */
  46653. getRenderWidth(useScreen?: boolean): number;
  46654. /**
  46655. * Gets the current render height
  46656. * @param useScreen defines if screen size must be used (or the current render target if any)
  46657. * @returns a number defining the current render height
  46658. */
  46659. getRenderHeight(useScreen?: boolean): number;
  46660. /**
  46661. * Set the WebGL's viewport
  46662. * @param viewport defines the viewport element to be used
  46663. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46664. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46665. */
  46666. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46667. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46668. /**
  46669. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46670. * @param pipelineContext defines the pipeline context to use
  46671. * @param uniformsNames defines the list of uniform names
  46672. * @returns an array of webGL uniform locations
  46673. */
  46674. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46675. /**
  46676. * Gets the lsit of active attributes for a given webGL program
  46677. * @param pipelineContext defines the pipeline context to use
  46678. * @param attributesNames defines the list of attribute names to get
  46679. * @returns an array of indices indicating the offset of each attribute
  46680. */
  46681. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46682. /**
  46683. * Binds an effect to the webGL context
  46684. * @param effect defines the effect to bind
  46685. */
  46686. bindSamplers(effect: Effect): void;
  46687. /**
  46688. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46689. * @param effect defines the effect to activate
  46690. */
  46691. enableEffect(effect: Effect): void;
  46692. /**
  46693. * Set various states to the webGL context
  46694. * @param culling defines backface culling state
  46695. * @param zOffset defines the value to apply to zOffset (0 by default)
  46696. * @param force defines if states must be applied even if cache is up to date
  46697. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46698. */
  46699. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46700. /**
  46701. * Set the value of an uniform to an array of int32
  46702. * @param uniform defines the webGL uniform location where to store the value
  46703. * @param array defines the array of int32 to store
  46704. */
  46705. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46706. /**
  46707. * Set the value of an uniform to an array of int32 (stored as vec2)
  46708. * @param uniform defines the webGL uniform location where to store the value
  46709. * @param array defines the array of int32 to store
  46710. */
  46711. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46712. /**
  46713. * Set the value of an uniform to an array of int32 (stored as vec3)
  46714. * @param uniform defines the webGL uniform location where to store the value
  46715. * @param array defines the array of int32 to store
  46716. */
  46717. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46718. /**
  46719. * Set the value of an uniform to an array of int32 (stored as vec4)
  46720. * @param uniform defines the webGL uniform location where to store the value
  46721. * @param array defines the array of int32 to store
  46722. */
  46723. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46724. /**
  46725. * Set the value of an uniform to an array of float32
  46726. * @param uniform defines the webGL uniform location where to store the value
  46727. * @param array defines the array of float32 to store
  46728. */
  46729. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46730. /**
  46731. * Set the value of an uniform to an array of float32 (stored as vec2)
  46732. * @param uniform defines the webGL uniform location where to store the value
  46733. * @param array defines the array of float32 to store
  46734. */
  46735. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46736. /**
  46737. * Set the value of an uniform to an array of float32 (stored as vec3)
  46738. * @param uniform defines the webGL uniform location where to store the value
  46739. * @param array defines the array of float32 to store
  46740. */
  46741. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46742. /**
  46743. * Set the value of an uniform to an array of float32 (stored as vec4)
  46744. * @param uniform defines the webGL uniform location where to store the value
  46745. * @param array defines the array of float32 to store
  46746. */
  46747. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46748. /**
  46749. * Set the value of an uniform to an array of number
  46750. * @param uniform defines the webGL uniform location where to store the value
  46751. * @param array defines the array of number to store
  46752. */
  46753. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46754. /**
  46755. * Set the value of an uniform to an array of number (stored as vec2)
  46756. * @param uniform defines the webGL uniform location where to store the value
  46757. * @param array defines the array of number to store
  46758. */
  46759. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46760. /**
  46761. * Set the value of an uniform to an array of number (stored as vec3)
  46762. * @param uniform defines the webGL uniform location where to store the value
  46763. * @param array defines the array of number to store
  46764. */
  46765. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46766. /**
  46767. * Set the value of an uniform to an array of number (stored as vec4)
  46768. * @param uniform defines the webGL uniform location where to store the value
  46769. * @param array defines the array of number to store
  46770. */
  46771. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46772. /**
  46773. * Set the value of an uniform to an array of float32 (stored as matrices)
  46774. * @param uniform defines the webGL uniform location where to store the value
  46775. * @param matrices defines the array of float32 to store
  46776. */
  46777. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46778. /**
  46779. * Set the value of an uniform to a matrix (3x3)
  46780. * @param uniform defines the webGL uniform location where to store the value
  46781. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46782. */
  46783. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46784. /**
  46785. * Set the value of an uniform to a matrix (2x2)
  46786. * @param uniform defines the webGL uniform location where to store the value
  46787. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46788. */
  46789. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46790. /**
  46791. * Set the value of an uniform to a number (float)
  46792. * @param uniform defines the webGL uniform location where to store the value
  46793. * @param value defines the float number to store
  46794. */
  46795. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46796. /**
  46797. * Set the value of an uniform to a vec2
  46798. * @param uniform defines the webGL uniform location where to store the value
  46799. * @param x defines the 1st component of the value
  46800. * @param y defines the 2nd component of the value
  46801. */
  46802. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46803. /**
  46804. * Set the value of an uniform to a vec3
  46805. * @param uniform defines the webGL uniform location where to store the value
  46806. * @param x defines the 1st component of the value
  46807. * @param y defines the 2nd component of the value
  46808. * @param z defines the 3rd component of the value
  46809. */
  46810. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46811. /**
  46812. * Set the value of an uniform to a boolean
  46813. * @param uniform defines the webGL uniform location where to store the value
  46814. * @param bool defines the boolean to store
  46815. */
  46816. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46817. /**
  46818. * Set the value of an uniform to a vec4
  46819. * @param uniform defines the webGL uniform location where to store the value
  46820. * @param x defines the 1st component of the value
  46821. * @param y defines the 2nd component of the value
  46822. * @param z defines the 3rd component of the value
  46823. * @param w defines the 4th component of the value
  46824. */
  46825. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46826. /**
  46827. * Sets the current alpha mode
  46828. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46829. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46830. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46831. */
  46832. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46833. /**
  46834. * Bind webGl buffers directly to the webGL context
  46835. * @param vertexBuffers defines the vertex buffer to bind
  46836. * @param indexBuffer defines the index buffer to bind
  46837. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46838. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46839. * @param effect defines the effect associated with the vertex buffer
  46840. */
  46841. bindBuffers(vertexBuffers: {
  46842. [key: string]: VertexBuffer;
  46843. }, indexBuffer: DataBuffer, effect: Effect): void;
  46844. /**
  46845. * Force the entire cache to be cleared
  46846. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46847. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46848. */
  46849. wipeCaches(bruteForce?: boolean): void;
  46850. /**
  46851. * Send a draw order
  46852. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46853. * @param indexStart defines the starting index
  46854. * @param indexCount defines the number of index to draw
  46855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46856. */
  46857. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46858. /**
  46859. * Draw a list of indexed primitives
  46860. * @param fillMode defines the primitive to use
  46861. * @param indexStart defines the starting index
  46862. * @param indexCount defines the number of index to draw
  46863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46864. */
  46865. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46866. /**
  46867. * Draw a list of unindexed primitives
  46868. * @param fillMode defines the primitive to use
  46869. * @param verticesStart defines the index of first vertex to draw
  46870. * @param verticesCount defines the count of vertices to draw
  46871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46872. */
  46873. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46874. /** @hidden */
  46875. _createTexture(): WebGLTexture;
  46876. /** @hidden */
  46877. _releaseTexture(texture: InternalTexture): void;
  46878. /**
  46879. * Usually called from Texture.ts.
  46880. * Passed information to create a WebGLTexture
  46881. * @param urlArg defines a value which contains one of the following:
  46882. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46883. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46884. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46885. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46886. * @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)
  46887. * @param scene needed for loading to the correct scene
  46888. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46889. * @param onLoad optional callback to be called upon successful completion
  46890. * @param onError optional callback to be called upon failure
  46891. * @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
  46892. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46893. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46894. * @param forcedExtension defines the extension to use to pick the right loader
  46895. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46896. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46897. */
  46898. 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;
  46899. /**
  46900. * Creates a new render target texture
  46901. * @param size defines the size of the texture
  46902. * @param options defines the options used to create the texture
  46903. * @returns a new render target texture stored in an InternalTexture
  46904. */
  46905. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46906. /**
  46907. * Update the sampling mode of a given texture
  46908. * @param samplingMode defines the required sampling mode
  46909. * @param texture defines the texture to update
  46910. */
  46911. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46912. /**
  46913. * Binds the frame buffer to the specified texture.
  46914. * @param texture The texture to render to or null for the default canvas
  46915. * @param faceIndex The face of the texture to render to in case of cube texture
  46916. * @param requiredWidth The width of the target to render to
  46917. * @param requiredHeight The height of the target to render to
  46918. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46919. * @param lodLevel defines le lod level to bind to the frame buffer
  46920. */
  46921. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46922. /**
  46923. * Unbind the current render target texture from the webGL context
  46924. * @param texture defines the render target texture to unbind
  46925. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46926. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46927. */
  46928. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46929. /**
  46930. * Creates a dynamic vertex buffer
  46931. * @param vertices the data for the dynamic vertex buffer
  46932. * @returns the new WebGL dynamic buffer
  46933. */
  46934. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46935. /**
  46936. * Update the content of a dynamic texture
  46937. * @param texture defines the texture to update
  46938. * @param canvas defines the canvas containing the source
  46939. * @param invertY defines if data must be stored with Y axis inverted
  46940. * @param premulAlpha defines if alpha is stored as premultiplied
  46941. * @param format defines the format of the data
  46942. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46943. */
  46944. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46945. /**
  46946. * Gets a boolean indicating if all created effects are ready
  46947. * @returns true if all effects are ready
  46948. */
  46949. areAllEffectsReady(): boolean;
  46950. /**
  46951. * @hidden
  46952. * Get the current error code of the webGL context
  46953. * @returns the error code
  46954. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46955. */
  46956. getError(): number;
  46957. /** @hidden */
  46958. _getUnpackAlignement(): number;
  46959. /** @hidden */
  46960. _unpackFlipY(value: boolean): void;
  46961. /**
  46962. * Update a dynamic index buffer
  46963. * @param indexBuffer defines the target index buffer
  46964. * @param indices defines the data to update
  46965. * @param offset defines the offset in the target index buffer where update should start
  46966. */
  46967. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46968. /**
  46969. * Updates a dynamic vertex buffer.
  46970. * @param vertexBuffer the vertex buffer to update
  46971. * @param vertices the data used to update the vertex buffer
  46972. * @param byteOffset the byte offset of the data (optional)
  46973. * @param byteLength the byte length of the data (optional)
  46974. */
  46975. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46976. /** @hidden */
  46977. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46978. /** @hidden */
  46979. _bindTexture(channel: number, texture: InternalTexture): void;
  46980. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46981. /**
  46982. * 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
  46983. */
  46984. releaseEffects(): void;
  46985. displayLoadingUI(): void;
  46986. hideLoadingUI(): void;
  46987. /** @hidden */
  46988. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46989. /** @hidden */
  46990. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46991. /** @hidden */
  46992. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46993. /** @hidden */
  46994. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46995. }
  46996. }
  46997. declare module BABYLON {
  46998. /** @hidden */
  46999. export class _OcclusionDataStorage {
  47000. /** @hidden */
  47001. occlusionInternalRetryCounter: number;
  47002. /** @hidden */
  47003. isOcclusionQueryInProgress: boolean;
  47004. /** @hidden */
  47005. isOccluded: boolean;
  47006. /** @hidden */
  47007. occlusionRetryCount: number;
  47008. /** @hidden */
  47009. occlusionType: number;
  47010. /** @hidden */
  47011. occlusionQueryAlgorithmType: number;
  47012. }
  47013. interface Engine {
  47014. /**
  47015. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47016. * @return the new query
  47017. */
  47018. createQuery(): WebGLQuery;
  47019. /**
  47020. * Delete and release a webGL query
  47021. * @param query defines the query to delete
  47022. * @return the current engine
  47023. */
  47024. deleteQuery(query: WebGLQuery): Engine;
  47025. /**
  47026. * Check if a given query has resolved and got its value
  47027. * @param query defines the query to check
  47028. * @returns true if the query got its value
  47029. */
  47030. isQueryResultAvailable(query: WebGLQuery): boolean;
  47031. /**
  47032. * Gets the value of a given query
  47033. * @param query defines the query to check
  47034. * @returns the value of the query
  47035. */
  47036. getQueryResult(query: WebGLQuery): number;
  47037. /**
  47038. * Initiates an occlusion query
  47039. * @param algorithmType defines the algorithm to use
  47040. * @param query defines the query to use
  47041. * @returns the current engine
  47042. * @see http://doc.babylonjs.com/features/occlusionquery
  47043. */
  47044. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47045. /**
  47046. * Ends an occlusion query
  47047. * @see http://doc.babylonjs.com/features/occlusionquery
  47048. * @param algorithmType defines the algorithm to use
  47049. * @returns the current engine
  47050. */
  47051. endOcclusionQuery(algorithmType: number): Engine;
  47052. /**
  47053. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47054. * Please note that only one query can be issued at a time
  47055. * @returns a time token used to track the time span
  47056. */
  47057. startTimeQuery(): Nullable<_TimeToken>;
  47058. /**
  47059. * Ends a time query
  47060. * @param token defines the token used to measure the time span
  47061. * @returns the time spent (in ns)
  47062. */
  47063. endTimeQuery(token: _TimeToken): int;
  47064. /** @hidden */
  47065. _currentNonTimestampToken: Nullable<_TimeToken>;
  47066. /** @hidden */
  47067. _createTimeQuery(): WebGLQuery;
  47068. /** @hidden */
  47069. _deleteTimeQuery(query: WebGLQuery): void;
  47070. /** @hidden */
  47071. _getGlAlgorithmType(algorithmType: number): number;
  47072. /** @hidden */
  47073. _getTimeQueryResult(query: WebGLQuery): any;
  47074. /** @hidden */
  47075. _getTimeQueryAvailability(query: WebGLQuery): any;
  47076. }
  47077. interface AbstractMesh {
  47078. /**
  47079. * Backing filed
  47080. * @hidden
  47081. */
  47082. __occlusionDataStorage: _OcclusionDataStorage;
  47083. /**
  47084. * Access property
  47085. * @hidden
  47086. */
  47087. _occlusionDataStorage: _OcclusionDataStorage;
  47088. /**
  47089. * 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.
  47090. * The default value is -1 which means don't break the query and wait till the result
  47091. * @see http://doc.babylonjs.com/features/occlusionquery
  47092. */
  47093. occlusionRetryCount: number;
  47094. /**
  47095. * 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:
  47096. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47097. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47098. * * 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.
  47099. * @see http://doc.babylonjs.com/features/occlusionquery
  47100. */
  47101. occlusionType: number;
  47102. /**
  47103. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47104. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47105. * * 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.
  47106. * @see http://doc.babylonjs.com/features/occlusionquery
  47107. */
  47108. occlusionQueryAlgorithmType: number;
  47109. /**
  47110. * 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
  47111. * @see http://doc.babylonjs.com/features/occlusionquery
  47112. */
  47113. isOccluded: boolean;
  47114. /**
  47115. * Flag to check the progress status of the query
  47116. * @see http://doc.babylonjs.com/features/occlusionquery
  47117. */
  47118. isOcclusionQueryInProgress: boolean;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /** @hidden */
  47123. export var _forceTransformFeedbackToBundle: boolean;
  47124. interface Engine {
  47125. /**
  47126. * Creates a webGL transform feedback object
  47127. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47128. * @returns the webGL transform feedback object
  47129. */
  47130. createTransformFeedback(): WebGLTransformFeedback;
  47131. /**
  47132. * Delete a webGL transform feedback object
  47133. * @param value defines the webGL transform feedback object to delete
  47134. */
  47135. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47136. /**
  47137. * Bind a webGL transform feedback object to the webgl context
  47138. * @param value defines the webGL transform feedback object to bind
  47139. */
  47140. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47141. /**
  47142. * Begins a transform feedback operation
  47143. * @param usePoints defines if points or triangles must be used
  47144. */
  47145. beginTransformFeedback(usePoints: boolean): void;
  47146. /**
  47147. * Ends a transform feedback operation
  47148. */
  47149. endTransformFeedback(): void;
  47150. /**
  47151. * Specify the varyings to use with transform feedback
  47152. * @param program defines the associated webGL program
  47153. * @param value defines the list of strings representing the varying names
  47154. */
  47155. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47156. /**
  47157. * Bind a webGL buffer for a transform feedback operation
  47158. * @param value defines the webGL buffer to bind
  47159. */
  47160. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47161. }
  47162. }
  47163. declare module BABYLON {
  47164. /**
  47165. * Creation options of the multi render target texture.
  47166. */
  47167. export interface IMultiRenderTargetOptions {
  47168. /**
  47169. * Define if the texture needs to create mip maps after render.
  47170. */
  47171. generateMipMaps?: boolean;
  47172. /**
  47173. * Define the types of all the draw buffers we want to create
  47174. */
  47175. types?: number[];
  47176. /**
  47177. * Define the sampling modes of all the draw buffers we want to create
  47178. */
  47179. samplingModes?: number[];
  47180. /**
  47181. * Define if a depth buffer is required
  47182. */
  47183. generateDepthBuffer?: boolean;
  47184. /**
  47185. * Define if a stencil buffer is required
  47186. */
  47187. generateStencilBuffer?: boolean;
  47188. /**
  47189. * Define if a depth texture is required instead of a depth buffer
  47190. */
  47191. generateDepthTexture?: boolean;
  47192. /**
  47193. * Define the number of desired draw buffers
  47194. */
  47195. textureCount?: number;
  47196. /**
  47197. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47198. */
  47199. doNotChangeAspectRatio?: boolean;
  47200. /**
  47201. * Define the default type of the buffers we are creating
  47202. */
  47203. defaultType?: number;
  47204. }
  47205. /**
  47206. * A multi render target, like a render target provides the ability to render to a texture.
  47207. * Unlike the render target, it can render to several draw buffers in one draw.
  47208. * This is specially interesting in deferred rendering or for any effects requiring more than
  47209. * just one color from a single pass.
  47210. */
  47211. export class MultiRenderTarget extends RenderTargetTexture {
  47212. private _internalTextures;
  47213. private _textures;
  47214. private _multiRenderTargetOptions;
  47215. /**
  47216. * Get if draw buffers are currently supported by the used hardware and browser.
  47217. */
  47218. get isSupported(): boolean;
  47219. /**
  47220. * Get the list of textures generated by the multi render target.
  47221. */
  47222. get textures(): Texture[];
  47223. /**
  47224. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47225. */
  47226. get depthTexture(): Texture;
  47227. /**
  47228. * Set the wrapping mode on U of all the textures we are rendering to.
  47229. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47230. */
  47231. set wrapU(wrap: number);
  47232. /**
  47233. * Set the wrapping mode on V of all the textures we are rendering to.
  47234. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47235. */
  47236. set wrapV(wrap: number);
  47237. /**
  47238. * Instantiate a new multi render target texture.
  47239. * A multi render target, like a render target provides the ability to render to a texture.
  47240. * Unlike the render target, it can render to several draw buffers in one draw.
  47241. * This is specially interesting in deferred rendering or for any effects requiring more than
  47242. * just one color from a single pass.
  47243. * @param name Define the name of the texture
  47244. * @param size Define the size of the buffers to render to
  47245. * @param count Define the number of target we are rendering into
  47246. * @param scene Define the scene the texture belongs to
  47247. * @param options Define the options used to create the multi render target
  47248. */
  47249. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47250. /** @hidden */
  47251. _rebuild(): void;
  47252. private _createInternalTextures;
  47253. private _createTextures;
  47254. /**
  47255. * Define the number of samples used if MSAA is enabled.
  47256. */
  47257. get samples(): number;
  47258. set samples(value: number);
  47259. /**
  47260. * Resize all the textures in the multi render target.
  47261. * Be carrefull as it will recreate all the data in the new texture.
  47262. * @param size Define the new size
  47263. */
  47264. resize(size: any): void;
  47265. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47266. /**
  47267. * Dispose the render targets and their associated resources
  47268. */
  47269. dispose(): void;
  47270. /**
  47271. * Release all the underlying texture used as draw buffers.
  47272. */
  47273. releaseInternalTextures(): void;
  47274. }
  47275. }
  47276. declare module BABYLON {
  47277. interface ThinEngine {
  47278. /**
  47279. * Unbind a list of render target textures from the webGL context
  47280. * This is used only when drawBuffer extension or webGL2 are active
  47281. * @param textures defines the render target textures to unbind
  47282. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47283. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47284. */
  47285. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47286. /**
  47287. * Create a multi render target texture
  47288. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47289. * @param size defines the size of the texture
  47290. * @param options defines the creation options
  47291. * @returns the cube texture as an InternalTexture
  47292. */
  47293. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47294. /**
  47295. * Update the sample count for a given multiple render target texture
  47296. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47297. * @param textures defines the textures to update
  47298. * @param samples defines the sample count to set
  47299. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47300. */
  47301. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47302. }
  47303. }
  47304. declare module BABYLON {
  47305. /**
  47306. * Class used to define an additional view for the engine
  47307. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47308. */
  47309. export class EngineView {
  47310. /** Defines the canvas where to render the view */
  47311. target: HTMLCanvasElement;
  47312. /** Defines an optional camera used to render the view (will use active camera else) */
  47313. camera?: Camera;
  47314. }
  47315. interface Engine {
  47316. /**
  47317. * Gets or sets the HTML element to use for attaching events
  47318. */
  47319. inputElement: Nullable<HTMLElement>;
  47320. /**
  47321. * Gets the current engine view
  47322. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47323. */
  47324. activeView: Nullable<EngineView>;
  47325. /** Gets or sets the list of views */
  47326. views: EngineView[];
  47327. /**
  47328. * Register a new child canvas
  47329. * @param canvas defines the canvas to register
  47330. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47331. * @returns the associated view
  47332. */
  47333. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47334. /**
  47335. * Remove a registered child canvas
  47336. * @param canvas defines the canvas to remove
  47337. * @returns the current engine
  47338. */
  47339. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47340. }
  47341. }
  47342. declare module BABYLON {
  47343. /**
  47344. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47345. */
  47346. export interface CubeMapInfo {
  47347. /**
  47348. * The pixel array for the front face.
  47349. * This is stored in format, left to right, up to down format.
  47350. */
  47351. front: Nullable<ArrayBufferView>;
  47352. /**
  47353. * The pixel array for the back face.
  47354. * This is stored in format, left to right, up to down format.
  47355. */
  47356. back: Nullable<ArrayBufferView>;
  47357. /**
  47358. * The pixel array for the left face.
  47359. * This is stored in format, left to right, up to down format.
  47360. */
  47361. left: Nullable<ArrayBufferView>;
  47362. /**
  47363. * The pixel array for the right face.
  47364. * This is stored in format, left to right, up to down format.
  47365. */
  47366. right: Nullable<ArrayBufferView>;
  47367. /**
  47368. * The pixel array for the up face.
  47369. * This is stored in format, left to right, up to down format.
  47370. */
  47371. up: Nullable<ArrayBufferView>;
  47372. /**
  47373. * The pixel array for the down face.
  47374. * This is stored in format, left to right, up to down format.
  47375. */
  47376. down: Nullable<ArrayBufferView>;
  47377. /**
  47378. * The size of the cubemap stored.
  47379. *
  47380. * Each faces will be size * size pixels.
  47381. */
  47382. size: number;
  47383. /**
  47384. * The format of the texture.
  47385. *
  47386. * RGBA, RGB.
  47387. */
  47388. format: number;
  47389. /**
  47390. * The type of the texture data.
  47391. *
  47392. * UNSIGNED_INT, FLOAT.
  47393. */
  47394. type: number;
  47395. /**
  47396. * Specifies whether the texture is in gamma space.
  47397. */
  47398. gammaSpace: boolean;
  47399. }
  47400. /**
  47401. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47402. */
  47403. export class PanoramaToCubeMapTools {
  47404. private static FACE_FRONT;
  47405. private static FACE_BACK;
  47406. private static FACE_RIGHT;
  47407. private static FACE_LEFT;
  47408. private static FACE_DOWN;
  47409. private static FACE_UP;
  47410. /**
  47411. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47412. *
  47413. * @param float32Array The source data.
  47414. * @param inputWidth The width of the input panorama.
  47415. * @param inputHeight The height of the input panorama.
  47416. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47417. * @return The cubemap data
  47418. */
  47419. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47420. private static CreateCubemapTexture;
  47421. private static CalcProjectionSpherical;
  47422. }
  47423. }
  47424. declare module BABYLON {
  47425. /**
  47426. * Helper class dealing with the extraction of spherical polynomial dataArray
  47427. * from a cube map.
  47428. */
  47429. export class CubeMapToSphericalPolynomialTools {
  47430. private static FileFaces;
  47431. /**
  47432. * Converts a texture to the according Spherical Polynomial data.
  47433. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47434. *
  47435. * @param texture The texture to extract the information from.
  47436. * @return The Spherical Polynomial data.
  47437. */
  47438. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47439. /**
  47440. * Converts a cubemap to the according Spherical Polynomial data.
  47441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47442. *
  47443. * @param cubeInfo The Cube map to extract the information from.
  47444. * @return The Spherical Polynomial data.
  47445. */
  47446. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47447. }
  47448. }
  47449. declare module BABYLON {
  47450. interface BaseTexture {
  47451. /**
  47452. * Get the polynomial representation of the texture data.
  47453. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47454. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47455. */
  47456. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47457. }
  47458. }
  47459. declare module BABYLON {
  47460. /** @hidden */
  47461. export var rgbdEncodePixelShader: {
  47462. name: string;
  47463. shader: string;
  47464. };
  47465. }
  47466. declare module BABYLON {
  47467. /** @hidden */
  47468. export var rgbdDecodePixelShader: {
  47469. name: string;
  47470. shader: string;
  47471. };
  47472. }
  47473. declare module BABYLON {
  47474. /**
  47475. * Raw texture data and descriptor sufficient for WebGL texture upload
  47476. */
  47477. export interface EnvironmentTextureInfo {
  47478. /**
  47479. * Version of the environment map
  47480. */
  47481. version: number;
  47482. /**
  47483. * Width of image
  47484. */
  47485. width: number;
  47486. /**
  47487. * Irradiance information stored in the file.
  47488. */
  47489. irradiance: any;
  47490. /**
  47491. * Specular information stored in the file.
  47492. */
  47493. specular: any;
  47494. }
  47495. /**
  47496. * Defines One Image in the file. It requires only the position in the file
  47497. * as well as the length.
  47498. */
  47499. interface BufferImageData {
  47500. /**
  47501. * Length of the image data.
  47502. */
  47503. length: number;
  47504. /**
  47505. * Position of the data from the null terminator delimiting the end of the JSON.
  47506. */
  47507. position: number;
  47508. }
  47509. /**
  47510. * Defines the specular data enclosed in the file.
  47511. * This corresponds to the version 1 of the data.
  47512. */
  47513. export interface EnvironmentTextureSpecularInfoV1 {
  47514. /**
  47515. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47516. */
  47517. specularDataPosition?: number;
  47518. /**
  47519. * This contains all the images data needed to reconstruct the cubemap.
  47520. */
  47521. mipmaps: Array<BufferImageData>;
  47522. /**
  47523. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47524. */
  47525. lodGenerationScale: number;
  47526. }
  47527. /**
  47528. * Sets of helpers addressing the serialization and deserialization of environment texture
  47529. * stored in a BabylonJS env file.
  47530. * Those files are usually stored as .env files.
  47531. */
  47532. export class EnvironmentTextureTools {
  47533. /**
  47534. * Magic number identifying the env file.
  47535. */
  47536. private static _MagicBytes;
  47537. /**
  47538. * Gets the environment info from an env file.
  47539. * @param data The array buffer containing the .env bytes.
  47540. * @returns the environment file info (the json header) if successfully parsed.
  47541. */
  47542. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47543. /**
  47544. * Creates an environment texture from a loaded cube texture.
  47545. * @param texture defines the cube texture to convert in env file
  47546. * @return a promise containing the environment data if succesfull.
  47547. */
  47548. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47549. /**
  47550. * Creates a JSON representation of the spherical data.
  47551. * @param texture defines the texture containing the polynomials
  47552. * @return the JSON representation of the spherical info
  47553. */
  47554. private static _CreateEnvTextureIrradiance;
  47555. /**
  47556. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47557. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47558. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47559. * @return the views described by info providing access to the underlying buffer
  47560. */
  47561. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47562. /**
  47563. * Uploads the texture info contained in the env file to the GPU.
  47564. * @param texture defines the internal texture to upload to
  47565. * @param arrayBuffer defines the buffer cotaining the data to load
  47566. * @param info defines the texture info retrieved through the GetEnvInfo method
  47567. * @returns a promise
  47568. */
  47569. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47570. private static _OnImageReadyAsync;
  47571. /**
  47572. * Uploads the levels of image data to the GPU.
  47573. * @param texture defines the internal texture to upload to
  47574. * @param imageData defines the array buffer views of image data [mipmap][face]
  47575. * @returns a promise
  47576. */
  47577. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47578. /**
  47579. * Uploads spherical polynomials information to the texture.
  47580. * @param texture defines the texture we are trying to upload the information to
  47581. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47582. */
  47583. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47584. /** @hidden */
  47585. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47586. }
  47587. }
  47588. declare module BABYLON {
  47589. /**
  47590. * Contains position and normal vectors for a vertex
  47591. */
  47592. export class PositionNormalVertex {
  47593. /** the position of the vertex (defaut: 0,0,0) */
  47594. position: Vector3;
  47595. /** the normal of the vertex (defaut: 0,1,0) */
  47596. normal: Vector3;
  47597. /**
  47598. * Creates a PositionNormalVertex
  47599. * @param position the position of the vertex (defaut: 0,0,0)
  47600. * @param normal the normal of the vertex (defaut: 0,1,0)
  47601. */
  47602. constructor(
  47603. /** the position of the vertex (defaut: 0,0,0) */
  47604. position?: Vector3,
  47605. /** the normal of the vertex (defaut: 0,1,0) */
  47606. normal?: Vector3);
  47607. /**
  47608. * Clones the PositionNormalVertex
  47609. * @returns the cloned PositionNormalVertex
  47610. */
  47611. clone(): PositionNormalVertex;
  47612. }
  47613. /**
  47614. * Contains position, normal and uv vectors for a vertex
  47615. */
  47616. export class PositionNormalTextureVertex {
  47617. /** the position of the vertex (defaut: 0,0,0) */
  47618. position: Vector3;
  47619. /** the normal of the vertex (defaut: 0,1,0) */
  47620. normal: Vector3;
  47621. /** the uv of the vertex (default: 0,0) */
  47622. uv: Vector2;
  47623. /**
  47624. * Creates a PositionNormalTextureVertex
  47625. * @param position the position of the vertex (defaut: 0,0,0)
  47626. * @param normal the normal of the vertex (defaut: 0,1,0)
  47627. * @param uv the uv of the vertex (default: 0,0)
  47628. */
  47629. constructor(
  47630. /** the position of the vertex (defaut: 0,0,0) */
  47631. position?: Vector3,
  47632. /** the normal of the vertex (defaut: 0,1,0) */
  47633. normal?: Vector3,
  47634. /** the uv of the vertex (default: 0,0) */
  47635. uv?: Vector2);
  47636. /**
  47637. * Clones the PositionNormalTextureVertex
  47638. * @returns the cloned PositionNormalTextureVertex
  47639. */
  47640. clone(): PositionNormalTextureVertex;
  47641. }
  47642. }
  47643. declare module BABYLON {
  47644. /** @hidden */
  47645. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47646. private _genericAttributeLocation;
  47647. private _varyingLocationCount;
  47648. private _varyingLocationMap;
  47649. private _replacements;
  47650. private _textureCount;
  47651. private _uniforms;
  47652. lineProcessor(line: string): string;
  47653. attributeProcessor(attribute: string): string;
  47654. varyingProcessor(varying: string, isFragment: boolean): string;
  47655. uniformProcessor(uniform: string): string;
  47656. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47657. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47658. }
  47659. }
  47660. declare module BABYLON {
  47661. /**
  47662. * Container for accessors for natively-stored mesh data buffers.
  47663. */
  47664. class NativeDataBuffer extends DataBuffer {
  47665. /**
  47666. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47667. */
  47668. nativeIndexBuffer?: any;
  47669. /**
  47670. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47671. */
  47672. nativeVertexBuffer?: any;
  47673. }
  47674. /** @hidden */
  47675. class NativeTexture extends InternalTexture {
  47676. getInternalTexture(): InternalTexture;
  47677. getViewCount(): number;
  47678. }
  47679. /** @hidden */
  47680. export class NativeEngine extends Engine {
  47681. private readonly _native;
  47682. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47683. private readonly INVALID_HANDLE;
  47684. getHardwareScalingLevel(): number;
  47685. constructor();
  47686. /**
  47687. * Can be used to override the current requestAnimationFrame requester.
  47688. * @hidden
  47689. */
  47690. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47691. /**
  47692. * Override default engine behavior.
  47693. * @param color
  47694. * @param backBuffer
  47695. * @param depth
  47696. * @param stencil
  47697. */
  47698. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47699. /**
  47700. * Gets host document
  47701. * @returns the host document object
  47702. */
  47703. getHostDocument(): Nullable<Document>;
  47704. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47705. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47706. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47707. recordVertexArrayObject(vertexBuffers: {
  47708. [key: string]: VertexBuffer;
  47709. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47710. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47711. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47712. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47713. /**
  47714. * Draw a list of indexed primitives
  47715. * @param fillMode defines the primitive to use
  47716. * @param indexStart defines the starting index
  47717. * @param indexCount defines the number of index to draw
  47718. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47719. */
  47720. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47721. /**
  47722. * Draw a list of unindexed primitives
  47723. * @param fillMode defines the primitive to use
  47724. * @param verticesStart defines the index of first vertex to draw
  47725. * @param verticesCount defines the count of vertices to draw
  47726. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47727. */
  47728. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47729. createPipelineContext(): IPipelineContext;
  47730. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47731. /** @hidden */
  47732. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47733. /** @hidden */
  47734. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47735. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47736. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47737. protected _setProgram(program: WebGLProgram): void;
  47738. _releaseEffect(effect: Effect): void;
  47739. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47740. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47741. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47742. bindSamplers(effect: Effect): void;
  47743. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47744. getRenderWidth(useScreen?: boolean): number;
  47745. getRenderHeight(useScreen?: boolean): number;
  47746. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47747. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47748. /**
  47749. * Set the z offset to apply to current rendering
  47750. * @param value defines the offset to apply
  47751. */
  47752. setZOffset(value: number): void;
  47753. /**
  47754. * Gets the current value of the zOffset
  47755. * @returns the current zOffset state
  47756. */
  47757. getZOffset(): number;
  47758. /**
  47759. * Enable or disable depth buffering
  47760. * @param enable defines the state to set
  47761. */
  47762. setDepthBuffer(enable: boolean): void;
  47763. /**
  47764. * Gets a boolean indicating if depth writing is enabled
  47765. * @returns the current depth writing state
  47766. */
  47767. getDepthWrite(): boolean;
  47768. /**
  47769. * Enable or disable depth writing
  47770. * @param enable defines the state to set
  47771. */
  47772. setDepthWrite(enable: boolean): void;
  47773. /**
  47774. * Enable or disable color writing
  47775. * @param enable defines the state to set
  47776. */
  47777. setColorWrite(enable: boolean): void;
  47778. /**
  47779. * Gets a boolean indicating if color writing is enabled
  47780. * @returns the current color writing state
  47781. */
  47782. getColorWrite(): boolean;
  47783. /**
  47784. * Sets alpha constants used by some alpha blending modes
  47785. * @param r defines the red component
  47786. * @param g defines the green component
  47787. * @param b defines the blue component
  47788. * @param a defines the alpha component
  47789. */
  47790. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47791. /**
  47792. * Sets the current alpha mode
  47793. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47794. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47796. */
  47797. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47798. /**
  47799. * Gets the current alpha mode
  47800. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47801. * @returns the current alpha mode
  47802. */
  47803. getAlphaMode(): number;
  47804. setInt(uniform: WebGLUniformLocation, int: number): void;
  47805. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47806. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47807. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47808. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47809. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47810. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47811. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47812. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47813. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47814. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47815. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47816. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47817. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47818. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47819. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47820. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47821. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47822. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47823. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47824. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47825. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47826. wipeCaches(bruteForce?: boolean): void;
  47827. _createTexture(): WebGLTexture;
  47828. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47829. /**
  47830. * Usually called from BABYLON.Texture.ts.
  47831. * Passed information to create a WebGLTexture
  47832. * @param urlArg defines a value which contains one of the following:
  47833. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47834. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47835. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47837. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47838. * @param scene needed for loading to the correct scene
  47839. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47840. * @param onLoad optional callback to be called upon successful completion
  47841. * @param onError optional callback to be called upon failure
  47842. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47843. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47844. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47845. * @param forcedExtension defines the extension to use to pick the right loader
  47846. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47847. */
  47848. 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;
  47849. /**
  47850. * Creates a cube texture
  47851. * @param rootUrl defines the url where the files to load is located
  47852. * @param scene defines the current scene
  47853. * @param files defines the list of files to load (1 per face)
  47854. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47855. * @param onLoad defines an optional callback raised when the texture is loaded
  47856. * @param onError defines an optional callback raised if there is an issue to load the texture
  47857. * @param format defines the format of the data
  47858. * @param forcedExtension defines the extension to use to pick the right loader
  47859. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47860. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47861. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47862. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47863. * @returns the cube texture as an InternalTexture
  47864. */
  47865. 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;
  47866. private _getSamplingFilter;
  47867. private static _GetNativeTextureFormat;
  47868. createRenderTargetTexture(size: number | {
  47869. width: number;
  47870. height: number;
  47871. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47872. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47873. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47874. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47875. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47876. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47877. /**
  47878. * Updates a dynamic vertex buffer.
  47879. * @param vertexBuffer the vertex buffer to update
  47880. * @param data the data used to update the vertex buffer
  47881. * @param byteOffset the byte offset of the data (optional)
  47882. * @param byteLength the byte length of the data (optional)
  47883. */
  47884. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47885. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47886. private _updateAnisotropicLevel;
  47887. private _getAddressMode;
  47888. /** @hidden */
  47889. _bindTexture(channel: number, texture: InternalTexture): void;
  47890. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47891. releaseEffects(): void;
  47892. /** @hidden */
  47893. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47894. /** @hidden */
  47895. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47896. /** @hidden */
  47897. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47898. /** @hidden */
  47899. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47900. }
  47901. }
  47902. declare module BABYLON {
  47903. /**
  47904. * Gather the list of clipboard event types as constants.
  47905. */
  47906. export class ClipboardEventTypes {
  47907. /**
  47908. * The clipboard event is fired when a copy command is active (pressed).
  47909. */
  47910. static readonly COPY: number;
  47911. /**
  47912. * The clipboard event is fired when a cut command is active (pressed).
  47913. */
  47914. static readonly CUT: number;
  47915. /**
  47916. * The clipboard event is fired when a paste command is active (pressed).
  47917. */
  47918. static readonly PASTE: number;
  47919. }
  47920. /**
  47921. * This class is used to store clipboard related info for the onClipboardObservable event.
  47922. */
  47923. export class ClipboardInfo {
  47924. /**
  47925. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47926. */
  47927. type: number;
  47928. /**
  47929. * Defines the related dom event
  47930. */
  47931. event: ClipboardEvent;
  47932. /**
  47933. *Creates an instance of ClipboardInfo.
  47934. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47935. * @param event Defines the related dom event
  47936. */
  47937. constructor(
  47938. /**
  47939. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47940. */
  47941. type: number,
  47942. /**
  47943. * Defines the related dom event
  47944. */
  47945. event: ClipboardEvent);
  47946. /**
  47947. * Get the clipboard event's type from the keycode.
  47948. * @param keyCode Defines the keyCode for the current keyboard event.
  47949. * @return {number}
  47950. */
  47951. static GetTypeFromCharacter(keyCode: number): number;
  47952. }
  47953. }
  47954. declare module BABYLON {
  47955. /**
  47956. * Google Daydream controller
  47957. */
  47958. export class DaydreamController extends WebVRController {
  47959. /**
  47960. * Base Url for the controller model.
  47961. */
  47962. static MODEL_BASE_URL: string;
  47963. /**
  47964. * File name for the controller model.
  47965. */
  47966. static MODEL_FILENAME: string;
  47967. /**
  47968. * Gamepad Id prefix used to identify Daydream Controller.
  47969. */
  47970. static readonly GAMEPAD_ID_PREFIX: string;
  47971. /**
  47972. * Creates a new DaydreamController from a gamepad
  47973. * @param vrGamepad the gamepad that the controller should be created from
  47974. */
  47975. constructor(vrGamepad: any);
  47976. /**
  47977. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47978. * @param scene scene in which to add meshes
  47979. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47980. */
  47981. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47982. /**
  47983. * Called once for each button that changed state since the last frame
  47984. * @param buttonIdx Which button index changed
  47985. * @param state New state of the button
  47986. * @param changes Which properties on the state changed since last frame
  47987. */
  47988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47989. }
  47990. }
  47991. declare module BABYLON {
  47992. /**
  47993. * Gear VR Controller
  47994. */
  47995. export class GearVRController extends WebVRController {
  47996. /**
  47997. * Base Url for the controller model.
  47998. */
  47999. static MODEL_BASE_URL: string;
  48000. /**
  48001. * File name for the controller model.
  48002. */
  48003. static MODEL_FILENAME: string;
  48004. /**
  48005. * Gamepad Id prefix used to identify this controller.
  48006. */
  48007. static readonly GAMEPAD_ID_PREFIX: string;
  48008. private readonly _buttonIndexToObservableNameMap;
  48009. /**
  48010. * Creates a new GearVRController from a gamepad
  48011. * @param vrGamepad the gamepad that the controller should be created from
  48012. */
  48013. constructor(vrGamepad: any);
  48014. /**
  48015. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48016. * @param scene scene in which to add meshes
  48017. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48018. */
  48019. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48020. /**
  48021. * Called once for each button that changed state since the last frame
  48022. * @param buttonIdx Which button index changed
  48023. * @param state New state of the button
  48024. * @param changes Which properties on the state changed since last frame
  48025. */
  48026. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48027. }
  48028. }
  48029. declare module BABYLON {
  48030. /**
  48031. * Generic Controller
  48032. */
  48033. export class GenericController extends WebVRController {
  48034. /**
  48035. * Base Url for the controller model.
  48036. */
  48037. static readonly MODEL_BASE_URL: string;
  48038. /**
  48039. * File name for the controller model.
  48040. */
  48041. static readonly MODEL_FILENAME: string;
  48042. /**
  48043. * Creates a new GenericController from a gamepad
  48044. * @param vrGamepad the gamepad that the controller should be created from
  48045. */
  48046. constructor(vrGamepad: any);
  48047. /**
  48048. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48049. * @param scene scene in which to add meshes
  48050. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48051. */
  48052. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48053. /**
  48054. * Called once for each button that changed state since the last frame
  48055. * @param buttonIdx Which button index changed
  48056. * @param state New state of the button
  48057. * @param changes Which properties on the state changed since last frame
  48058. */
  48059. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48060. }
  48061. }
  48062. declare module BABYLON {
  48063. /**
  48064. * Oculus Touch Controller
  48065. */
  48066. export class OculusTouchController extends WebVRController {
  48067. /**
  48068. * Base Url for the controller model.
  48069. */
  48070. static MODEL_BASE_URL: string;
  48071. /**
  48072. * File name for the left controller model.
  48073. */
  48074. static MODEL_LEFT_FILENAME: string;
  48075. /**
  48076. * File name for the right controller model.
  48077. */
  48078. static MODEL_RIGHT_FILENAME: string;
  48079. /**
  48080. * Base Url for the Quest controller model.
  48081. */
  48082. static QUEST_MODEL_BASE_URL: string;
  48083. /**
  48084. * @hidden
  48085. * If the controllers are running on a device that needs the updated Quest controller models
  48086. */
  48087. static _IsQuest: boolean;
  48088. /**
  48089. * Fired when the secondary trigger on this controller is modified
  48090. */
  48091. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48092. /**
  48093. * Fired when the thumb rest on this controller is modified
  48094. */
  48095. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48096. /**
  48097. * Creates a new OculusTouchController from a gamepad
  48098. * @param vrGamepad the gamepad that the controller should be created from
  48099. */
  48100. constructor(vrGamepad: any);
  48101. /**
  48102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48103. * @param scene scene in which to add meshes
  48104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48105. */
  48106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48107. /**
  48108. * Fired when the A button on this controller is modified
  48109. */
  48110. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48111. /**
  48112. * Fired when the B button on this controller is modified
  48113. */
  48114. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48115. /**
  48116. * Fired when the X button on this controller is modified
  48117. */
  48118. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48119. /**
  48120. * Fired when the Y button on this controller is modified
  48121. */
  48122. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48123. /**
  48124. * Called once for each button that changed state since the last frame
  48125. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48126. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48127. * 2) secondary trigger (same)
  48128. * 3) A (right) X (left), touch, pressed = value
  48129. * 4) B / Y
  48130. * 5) thumb rest
  48131. * @param buttonIdx Which button index changed
  48132. * @param state New state of the button
  48133. * @param changes Which properties on the state changed since last frame
  48134. */
  48135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48136. }
  48137. }
  48138. declare module BABYLON {
  48139. /**
  48140. * Vive Controller
  48141. */
  48142. export class ViveController extends WebVRController {
  48143. /**
  48144. * Base Url for the controller model.
  48145. */
  48146. static MODEL_BASE_URL: string;
  48147. /**
  48148. * File name for the controller model.
  48149. */
  48150. static MODEL_FILENAME: string;
  48151. /**
  48152. * Creates a new ViveController from a gamepad
  48153. * @param vrGamepad the gamepad that the controller should be created from
  48154. */
  48155. constructor(vrGamepad: any);
  48156. /**
  48157. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48158. * @param scene scene in which to add meshes
  48159. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48160. */
  48161. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48162. /**
  48163. * Fired when the left button on this controller is modified
  48164. */
  48165. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48166. /**
  48167. * Fired when the right button on this controller is modified
  48168. */
  48169. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48170. /**
  48171. * Fired when the menu button on this controller is modified
  48172. */
  48173. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48174. /**
  48175. * Called once for each button that changed state since the last frame
  48176. * Vive mapping:
  48177. * 0: touchpad
  48178. * 1: trigger
  48179. * 2: left AND right buttons
  48180. * 3: menu button
  48181. * @param buttonIdx Which button index changed
  48182. * @param state New state of the button
  48183. * @param changes Which properties on the state changed since last frame
  48184. */
  48185. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48186. }
  48187. }
  48188. declare module BABYLON {
  48189. /**
  48190. * Defines the WindowsMotionController object that the state of the windows motion controller
  48191. */
  48192. export class WindowsMotionController extends WebVRController {
  48193. /**
  48194. * The base url used to load the left and right controller models
  48195. */
  48196. static MODEL_BASE_URL: string;
  48197. /**
  48198. * The name of the left controller model file
  48199. */
  48200. static MODEL_LEFT_FILENAME: string;
  48201. /**
  48202. * The name of the right controller model file
  48203. */
  48204. static MODEL_RIGHT_FILENAME: string;
  48205. /**
  48206. * The controller name prefix for this controller type
  48207. */
  48208. static readonly GAMEPAD_ID_PREFIX: string;
  48209. /**
  48210. * The controller id pattern for this controller type
  48211. */
  48212. private static readonly GAMEPAD_ID_PATTERN;
  48213. private _loadedMeshInfo;
  48214. protected readonly _mapping: {
  48215. buttons: string[];
  48216. buttonMeshNames: {
  48217. 'trigger': string;
  48218. 'menu': string;
  48219. 'grip': string;
  48220. 'thumbstick': string;
  48221. 'trackpad': string;
  48222. };
  48223. buttonObservableNames: {
  48224. 'trigger': string;
  48225. 'menu': string;
  48226. 'grip': string;
  48227. 'thumbstick': string;
  48228. 'trackpad': string;
  48229. };
  48230. axisMeshNames: string[];
  48231. pointingPoseMeshName: string;
  48232. };
  48233. /**
  48234. * Fired when the trackpad on this controller is clicked
  48235. */
  48236. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48237. /**
  48238. * Fired when the trackpad on this controller is modified
  48239. */
  48240. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48241. /**
  48242. * The current x and y values of this controller's trackpad
  48243. */
  48244. trackpad: StickValues;
  48245. /**
  48246. * Creates a new WindowsMotionController from a gamepad
  48247. * @param vrGamepad the gamepad that the controller should be created from
  48248. */
  48249. constructor(vrGamepad: any);
  48250. /**
  48251. * Fired when the trigger on this controller is modified
  48252. */
  48253. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48254. /**
  48255. * Fired when the menu button on this controller is modified
  48256. */
  48257. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48258. /**
  48259. * Fired when the grip button on this controller is modified
  48260. */
  48261. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48262. /**
  48263. * Fired when the thumbstick button on this controller is modified
  48264. */
  48265. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48266. /**
  48267. * Fired when the touchpad button on this controller is modified
  48268. */
  48269. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48270. /**
  48271. * Fired when the touchpad values on this controller are modified
  48272. */
  48273. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48274. protected _updateTrackpad(): void;
  48275. /**
  48276. * Called once per frame by the engine.
  48277. */
  48278. update(): void;
  48279. /**
  48280. * Called once for each button that changed state since the last frame
  48281. * @param buttonIdx Which button index changed
  48282. * @param state New state of the button
  48283. * @param changes Which properties on the state changed since last frame
  48284. */
  48285. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48286. /**
  48287. * Moves the buttons on the controller mesh based on their current state
  48288. * @param buttonName the name of the button to move
  48289. * @param buttonValue the value of the button which determines the buttons new position
  48290. */
  48291. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48292. /**
  48293. * Moves the axis on the controller mesh based on its current state
  48294. * @param axis the index of the axis
  48295. * @param axisValue the value of the axis which determines the meshes new position
  48296. * @hidden
  48297. */
  48298. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48299. /**
  48300. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48301. * @param scene scene in which to add meshes
  48302. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48303. */
  48304. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48305. /**
  48306. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48307. * can be transformed by button presses and axes values, based on this._mapping.
  48308. *
  48309. * @param scene scene in which the meshes exist
  48310. * @param meshes list of meshes that make up the controller model to process
  48311. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48312. */
  48313. private processModel;
  48314. private createMeshInfo;
  48315. /**
  48316. * Gets the ray of the controller in the direction the controller is pointing
  48317. * @param length the length the resulting ray should be
  48318. * @returns a ray in the direction the controller is pointing
  48319. */
  48320. getForwardRay(length?: number): Ray;
  48321. /**
  48322. * Disposes of the controller
  48323. */
  48324. dispose(): void;
  48325. }
  48326. /**
  48327. * This class represents a new windows motion controller in XR.
  48328. */
  48329. export class XRWindowsMotionController extends WindowsMotionController {
  48330. /**
  48331. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48332. */
  48333. protected readonly _mapping: {
  48334. buttons: string[];
  48335. buttonMeshNames: {
  48336. 'trigger': string;
  48337. 'menu': string;
  48338. 'grip': string;
  48339. 'thumbstick': string;
  48340. 'trackpad': string;
  48341. };
  48342. buttonObservableNames: {
  48343. 'trigger': string;
  48344. 'menu': string;
  48345. 'grip': string;
  48346. 'thumbstick': string;
  48347. 'trackpad': string;
  48348. };
  48349. axisMeshNames: string[];
  48350. pointingPoseMeshName: string;
  48351. };
  48352. /**
  48353. * Construct a new XR-Based windows motion controller
  48354. *
  48355. * @param gamepadInfo the gamepad object from the browser
  48356. */
  48357. constructor(gamepadInfo: any);
  48358. /**
  48359. * holds the thumbstick values (X,Y)
  48360. */
  48361. thumbstickValues: StickValues;
  48362. /**
  48363. * Fired when the thumbstick on this controller is clicked
  48364. */
  48365. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48366. /**
  48367. * Fired when the thumbstick on this controller is modified
  48368. */
  48369. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48370. /**
  48371. * Fired when the touchpad button on this controller is modified
  48372. */
  48373. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48374. /**
  48375. * Fired when the touchpad values on this controller are modified
  48376. */
  48377. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48378. /**
  48379. * Fired when the thumbstick button on this controller is modified
  48380. * here to prevent breaking changes
  48381. */
  48382. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48383. /**
  48384. * updating the thumbstick(!) and not the trackpad.
  48385. * This is named this way due to the difference between WebVR and XR and to avoid
  48386. * changing the parent class.
  48387. */
  48388. protected _updateTrackpad(): void;
  48389. /**
  48390. * Disposes the class with joy
  48391. */
  48392. dispose(): void;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Class containing static functions to help procedurally build meshes
  48398. */
  48399. export class PolyhedronBuilder {
  48400. /**
  48401. * Creates a polyhedron mesh
  48402. * * 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
  48403. * * The parameter `size` (positive float, default 1) sets the polygon size
  48404. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48405. * * 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`
  48406. * * 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
  48407. * * 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)`)
  48408. * * 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
  48409. * * 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
  48410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48411. * * 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
  48412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48413. * @param name defines the name of the mesh
  48414. * @param options defines the options used to create the mesh
  48415. * @param scene defines the hosting scene
  48416. * @returns the polyhedron mesh
  48417. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48418. */
  48419. static CreatePolyhedron(name: string, options: {
  48420. type?: number;
  48421. size?: number;
  48422. sizeX?: number;
  48423. sizeY?: number;
  48424. sizeZ?: number;
  48425. custom?: any;
  48426. faceUV?: Vector4[];
  48427. faceColors?: Color4[];
  48428. flat?: boolean;
  48429. updatable?: boolean;
  48430. sideOrientation?: number;
  48431. frontUVs?: Vector4;
  48432. backUVs?: Vector4;
  48433. }, scene?: Nullable<Scene>): Mesh;
  48434. }
  48435. }
  48436. declare module BABYLON {
  48437. /**
  48438. * Gizmo that enables scaling a mesh along 3 axis
  48439. */
  48440. export class ScaleGizmo extends Gizmo {
  48441. /**
  48442. * Internal gizmo used for interactions on the x axis
  48443. */
  48444. xGizmo: AxisScaleGizmo;
  48445. /**
  48446. * Internal gizmo used for interactions on the y axis
  48447. */
  48448. yGizmo: AxisScaleGizmo;
  48449. /**
  48450. * Internal gizmo used for interactions on the z axis
  48451. */
  48452. zGizmo: AxisScaleGizmo;
  48453. /**
  48454. * Internal gizmo used to scale all axis equally
  48455. */
  48456. uniformScaleGizmo: AxisScaleGizmo;
  48457. private _meshAttached;
  48458. private _updateGizmoRotationToMatchAttachedMesh;
  48459. private _snapDistance;
  48460. private _scaleRatio;
  48461. private _uniformScalingMesh;
  48462. private _octahedron;
  48463. private _sensitivity;
  48464. /** Fires an event when any of it's sub gizmos are dragged */
  48465. onDragStartObservable: Observable<unknown>;
  48466. /** Fires an event when any of it's sub gizmos are released from dragging */
  48467. onDragEndObservable: Observable<unknown>;
  48468. get attachedMesh(): Nullable<AbstractMesh>;
  48469. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48470. /**
  48471. * Creates a ScaleGizmo
  48472. * @param gizmoLayer The utility layer the gizmo will be added to
  48473. */
  48474. constructor(gizmoLayer?: UtilityLayerRenderer);
  48475. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48476. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48477. /**
  48478. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48479. */
  48480. set snapDistance(value: number);
  48481. get snapDistance(): number;
  48482. /**
  48483. * Ratio for the scale of the gizmo (Default: 1)
  48484. */
  48485. set scaleRatio(value: number);
  48486. get scaleRatio(): number;
  48487. /**
  48488. * Sensitivity factor for dragging (Default: 1)
  48489. */
  48490. set sensitivity(value: number);
  48491. get sensitivity(): number;
  48492. /**
  48493. * Disposes of the gizmo
  48494. */
  48495. dispose(): void;
  48496. }
  48497. }
  48498. declare module BABYLON {
  48499. /**
  48500. * Single axis scale gizmo
  48501. */
  48502. export class AxisScaleGizmo extends Gizmo {
  48503. /**
  48504. * Drag behavior responsible for the gizmos dragging interactions
  48505. */
  48506. dragBehavior: PointerDragBehavior;
  48507. private _pointerObserver;
  48508. /**
  48509. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48510. */
  48511. snapDistance: number;
  48512. /**
  48513. * Event that fires each time the gizmo snaps to a new location.
  48514. * * snapDistance is the the change in distance
  48515. */
  48516. onSnapObservable: Observable<{
  48517. snapDistance: number;
  48518. }>;
  48519. /**
  48520. * If the scaling operation should be done on all axis (default: false)
  48521. */
  48522. uniformScaling: boolean;
  48523. /**
  48524. * Custom sensitivity value for the drag strength
  48525. */
  48526. sensitivity: number;
  48527. private _isEnabled;
  48528. private _parent;
  48529. private _arrow;
  48530. private _coloredMaterial;
  48531. private _hoverMaterial;
  48532. /**
  48533. * Creates an AxisScaleGizmo
  48534. * @param gizmoLayer The utility layer the gizmo will be added to
  48535. * @param dragAxis The axis which the gizmo will be able to scale on
  48536. * @param color The color of the gizmo
  48537. */
  48538. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48540. /**
  48541. * If the gizmo is enabled
  48542. */
  48543. set isEnabled(value: boolean);
  48544. get isEnabled(): boolean;
  48545. /**
  48546. * Disposes of the gizmo
  48547. */
  48548. dispose(): void;
  48549. /**
  48550. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48551. * @param mesh The mesh to replace the default mesh of the gizmo
  48552. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48553. */
  48554. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48555. }
  48556. }
  48557. declare module BABYLON {
  48558. /**
  48559. * Bounding box gizmo
  48560. */
  48561. export class BoundingBoxGizmo extends Gizmo {
  48562. private _lineBoundingBox;
  48563. private _rotateSpheresParent;
  48564. private _scaleBoxesParent;
  48565. private _boundingDimensions;
  48566. private _renderObserver;
  48567. private _pointerObserver;
  48568. private _scaleDragSpeed;
  48569. private _tmpQuaternion;
  48570. private _tmpVector;
  48571. private _tmpRotationMatrix;
  48572. /**
  48573. * 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)
  48574. */
  48575. ignoreChildren: boolean;
  48576. /**
  48577. * 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)
  48578. */
  48579. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48580. /**
  48581. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48582. */
  48583. rotationSphereSize: number;
  48584. /**
  48585. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48586. */
  48587. scaleBoxSize: number;
  48588. /**
  48589. * 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)
  48590. */
  48591. fixedDragMeshScreenSize: boolean;
  48592. /**
  48593. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48594. */
  48595. fixedDragMeshScreenSizeDistanceFactor: number;
  48596. /**
  48597. * Fired when a rotation sphere or scale box is dragged
  48598. */
  48599. onDragStartObservable: Observable<{}>;
  48600. /**
  48601. * Fired when a scale box is dragged
  48602. */
  48603. onScaleBoxDragObservable: Observable<{}>;
  48604. /**
  48605. * Fired when a scale box drag is ended
  48606. */
  48607. onScaleBoxDragEndObservable: Observable<{}>;
  48608. /**
  48609. * Fired when a rotation sphere is dragged
  48610. */
  48611. onRotationSphereDragObservable: Observable<{}>;
  48612. /**
  48613. * Fired when a rotation sphere drag is ended
  48614. */
  48615. onRotationSphereDragEndObservable: Observable<{}>;
  48616. /**
  48617. * 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)
  48618. */
  48619. scalePivot: Nullable<Vector3>;
  48620. /**
  48621. * Mesh used as a pivot to rotate the attached mesh
  48622. */
  48623. private _anchorMesh;
  48624. private _existingMeshScale;
  48625. private _dragMesh;
  48626. private pointerDragBehavior;
  48627. private coloredMaterial;
  48628. private hoverColoredMaterial;
  48629. /**
  48630. * Sets the color of the bounding box gizmo
  48631. * @param color the color to set
  48632. */
  48633. setColor(color: Color3): void;
  48634. /**
  48635. * Creates an BoundingBoxGizmo
  48636. * @param gizmoLayer The utility layer the gizmo will be added to
  48637. * @param color The color of the gizmo
  48638. */
  48639. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48641. private _selectNode;
  48642. /**
  48643. * Updates the bounding box information for the Gizmo
  48644. */
  48645. updateBoundingBox(): void;
  48646. private _updateRotationSpheres;
  48647. private _updateScaleBoxes;
  48648. /**
  48649. * Enables rotation on the specified axis and disables rotation on the others
  48650. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48651. */
  48652. setEnabledRotationAxis(axis: string): void;
  48653. /**
  48654. * Enables/disables scaling
  48655. * @param enable if scaling should be enabled
  48656. */
  48657. setEnabledScaling(enable: boolean): void;
  48658. private _updateDummy;
  48659. /**
  48660. * Enables a pointer drag behavior on the bounding box of the gizmo
  48661. */
  48662. enableDragBehavior(): void;
  48663. /**
  48664. * Disposes of the gizmo
  48665. */
  48666. dispose(): void;
  48667. /**
  48668. * 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)
  48669. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48670. * @returns the bounding box mesh with the passed in mesh as a child
  48671. */
  48672. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48673. /**
  48674. * CustomMeshes are not supported by this gizmo
  48675. * @param mesh The mesh to replace the default mesh of the gizmo
  48676. */
  48677. setCustomMesh(mesh: Mesh): void;
  48678. }
  48679. }
  48680. declare module BABYLON {
  48681. /**
  48682. * Single plane rotation gizmo
  48683. */
  48684. export class PlaneRotationGizmo extends Gizmo {
  48685. /**
  48686. * Drag behavior responsible for the gizmos dragging interactions
  48687. */
  48688. dragBehavior: PointerDragBehavior;
  48689. private _pointerObserver;
  48690. /**
  48691. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48692. */
  48693. snapDistance: number;
  48694. /**
  48695. * Event that fires each time the gizmo snaps to a new location.
  48696. * * snapDistance is the the change in distance
  48697. */
  48698. onSnapObservable: Observable<{
  48699. snapDistance: number;
  48700. }>;
  48701. private _isEnabled;
  48702. private _parent;
  48703. /**
  48704. * Creates a PlaneRotationGizmo
  48705. * @param gizmoLayer The utility layer the gizmo will be added to
  48706. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48707. * @param color The color of the gizmo
  48708. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48709. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48710. */
  48711. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48712. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48713. /**
  48714. * If the gizmo is enabled
  48715. */
  48716. set isEnabled(value: boolean);
  48717. get isEnabled(): boolean;
  48718. /**
  48719. * Disposes of the gizmo
  48720. */
  48721. dispose(): void;
  48722. }
  48723. }
  48724. declare module BABYLON {
  48725. /**
  48726. * Gizmo that enables rotating a mesh along 3 axis
  48727. */
  48728. export class RotationGizmo extends Gizmo {
  48729. /**
  48730. * Internal gizmo used for interactions on the x axis
  48731. */
  48732. xGizmo: PlaneRotationGizmo;
  48733. /**
  48734. * Internal gizmo used for interactions on the y axis
  48735. */
  48736. yGizmo: PlaneRotationGizmo;
  48737. /**
  48738. * Internal gizmo used for interactions on the z axis
  48739. */
  48740. zGizmo: PlaneRotationGizmo;
  48741. /** Fires an event when any of it's sub gizmos are dragged */
  48742. onDragStartObservable: Observable<unknown>;
  48743. /** Fires an event when any of it's sub gizmos are released from dragging */
  48744. onDragEndObservable: Observable<unknown>;
  48745. private _meshAttached;
  48746. get attachedMesh(): Nullable<AbstractMesh>;
  48747. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48748. /**
  48749. * Creates a RotationGizmo
  48750. * @param gizmoLayer The utility layer the gizmo will be added to
  48751. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48752. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48753. */
  48754. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48755. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48756. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48757. /**
  48758. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48759. */
  48760. set snapDistance(value: number);
  48761. get snapDistance(): number;
  48762. /**
  48763. * Ratio for the scale of the gizmo (Default: 1)
  48764. */
  48765. set scaleRatio(value: number);
  48766. get scaleRatio(): number;
  48767. /**
  48768. * Disposes of the gizmo
  48769. */
  48770. dispose(): void;
  48771. /**
  48772. * CustomMeshes are not supported by this gizmo
  48773. * @param mesh The mesh to replace the default mesh of the gizmo
  48774. */
  48775. setCustomMesh(mesh: Mesh): void;
  48776. }
  48777. }
  48778. declare module BABYLON {
  48779. /**
  48780. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48781. */
  48782. export class GizmoManager implements IDisposable {
  48783. private scene;
  48784. /**
  48785. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48786. */
  48787. gizmos: {
  48788. positionGizmo: Nullable<PositionGizmo>;
  48789. rotationGizmo: Nullable<RotationGizmo>;
  48790. scaleGizmo: Nullable<ScaleGizmo>;
  48791. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48792. };
  48793. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48794. clearGizmoOnEmptyPointerEvent: boolean;
  48795. /** Fires an event when the manager is attached to a mesh */
  48796. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48797. private _gizmosEnabled;
  48798. private _pointerObserver;
  48799. private _attachedMesh;
  48800. private _boundingBoxColor;
  48801. private _defaultUtilityLayer;
  48802. private _defaultKeepDepthUtilityLayer;
  48803. /**
  48804. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48805. */
  48806. boundingBoxDragBehavior: SixDofDragBehavior;
  48807. /**
  48808. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48809. */
  48810. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48811. /**
  48812. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48813. */
  48814. usePointerToAttachGizmos: boolean;
  48815. /**
  48816. * Utility layer that the bounding box gizmo belongs to
  48817. */
  48818. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48819. /**
  48820. * Utility layer that all gizmos besides bounding box belong to
  48821. */
  48822. get utilityLayer(): UtilityLayerRenderer;
  48823. /**
  48824. * Instatiates a gizmo manager
  48825. * @param scene the scene to overlay the gizmos on top of
  48826. */
  48827. constructor(scene: Scene);
  48828. /**
  48829. * Attaches a set of gizmos to the specified mesh
  48830. * @param mesh The mesh the gizmo's should be attached to
  48831. */
  48832. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48833. /**
  48834. * If the position gizmo is enabled
  48835. */
  48836. set positionGizmoEnabled(value: boolean);
  48837. get positionGizmoEnabled(): boolean;
  48838. /**
  48839. * If the rotation gizmo is enabled
  48840. */
  48841. set rotationGizmoEnabled(value: boolean);
  48842. get rotationGizmoEnabled(): boolean;
  48843. /**
  48844. * If the scale gizmo is enabled
  48845. */
  48846. set scaleGizmoEnabled(value: boolean);
  48847. get scaleGizmoEnabled(): boolean;
  48848. /**
  48849. * If the boundingBox gizmo is enabled
  48850. */
  48851. set boundingBoxGizmoEnabled(value: boolean);
  48852. get boundingBoxGizmoEnabled(): boolean;
  48853. /**
  48854. * Disposes of the gizmo manager
  48855. */
  48856. dispose(): void;
  48857. }
  48858. }
  48859. declare module BABYLON {
  48860. /**
  48861. * A directional light is defined by a direction (what a surprise!).
  48862. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48863. * 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.
  48864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48865. */
  48866. export class DirectionalLight extends ShadowLight {
  48867. private _shadowFrustumSize;
  48868. /**
  48869. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48870. */
  48871. get shadowFrustumSize(): number;
  48872. /**
  48873. * Specifies a fix frustum size for the shadow generation.
  48874. */
  48875. set shadowFrustumSize(value: number);
  48876. private _shadowOrthoScale;
  48877. /**
  48878. * Gets the shadow projection scale against the optimal computed one.
  48879. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48880. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48881. */
  48882. get shadowOrthoScale(): number;
  48883. /**
  48884. * Sets the shadow projection scale against the optimal computed one.
  48885. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48886. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48887. */
  48888. set shadowOrthoScale(value: number);
  48889. /**
  48890. * Automatically compute the projection matrix to best fit (including all the casters)
  48891. * on each frame.
  48892. */
  48893. autoUpdateExtends: boolean;
  48894. /**
  48895. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48896. * on each frame. autoUpdateExtends must be set to true for this to work
  48897. */
  48898. autoCalcShadowZBounds: boolean;
  48899. private _orthoLeft;
  48900. private _orthoRight;
  48901. private _orthoTop;
  48902. private _orthoBottom;
  48903. /**
  48904. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48905. * The directional light is emitted from everywhere in the given direction.
  48906. * It can cast shadows.
  48907. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48908. * @param name The friendly name of the light
  48909. * @param direction The direction of the light
  48910. * @param scene The scene the light belongs to
  48911. */
  48912. constructor(name: string, direction: Vector3, scene: Scene);
  48913. /**
  48914. * Returns the string "DirectionalLight".
  48915. * @return The class name
  48916. */
  48917. getClassName(): string;
  48918. /**
  48919. * Returns the integer 1.
  48920. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48921. */
  48922. getTypeID(): number;
  48923. /**
  48924. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48925. * Returns the DirectionalLight Shadow projection matrix.
  48926. */
  48927. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48928. /**
  48929. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48930. * Returns the DirectionalLight Shadow projection matrix.
  48931. */
  48932. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48933. /**
  48934. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48935. * Returns the DirectionalLight Shadow projection matrix.
  48936. */
  48937. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48938. protected _buildUniformLayout(): void;
  48939. /**
  48940. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48941. * @param effect The effect to update
  48942. * @param lightIndex The index of the light in the effect to update
  48943. * @returns The directional light
  48944. */
  48945. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48946. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48947. /**
  48948. * Gets the minZ used for shadow according to both the scene and the light.
  48949. *
  48950. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48951. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48952. * @param activeCamera The camera we are returning the min for
  48953. * @returns the depth min z
  48954. */
  48955. getDepthMinZ(activeCamera: Camera): number;
  48956. /**
  48957. * Gets the maxZ used for shadow according to both the scene and the light.
  48958. *
  48959. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48960. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48961. * @param activeCamera The camera we are returning the max for
  48962. * @returns the depth max z
  48963. */
  48964. getDepthMaxZ(activeCamera: Camera): number;
  48965. /**
  48966. * Prepares the list of defines specific to the light type.
  48967. * @param defines the list of defines
  48968. * @param lightIndex defines the index of the light for the effect
  48969. */
  48970. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48971. }
  48972. }
  48973. declare module BABYLON {
  48974. /**
  48975. * Class containing static functions to help procedurally build meshes
  48976. */
  48977. export class HemisphereBuilder {
  48978. /**
  48979. * Creates a hemisphere mesh
  48980. * @param name defines the name of the mesh
  48981. * @param options defines the options used to create the mesh
  48982. * @param scene defines the hosting scene
  48983. * @returns the hemisphere mesh
  48984. */
  48985. static CreateHemisphere(name: string, options: {
  48986. segments?: number;
  48987. diameter?: number;
  48988. sideOrientation?: number;
  48989. }, scene: any): Mesh;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48995. * These values define a cone of light starting from the position, emitting toward the direction.
  48996. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48997. * and the exponent defines the speed of the decay of the light with distance (reach).
  48998. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48999. */
  49000. export class SpotLight extends ShadowLight {
  49001. private _angle;
  49002. private _innerAngle;
  49003. private _cosHalfAngle;
  49004. private _lightAngleScale;
  49005. private _lightAngleOffset;
  49006. /**
  49007. * Gets the cone angle of the spot light in Radians.
  49008. */
  49009. get angle(): number;
  49010. /**
  49011. * Sets the cone angle of the spot light in Radians.
  49012. */
  49013. set angle(value: number);
  49014. /**
  49015. * Only used in gltf falloff mode, this defines the angle where
  49016. * the directional falloff will start before cutting at angle which could be seen
  49017. * as outer angle.
  49018. */
  49019. get innerAngle(): number;
  49020. /**
  49021. * Only used in gltf falloff mode, this defines the angle where
  49022. * the directional falloff will start before cutting at angle which could be seen
  49023. * as outer angle.
  49024. */
  49025. set innerAngle(value: number);
  49026. private _shadowAngleScale;
  49027. /**
  49028. * Allows scaling the angle of the light for shadow generation only.
  49029. */
  49030. get shadowAngleScale(): number;
  49031. /**
  49032. * Allows scaling the angle of the light for shadow generation only.
  49033. */
  49034. set shadowAngleScale(value: number);
  49035. /**
  49036. * The light decay speed with the distance from the emission spot.
  49037. */
  49038. exponent: number;
  49039. private _projectionTextureMatrix;
  49040. /**
  49041. * Allows reading the projecton texture
  49042. */
  49043. get projectionTextureMatrix(): Matrix;
  49044. protected _projectionTextureLightNear: number;
  49045. /**
  49046. * Gets the near clip of the Spotlight for texture projection.
  49047. */
  49048. get projectionTextureLightNear(): number;
  49049. /**
  49050. * Sets the near clip of the Spotlight for texture projection.
  49051. */
  49052. set projectionTextureLightNear(value: number);
  49053. protected _projectionTextureLightFar: number;
  49054. /**
  49055. * Gets the far clip of the Spotlight for texture projection.
  49056. */
  49057. get projectionTextureLightFar(): number;
  49058. /**
  49059. * Sets the far clip of the Spotlight for texture projection.
  49060. */
  49061. set projectionTextureLightFar(value: number);
  49062. protected _projectionTextureUpDirection: Vector3;
  49063. /**
  49064. * Gets the Up vector of the Spotlight for texture projection.
  49065. */
  49066. get projectionTextureUpDirection(): Vector3;
  49067. /**
  49068. * Sets the Up vector of the Spotlight for texture projection.
  49069. */
  49070. set projectionTextureUpDirection(value: Vector3);
  49071. private _projectionTexture;
  49072. /**
  49073. * Gets the projection texture of the light.
  49074. */
  49075. get projectionTexture(): Nullable<BaseTexture>;
  49076. /**
  49077. * Sets the projection texture of the light.
  49078. */
  49079. set projectionTexture(value: Nullable<BaseTexture>);
  49080. private _projectionTextureViewLightDirty;
  49081. private _projectionTextureProjectionLightDirty;
  49082. private _projectionTextureDirty;
  49083. private _projectionTextureViewTargetVector;
  49084. private _projectionTextureViewLightMatrix;
  49085. private _projectionTextureProjectionLightMatrix;
  49086. private _projectionTextureScalingMatrix;
  49087. /**
  49088. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49089. * It can cast shadows.
  49090. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49091. * @param name The light friendly name
  49092. * @param position The position of the spot light in the scene
  49093. * @param direction The direction of the light in the scene
  49094. * @param angle The cone angle of the light in Radians
  49095. * @param exponent The light decay speed with the distance from the emission spot
  49096. * @param scene The scene the lights belongs to
  49097. */
  49098. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49099. /**
  49100. * Returns the string "SpotLight".
  49101. * @returns the class name
  49102. */
  49103. getClassName(): string;
  49104. /**
  49105. * Returns the integer 2.
  49106. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49107. */
  49108. getTypeID(): number;
  49109. /**
  49110. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49111. */
  49112. protected _setDirection(value: Vector3): void;
  49113. /**
  49114. * Overrides the position setter to recompute the projection texture view light Matrix.
  49115. */
  49116. protected _setPosition(value: Vector3): void;
  49117. /**
  49118. * 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.
  49119. * Returns the SpotLight.
  49120. */
  49121. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49122. protected _computeProjectionTextureViewLightMatrix(): void;
  49123. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49124. /**
  49125. * Main function for light texture projection matrix computing.
  49126. */
  49127. protected _computeProjectionTextureMatrix(): void;
  49128. protected _buildUniformLayout(): void;
  49129. private _computeAngleValues;
  49130. /**
  49131. * Sets the passed Effect "effect" with the Light textures.
  49132. * @param effect The effect to update
  49133. * @param lightIndex The index of the light in the effect to update
  49134. * @returns The light
  49135. */
  49136. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49137. /**
  49138. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49139. * @param effect The effect to update
  49140. * @param lightIndex The index of the light in the effect to update
  49141. * @returns The spot light
  49142. */
  49143. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49144. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49145. /**
  49146. * Disposes the light and the associated resources.
  49147. */
  49148. dispose(): void;
  49149. /**
  49150. * Prepares the list of defines specific to the light type.
  49151. * @param defines the list of defines
  49152. * @param lightIndex defines the index of the light for the effect
  49153. */
  49154. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49155. }
  49156. }
  49157. declare module BABYLON {
  49158. /**
  49159. * Gizmo that enables viewing a light
  49160. */
  49161. export class LightGizmo extends Gizmo {
  49162. private _lightMesh;
  49163. private _material;
  49164. private _cachedPosition;
  49165. private _cachedForward;
  49166. private _attachedMeshParent;
  49167. /**
  49168. * Creates a LightGizmo
  49169. * @param gizmoLayer The utility layer the gizmo will be added to
  49170. */
  49171. constructor(gizmoLayer?: UtilityLayerRenderer);
  49172. private _light;
  49173. /**
  49174. * The light that the gizmo is attached to
  49175. */
  49176. set light(light: Nullable<Light>);
  49177. get light(): Nullable<Light>;
  49178. /**
  49179. * Gets the material used to render the light gizmo
  49180. */
  49181. get material(): StandardMaterial;
  49182. /**
  49183. * @hidden
  49184. * Updates the gizmo to match the attached mesh's position/rotation
  49185. */
  49186. protected _update(): void;
  49187. private static _Scale;
  49188. /**
  49189. * Creates the lines for a light mesh
  49190. */
  49191. private static _CreateLightLines;
  49192. /**
  49193. * Disposes of the light gizmo
  49194. */
  49195. dispose(): void;
  49196. private static _CreateHemisphericLightMesh;
  49197. private static _CreatePointLightMesh;
  49198. private static _CreateSpotLightMesh;
  49199. private static _CreateDirectionalLightMesh;
  49200. }
  49201. }
  49202. declare module BABYLON {
  49203. /** @hidden */
  49204. export var backgroundFragmentDeclaration: {
  49205. name: string;
  49206. shader: string;
  49207. };
  49208. }
  49209. declare module BABYLON {
  49210. /** @hidden */
  49211. export var backgroundUboDeclaration: {
  49212. name: string;
  49213. shader: string;
  49214. };
  49215. }
  49216. declare module BABYLON {
  49217. /** @hidden */
  49218. export var backgroundPixelShader: {
  49219. name: string;
  49220. shader: string;
  49221. };
  49222. }
  49223. declare module BABYLON {
  49224. /** @hidden */
  49225. export var backgroundVertexDeclaration: {
  49226. name: string;
  49227. shader: string;
  49228. };
  49229. }
  49230. declare module BABYLON {
  49231. /** @hidden */
  49232. export var backgroundVertexShader: {
  49233. name: string;
  49234. shader: string;
  49235. };
  49236. }
  49237. declare module BABYLON {
  49238. /**
  49239. * Background material used to create an efficient environement around your scene.
  49240. */
  49241. export class BackgroundMaterial extends PushMaterial {
  49242. /**
  49243. * Standard reflectance value at parallel view angle.
  49244. */
  49245. static StandardReflectance0: number;
  49246. /**
  49247. * Standard reflectance value at grazing angle.
  49248. */
  49249. static StandardReflectance90: number;
  49250. protected _primaryColor: Color3;
  49251. /**
  49252. * Key light Color (multiply against the environement texture)
  49253. */
  49254. primaryColor: Color3;
  49255. protected __perceptualColor: Nullable<Color3>;
  49256. /**
  49257. * Experimental Internal Use Only.
  49258. *
  49259. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49260. * This acts as a helper to set the primary color to a more "human friendly" value.
  49261. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49262. * output color as close as possible from the chosen value.
  49263. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49264. * part of lighting setup.)
  49265. */
  49266. get _perceptualColor(): Nullable<Color3>;
  49267. set _perceptualColor(value: Nullable<Color3>);
  49268. protected _primaryColorShadowLevel: float;
  49269. /**
  49270. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49271. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49272. */
  49273. get primaryColorShadowLevel(): float;
  49274. set primaryColorShadowLevel(value: float);
  49275. protected _primaryColorHighlightLevel: float;
  49276. /**
  49277. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49278. * The primary color is used at the level chosen to define what the white area would look.
  49279. */
  49280. get primaryColorHighlightLevel(): float;
  49281. set primaryColorHighlightLevel(value: float);
  49282. protected _reflectionTexture: Nullable<BaseTexture>;
  49283. /**
  49284. * Reflection Texture used in the material.
  49285. * Should be author in a specific way for the best result (refer to the documentation).
  49286. */
  49287. reflectionTexture: Nullable<BaseTexture>;
  49288. protected _reflectionBlur: float;
  49289. /**
  49290. * Reflection Texture level of blur.
  49291. *
  49292. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49293. * texture twice.
  49294. */
  49295. reflectionBlur: float;
  49296. protected _diffuseTexture: Nullable<BaseTexture>;
  49297. /**
  49298. * Diffuse Texture used in the material.
  49299. * Should be author in a specific way for the best result (refer to the documentation).
  49300. */
  49301. diffuseTexture: Nullable<BaseTexture>;
  49302. protected _shadowLights: Nullable<IShadowLight[]>;
  49303. /**
  49304. * Specify the list of lights casting shadow on the material.
  49305. * All scene shadow lights will be included if null.
  49306. */
  49307. shadowLights: Nullable<IShadowLight[]>;
  49308. protected _shadowLevel: float;
  49309. /**
  49310. * Helps adjusting the shadow to a softer level if required.
  49311. * 0 means black shadows and 1 means no shadows.
  49312. */
  49313. shadowLevel: float;
  49314. protected _sceneCenter: Vector3;
  49315. /**
  49316. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49317. * It is usually zero but might be interesting to modify according to your setup.
  49318. */
  49319. sceneCenter: Vector3;
  49320. protected _opacityFresnel: boolean;
  49321. /**
  49322. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49323. * This helps ensuring a nice transition when the camera goes under the ground.
  49324. */
  49325. opacityFresnel: boolean;
  49326. protected _reflectionFresnel: boolean;
  49327. /**
  49328. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49329. * This helps adding a mirror texture on the ground.
  49330. */
  49331. reflectionFresnel: boolean;
  49332. protected _reflectionFalloffDistance: number;
  49333. /**
  49334. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49335. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49336. */
  49337. reflectionFalloffDistance: number;
  49338. protected _reflectionAmount: number;
  49339. /**
  49340. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49341. */
  49342. reflectionAmount: number;
  49343. protected _reflectionReflectance0: number;
  49344. /**
  49345. * This specifies the weight of the reflection at grazing angle.
  49346. */
  49347. reflectionReflectance0: number;
  49348. protected _reflectionReflectance90: number;
  49349. /**
  49350. * This specifies the weight of the reflection at a perpendicular point of view.
  49351. */
  49352. reflectionReflectance90: number;
  49353. /**
  49354. * Sets the reflection reflectance fresnel values according to the default standard
  49355. * empirically know to work well :-)
  49356. */
  49357. set reflectionStandardFresnelWeight(value: number);
  49358. protected _useRGBColor: boolean;
  49359. /**
  49360. * Helps to directly use the maps channels instead of their level.
  49361. */
  49362. useRGBColor: boolean;
  49363. protected _enableNoise: boolean;
  49364. /**
  49365. * This helps reducing the banding effect that could occur on the background.
  49366. */
  49367. enableNoise: boolean;
  49368. /**
  49369. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49370. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49371. * Recommended to be keep at 1.0 except for special cases.
  49372. */
  49373. get fovMultiplier(): number;
  49374. set fovMultiplier(value: number);
  49375. private _fovMultiplier;
  49376. /**
  49377. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49378. */
  49379. useEquirectangularFOV: boolean;
  49380. private _maxSimultaneousLights;
  49381. /**
  49382. * Number of Simultaneous lights allowed on the material.
  49383. */
  49384. maxSimultaneousLights: int;
  49385. /**
  49386. * Default configuration related to image processing available in the Background Material.
  49387. */
  49388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49389. /**
  49390. * Keep track of the image processing observer to allow dispose and replace.
  49391. */
  49392. private _imageProcessingObserver;
  49393. /**
  49394. * Attaches a new image processing configuration to the PBR Material.
  49395. * @param configuration (if null the scene configuration will be use)
  49396. */
  49397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49398. /**
  49399. * Gets the image processing configuration used either in this material.
  49400. */
  49401. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49402. /**
  49403. * Sets the Default image processing configuration used either in the this material.
  49404. *
  49405. * If sets to null, the scene one is in use.
  49406. */
  49407. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49408. /**
  49409. * Gets wether the color curves effect is enabled.
  49410. */
  49411. get cameraColorCurvesEnabled(): boolean;
  49412. /**
  49413. * Sets wether the color curves effect is enabled.
  49414. */
  49415. set cameraColorCurvesEnabled(value: boolean);
  49416. /**
  49417. * Gets wether the color grading effect is enabled.
  49418. */
  49419. get cameraColorGradingEnabled(): boolean;
  49420. /**
  49421. * Gets wether the color grading effect is enabled.
  49422. */
  49423. set cameraColorGradingEnabled(value: boolean);
  49424. /**
  49425. * Gets wether tonemapping is enabled or not.
  49426. */
  49427. get cameraToneMappingEnabled(): boolean;
  49428. /**
  49429. * Sets wether tonemapping is enabled or not
  49430. */
  49431. set cameraToneMappingEnabled(value: boolean);
  49432. /**
  49433. * The camera exposure used on this material.
  49434. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49435. * This corresponds to a photographic exposure.
  49436. */
  49437. get cameraExposure(): float;
  49438. /**
  49439. * The camera exposure used on this material.
  49440. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49441. * This corresponds to a photographic exposure.
  49442. */
  49443. set cameraExposure(value: float);
  49444. /**
  49445. * Gets The camera contrast used on this material.
  49446. */
  49447. get cameraContrast(): float;
  49448. /**
  49449. * Sets The camera contrast used on this material.
  49450. */
  49451. set cameraContrast(value: float);
  49452. /**
  49453. * Gets the Color Grading 2D Lookup Texture.
  49454. */
  49455. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49456. /**
  49457. * Sets the Color Grading 2D Lookup Texture.
  49458. */
  49459. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49460. /**
  49461. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49462. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49463. * 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;
  49464. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49465. */
  49466. get cameraColorCurves(): Nullable<ColorCurves>;
  49467. /**
  49468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49470. * 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;
  49471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49472. */
  49473. set cameraColorCurves(value: Nullable<ColorCurves>);
  49474. /**
  49475. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49476. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49477. */
  49478. switchToBGR: boolean;
  49479. private _renderTargets;
  49480. private _reflectionControls;
  49481. private _white;
  49482. private _primaryShadowColor;
  49483. private _primaryHighlightColor;
  49484. /**
  49485. * Instantiates a Background Material in the given scene
  49486. * @param name The friendly name of the material
  49487. * @param scene The scene to add the material to
  49488. */
  49489. constructor(name: string, scene: Scene);
  49490. /**
  49491. * Gets a boolean indicating that current material needs to register RTT
  49492. */
  49493. get hasRenderTargetTextures(): boolean;
  49494. /**
  49495. * The entire material has been created in order to prevent overdraw.
  49496. * @returns false
  49497. */
  49498. needAlphaTesting(): boolean;
  49499. /**
  49500. * The entire material has been created in order to prevent overdraw.
  49501. * @returns true if blending is enable
  49502. */
  49503. needAlphaBlending(): boolean;
  49504. /**
  49505. * Checks wether the material is ready to be rendered for a given mesh.
  49506. * @param mesh The mesh to render
  49507. * @param subMesh The submesh to check against
  49508. * @param useInstances Specify wether or not the material is used with instances
  49509. * @returns true if all the dependencies are ready (Textures, Effects...)
  49510. */
  49511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49512. /**
  49513. * Compute the primary color according to the chosen perceptual color.
  49514. */
  49515. private _computePrimaryColorFromPerceptualColor;
  49516. /**
  49517. * Compute the highlights and shadow colors according to their chosen levels.
  49518. */
  49519. private _computePrimaryColors;
  49520. /**
  49521. * Build the uniform buffer used in the material.
  49522. */
  49523. buildUniformLayout(): void;
  49524. /**
  49525. * Unbind the material.
  49526. */
  49527. unbind(): void;
  49528. /**
  49529. * Bind only the world matrix to the material.
  49530. * @param world The world matrix to bind.
  49531. */
  49532. bindOnlyWorldMatrix(world: Matrix): void;
  49533. /**
  49534. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49535. * @param world The world matrix to bind.
  49536. * @param subMesh The submesh to bind for.
  49537. */
  49538. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49539. /**
  49540. * Checks to see if a texture is used in the material.
  49541. * @param texture - Base texture to use.
  49542. * @returns - Boolean specifying if a texture is used in the material.
  49543. */
  49544. hasTexture(texture: BaseTexture): boolean;
  49545. /**
  49546. * Dispose the material.
  49547. * @param forceDisposeEffect Force disposal of the associated effect.
  49548. * @param forceDisposeTextures Force disposal of the associated textures.
  49549. */
  49550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49551. /**
  49552. * Clones the material.
  49553. * @param name The cloned name.
  49554. * @returns The cloned material.
  49555. */
  49556. clone(name: string): BackgroundMaterial;
  49557. /**
  49558. * Serializes the current material to its JSON representation.
  49559. * @returns The JSON representation.
  49560. */
  49561. serialize(): any;
  49562. /**
  49563. * Gets the class name of the material
  49564. * @returns "BackgroundMaterial"
  49565. */
  49566. getClassName(): string;
  49567. /**
  49568. * Parse a JSON input to create back a background material.
  49569. * @param source The JSON data to parse
  49570. * @param scene The scene to create the parsed material in
  49571. * @param rootUrl The root url of the assets the material depends upon
  49572. * @returns the instantiated BackgroundMaterial.
  49573. */
  49574. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49575. }
  49576. }
  49577. declare module BABYLON {
  49578. /**
  49579. * Represents the different options available during the creation of
  49580. * a Environment helper.
  49581. *
  49582. * This can control the default ground, skybox and image processing setup of your scene.
  49583. */
  49584. export interface IEnvironmentHelperOptions {
  49585. /**
  49586. * Specifies wether or not to create a ground.
  49587. * True by default.
  49588. */
  49589. createGround: boolean;
  49590. /**
  49591. * Specifies the ground size.
  49592. * 15 by default.
  49593. */
  49594. groundSize: number;
  49595. /**
  49596. * The texture used on the ground for the main color.
  49597. * Comes from the BabylonJS CDN by default.
  49598. *
  49599. * Remarks: Can be either a texture or a url.
  49600. */
  49601. groundTexture: string | BaseTexture;
  49602. /**
  49603. * The color mixed in the ground texture by default.
  49604. * BabylonJS clearColor by default.
  49605. */
  49606. groundColor: Color3;
  49607. /**
  49608. * Specifies the ground opacity.
  49609. * 1 by default.
  49610. */
  49611. groundOpacity: number;
  49612. /**
  49613. * Enables the ground to receive shadows.
  49614. * True by default.
  49615. */
  49616. enableGroundShadow: boolean;
  49617. /**
  49618. * Helps preventing the shadow to be fully black on the ground.
  49619. * 0.5 by default.
  49620. */
  49621. groundShadowLevel: number;
  49622. /**
  49623. * Creates a mirror texture attach to the ground.
  49624. * false by default.
  49625. */
  49626. enableGroundMirror: boolean;
  49627. /**
  49628. * Specifies the ground mirror size ratio.
  49629. * 0.3 by default as the default kernel is 64.
  49630. */
  49631. groundMirrorSizeRatio: number;
  49632. /**
  49633. * Specifies the ground mirror blur kernel size.
  49634. * 64 by default.
  49635. */
  49636. groundMirrorBlurKernel: number;
  49637. /**
  49638. * Specifies the ground mirror visibility amount.
  49639. * 1 by default
  49640. */
  49641. groundMirrorAmount: number;
  49642. /**
  49643. * Specifies the ground mirror reflectance weight.
  49644. * This uses the standard weight of the background material to setup the fresnel effect
  49645. * of the mirror.
  49646. * 1 by default.
  49647. */
  49648. groundMirrorFresnelWeight: number;
  49649. /**
  49650. * Specifies the ground mirror Falloff distance.
  49651. * This can helps reducing the size of the reflection.
  49652. * 0 by Default.
  49653. */
  49654. groundMirrorFallOffDistance: number;
  49655. /**
  49656. * Specifies the ground mirror texture type.
  49657. * Unsigned Int by Default.
  49658. */
  49659. groundMirrorTextureType: number;
  49660. /**
  49661. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49662. * the shown objects.
  49663. */
  49664. groundYBias: number;
  49665. /**
  49666. * Specifies wether or not to create a skybox.
  49667. * True by default.
  49668. */
  49669. createSkybox: boolean;
  49670. /**
  49671. * Specifies the skybox size.
  49672. * 20 by default.
  49673. */
  49674. skyboxSize: number;
  49675. /**
  49676. * The texture used on the skybox for the main color.
  49677. * Comes from the BabylonJS CDN by default.
  49678. *
  49679. * Remarks: Can be either a texture or a url.
  49680. */
  49681. skyboxTexture: string | BaseTexture;
  49682. /**
  49683. * The color mixed in the skybox texture by default.
  49684. * BabylonJS clearColor by default.
  49685. */
  49686. skyboxColor: Color3;
  49687. /**
  49688. * The background rotation around the Y axis of the scene.
  49689. * This helps aligning the key lights of your scene with the background.
  49690. * 0 by default.
  49691. */
  49692. backgroundYRotation: number;
  49693. /**
  49694. * Compute automatically the size of the elements to best fit with the scene.
  49695. */
  49696. sizeAuto: boolean;
  49697. /**
  49698. * Default position of the rootMesh if autoSize is not true.
  49699. */
  49700. rootPosition: Vector3;
  49701. /**
  49702. * Sets up the image processing in the scene.
  49703. * true by default.
  49704. */
  49705. setupImageProcessing: boolean;
  49706. /**
  49707. * The texture used as your environment texture in the scene.
  49708. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49709. *
  49710. * Remarks: Can be either a texture or a url.
  49711. */
  49712. environmentTexture: string | BaseTexture;
  49713. /**
  49714. * The value of the exposure to apply to the scene.
  49715. * 0.6 by default if setupImageProcessing is true.
  49716. */
  49717. cameraExposure: number;
  49718. /**
  49719. * The value of the contrast to apply to the scene.
  49720. * 1.6 by default if setupImageProcessing is true.
  49721. */
  49722. cameraContrast: number;
  49723. /**
  49724. * Specifies wether or not tonemapping should be enabled in the scene.
  49725. * true by default if setupImageProcessing is true.
  49726. */
  49727. toneMappingEnabled: boolean;
  49728. }
  49729. /**
  49730. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49731. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49732. * It also helps with the default setup of your imageProcessing configuration.
  49733. */
  49734. export class EnvironmentHelper {
  49735. /**
  49736. * Default ground texture URL.
  49737. */
  49738. private static _groundTextureCDNUrl;
  49739. /**
  49740. * Default skybox texture URL.
  49741. */
  49742. private static _skyboxTextureCDNUrl;
  49743. /**
  49744. * Default environment texture URL.
  49745. */
  49746. private static _environmentTextureCDNUrl;
  49747. /**
  49748. * Creates the default options for the helper.
  49749. */
  49750. private static _getDefaultOptions;
  49751. private _rootMesh;
  49752. /**
  49753. * Gets the root mesh created by the helper.
  49754. */
  49755. get rootMesh(): Mesh;
  49756. private _skybox;
  49757. /**
  49758. * Gets the skybox created by the helper.
  49759. */
  49760. get skybox(): Nullable<Mesh>;
  49761. private _skyboxTexture;
  49762. /**
  49763. * Gets the skybox texture created by the helper.
  49764. */
  49765. get skyboxTexture(): Nullable<BaseTexture>;
  49766. private _skyboxMaterial;
  49767. /**
  49768. * Gets the skybox material created by the helper.
  49769. */
  49770. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49771. private _ground;
  49772. /**
  49773. * Gets the ground mesh created by the helper.
  49774. */
  49775. get ground(): Nullable<Mesh>;
  49776. private _groundTexture;
  49777. /**
  49778. * Gets the ground texture created by the helper.
  49779. */
  49780. get groundTexture(): Nullable<BaseTexture>;
  49781. private _groundMirror;
  49782. /**
  49783. * Gets the ground mirror created by the helper.
  49784. */
  49785. get groundMirror(): Nullable<MirrorTexture>;
  49786. /**
  49787. * Gets the ground mirror render list to helps pushing the meshes
  49788. * you wish in the ground reflection.
  49789. */
  49790. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49791. private _groundMaterial;
  49792. /**
  49793. * Gets the ground material created by the helper.
  49794. */
  49795. get groundMaterial(): Nullable<BackgroundMaterial>;
  49796. /**
  49797. * Stores the creation options.
  49798. */
  49799. private readonly _scene;
  49800. private _options;
  49801. /**
  49802. * This observable will be notified with any error during the creation of the environment,
  49803. * mainly texture creation errors.
  49804. */
  49805. onErrorObservable: Observable<{
  49806. message?: string;
  49807. exception?: any;
  49808. }>;
  49809. /**
  49810. * constructor
  49811. * @param options Defines the options we want to customize the helper
  49812. * @param scene The scene to add the material to
  49813. */
  49814. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49815. /**
  49816. * Updates the background according to the new options
  49817. * @param options
  49818. */
  49819. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49820. /**
  49821. * Sets the primary color of all the available elements.
  49822. * @param color the main color to affect to the ground and the background
  49823. */
  49824. setMainColor(color: Color3): void;
  49825. /**
  49826. * Setup the image processing according to the specified options.
  49827. */
  49828. private _setupImageProcessing;
  49829. /**
  49830. * Setup the environment texture according to the specified options.
  49831. */
  49832. private _setupEnvironmentTexture;
  49833. /**
  49834. * Setup the background according to the specified options.
  49835. */
  49836. private _setupBackground;
  49837. /**
  49838. * Get the scene sizes according to the setup.
  49839. */
  49840. private _getSceneSize;
  49841. /**
  49842. * Setup the ground according to the specified options.
  49843. */
  49844. private _setupGround;
  49845. /**
  49846. * Setup the ground material according to the specified options.
  49847. */
  49848. private _setupGroundMaterial;
  49849. /**
  49850. * Setup the ground diffuse texture according to the specified options.
  49851. */
  49852. private _setupGroundDiffuseTexture;
  49853. /**
  49854. * Setup the ground mirror texture according to the specified options.
  49855. */
  49856. private _setupGroundMirrorTexture;
  49857. /**
  49858. * Setup the ground to receive the mirror texture.
  49859. */
  49860. private _setupMirrorInGroundMaterial;
  49861. /**
  49862. * Setup the skybox according to the specified options.
  49863. */
  49864. private _setupSkybox;
  49865. /**
  49866. * Setup the skybox material according to the specified options.
  49867. */
  49868. private _setupSkyboxMaterial;
  49869. /**
  49870. * Setup the skybox reflection texture according to the specified options.
  49871. */
  49872. private _setupSkyboxReflectionTexture;
  49873. private _errorHandler;
  49874. /**
  49875. * Dispose all the elements created by the Helper.
  49876. */
  49877. dispose(): void;
  49878. }
  49879. }
  49880. declare module BABYLON {
  49881. /**
  49882. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49883. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49884. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49885. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49886. */
  49887. export class PhotoDome extends TransformNode {
  49888. /**
  49889. * Define the image as a Monoscopic panoramic 360 image.
  49890. */
  49891. static readonly MODE_MONOSCOPIC: number;
  49892. /**
  49893. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49894. */
  49895. static readonly MODE_TOPBOTTOM: number;
  49896. /**
  49897. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49898. */
  49899. static readonly MODE_SIDEBYSIDE: number;
  49900. private _useDirectMapping;
  49901. /**
  49902. * The texture being displayed on the sphere
  49903. */
  49904. protected _photoTexture: Texture;
  49905. /**
  49906. * Gets or sets the texture being displayed on the sphere
  49907. */
  49908. get photoTexture(): Texture;
  49909. set photoTexture(value: Texture);
  49910. /**
  49911. * Observable raised when an error occured while loading the 360 image
  49912. */
  49913. onLoadErrorObservable: Observable<string>;
  49914. /**
  49915. * The skybox material
  49916. */
  49917. protected _material: BackgroundMaterial;
  49918. /**
  49919. * The surface used for the skybox
  49920. */
  49921. protected _mesh: Mesh;
  49922. /**
  49923. * Gets the mesh used for the skybox.
  49924. */
  49925. get mesh(): Mesh;
  49926. /**
  49927. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49928. * Also see the options.resolution property.
  49929. */
  49930. get fovMultiplier(): number;
  49931. set fovMultiplier(value: number);
  49932. private _imageMode;
  49933. /**
  49934. * Gets or set the current video mode for the video. It can be:
  49935. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49936. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49937. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49938. */
  49939. get imageMode(): number;
  49940. set imageMode(value: number);
  49941. /**
  49942. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49943. * @param name Element's name, child elements will append suffixes for their own names.
  49944. * @param urlsOfPhoto defines the url of the photo to display
  49945. * @param options defines an object containing optional or exposed sub element properties
  49946. * @param onError defines a callback called when an error occured while loading the texture
  49947. */
  49948. constructor(name: string, urlOfPhoto: string, options: {
  49949. resolution?: number;
  49950. size?: number;
  49951. useDirectMapping?: boolean;
  49952. faceForward?: boolean;
  49953. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49954. private _onBeforeCameraRenderObserver;
  49955. private _changeImageMode;
  49956. /**
  49957. * Releases resources associated with this node.
  49958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49960. */
  49961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49962. }
  49963. }
  49964. declare module BABYLON {
  49965. /**
  49966. * Class used to host RGBD texture specific utilities
  49967. */
  49968. export class RGBDTextureTools {
  49969. /**
  49970. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49971. * @param texture the texture to expand.
  49972. */
  49973. static ExpandRGBDTexture(texture: Texture): void;
  49974. }
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * Class used to host texture specific utilities
  49979. */
  49980. export class BRDFTextureTools {
  49981. /**
  49982. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49983. * @param scene defines the hosting scene
  49984. * @returns the environment BRDF texture
  49985. */
  49986. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49987. private static _environmentBRDFBase64Texture;
  49988. }
  49989. }
  49990. declare module BABYLON {
  49991. /**
  49992. * @hidden
  49993. */
  49994. export interface IMaterialClearCoatDefines {
  49995. CLEARCOAT: boolean;
  49996. CLEARCOAT_DEFAULTIOR: boolean;
  49997. CLEARCOAT_TEXTURE: boolean;
  49998. CLEARCOAT_TEXTUREDIRECTUV: number;
  49999. CLEARCOAT_BUMP: boolean;
  50000. CLEARCOAT_BUMPDIRECTUV: number;
  50001. CLEARCOAT_TINT: boolean;
  50002. CLEARCOAT_TINT_TEXTURE: boolean;
  50003. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50004. /** @hidden */
  50005. _areTexturesDirty: boolean;
  50006. }
  50007. /**
  50008. * Define the code related to the clear coat parameters of the pbr material.
  50009. */
  50010. export class PBRClearCoatConfiguration {
  50011. /**
  50012. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50013. * The default fits with a polyurethane material.
  50014. */
  50015. private static readonly _DefaultIndexOfRefraction;
  50016. private _isEnabled;
  50017. /**
  50018. * Defines if the clear coat is enabled in the material.
  50019. */
  50020. isEnabled: boolean;
  50021. /**
  50022. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50023. */
  50024. intensity: number;
  50025. /**
  50026. * Defines the clear coat layer roughness.
  50027. */
  50028. roughness: number;
  50029. private _indexOfRefraction;
  50030. /**
  50031. * Defines the index of refraction of the clear coat.
  50032. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50033. * The default fits with a polyurethane material.
  50034. * Changing the default value is more performance intensive.
  50035. */
  50036. indexOfRefraction: number;
  50037. private _texture;
  50038. /**
  50039. * Stores the clear coat values in a texture.
  50040. */
  50041. texture: Nullable<BaseTexture>;
  50042. private _bumpTexture;
  50043. /**
  50044. * Define the clear coat specific bump texture.
  50045. */
  50046. bumpTexture: Nullable<BaseTexture>;
  50047. private _isTintEnabled;
  50048. /**
  50049. * Defines if the clear coat tint is enabled in the material.
  50050. */
  50051. isTintEnabled: boolean;
  50052. /**
  50053. * Defines the clear coat tint of the material.
  50054. * This is only use if tint is enabled
  50055. */
  50056. tintColor: Color3;
  50057. /**
  50058. * Defines the distance at which the tint color should be found in the
  50059. * clear coat media.
  50060. * This is only use if tint is enabled
  50061. */
  50062. tintColorAtDistance: number;
  50063. /**
  50064. * Defines the clear coat layer thickness.
  50065. * This is only use if tint is enabled
  50066. */
  50067. tintThickness: number;
  50068. private _tintTexture;
  50069. /**
  50070. * Stores the clear tint values in a texture.
  50071. * rgb is tint
  50072. * a is a thickness factor
  50073. */
  50074. tintTexture: Nullable<BaseTexture>;
  50075. /** @hidden */
  50076. private _internalMarkAllSubMeshesAsTexturesDirty;
  50077. /** @hidden */
  50078. _markAllSubMeshesAsTexturesDirty(): void;
  50079. /**
  50080. * Instantiate a new istance of clear coat configuration.
  50081. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50082. */
  50083. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50084. /**
  50085. * Gets wehter the submesh is ready to be used or not.
  50086. * @param defines the list of "defines" to update.
  50087. * @param scene defines the scene the material belongs to.
  50088. * @param engine defines the engine the material belongs to.
  50089. * @param disableBumpMap defines wether the material disables bump or not.
  50090. * @returns - boolean indicating that the submesh is ready or not.
  50091. */
  50092. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50093. /**
  50094. * Checks to see if a texture is used in the material.
  50095. * @param defines the list of "defines" to update.
  50096. * @param scene defines the scene to the material belongs to.
  50097. */
  50098. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50099. /**
  50100. * Binds the material data.
  50101. * @param uniformBuffer defines the Uniform buffer to fill in.
  50102. * @param scene defines the scene the material belongs to.
  50103. * @param engine defines the engine the material belongs to.
  50104. * @param disableBumpMap defines wether the material disables bump or not.
  50105. * @param isFrozen defines wether the material is frozen or not.
  50106. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50107. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50108. */
  50109. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50110. /**
  50111. * Checks to see if a texture is used in the material.
  50112. * @param texture - Base texture to use.
  50113. * @returns - Boolean specifying if a texture is used in the material.
  50114. */
  50115. hasTexture(texture: BaseTexture): boolean;
  50116. /**
  50117. * Returns an array of the actively used textures.
  50118. * @param activeTextures Array of BaseTextures
  50119. */
  50120. getActiveTextures(activeTextures: BaseTexture[]): void;
  50121. /**
  50122. * Returns the animatable textures.
  50123. * @param animatables Array of animatable textures.
  50124. */
  50125. getAnimatables(animatables: IAnimatable[]): void;
  50126. /**
  50127. * Disposes the resources of the material.
  50128. * @param forceDisposeTextures - Forces the disposal of all textures.
  50129. */
  50130. dispose(forceDisposeTextures?: boolean): void;
  50131. /**
  50132. * Get the current class name of the texture useful for serialization or dynamic coding.
  50133. * @returns "PBRClearCoatConfiguration"
  50134. */
  50135. getClassName(): string;
  50136. /**
  50137. * Add fallbacks to the effect fallbacks list.
  50138. * @param defines defines the Base texture to use.
  50139. * @param fallbacks defines the current fallback list.
  50140. * @param currentRank defines the current fallback rank.
  50141. * @returns the new fallback rank.
  50142. */
  50143. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50144. /**
  50145. * Add the required uniforms to the current list.
  50146. * @param uniforms defines the current uniform list.
  50147. */
  50148. static AddUniforms(uniforms: string[]): void;
  50149. /**
  50150. * Add the required samplers to the current list.
  50151. * @param samplers defines the current sampler list.
  50152. */
  50153. static AddSamplers(samplers: string[]): void;
  50154. /**
  50155. * Add the required uniforms to the current buffer.
  50156. * @param uniformBuffer defines the current uniform buffer.
  50157. */
  50158. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50159. /**
  50160. * Makes a duplicate of the current configuration into another one.
  50161. * @param clearCoatConfiguration define the config where to copy the info
  50162. */
  50163. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50164. /**
  50165. * Serializes this clear coat configuration.
  50166. * @returns - An object with the serialized config.
  50167. */
  50168. serialize(): any;
  50169. /**
  50170. * Parses a anisotropy Configuration from a serialized object.
  50171. * @param source - Serialized object.
  50172. * @param scene Defines the scene we are parsing for
  50173. * @param rootUrl Defines the rootUrl to load from
  50174. */
  50175. parse(source: any, scene: Scene, rootUrl: string): void;
  50176. }
  50177. }
  50178. declare module BABYLON {
  50179. /**
  50180. * @hidden
  50181. */
  50182. export interface IMaterialAnisotropicDefines {
  50183. ANISOTROPIC: boolean;
  50184. ANISOTROPIC_TEXTURE: boolean;
  50185. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50186. MAINUV1: boolean;
  50187. _areTexturesDirty: boolean;
  50188. _needUVs: boolean;
  50189. }
  50190. /**
  50191. * Define the code related to the anisotropic parameters of the pbr material.
  50192. */
  50193. export class PBRAnisotropicConfiguration {
  50194. private _isEnabled;
  50195. /**
  50196. * Defines if the anisotropy is enabled in the material.
  50197. */
  50198. isEnabled: boolean;
  50199. /**
  50200. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50201. */
  50202. intensity: number;
  50203. /**
  50204. * Defines if the effect is along the tangents, bitangents or in between.
  50205. * By default, the effect is "strectching" the highlights along the tangents.
  50206. */
  50207. direction: Vector2;
  50208. private _texture;
  50209. /**
  50210. * Stores the anisotropy values in a texture.
  50211. * rg is direction (like normal from -1 to 1)
  50212. * b is a intensity
  50213. */
  50214. texture: Nullable<BaseTexture>;
  50215. /** @hidden */
  50216. private _internalMarkAllSubMeshesAsTexturesDirty;
  50217. /** @hidden */
  50218. _markAllSubMeshesAsTexturesDirty(): void;
  50219. /**
  50220. * Instantiate a new istance of anisotropy configuration.
  50221. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50222. */
  50223. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50224. /**
  50225. * Specifies that the submesh is ready to be used.
  50226. * @param defines the list of "defines" to update.
  50227. * @param scene defines the scene the material belongs to.
  50228. * @returns - boolean indicating that the submesh is ready or not.
  50229. */
  50230. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50231. /**
  50232. * Checks to see if a texture is used in the material.
  50233. * @param defines the list of "defines" to update.
  50234. * @param mesh the mesh we are preparing the defines for.
  50235. * @param scene defines the scene the material belongs to.
  50236. */
  50237. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50238. /**
  50239. * Binds the material data.
  50240. * @param uniformBuffer defines the Uniform buffer to fill in.
  50241. * @param scene defines the scene the material belongs to.
  50242. * @param isFrozen defines wether the material is frozen or not.
  50243. */
  50244. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50245. /**
  50246. * Checks to see if a texture is used in the material.
  50247. * @param texture - Base texture to use.
  50248. * @returns - Boolean specifying if a texture is used in the material.
  50249. */
  50250. hasTexture(texture: BaseTexture): boolean;
  50251. /**
  50252. * Returns an array of the actively used textures.
  50253. * @param activeTextures Array of BaseTextures
  50254. */
  50255. getActiveTextures(activeTextures: BaseTexture[]): void;
  50256. /**
  50257. * Returns the animatable textures.
  50258. * @param animatables Array of animatable textures.
  50259. */
  50260. getAnimatables(animatables: IAnimatable[]): void;
  50261. /**
  50262. * Disposes the resources of the material.
  50263. * @param forceDisposeTextures - Forces the disposal of all textures.
  50264. */
  50265. dispose(forceDisposeTextures?: boolean): void;
  50266. /**
  50267. * Get the current class name of the texture useful for serialization or dynamic coding.
  50268. * @returns "PBRAnisotropicConfiguration"
  50269. */
  50270. getClassName(): string;
  50271. /**
  50272. * Add fallbacks to the effect fallbacks list.
  50273. * @param defines defines the Base texture to use.
  50274. * @param fallbacks defines the current fallback list.
  50275. * @param currentRank defines the current fallback rank.
  50276. * @returns the new fallback rank.
  50277. */
  50278. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50279. /**
  50280. * Add the required uniforms to the current list.
  50281. * @param uniforms defines the current uniform list.
  50282. */
  50283. static AddUniforms(uniforms: string[]): void;
  50284. /**
  50285. * Add the required uniforms to the current buffer.
  50286. * @param uniformBuffer defines the current uniform buffer.
  50287. */
  50288. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50289. /**
  50290. * Add the required samplers to the current list.
  50291. * @param samplers defines the current sampler list.
  50292. */
  50293. static AddSamplers(samplers: string[]): void;
  50294. /**
  50295. * Makes a duplicate of the current configuration into another one.
  50296. * @param anisotropicConfiguration define the config where to copy the info
  50297. */
  50298. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50299. /**
  50300. * Serializes this anisotropy configuration.
  50301. * @returns - An object with the serialized config.
  50302. */
  50303. serialize(): any;
  50304. /**
  50305. * Parses a anisotropy Configuration from a serialized object.
  50306. * @param source - Serialized object.
  50307. * @param scene Defines the scene we are parsing for
  50308. * @param rootUrl Defines the rootUrl to load from
  50309. */
  50310. parse(source: any, scene: Scene, rootUrl: string): void;
  50311. }
  50312. }
  50313. declare module BABYLON {
  50314. /**
  50315. * @hidden
  50316. */
  50317. export interface IMaterialBRDFDefines {
  50318. BRDF_V_HEIGHT_CORRELATED: boolean;
  50319. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50320. SPHERICAL_HARMONICS: boolean;
  50321. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50322. /** @hidden */
  50323. _areMiscDirty: boolean;
  50324. }
  50325. /**
  50326. * Define the code related to the BRDF parameters of the pbr material.
  50327. */
  50328. export class PBRBRDFConfiguration {
  50329. /**
  50330. * Default value used for the energy conservation.
  50331. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50332. */
  50333. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50334. /**
  50335. * Default value used for the Smith Visibility Height Correlated mode.
  50336. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50337. */
  50338. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50339. /**
  50340. * Default value used for the IBL diffuse part.
  50341. * This can help switching back to the polynomials mode globally which is a tiny bit
  50342. * less GPU intensive at the drawback of a lower quality.
  50343. */
  50344. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50345. /**
  50346. * Default value used for activating energy conservation for the specular workflow.
  50347. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50348. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50349. */
  50350. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50351. private _useEnergyConservation;
  50352. /**
  50353. * Defines if the material uses energy conservation.
  50354. */
  50355. useEnergyConservation: boolean;
  50356. private _useSmithVisibilityHeightCorrelated;
  50357. /**
  50358. * LEGACY Mode set to false
  50359. * Defines if the material uses height smith correlated visibility term.
  50360. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50361. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50362. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50363. * Not relying on height correlated will also disable energy conservation.
  50364. */
  50365. useSmithVisibilityHeightCorrelated: boolean;
  50366. private _useSphericalHarmonics;
  50367. /**
  50368. * LEGACY Mode set to false
  50369. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50370. * diffuse part of the IBL.
  50371. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50372. * to the ground truth.
  50373. */
  50374. useSphericalHarmonics: boolean;
  50375. private _useSpecularGlossinessInputEnergyConservation;
  50376. /**
  50377. * Defines if the material uses energy conservation, when the specular workflow is active.
  50378. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50379. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50380. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50381. */
  50382. useSpecularGlossinessInputEnergyConservation: boolean;
  50383. /** @hidden */
  50384. private _internalMarkAllSubMeshesAsMiscDirty;
  50385. /** @hidden */
  50386. _markAllSubMeshesAsMiscDirty(): void;
  50387. /**
  50388. * Instantiate a new istance of clear coat configuration.
  50389. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50390. */
  50391. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50392. /**
  50393. * Checks to see if a texture is used in the material.
  50394. * @param defines the list of "defines" to update.
  50395. */
  50396. prepareDefines(defines: IMaterialBRDFDefines): void;
  50397. /**
  50398. * Get the current class name of the texture useful for serialization or dynamic coding.
  50399. * @returns "PBRClearCoatConfiguration"
  50400. */
  50401. getClassName(): string;
  50402. /**
  50403. * Makes a duplicate of the current configuration into another one.
  50404. * @param brdfConfiguration define the config where to copy the info
  50405. */
  50406. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50407. /**
  50408. * Serializes this BRDF configuration.
  50409. * @returns - An object with the serialized config.
  50410. */
  50411. serialize(): any;
  50412. /**
  50413. * Parses a anisotropy Configuration from a serialized object.
  50414. * @param source - Serialized object.
  50415. * @param scene Defines the scene we are parsing for
  50416. * @param rootUrl Defines the rootUrl to load from
  50417. */
  50418. parse(source: any, scene: Scene, rootUrl: string): void;
  50419. }
  50420. }
  50421. declare module BABYLON {
  50422. /**
  50423. * @hidden
  50424. */
  50425. export interface IMaterialSheenDefines {
  50426. SHEEN: boolean;
  50427. SHEEN_TEXTURE: boolean;
  50428. SHEEN_TEXTUREDIRECTUV: number;
  50429. SHEEN_LINKWITHALBEDO: boolean;
  50430. /** @hidden */
  50431. _areTexturesDirty: boolean;
  50432. }
  50433. /**
  50434. * Define the code related to the Sheen parameters of the pbr material.
  50435. */
  50436. export class PBRSheenConfiguration {
  50437. private _isEnabled;
  50438. /**
  50439. * Defines if the material uses sheen.
  50440. */
  50441. isEnabled: boolean;
  50442. private _linkSheenWithAlbedo;
  50443. /**
  50444. * Defines if the sheen is linked to the sheen color.
  50445. */
  50446. linkSheenWithAlbedo: boolean;
  50447. /**
  50448. * Defines the sheen intensity.
  50449. */
  50450. intensity: number;
  50451. /**
  50452. * Defines the sheen color.
  50453. */
  50454. color: Color3;
  50455. private _texture;
  50456. /**
  50457. * Stores the sheen tint values in a texture.
  50458. * rgb is tint
  50459. * a is a intensity
  50460. */
  50461. texture: Nullable<BaseTexture>;
  50462. /** @hidden */
  50463. private _internalMarkAllSubMeshesAsTexturesDirty;
  50464. /** @hidden */
  50465. _markAllSubMeshesAsTexturesDirty(): void;
  50466. /**
  50467. * Instantiate a new istance of clear coat configuration.
  50468. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50469. */
  50470. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50471. /**
  50472. * Specifies that the submesh is ready to be used.
  50473. * @param defines the list of "defines" to update.
  50474. * @param scene defines the scene the material belongs to.
  50475. * @returns - boolean indicating that the submesh is ready or not.
  50476. */
  50477. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50478. /**
  50479. * Checks to see if a texture is used in the material.
  50480. * @param defines the list of "defines" to update.
  50481. * @param scene defines the scene the material belongs to.
  50482. */
  50483. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50484. /**
  50485. * Binds the material data.
  50486. * @param uniformBuffer defines the Uniform buffer to fill in.
  50487. * @param scene defines the scene the material belongs to.
  50488. * @param isFrozen defines wether the material is frozen or not.
  50489. */
  50490. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50491. /**
  50492. * Checks to see if a texture is used in the material.
  50493. * @param texture - Base texture to use.
  50494. * @returns - Boolean specifying if a texture is used in the material.
  50495. */
  50496. hasTexture(texture: BaseTexture): boolean;
  50497. /**
  50498. * Returns an array of the actively used textures.
  50499. * @param activeTextures Array of BaseTextures
  50500. */
  50501. getActiveTextures(activeTextures: BaseTexture[]): void;
  50502. /**
  50503. * Returns the animatable textures.
  50504. * @param animatables Array of animatable textures.
  50505. */
  50506. getAnimatables(animatables: IAnimatable[]): void;
  50507. /**
  50508. * Disposes the resources of the material.
  50509. * @param forceDisposeTextures - Forces the disposal of all textures.
  50510. */
  50511. dispose(forceDisposeTextures?: boolean): void;
  50512. /**
  50513. * Get the current class name of the texture useful for serialization or dynamic coding.
  50514. * @returns "PBRSheenConfiguration"
  50515. */
  50516. getClassName(): string;
  50517. /**
  50518. * Add fallbacks to the effect fallbacks list.
  50519. * @param defines defines the Base texture to use.
  50520. * @param fallbacks defines the current fallback list.
  50521. * @param currentRank defines the current fallback rank.
  50522. * @returns the new fallback rank.
  50523. */
  50524. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50525. /**
  50526. * Add the required uniforms to the current list.
  50527. * @param uniforms defines the current uniform list.
  50528. */
  50529. static AddUniforms(uniforms: string[]): void;
  50530. /**
  50531. * Add the required uniforms to the current buffer.
  50532. * @param uniformBuffer defines the current uniform buffer.
  50533. */
  50534. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50535. /**
  50536. * Add the required samplers to the current list.
  50537. * @param samplers defines the current sampler list.
  50538. */
  50539. static AddSamplers(samplers: string[]): void;
  50540. /**
  50541. * Makes a duplicate of the current configuration into another one.
  50542. * @param sheenConfiguration define the config where to copy the info
  50543. */
  50544. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50545. /**
  50546. * Serializes this BRDF configuration.
  50547. * @returns - An object with the serialized config.
  50548. */
  50549. serialize(): any;
  50550. /**
  50551. * Parses a anisotropy Configuration from a serialized object.
  50552. * @param source - Serialized object.
  50553. * @param scene Defines the scene we are parsing for
  50554. * @param rootUrl Defines the rootUrl to load from
  50555. */
  50556. parse(source: any, scene: Scene, rootUrl: string): void;
  50557. }
  50558. }
  50559. declare module BABYLON {
  50560. /**
  50561. * @hidden
  50562. */
  50563. export interface IMaterialSubSurfaceDefines {
  50564. SUBSURFACE: boolean;
  50565. SS_REFRACTION: boolean;
  50566. SS_TRANSLUCENCY: boolean;
  50567. SS_SCATERRING: boolean;
  50568. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50569. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50570. SS_REFRACTIONMAP_3D: boolean;
  50571. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50572. SS_LODINREFRACTIONALPHA: boolean;
  50573. SS_GAMMAREFRACTION: boolean;
  50574. SS_RGBDREFRACTION: boolean;
  50575. SS_LINEARSPECULARREFRACTION: boolean;
  50576. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50577. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50578. /** @hidden */
  50579. _areTexturesDirty: boolean;
  50580. }
  50581. /**
  50582. * Define the code related to the sub surface parameters of the pbr material.
  50583. */
  50584. export class PBRSubSurfaceConfiguration {
  50585. private _isRefractionEnabled;
  50586. /**
  50587. * Defines if the refraction is enabled in the material.
  50588. */
  50589. isRefractionEnabled: boolean;
  50590. private _isTranslucencyEnabled;
  50591. /**
  50592. * Defines if the translucency is enabled in the material.
  50593. */
  50594. isTranslucencyEnabled: boolean;
  50595. private _isScatteringEnabled;
  50596. /**
  50597. * Defines the refraction intensity of the material.
  50598. * The refraction when enabled replaces the Diffuse part of the material.
  50599. * The intensity helps transitionning between diffuse and refraction.
  50600. */
  50601. refractionIntensity: number;
  50602. /**
  50603. * Defines the translucency intensity of the material.
  50604. * When translucency has been enabled, this defines how much of the "translucency"
  50605. * is addded to the diffuse part of the material.
  50606. */
  50607. translucencyIntensity: number;
  50608. /**
  50609. * Defines the scattering intensity of the material.
  50610. * When scattering has been enabled, this defines how much of the "scattered light"
  50611. * is addded to the diffuse part of the material.
  50612. */
  50613. scatteringIntensity: number;
  50614. private _thicknessTexture;
  50615. /**
  50616. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50617. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50618. * 0 would mean minimumThickness
  50619. * 1 would mean maximumThickness
  50620. * The other channels might be use as a mask to vary the different effects intensity.
  50621. */
  50622. thicknessTexture: Nullable<BaseTexture>;
  50623. private _refractionTexture;
  50624. /**
  50625. * Defines the texture to use for refraction.
  50626. */
  50627. refractionTexture: Nullable<BaseTexture>;
  50628. private _indexOfRefraction;
  50629. /**
  50630. * Defines the index of refraction used in the material.
  50631. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50632. */
  50633. indexOfRefraction: number;
  50634. private _invertRefractionY;
  50635. /**
  50636. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50637. */
  50638. invertRefractionY: boolean;
  50639. private _linkRefractionWithTransparency;
  50640. /**
  50641. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50642. * Materials half opaque for instance using refraction could benefit from this control.
  50643. */
  50644. linkRefractionWithTransparency: boolean;
  50645. /**
  50646. * Defines the minimum thickness stored in the thickness map.
  50647. * If no thickness map is defined, this value will be used to simulate thickness.
  50648. */
  50649. minimumThickness: number;
  50650. /**
  50651. * Defines the maximum thickness stored in the thickness map.
  50652. */
  50653. maximumThickness: number;
  50654. /**
  50655. * Defines the volume tint of the material.
  50656. * This is used for both translucency and scattering.
  50657. */
  50658. tintColor: Color3;
  50659. /**
  50660. * Defines the distance at which the tint color should be found in the media.
  50661. * This is used for refraction only.
  50662. */
  50663. tintColorAtDistance: number;
  50664. /**
  50665. * Defines how far each channel transmit through the media.
  50666. * It is defined as a color to simplify it selection.
  50667. */
  50668. diffusionDistance: Color3;
  50669. private _useMaskFromThicknessTexture;
  50670. /**
  50671. * Stores the intensity of the different subsurface effects in the thickness texture.
  50672. * * the green channel is the translucency intensity.
  50673. * * the blue channel is the scattering intensity.
  50674. * * the alpha channel is the refraction intensity.
  50675. */
  50676. useMaskFromThicknessTexture: boolean;
  50677. /** @hidden */
  50678. private _internalMarkAllSubMeshesAsTexturesDirty;
  50679. /** @hidden */
  50680. _markAllSubMeshesAsTexturesDirty(): void;
  50681. /**
  50682. * Instantiate a new istance of sub surface configuration.
  50683. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50684. */
  50685. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50686. /**
  50687. * Gets wehter the submesh is ready to be used or not.
  50688. * @param defines the list of "defines" to update.
  50689. * @param scene defines the scene the material belongs to.
  50690. * @returns - boolean indicating that the submesh is ready or not.
  50691. */
  50692. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50693. /**
  50694. * Checks to see if a texture is used in the material.
  50695. * @param defines the list of "defines" to update.
  50696. * @param scene defines the scene to the material belongs to.
  50697. */
  50698. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50699. /**
  50700. * Binds the material data.
  50701. * @param uniformBuffer defines the Uniform buffer to fill in.
  50702. * @param scene defines the scene the material belongs to.
  50703. * @param engine defines the engine the material belongs to.
  50704. * @param isFrozen defines wether the material is frozen or not.
  50705. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50706. */
  50707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50708. /**
  50709. * Unbinds the material from the mesh.
  50710. * @param activeEffect defines the effect that should be unbound from.
  50711. * @returns true if unbound, otherwise false
  50712. */
  50713. unbind(activeEffect: Effect): boolean;
  50714. /**
  50715. * Returns the texture used for refraction or null if none is used.
  50716. * @param scene defines the scene the material belongs to.
  50717. * @returns - Refraction texture if present. If no refraction texture and refraction
  50718. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50719. */
  50720. private _getRefractionTexture;
  50721. /**
  50722. * Returns true if alpha blending should be disabled.
  50723. */
  50724. get disableAlphaBlending(): boolean;
  50725. /**
  50726. * Fills the list of render target textures.
  50727. * @param renderTargets the list of render targets to update
  50728. */
  50729. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50730. /**
  50731. * Checks to see if a texture is used in the material.
  50732. * @param texture - Base texture to use.
  50733. * @returns - Boolean specifying if a texture is used in the material.
  50734. */
  50735. hasTexture(texture: BaseTexture): boolean;
  50736. /**
  50737. * Gets a boolean indicating that current material needs to register RTT
  50738. * @returns true if this uses a render target otherwise false.
  50739. */
  50740. hasRenderTargetTextures(): boolean;
  50741. /**
  50742. * Returns an array of the actively used textures.
  50743. * @param activeTextures Array of BaseTextures
  50744. */
  50745. getActiveTextures(activeTextures: BaseTexture[]): void;
  50746. /**
  50747. * Returns the animatable textures.
  50748. * @param animatables Array of animatable textures.
  50749. */
  50750. getAnimatables(animatables: IAnimatable[]): void;
  50751. /**
  50752. * Disposes the resources of the material.
  50753. * @param forceDisposeTextures - Forces the disposal of all textures.
  50754. */
  50755. dispose(forceDisposeTextures?: boolean): void;
  50756. /**
  50757. * Get the current class name of the texture useful for serialization or dynamic coding.
  50758. * @returns "PBRSubSurfaceConfiguration"
  50759. */
  50760. getClassName(): string;
  50761. /**
  50762. * Add fallbacks to the effect fallbacks list.
  50763. * @param defines defines the Base texture to use.
  50764. * @param fallbacks defines the current fallback list.
  50765. * @param currentRank defines the current fallback rank.
  50766. * @returns the new fallback rank.
  50767. */
  50768. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50769. /**
  50770. * Add the required uniforms to the current list.
  50771. * @param uniforms defines the current uniform list.
  50772. */
  50773. static AddUniforms(uniforms: string[]): void;
  50774. /**
  50775. * Add the required samplers to the current list.
  50776. * @param samplers defines the current sampler list.
  50777. */
  50778. static AddSamplers(samplers: string[]): void;
  50779. /**
  50780. * Add the required uniforms to the current buffer.
  50781. * @param uniformBuffer defines the current uniform buffer.
  50782. */
  50783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50784. /**
  50785. * Makes a duplicate of the current configuration into another one.
  50786. * @param configuration define the config where to copy the info
  50787. */
  50788. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50789. /**
  50790. * Serializes this Sub Surface configuration.
  50791. * @returns - An object with the serialized config.
  50792. */
  50793. serialize(): any;
  50794. /**
  50795. * Parses a anisotropy Configuration from a serialized object.
  50796. * @param source - Serialized object.
  50797. * @param scene Defines the scene we are parsing for
  50798. * @param rootUrl Defines the rootUrl to load from
  50799. */
  50800. parse(source: any, scene: Scene, rootUrl: string): void;
  50801. }
  50802. }
  50803. declare module BABYLON {
  50804. /** @hidden */
  50805. export var pbrFragmentDeclaration: {
  50806. name: string;
  50807. shader: string;
  50808. };
  50809. }
  50810. declare module BABYLON {
  50811. /** @hidden */
  50812. export var pbrUboDeclaration: {
  50813. name: string;
  50814. shader: string;
  50815. };
  50816. }
  50817. declare module BABYLON {
  50818. /** @hidden */
  50819. export var pbrFragmentExtraDeclaration: {
  50820. name: string;
  50821. shader: string;
  50822. };
  50823. }
  50824. declare module BABYLON {
  50825. /** @hidden */
  50826. export var pbrFragmentSamplersDeclaration: {
  50827. name: string;
  50828. shader: string;
  50829. };
  50830. }
  50831. declare module BABYLON {
  50832. /** @hidden */
  50833. export var pbrHelperFunctions: {
  50834. name: string;
  50835. shader: string;
  50836. };
  50837. }
  50838. declare module BABYLON {
  50839. /** @hidden */
  50840. export var harmonicsFunctions: {
  50841. name: string;
  50842. shader: string;
  50843. };
  50844. }
  50845. declare module BABYLON {
  50846. /** @hidden */
  50847. export var pbrDirectLightingSetupFunctions: {
  50848. name: string;
  50849. shader: string;
  50850. };
  50851. }
  50852. declare module BABYLON {
  50853. /** @hidden */
  50854. export var pbrDirectLightingFalloffFunctions: {
  50855. name: string;
  50856. shader: string;
  50857. };
  50858. }
  50859. declare module BABYLON {
  50860. /** @hidden */
  50861. export var pbrBRDFFunctions: {
  50862. name: string;
  50863. shader: string;
  50864. };
  50865. }
  50866. declare module BABYLON {
  50867. /** @hidden */
  50868. export var pbrDirectLightingFunctions: {
  50869. name: string;
  50870. shader: string;
  50871. };
  50872. }
  50873. declare module BABYLON {
  50874. /** @hidden */
  50875. export var pbrIBLFunctions: {
  50876. name: string;
  50877. shader: string;
  50878. };
  50879. }
  50880. declare module BABYLON {
  50881. /** @hidden */
  50882. export var pbrDebug: {
  50883. name: string;
  50884. shader: string;
  50885. };
  50886. }
  50887. declare module BABYLON {
  50888. /** @hidden */
  50889. export var pbrPixelShader: {
  50890. name: string;
  50891. shader: string;
  50892. };
  50893. }
  50894. declare module BABYLON {
  50895. /** @hidden */
  50896. export var pbrVertexDeclaration: {
  50897. name: string;
  50898. shader: string;
  50899. };
  50900. }
  50901. declare module BABYLON {
  50902. /** @hidden */
  50903. export var pbrVertexShader: {
  50904. name: string;
  50905. shader: string;
  50906. };
  50907. }
  50908. declare module BABYLON {
  50909. /**
  50910. * Manages the defines for the PBR Material.
  50911. * @hidden
  50912. */
  50913. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50914. PBR: boolean;
  50915. MAINUV1: boolean;
  50916. MAINUV2: boolean;
  50917. UV1: boolean;
  50918. UV2: boolean;
  50919. ALBEDO: boolean;
  50920. ALBEDODIRECTUV: number;
  50921. VERTEXCOLOR: boolean;
  50922. AMBIENT: boolean;
  50923. AMBIENTDIRECTUV: number;
  50924. AMBIENTINGRAYSCALE: boolean;
  50925. OPACITY: boolean;
  50926. VERTEXALPHA: boolean;
  50927. OPACITYDIRECTUV: number;
  50928. OPACITYRGB: boolean;
  50929. ALPHATEST: boolean;
  50930. DEPTHPREPASS: boolean;
  50931. ALPHABLEND: boolean;
  50932. ALPHAFROMALBEDO: boolean;
  50933. ALPHATESTVALUE: string;
  50934. SPECULAROVERALPHA: boolean;
  50935. RADIANCEOVERALPHA: boolean;
  50936. ALPHAFRESNEL: boolean;
  50937. LINEARALPHAFRESNEL: boolean;
  50938. PREMULTIPLYALPHA: boolean;
  50939. EMISSIVE: boolean;
  50940. EMISSIVEDIRECTUV: number;
  50941. REFLECTIVITY: boolean;
  50942. REFLECTIVITYDIRECTUV: number;
  50943. SPECULARTERM: boolean;
  50944. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50945. MICROSURFACEAUTOMATIC: boolean;
  50946. LODBASEDMICROSFURACE: boolean;
  50947. MICROSURFACEMAP: boolean;
  50948. MICROSURFACEMAPDIRECTUV: number;
  50949. METALLICWORKFLOW: boolean;
  50950. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50951. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50952. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50953. AOSTOREINMETALMAPRED: boolean;
  50954. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50955. ENVIRONMENTBRDF: boolean;
  50956. ENVIRONMENTBRDF_RGBD: boolean;
  50957. NORMAL: boolean;
  50958. TANGENT: boolean;
  50959. BUMP: boolean;
  50960. BUMPDIRECTUV: number;
  50961. OBJECTSPACE_NORMALMAP: boolean;
  50962. PARALLAX: boolean;
  50963. PARALLAXOCCLUSION: boolean;
  50964. NORMALXYSCALE: boolean;
  50965. LIGHTMAP: boolean;
  50966. LIGHTMAPDIRECTUV: number;
  50967. USELIGHTMAPASSHADOWMAP: boolean;
  50968. GAMMALIGHTMAP: boolean;
  50969. RGBDLIGHTMAP: boolean;
  50970. REFLECTION: boolean;
  50971. REFLECTIONMAP_3D: boolean;
  50972. REFLECTIONMAP_SPHERICAL: boolean;
  50973. REFLECTIONMAP_PLANAR: boolean;
  50974. REFLECTIONMAP_CUBIC: boolean;
  50975. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50976. REFLECTIONMAP_PROJECTION: boolean;
  50977. REFLECTIONMAP_SKYBOX: boolean;
  50978. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50979. REFLECTIONMAP_EXPLICIT: boolean;
  50980. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50981. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50982. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50983. INVERTCUBICMAP: boolean;
  50984. USESPHERICALFROMREFLECTIONMAP: boolean;
  50985. USEIRRADIANCEMAP: boolean;
  50986. SPHERICAL_HARMONICS: boolean;
  50987. USESPHERICALINVERTEX: boolean;
  50988. REFLECTIONMAP_OPPOSITEZ: boolean;
  50989. LODINREFLECTIONALPHA: boolean;
  50990. GAMMAREFLECTION: boolean;
  50991. RGBDREFLECTION: boolean;
  50992. LINEARSPECULARREFLECTION: boolean;
  50993. RADIANCEOCCLUSION: boolean;
  50994. HORIZONOCCLUSION: boolean;
  50995. INSTANCES: boolean;
  50996. NUM_BONE_INFLUENCERS: number;
  50997. BonesPerMesh: number;
  50998. BONETEXTURE: boolean;
  50999. NONUNIFORMSCALING: boolean;
  51000. MORPHTARGETS: boolean;
  51001. MORPHTARGETS_NORMAL: boolean;
  51002. MORPHTARGETS_TANGENT: boolean;
  51003. MORPHTARGETS_UV: boolean;
  51004. NUM_MORPH_INFLUENCERS: number;
  51005. IMAGEPROCESSING: boolean;
  51006. VIGNETTE: boolean;
  51007. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51008. VIGNETTEBLENDMODEOPAQUE: boolean;
  51009. TONEMAPPING: boolean;
  51010. TONEMAPPING_ACES: boolean;
  51011. CONTRAST: boolean;
  51012. COLORCURVES: boolean;
  51013. COLORGRADING: boolean;
  51014. COLORGRADING3D: boolean;
  51015. SAMPLER3DGREENDEPTH: boolean;
  51016. SAMPLER3DBGRMAP: boolean;
  51017. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51018. EXPOSURE: boolean;
  51019. MULTIVIEW: boolean;
  51020. USEPHYSICALLIGHTFALLOFF: boolean;
  51021. USEGLTFLIGHTFALLOFF: boolean;
  51022. TWOSIDEDLIGHTING: boolean;
  51023. SHADOWFLOAT: boolean;
  51024. CLIPPLANE: boolean;
  51025. CLIPPLANE2: boolean;
  51026. CLIPPLANE3: boolean;
  51027. CLIPPLANE4: boolean;
  51028. CLIPPLANE5: boolean;
  51029. CLIPPLANE6: boolean;
  51030. POINTSIZE: boolean;
  51031. FOG: boolean;
  51032. LOGARITHMICDEPTH: boolean;
  51033. FORCENORMALFORWARD: boolean;
  51034. SPECULARAA: boolean;
  51035. CLEARCOAT: boolean;
  51036. CLEARCOAT_DEFAULTIOR: boolean;
  51037. CLEARCOAT_TEXTURE: boolean;
  51038. CLEARCOAT_TEXTUREDIRECTUV: number;
  51039. CLEARCOAT_BUMP: boolean;
  51040. CLEARCOAT_BUMPDIRECTUV: number;
  51041. CLEARCOAT_TINT: boolean;
  51042. CLEARCOAT_TINT_TEXTURE: boolean;
  51043. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51044. ANISOTROPIC: boolean;
  51045. ANISOTROPIC_TEXTURE: boolean;
  51046. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51047. BRDF_V_HEIGHT_CORRELATED: boolean;
  51048. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51049. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51050. SHEEN: boolean;
  51051. SHEEN_TEXTURE: boolean;
  51052. SHEEN_TEXTUREDIRECTUV: number;
  51053. SHEEN_LINKWITHALBEDO: boolean;
  51054. SUBSURFACE: boolean;
  51055. SS_REFRACTION: boolean;
  51056. SS_TRANSLUCENCY: boolean;
  51057. SS_SCATERRING: boolean;
  51058. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51059. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51060. SS_REFRACTIONMAP_3D: boolean;
  51061. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51062. SS_LODINREFRACTIONALPHA: boolean;
  51063. SS_GAMMAREFRACTION: boolean;
  51064. SS_RGBDREFRACTION: boolean;
  51065. SS_LINEARSPECULARREFRACTION: boolean;
  51066. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51067. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51068. UNLIT: boolean;
  51069. DEBUGMODE: number;
  51070. /**
  51071. * Initializes the PBR Material defines.
  51072. */
  51073. constructor();
  51074. /**
  51075. * Resets the PBR Material defines.
  51076. */
  51077. reset(): void;
  51078. }
  51079. /**
  51080. * The Physically based material base class of BJS.
  51081. *
  51082. * This offers the main features of a standard PBR material.
  51083. * For more information, please refer to the documentation :
  51084. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51085. */
  51086. export abstract class PBRBaseMaterial extends PushMaterial {
  51087. /**
  51088. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51089. */
  51090. static readonly PBRMATERIAL_OPAQUE: number;
  51091. /**
  51092. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51093. */
  51094. static readonly PBRMATERIAL_ALPHATEST: number;
  51095. /**
  51096. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51097. */
  51098. static readonly PBRMATERIAL_ALPHABLEND: number;
  51099. /**
  51100. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51101. * They are also discarded below the alpha cutoff threshold to improve performances.
  51102. */
  51103. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51104. /**
  51105. * Defines the default value of how much AO map is occluding the analytical lights
  51106. * (point spot...).
  51107. */
  51108. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51109. /**
  51110. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51111. */
  51112. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51113. /**
  51114. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51115. * to enhance interoperability with other engines.
  51116. */
  51117. static readonly LIGHTFALLOFF_GLTF: number;
  51118. /**
  51119. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51120. * to enhance interoperability with other materials.
  51121. */
  51122. static readonly LIGHTFALLOFF_STANDARD: number;
  51123. /**
  51124. * Intensity of the direct lights e.g. the four lights available in your scene.
  51125. * This impacts both the direct diffuse and specular highlights.
  51126. */
  51127. protected _directIntensity: number;
  51128. /**
  51129. * Intensity of the emissive part of the material.
  51130. * This helps controlling the emissive effect without modifying the emissive color.
  51131. */
  51132. protected _emissiveIntensity: number;
  51133. /**
  51134. * Intensity of the environment e.g. how much the environment will light the object
  51135. * either through harmonics for rough material or through the refelction for shiny ones.
  51136. */
  51137. protected _environmentIntensity: number;
  51138. /**
  51139. * This is a special control allowing the reduction of the specular highlights coming from the
  51140. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51141. */
  51142. protected _specularIntensity: number;
  51143. /**
  51144. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51145. */
  51146. private _lightingInfos;
  51147. /**
  51148. * Debug Control allowing disabling the bump map on this material.
  51149. */
  51150. protected _disableBumpMap: boolean;
  51151. /**
  51152. * AKA Diffuse Texture in standard nomenclature.
  51153. */
  51154. protected _albedoTexture: Nullable<BaseTexture>;
  51155. /**
  51156. * AKA Occlusion Texture in other nomenclature.
  51157. */
  51158. protected _ambientTexture: Nullable<BaseTexture>;
  51159. /**
  51160. * AKA Occlusion Texture Intensity in other nomenclature.
  51161. */
  51162. protected _ambientTextureStrength: number;
  51163. /**
  51164. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51165. * 1 means it completely occludes it
  51166. * 0 mean it has no impact
  51167. */
  51168. protected _ambientTextureImpactOnAnalyticalLights: number;
  51169. /**
  51170. * Stores the alpha values in a texture.
  51171. */
  51172. protected _opacityTexture: Nullable<BaseTexture>;
  51173. /**
  51174. * Stores the reflection values in a texture.
  51175. */
  51176. protected _reflectionTexture: Nullable<BaseTexture>;
  51177. /**
  51178. * Stores the emissive values in a texture.
  51179. */
  51180. protected _emissiveTexture: Nullable<BaseTexture>;
  51181. /**
  51182. * AKA Specular texture in other nomenclature.
  51183. */
  51184. protected _reflectivityTexture: Nullable<BaseTexture>;
  51185. /**
  51186. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51187. */
  51188. protected _metallicTexture: Nullable<BaseTexture>;
  51189. /**
  51190. * Specifies the metallic scalar of the metallic/roughness workflow.
  51191. * Can also be used to scale the metalness values of the metallic texture.
  51192. */
  51193. protected _metallic: Nullable<number>;
  51194. /**
  51195. * Specifies the roughness scalar of the metallic/roughness workflow.
  51196. * Can also be used to scale the roughness values of the metallic texture.
  51197. */
  51198. protected _roughness: Nullable<number>;
  51199. /**
  51200. * Specifies the an F0 factor to help configuring the material F0.
  51201. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51202. * to 0.5 the previously hard coded value stays the same.
  51203. * Can also be used to scale the F0 values of the metallic texture.
  51204. */
  51205. protected _metallicF0Factor: number;
  51206. /**
  51207. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51208. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51209. * your expectation as it multiplies with the texture data.
  51210. */
  51211. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51212. /**
  51213. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51214. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51215. */
  51216. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51217. /**
  51218. * Stores surface normal data used to displace a mesh in a texture.
  51219. */
  51220. protected _bumpTexture: Nullable<BaseTexture>;
  51221. /**
  51222. * Stores the pre-calculated light information of a mesh in a texture.
  51223. */
  51224. protected _lightmapTexture: Nullable<BaseTexture>;
  51225. /**
  51226. * The color of a material in ambient lighting.
  51227. */
  51228. protected _ambientColor: Color3;
  51229. /**
  51230. * AKA Diffuse Color in other nomenclature.
  51231. */
  51232. protected _albedoColor: Color3;
  51233. /**
  51234. * AKA Specular Color in other nomenclature.
  51235. */
  51236. protected _reflectivityColor: Color3;
  51237. /**
  51238. * The color applied when light is reflected from a material.
  51239. */
  51240. protected _reflectionColor: Color3;
  51241. /**
  51242. * The color applied when light is emitted from a material.
  51243. */
  51244. protected _emissiveColor: Color3;
  51245. /**
  51246. * AKA Glossiness in other nomenclature.
  51247. */
  51248. protected _microSurface: number;
  51249. /**
  51250. * Specifies that the material will use the light map as a show map.
  51251. */
  51252. protected _useLightmapAsShadowmap: boolean;
  51253. /**
  51254. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51255. * makes the reflect vector face the model (under horizon).
  51256. */
  51257. protected _useHorizonOcclusion: boolean;
  51258. /**
  51259. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51260. * too much the area relying on ambient texture to define their ambient occlusion.
  51261. */
  51262. protected _useRadianceOcclusion: boolean;
  51263. /**
  51264. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51265. */
  51266. protected _useAlphaFromAlbedoTexture: boolean;
  51267. /**
  51268. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51269. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51270. */
  51271. protected _useSpecularOverAlpha: boolean;
  51272. /**
  51273. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51274. */
  51275. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51276. /**
  51277. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51278. */
  51279. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51280. /**
  51281. * Specifies if the metallic texture contains the roughness information in its green channel.
  51282. */
  51283. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51284. /**
  51285. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51286. */
  51287. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51288. /**
  51289. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51290. */
  51291. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51292. /**
  51293. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51294. */
  51295. protected _useAmbientInGrayScale: boolean;
  51296. /**
  51297. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51298. * The material will try to infer what glossiness each pixel should be.
  51299. */
  51300. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51301. /**
  51302. * Defines the falloff type used in this material.
  51303. * It by default is Physical.
  51304. */
  51305. protected _lightFalloff: number;
  51306. /**
  51307. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51308. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51309. */
  51310. protected _useRadianceOverAlpha: boolean;
  51311. /**
  51312. * Allows using an object space normal map (instead of tangent space).
  51313. */
  51314. protected _useObjectSpaceNormalMap: boolean;
  51315. /**
  51316. * Allows using the bump map in parallax mode.
  51317. */
  51318. protected _useParallax: boolean;
  51319. /**
  51320. * Allows using the bump map in parallax occlusion mode.
  51321. */
  51322. protected _useParallaxOcclusion: boolean;
  51323. /**
  51324. * Controls the scale bias of the parallax mode.
  51325. */
  51326. protected _parallaxScaleBias: number;
  51327. /**
  51328. * If sets to true, disables all the lights affecting the material.
  51329. */
  51330. protected _disableLighting: boolean;
  51331. /**
  51332. * Number of Simultaneous lights allowed on the material.
  51333. */
  51334. protected _maxSimultaneousLights: number;
  51335. /**
  51336. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51337. */
  51338. protected _invertNormalMapX: boolean;
  51339. /**
  51340. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51341. */
  51342. protected _invertNormalMapY: boolean;
  51343. /**
  51344. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51345. */
  51346. protected _twoSidedLighting: boolean;
  51347. /**
  51348. * Defines the alpha limits in alpha test mode.
  51349. */
  51350. protected _alphaCutOff: number;
  51351. /**
  51352. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51353. */
  51354. protected _forceAlphaTest: boolean;
  51355. /**
  51356. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51357. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51358. */
  51359. protected _useAlphaFresnel: boolean;
  51360. /**
  51361. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51362. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51363. */
  51364. protected _useLinearAlphaFresnel: boolean;
  51365. /**
  51366. * The transparency mode of the material.
  51367. */
  51368. protected _transparencyMode: Nullable<number>;
  51369. /**
  51370. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51371. * from cos thetav and roughness:
  51372. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51373. */
  51374. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51375. /**
  51376. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51377. */
  51378. protected _forceIrradianceInFragment: boolean;
  51379. /**
  51380. * Force normal to face away from face.
  51381. */
  51382. protected _forceNormalForward: boolean;
  51383. /**
  51384. * Enables specular anti aliasing in the PBR shader.
  51385. * It will both interacts on the Geometry for analytical and IBL lighting.
  51386. * It also prefilter the roughness map based on the bump values.
  51387. */
  51388. protected _enableSpecularAntiAliasing: boolean;
  51389. /**
  51390. * Default configuration related to image processing available in the PBR Material.
  51391. */
  51392. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51393. /**
  51394. * Keep track of the image processing observer to allow dispose and replace.
  51395. */
  51396. private _imageProcessingObserver;
  51397. /**
  51398. * Attaches a new image processing configuration to the PBR Material.
  51399. * @param configuration
  51400. */
  51401. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51402. /**
  51403. * Stores the available render targets.
  51404. */
  51405. private _renderTargets;
  51406. /**
  51407. * Sets the global ambient color for the material used in lighting calculations.
  51408. */
  51409. private _globalAmbientColor;
  51410. /**
  51411. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51412. */
  51413. private _useLogarithmicDepth;
  51414. /**
  51415. * If set to true, no lighting calculations will be applied.
  51416. */
  51417. private _unlit;
  51418. private _debugMode;
  51419. /**
  51420. * @hidden
  51421. * This is reserved for the inspector.
  51422. * Defines the material debug mode.
  51423. * It helps seeing only some components of the material while troubleshooting.
  51424. */
  51425. debugMode: number;
  51426. /**
  51427. * @hidden
  51428. * This is reserved for the inspector.
  51429. * Specify from where on screen the debug mode should start.
  51430. * The value goes from -1 (full screen) to 1 (not visible)
  51431. * It helps with side by side comparison against the final render
  51432. * This defaults to -1
  51433. */
  51434. private debugLimit;
  51435. /**
  51436. * @hidden
  51437. * This is reserved for the inspector.
  51438. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51439. * You can use the factor to better multiply the final value.
  51440. */
  51441. private debugFactor;
  51442. /**
  51443. * Defines the clear coat layer parameters for the material.
  51444. */
  51445. readonly clearCoat: PBRClearCoatConfiguration;
  51446. /**
  51447. * Defines the anisotropic parameters for the material.
  51448. */
  51449. readonly anisotropy: PBRAnisotropicConfiguration;
  51450. /**
  51451. * Defines the BRDF parameters for the material.
  51452. */
  51453. readonly brdf: PBRBRDFConfiguration;
  51454. /**
  51455. * Defines the Sheen parameters for the material.
  51456. */
  51457. readonly sheen: PBRSheenConfiguration;
  51458. /**
  51459. * Defines the SubSurface parameters for the material.
  51460. */
  51461. readonly subSurface: PBRSubSurfaceConfiguration;
  51462. /**
  51463. * Custom callback helping to override the default shader used in the material.
  51464. */
  51465. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51466. protected _rebuildInParallel: boolean;
  51467. /**
  51468. * Instantiates a new PBRMaterial instance.
  51469. *
  51470. * @param name The material name
  51471. * @param scene The scene the material will be use in.
  51472. */
  51473. constructor(name: string, scene: Scene);
  51474. /**
  51475. * Gets a boolean indicating that current material needs to register RTT
  51476. */
  51477. get hasRenderTargetTextures(): boolean;
  51478. /**
  51479. * Gets the name of the material class.
  51480. */
  51481. getClassName(): string;
  51482. /**
  51483. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51484. */
  51485. get useLogarithmicDepth(): boolean;
  51486. /**
  51487. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51488. */
  51489. set useLogarithmicDepth(value: boolean);
  51490. /**
  51491. * Gets the current transparency mode.
  51492. */
  51493. get transparencyMode(): Nullable<number>;
  51494. /**
  51495. * Sets the transparency mode of the material.
  51496. *
  51497. * | Value | Type | Description |
  51498. * | ----- | ----------------------------------- | ----------- |
  51499. * | 0 | OPAQUE | |
  51500. * | 1 | ALPHATEST | |
  51501. * | 2 | ALPHABLEND | |
  51502. * | 3 | ALPHATESTANDBLEND | |
  51503. *
  51504. */
  51505. set transparencyMode(value: Nullable<number>);
  51506. /**
  51507. * Returns true if alpha blending should be disabled.
  51508. */
  51509. private get _disableAlphaBlending();
  51510. /**
  51511. * Specifies whether or not this material should be rendered in alpha blend mode.
  51512. */
  51513. needAlphaBlending(): boolean;
  51514. /**
  51515. * Specifies if the mesh will require alpha blending.
  51516. * @param mesh - BJS mesh.
  51517. */
  51518. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51519. /**
  51520. * Specifies whether or not this material should be rendered in alpha test mode.
  51521. */
  51522. needAlphaTesting(): boolean;
  51523. /**
  51524. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51525. */
  51526. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51527. /**
  51528. * Gets the texture used for the alpha test.
  51529. */
  51530. getAlphaTestTexture(): Nullable<BaseTexture>;
  51531. /**
  51532. * Specifies that the submesh is ready to be used.
  51533. * @param mesh - BJS mesh.
  51534. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51535. * @param useInstances - Specifies that instances should be used.
  51536. * @returns - boolean indicating that the submesh is ready or not.
  51537. */
  51538. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51539. /**
  51540. * Specifies if the material uses metallic roughness workflow.
  51541. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51542. */
  51543. isMetallicWorkflow(): boolean;
  51544. private _prepareEffect;
  51545. private _prepareDefines;
  51546. /**
  51547. * Force shader compilation
  51548. */
  51549. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51550. /**
  51551. * Initializes the uniform buffer layout for the shader.
  51552. */
  51553. buildUniformLayout(): void;
  51554. /**
  51555. * Unbinds the material from the mesh
  51556. */
  51557. unbind(): void;
  51558. /**
  51559. * Binds the submesh data.
  51560. * @param world - The world matrix.
  51561. * @param mesh - The BJS mesh.
  51562. * @param subMesh - A submesh of the BJS mesh.
  51563. */
  51564. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51565. /**
  51566. * Returns the animatable textures.
  51567. * @returns - Array of animatable textures.
  51568. */
  51569. getAnimatables(): IAnimatable[];
  51570. /**
  51571. * Returns the texture used for reflections.
  51572. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51573. */
  51574. private _getReflectionTexture;
  51575. /**
  51576. * Returns an array of the actively used textures.
  51577. * @returns - Array of BaseTextures
  51578. */
  51579. getActiveTextures(): BaseTexture[];
  51580. /**
  51581. * Checks to see if a texture is used in the material.
  51582. * @param texture - Base texture to use.
  51583. * @returns - Boolean specifying if a texture is used in the material.
  51584. */
  51585. hasTexture(texture: BaseTexture): boolean;
  51586. /**
  51587. * Disposes the resources of the material.
  51588. * @param forceDisposeEffect - Forces the disposal of effects.
  51589. * @param forceDisposeTextures - Forces the disposal of all textures.
  51590. */
  51591. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51592. }
  51593. }
  51594. declare module BABYLON {
  51595. /**
  51596. * The Physically based material of BJS.
  51597. *
  51598. * This offers the main features of a standard PBR material.
  51599. * For more information, please refer to the documentation :
  51600. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51601. */
  51602. export class PBRMaterial extends PBRBaseMaterial {
  51603. /**
  51604. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51605. */
  51606. static readonly PBRMATERIAL_OPAQUE: number;
  51607. /**
  51608. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51609. */
  51610. static readonly PBRMATERIAL_ALPHATEST: number;
  51611. /**
  51612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51613. */
  51614. static readonly PBRMATERIAL_ALPHABLEND: number;
  51615. /**
  51616. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51617. * They are also discarded below the alpha cutoff threshold to improve performances.
  51618. */
  51619. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51620. /**
  51621. * Defines the default value of how much AO map is occluding the analytical lights
  51622. * (point spot...).
  51623. */
  51624. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51625. /**
  51626. * Intensity of the direct lights e.g. the four lights available in your scene.
  51627. * This impacts both the direct diffuse and specular highlights.
  51628. */
  51629. directIntensity: number;
  51630. /**
  51631. * Intensity of the emissive part of the material.
  51632. * This helps controlling the emissive effect without modifying the emissive color.
  51633. */
  51634. emissiveIntensity: number;
  51635. /**
  51636. * Intensity of the environment e.g. how much the environment will light the object
  51637. * either through harmonics for rough material or through the refelction for shiny ones.
  51638. */
  51639. environmentIntensity: number;
  51640. /**
  51641. * This is a special control allowing the reduction of the specular highlights coming from the
  51642. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51643. */
  51644. specularIntensity: number;
  51645. /**
  51646. * Debug Control allowing disabling the bump map on this material.
  51647. */
  51648. disableBumpMap: boolean;
  51649. /**
  51650. * AKA Diffuse Texture in standard nomenclature.
  51651. */
  51652. albedoTexture: BaseTexture;
  51653. /**
  51654. * AKA Occlusion Texture in other nomenclature.
  51655. */
  51656. ambientTexture: BaseTexture;
  51657. /**
  51658. * AKA Occlusion Texture Intensity in other nomenclature.
  51659. */
  51660. ambientTextureStrength: number;
  51661. /**
  51662. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51663. * 1 means it completely occludes it
  51664. * 0 mean it has no impact
  51665. */
  51666. ambientTextureImpactOnAnalyticalLights: number;
  51667. /**
  51668. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51669. */
  51670. opacityTexture: BaseTexture;
  51671. /**
  51672. * Stores the reflection values in a texture.
  51673. */
  51674. reflectionTexture: Nullable<BaseTexture>;
  51675. /**
  51676. * Stores the emissive values in a texture.
  51677. */
  51678. emissiveTexture: BaseTexture;
  51679. /**
  51680. * AKA Specular texture in other nomenclature.
  51681. */
  51682. reflectivityTexture: BaseTexture;
  51683. /**
  51684. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51685. */
  51686. metallicTexture: BaseTexture;
  51687. /**
  51688. * Specifies the metallic scalar of the metallic/roughness workflow.
  51689. * Can also be used to scale the metalness values of the metallic texture.
  51690. */
  51691. metallic: Nullable<number>;
  51692. /**
  51693. * Specifies the roughness scalar of the metallic/roughness workflow.
  51694. * Can also be used to scale the roughness values of the metallic texture.
  51695. */
  51696. roughness: Nullable<number>;
  51697. /**
  51698. * Specifies the an F0 factor to help configuring the material F0.
  51699. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51700. * to 0.5 the previously hard coded value stays the same.
  51701. * Can also be used to scale the F0 values of the metallic texture.
  51702. */
  51703. metallicF0Factor: number;
  51704. /**
  51705. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51706. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51707. * your expectation as it multiplies with the texture data.
  51708. */
  51709. useMetallicF0FactorFromMetallicTexture: boolean;
  51710. /**
  51711. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51712. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51713. */
  51714. microSurfaceTexture: BaseTexture;
  51715. /**
  51716. * Stores surface normal data used to displace a mesh in a texture.
  51717. */
  51718. bumpTexture: BaseTexture;
  51719. /**
  51720. * Stores the pre-calculated light information of a mesh in a texture.
  51721. */
  51722. lightmapTexture: BaseTexture;
  51723. /**
  51724. * Stores the refracted light information in a texture.
  51725. */
  51726. get refractionTexture(): Nullable<BaseTexture>;
  51727. set refractionTexture(value: Nullable<BaseTexture>);
  51728. /**
  51729. * The color of a material in ambient lighting.
  51730. */
  51731. ambientColor: Color3;
  51732. /**
  51733. * AKA Diffuse Color in other nomenclature.
  51734. */
  51735. albedoColor: Color3;
  51736. /**
  51737. * AKA Specular Color in other nomenclature.
  51738. */
  51739. reflectivityColor: Color3;
  51740. /**
  51741. * The color reflected from the material.
  51742. */
  51743. reflectionColor: Color3;
  51744. /**
  51745. * The color emitted from the material.
  51746. */
  51747. emissiveColor: Color3;
  51748. /**
  51749. * AKA Glossiness in other nomenclature.
  51750. */
  51751. microSurface: number;
  51752. /**
  51753. * source material index of refraction (IOR)' / 'destination material IOR.
  51754. */
  51755. get indexOfRefraction(): number;
  51756. set indexOfRefraction(value: number);
  51757. /**
  51758. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51759. */
  51760. get invertRefractionY(): boolean;
  51761. set invertRefractionY(value: boolean);
  51762. /**
  51763. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51764. * Materials half opaque for instance using refraction could benefit from this control.
  51765. */
  51766. get linkRefractionWithTransparency(): boolean;
  51767. set linkRefractionWithTransparency(value: boolean);
  51768. /**
  51769. * If true, the light map contains occlusion information instead of lighting info.
  51770. */
  51771. useLightmapAsShadowmap: boolean;
  51772. /**
  51773. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51774. */
  51775. useAlphaFromAlbedoTexture: boolean;
  51776. /**
  51777. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51778. */
  51779. forceAlphaTest: boolean;
  51780. /**
  51781. * Defines the alpha limits in alpha test mode.
  51782. */
  51783. alphaCutOff: number;
  51784. /**
  51785. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51786. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51787. */
  51788. useSpecularOverAlpha: boolean;
  51789. /**
  51790. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51791. */
  51792. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51793. /**
  51794. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51795. */
  51796. useRoughnessFromMetallicTextureAlpha: boolean;
  51797. /**
  51798. * Specifies if the metallic texture contains the roughness information in its green channel.
  51799. */
  51800. useRoughnessFromMetallicTextureGreen: boolean;
  51801. /**
  51802. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51803. */
  51804. useMetallnessFromMetallicTextureBlue: boolean;
  51805. /**
  51806. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51807. */
  51808. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51809. /**
  51810. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51811. */
  51812. useAmbientInGrayScale: boolean;
  51813. /**
  51814. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51815. * The material will try to infer what glossiness each pixel should be.
  51816. */
  51817. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51818. /**
  51819. * BJS is using an harcoded light falloff based on a manually sets up range.
  51820. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51821. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51822. */
  51823. get usePhysicalLightFalloff(): boolean;
  51824. /**
  51825. * BJS is using an harcoded light falloff based on a manually sets up range.
  51826. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51827. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51828. */
  51829. set usePhysicalLightFalloff(value: boolean);
  51830. /**
  51831. * In order to support the falloff compatibility with gltf, a special mode has been added
  51832. * to reproduce the gltf light falloff.
  51833. */
  51834. get useGLTFLightFalloff(): boolean;
  51835. /**
  51836. * In order to support the falloff compatibility with gltf, a special mode has been added
  51837. * to reproduce the gltf light falloff.
  51838. */
  51839. set useGLTFLightFalloff(value: boolean);
  51840. /**
  51841. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51842. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51843. */
  51844. useRadianceOverAlpha: boolean;
  51845. /**
  51846. * Allows using an object space normal map (instead of tangent space).
  51847. */
  51848. useObjectSpaceNormalMap: boolean;
  51849. /**
  51850. * Allows using the bump map in parallax mode.
  51851. */
  51852. useParallax: boolean;
  51853. /**
  51854. * Allows using the bump map in parallax occlusion mode.
  51855. */
  51856. useParallaxOcclusion: boolean;
  51857. /**
  51858. * Controls the scale bias of the parallax mode.
  51859. */
  51860. parallaxScaleBias: number;
  51861. /**
  51862. * If sets to true, disables all the lights affecting the material.
  51863. */
  51864. disableLighting: boolean;
  51865. /**
  51866. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51867. */
  51868. forceIrradianceInFragment: boolean;
  51869. /**
  51870. * Number of Simultaneous lights allowed on the material.
  51871. */
  51872. maxSimultaneousLights: number;
  51873. /**
  51874. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51875. */
  51876. invertNormalMapX: boolean;
  51877. /**
  51878. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51879. */
  51880. invertNormalMapY: boolean;
  51881. /**
  51882. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51883. */
  51884. twoSidedLighting: boolean;
  51885. /**
  51886. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51887. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51888. */
  51889. useAlphaFresnel: boolean;
  51890. /**
  51891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51892. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51893. */
  51894. useLinearAlphaFresnel: boolean;
  51895. /**
  51896. * Let user defines the brdf lookup texture used for IBL.
  51897. * A default 8bit version is embedded but you could point at :
  51898. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51899. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51900. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51901. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51902. */
  51903. environmentBRDFTexture: Nullable<BaseTexture>;
  51904. /**
  51905. * Force normal to face away from face.
  51906. */
  51907. forceNormalForward: boolean;
  51908. /**
  51909. * Enables specular anti aliasing in the PBR shader.
  51910. * It will both interacts on the Geometry for analytical and IBL lighting.
  51911. * It also prefilter the roughness map based on the bump values.
  51912. */
  51913. enableSpecularAntiAliasing: boolean;
  51914. /**
  51915. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51916. * makes the reflect vector face the model (under horizon).
  51917. */
  51918. useHorizonOcclusion: boolean;
  51919. /**
  51920. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51921. * too much the area relying on ambient texture to define their ambient occlusion.
  51922. */
  51923. useRadianceOcclusion: boolean;
  51924. /**
  51925. * If set to true, no lighting calculations will be applied.
  51926. */
  51927. unlit: boolean;
  51928. /**
  51929. * Gets the image processing configuration used either in this material.
  51930. */
  51931. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51932. /**
  51933. * Sets the Default image processing configuration used either in the this material.
  51934. *
  51935. * If sets to null, the scene one is in use.
  51936. */
  51937. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51938. /**
  51939. * Gets wether the color curves effect is enabled.
  51940. */
  51941. get cameraColorCurvesEnabled(): boolean;
  51942. /**
  51943. * Sets wether the color curves effect is enabled.
  51944. */
  51945. set cameraColorCurvesEnabled(value: boolean);
  51946. /**
  51947. * Gets wether the color grading effect is enabled.
  51948. */
  51949. get cameraColorGradingEnabled(): boolean;
  51950. /**
  51951. * Gets wether the color grading effect is enabled.
  51952. */
  51953. set cameraColorGradingEnabled(value: boolean);
  51954. /**
  51955. * Gets wether tonemapping is enabled or not.
  51956. */
  51957. get cameraToneMappingEnabled(): boolean;
  51958. /**
  51959. * Sets wether tonemapping is enabled or not
  51960. */
  51961. set cameraToneMappingEnabled(value: boolean);
  51962. /**
  51963. * The camera exposure used on this material.
  51964. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51965. * This corresponds to a photographic exposure.
  51966. */
  51967. get cameraExposure(): number;
  51968. /**
  51969. * The camera exposure used on this material.
  51970. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51971. * This corresponds to a photographic exposure.
  51972. */
  51973. set cameraExposure(value: number);
  51974. /**
  51975. * Gets The camera contrast used on this material.
  51976. */
  51977. get cameraContrast(): number;
  51978. /**
  51979. * Sets The camera contrast used on this material.
  51980. */
  51981. set cameraContrast(value: number);
  51982. /**
  51983. * Gets the Color Grading 2D Lookup Texture.
  51984. */
  51985. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51986. /**
  51987. * Sets the Color Grading 2D Lookup Texture.
  51988. */
  51989. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51990. /**
  51991. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51992. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51993. * 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;
  51994. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51995. */
  51996. get cameraColorCurves(): Nullable<ColorCurves>;
  51997. /**
  51998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52000. * 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;
  52001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52002. */
  52003. set cameraColorCurves(value: Nullable<ColorCurves>);
  52004. /**
  52005. * Instantiates a new PBRMaterial instance.
  52006. *
  52007. * @param name The material name
  52008. * @param scene The scene the material will be use in.
  52009. */
  52010. constructor(name: string, scene: Scene);
  52011. /**
  52012. * Returns the name of this material class.
  52013. */
  52014. getClassName(): string;
  52015. /**
  52016. * Makes a duplicate of the current material.
  52017. * @param name - name to use for the new material.
  52018. */
  52019. clone(name: string): PBRMaterial;
  52020. /**
  52021. * Serializes this PBR Material.
  52022. * @returns - An object with the serialized material.
  52023. */
  52024. serialize(): any;
  52025. /**
  52026. * Parses a PBR Material from a serialized object.
  52027. * @param source - Serialized object.
  52028. * @param scene - BJS scene instance.
  52029. * @param rootUrl - url for the scene object
  52030. * @returns - PBRMaterial
  52031. */
  52032. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52033. }
  52034. }
  52035. declare module BABYLON {
  52036. /**
  52037. * Direct draw surface info
  52038. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52039. */
  52040. export interface DDSInfo {
  52041. /**
  52042. * Width of the texture
  52043. */
  52044. width: number;
  52045. /**
  52046. * Width of the texture
  52047. */
  52048. height: number;
  52049. /**
  52050. * Number of Mipmaps for the texture
  52051. * @see https://en.wikipedia.org/wiki/Mipmap
  52052. */
  52053. mipmapCount: number;
  52054. /**
  52055. * If the textures format is a known fourCC format
  52056. * @see https://www.fourcc.org/
  52057. */
  52058. isFourCC: boolean;
  52059. /**
  52060. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52061. */
  52062. isRGB: boolean;
  52063. /**
  52064. * If the texture is a lumincance format
  52065. */
  52066. isLuminance: boolean;
  52067. /**
  52068. * If this is a cube texture
  52069. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52070. */
  52071. isCube: boolean;
  52072. /**
  52073. * If the texture is a compressed format eg. FOURCC_DXT1
  52074. */
  52075. isCompressed: boolean;
  52076. /**
  52077. * The dxgiFormat of the texture
  52078. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52079. */
  52080. dxgiFormat: number;
  52081. /**
  52082. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52083. */
  52084. textureType: number;
  52085. /**
  52086. * Sphericle polynomial created for the dds texture
  52087. */
  52088. sphericalPolynomial?: SphericalPolynomial;
  52089. }
  52090. /**
  52091. * Class used to provide DDS decompression tools
  52092. */
  52093. export class DDSTools {
  52094. /**
  52095. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52096. */
  52097. static StoreLODInAlphaChannel: boolean;
  52098. /**
  52099. * Gets DDS information from an array buffer
  52100. * @param arrayBuffer defines the array buffer to read data from
  52101. * @returns the DDS information
  52102. */
  52103. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  52104. private static _FloatView;
  52105. private static _Int32View;
  52106. private static _ToHalfFloat;
  52107. private static _FromHalfFloat;
  52108. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52109. private static _GetHalfFloatRGBAArrayBuffer;
  52110. private static _GetFloatRGBAArrayBuffer;
  52111. private static _GetFloatAsUIntRGBAArrayBuffer;
  52112. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52113. private static _GetRGBAArrayBuffer;
  52114. private static _ExtractLongWordOrder;
  52115. private static _GetRGBArrayBuffer;
  52116. private static _GetLuminanceArrayBuffer;
  52117. /**
  52118. * Uploads DDS Levels to a Babylon Texture
  52119. * @hidden
  52120. */
  52121. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52122. }
  52123. interface ThinEngine {
  52124. /**
  52125. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52126. * @param rootUrl defines the url where the file to load is located
  52127. * @param scene defines the current scene
  52128. * @param lodScale defines scale to apply to the mip map selection
  52129. * @param lodOffset defines offset to apply to the mip map selection
  52130. * @param onLoad defines an optional callback raised when the texture is loaded
  52131. * @param onError defines an optional callback raised if there is an issue to load the texture
  52132. * @param format defines the format of the data
  52133. * @param forcedExtension defines the extension to use to pick the right loader
  52134. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52135. * @returns the cube texture as an InternalTexture
  52136. */
  52137. 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;
  52138. }
  52139. }
  52140. declare module BABYLON {
  52141. /**
  52142. * Implementation of the DDS Texture Loader.
  52143. * @hidden
  52144. */
  52145. export class _DDSTextureLoader implements IInternalTextureLoader {
  52146. /**
  52147. * Defines wether the loader supports cascade loading the different faces.
  52148. */
  52149. readonly supportCascades: boolean;
  52150. /**
  52151. * This returns if the loader support the current file information.
  52152. * @param extension defines the file extension of the file being loaded
  52153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52154. * @param fallback defines the fallback internal texture if any
  52155. * @param isBase64 defines whether the texture is encoded as a base64
  52156. * @param isBuffer defines whether the texture data are stored as a buffer
  52157. * @returns true if the loader can load the specified file
  52158. */
  52159. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52160. /**
  52161. * Transform the url before loading if required.
  52162. * @param rootUrl the url of the texture
  52163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52164. * @returns the transformed texture
  52165. */
  52166. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52167. /**
  52168. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52169. * @param rootUrl the url of the texture
  52170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52171. * @returns the fallback texture
  52172. */
  52173. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52174. /**
  52175. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52176. * @param data contains the texture data
  52177. * @param texture defines the BabylonJS internal texture
  52178. * @param createPolynomials will be true if polynomials have been requested
  52179. * @param onLoad defines the callback to trigger once the texture is ready
  52180. * @param onError defines the callback to trigger in case of error
  52181. */
  52182. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52183. /**
  52184. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52185. * @param data contains the texture data
  52186. * @param texture defines the BabylonJS internal texture
  52187. * @param callback defines the method to call once ready to upload
  52188. */
  52189. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52190. }
  52191. }
  52192. declare module BABYLON {
  52193. /**
  52194. * Implementation of the ENV Texture Loader.
  52195. * @hidden
  52196. */
  52197. export class _ENVTextureLoader implements IInternalTextureLoader {
  52198. /**
  52199. * Defines wether the loader supports cascade loading the different faces.
  52200. */
  52201. readonly supportCascades: boolean;
  52202. /**
  52203. * This returns if the loader support the current file information.
  52204. * @param extension defines the file extension of the file being loaded
  52205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52206. * @param fallback defines the fallback internal texture if any
  52207. * @param isBase64 defines whether the texture is encoded as a base64
  52208. * @param isBuffer defines whether the texture data are stored as a buffer
  52209. * @returns true if the loader can load the specified file
  52210. */
  52211. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52212. /**
  52213. * Transform the url before loading if required.
  52214. * @param rootUrl the url of the texture
  52215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52216. * @returns the transformed texture
  52217. */
  52218. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52219. /**
  52220. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52221. * @param rootUrl the url of the texture
  52222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52223. * @returns the fallback texture
  52224. */
  52225. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52226. /**
  52227. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52228. * @param data contains the texture data
  52229. * @param texture defines the BabylonJS internal texture
  52230. * @param createPolynomials will be true if polynomials have been requested
  52231. * @param onLoad defines the callback to trigger once the texture is ready
  52232. * @param onError defines the callback to trigger in case of error
  52233. */
  52234. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52235. /**
  52236. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52237. * @param data contains the texture data
  52238. * @param texture defines the BabylonJS internal texture
  52239. * @param callback defines the method to call once ready to upload
  52240. */
  52241. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52242. }
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52247. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52248. */
  52249. export class KhronosTextureContainer {
  52250. /** contents of the KTX container file */
  52251. arrayBuffer: any;
  52252. private static HEADER_LEN;
  52253. private static COMPRESSED_2D;
  52254. private static COMPRESSED_3D;
  52255. private static TEX_2D;
  52256. private static TEX_3D;
  52257. /**
  52258. * Gets the openGL type
  52259. */
  52260. glType: number;
  52261. /**
  52262. * Gets the openGL type size
  52263. */
  52264. glTypeSize: number;
  52265. /**
  52266. * Gets the openGL format
  52267. */
  52268. glFormat: number;
  52269. /**
  52270. * Gets the openGL internal format
  52271. */
  52272. glInternalFormat: number;
  52273. /**
  52274. * Gets the base internal format
  52275. */
  52276. glBaseInternalFormat: number;
  52277. /**
  52278. * Gets image width in pixel
  52279. */
  52280. pixelWidth: number;
  52281. /**
  52282. * Gets image height in pixel
  52283. */
  52284. pixelHeight: number;
  52285. /**
  52286. * Gets image depth in pixels
  52287. */
  52288. pixelDepth: number;
  52289. /**
  52290. * Gets the number of array elements
  52291. */
  52292. numberOfArrayElements: number;
  52293. /**
  52294. * Gets the number of faces
  52295. */
  52296. numberOfFaces: number;
  52297. /**
  52298. * Gets the number of mipmap levels
  52299. */
  52300. numberOfMipmapLevels: number;
  52301. /**
  52302. * Gets the bytes of key value data
  52303. */
  52304. bytesOfKeyValueData: number;
  52305. /**
  52306. * Gets the load type
  52307. */
  52308. loadType: number;
  52309. /**
  52310. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52311. */
  52312. isInvalid: boolean;
  52313. /**
  52314. * Creates a new KhronosTextureContainer
  52315. * @param arrayBuffer contents of the KTX container file
  52316. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52317. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52318. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52319. */
  52320. constructor(
  52321. /** contents of the KTX container file */
  52322. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52323. /**
  52324. * Uploads KTX content to a Babylon Texture.
  52325. * It is assumed that the texture has already been created & is currently bound
  52326. * @hidden
  52327. */
  52328. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52329. private _upload2DCompressedLevels;
  52330. }
  52331. }
  52332. declare module BABYLON {
  52333. /**
  52334. * Implementation of the KTX Texture Loader.
  52335. * @hidden
  52336. */
  52337. export class _KTXTextureLoader implements IInternalTextureLoader {
  52338. /**
  52339. * Defines wether the loader supports cascade loading the different faces.
  52340. */
  52341. readonly supportCascades: boolean;
  52342. /**
  52343. * This returns if the loader support the current file information.
  52344. * @param extension defines the file extension of the file being loaded
  52345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52346. * @param fallback defines the fallback internal texture if any
  52347. * @param isBase64 defines whether the texture is encoded as a base64
  52348. * @param isBuffer defines whether the texture data are stored as a buffer
  52349. * @returns true if the loader can load the specified file
  52350. */
  52351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52352. /**
  52353. * Transform the url before loading if required.
  52354. * @param rootUrl the url of the texture
  52355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52356. * @returns the transformed texture
  52357. */
  52358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52359. /**
  52360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52361. * @param rootUrl the url of the texture
  52362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52363. * @returns the fallback texture
  52364. */
  52365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52366. /**
  52367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52368. * @param data contains the texture data
  52369. * @param texture defines the BabylonJS internal texture
  52370. * @param createPolynomials will be true if polynomials have been requested
  52371. * @param onLoad defines the callback to trigger once the texture is ready
  52372. * @param onError defines the callback to trigger in case of error
  52373. */
  52374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52375. /**
  52376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52377. * @param data contains the texture data
  52378. * @param texture defines the BabylonJS internal texture
  52379. * @param callback defines the method to call once ready to upload
  52380. */
  52381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52382. }
  52383. }
  52384. declare module BABYLON {
  52385. /** @hidden */
  52386. export var _forceSceneHelpersToBundle: boolean;
  52387. interface Scene {
  52388. /**
  52389. * Creates a default light for the scene.
  52390. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52391. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52392. */
  52393. createDefaultLight(replace?: boolean): void;
  52394. /**
  52395. * Creates a default camera for the scene.
  52396. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52397. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52398. * @param replace has default false, when true replaces the active camera in the scene
  52399. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52400. */
  52401. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52402. /**
  52403. * Creates a default camera and a default light.
  52404. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52405. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52406. * @param replace has the default false, when true replaces the active camera/light in the scene
  52407. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52408. */
  52409. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52410. /**
  52411. * Creates a new sky box
  52412. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52413. * @param environmentTexture defines the texture to use as environment texture
  52414. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52415. * @param scale defines the overall scale of the skybox
  52416. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52417. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52418. * @returns a new mesh holding the sky box
  52419. */
  52420. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52421. /**
  52422. * Creates a new environment
  52423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52424. * @param options defines the options you can use to configure the environment
  52425. * @returns the new EnvironmentHelper
  52426. */
  52427. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52428. /**
  52429. * Creates a new VREXperienceHelper
  52430. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52431. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52432. * @returns a new VREXperienceHelper
  52433. */
  52434. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52435. /**
  52436. * Creates a new WebXRDefaultExperience
  52437. * @see http://doc.babylonjs.com/how_to/webxr
  52438. * @param options experience options
  52439. * @returns a promise for a new WebXRDefaultExperience
  52440. */
  52441. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52442. }
  52443. }
  52444. declare module BABYLON {
  52445. /**
  52446. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52447. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52448. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52449. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52450. */
  52451. export class VideoDome extends TransformNode {
  52452. /**
  52453. * Define the video source as a Monoscopic panoramic 360 video.
  52454. */
  52455. static readonly MODE_MONOSCOPIC: number;
  52456. /**
  52457. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52458. */
  52459. static readonly MODE_TOPBOTTOM: number;
  52460. /**
  52461. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52462. */
  52463. static readonly MODE_SIDEBYSIDE: number;
  52464. private _halfDome;
  52465. private _useDirectMapping;
  52466. /**
  52467. * The video texture being displayed on the sphere
  52468. */
  52469. protected _videoTexture: VideoTexture;
  52470. /**
  52471. * Gets the video texture being displayed on the sphere
  52472. */
  52473. get videoTexture(): VideoTexture;
  52474. /**
  52475. * The skybox material
  52476. */
  52477. protected _material: BackgroundMaterial;
  52478. /**
  52479. * The surface used for the skybox
  52480. */
  52481. protected _mesh: Mesh;
  52482. /**
  52483. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52484. */
  52485. private _halfDomeMask;
  52486. /**
  52487. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52488. * Also see the options.resolution property.
  52489. */
  52490. get fovMultiplier(): number;
  52491. set fovMultiplier(value: number);
  52492. private _videoMode;
  52493. /**
  52494. * Gets or set the current video mode for the video. It can be:
  52495. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52496. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52497. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52498. */
  52499. get videoMode(): number;
  52500. set videoMode(value: number);
  52501. /**
  52502. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52503. *
  52504. */
  52505. get halfDome(): boolean;
  52506. /**
  52507. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52508. */
  52509. set halfDome(enabled: boolean);
  52510. /**
  52511. * Oberserver used in Stereoscopic VR Mode.
  52512. */
  52513. private _onBeforeCameraRenderObserver;
  52514. /**
  52515. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52516. * @param name Element's name, child elements will append suffixes for their own names.
  52517. * @param urlsOrVideo defines the url(s) or the video element to use
  52518. * @param options An object containing optional or exposed sub element properties
  52519. */
  52520. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52521. resolution?: number;
  52522. clickToPlay?: boolean;
  52523. autoPlay?: boolean;
  52524. loop?: boolean;
  52525. size?: number;
  52526. poster?: string;
  52527. faceForward?: boolean;
  52528. useDirectMapping?: boolean;
  52529. halfDomeMode?: boolean;
  52530. }, scene: Scene);
  52531. private _changeVideoMode;
  52532. /**
  52533. * Releases resources associated with this node.
  52534. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52535. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52536. */
  52537. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52538. }
  52539. }
  52540. declare module BABYLON {
  52541. /**
  52542. * This class can be used to get instrumentation data from a Babylon engine
  52543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52544. */
  52545. export class EngineInstrumentation implements IDisposable {
  52546. /**
  52547. * Define the instrumented engine.
  52548. */
  52549. engine: Engine;
  52550. private _captureGPUFrameTime;
  52551. private _gpuFrameTimeToken;
  52552. private _gpuFrameTime;
  52553. private _captureShaderCompilationTime;
  52554. private _shaderCompilationTime;
  52555. private _onBeginFrameObserver;
  52556. private _onEndFrameObserver;
  52557. private _onBeforeShaderCompilationObserver;
  52558. private _onAfterShaderCompilationObserver;
  52559. /**
  52560. * Gets the perf counter used for GPU frame time
  52561. */
  52562. get gpuFrameTimeCounter(): PerfCounter;
  52563. /**
  52564. * Gets the GPU frame time capture status
  52565. */
  52566. get captureGPUFrameTime(): boolean;
  52567. /**
  52568. * Enable or disable the GPU frame time capture
  52569. */
  52570. set captureGPUFrameTime(value: boolean);
  52571. /**
  52572. * Gets the perf counter used for shader compilation time
  52573. */
  52574. get shaderCompilationTimeCounter(): PerfCounter;
  52575. /**
  52576. * Gets the shader compilation time capture status
  52577. */
  52578. get captureShaderCompilationTime(): boolean;
  52579. /**
  52580. * Enable or disable the shader compilation time capture
  52581. */
  52582. set captureShaderCompilationTime(value: boolean);
  52583. /**
  52584. * Instantiates a new engine instrumentation.
  52585. * This class can be used to get instrumentation data from a Babylon engine
  52586. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52587. * @param engine Defines the engine to instrument
  52588. */
  52589. constructor(
  52590. /**
  52591. * Define the instrumented engine.
  52592. */
  52593. engine: Engine);
  52594. /**
  52595. * Dispose and release associated resources.
  52596. */
  52597. dispose(): void;
  52598. }
  52599. }
  52600. declare module BABYLON {
  52601. /**
  52602. * This class can be used to get instrumentation data from a Babylon engine
  52603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52604. */
  52605. export class SceneInstrumentation implements IDisposable {
  52606. /**
  52607. * Defines the scene to instrument
  52608. */
  52609. scene: Scene;
  52610. private _captureActiveMeshesEvaluationTime;
  52611. private _activeMeshesEvaluationTime;
  52612. private _captureRenderTargetsRenderTime;
  52613. private _renderTargetsRenderTime;
  52614. private _captureFrameTime;
  52615. private _frameTime;
  52616. private _captureRenderTime;
  52617. private _renderTime;
  52618. private _captureInterFrameTime;
  52619. private _interFrameTime;
  52620. private _captureParticlesRenderTime;
  52621. private _particlesRenderTime;
  52622. private _captureSpritesRenderTime;
  52623. private _spritesRenderTime;
  52624. private _capturePhysicsTime;
  52625. private _physicsTime;
  52626. private _captureAnimationsTime;
  52627. private _animationsTime;
  52628. private _captureCameraRenderTime;
  52629. private _cameraRenderTime;
  52630. private _onBeforeActiveMeshesEvaluationObserver;
  52631. private _onAfterActiveMeshesEvaluationObserver;
  52632. private _onBeforeRenderTargetsRenderObserver;
  52633. private _onAfterRenderTargetsRenderObserver;
  52634. private _onAfterRenderObserver;
  52635. private _onBeforeDrawPhaseObserver;
  52636. private _onAfterDrawPhaseObserver;
  52637. private _onBeforeAnimationsObserver;
  52638. private _onBeforeParticlesRenderingObserver;
  52639. private _onAfterParticlesRenderingObserver;
  52640. private _onBeforeSpritesRenderingObserver;
  52641. private _onAfterSpritesRenderingObserver;
  52642. private _onBeforePhysicsObserver;
  52643. private _onAfterPhysicsObserver;
  52644. private _onAfterAnimationsObserver;
  52645. private _onBeforeCameraRenderObserver;
  52646. private _onAfterCameraRenderObserver;
  52647. /**
  52648. * Gets the perf counter used for active meshes evaluation time
  52649. */
  52650. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52651. /**
  52652. * Gets the active meshes evaluation time capture status
  52653. */
  52654. get captureActiveMeshesEvaluationTime(): boolean;
  52655. /**
  52656. * Enable or disable the active meshes evaluation time capture
  52657. */
  52658. set captureActiveMeshesEvaluationTime(value: boolean);
  52659. /**
  52660. * Gets the perf counter used for render targets render time
  52661. */
  52662. get renderTargetsRenderTimeCounter(): PerfCounter;
  52663. /**
  52664. * Gets the render targets render time capture status
  52665. */
  52666. get captureRenderTargetsRenderTime(): boolean;
  52667. /**
  52668. * Enable or disable the render targets render time capture
  52669. */
  52670. set captureRenderTargetsRenderTime(value: boolean);
  52671. /**
  52672. * Gets the perf counter used for particles render time
  52673. */
  52674. get particlesRenderTimeCounter(): PerfCounter;
  52675. /**
  52676. * Gets the particles render time capture status
  52677. */
  52678. get captureParticlesRenderTime(): boolean;
  52679. /**
  52680. * Enable or disable the particles render time capture
  52681. */
  52682. set captureParticlesRenderTime(value: boolean);
  52683. /**
  52684. * Gets the perf counter used for sprites render time
  52685. */
  52686. get spritesRenderTimeCounter(): PerfCounter;
  52687. /**
  52688. * Gets the sprites render time capture status
  52689. */
  52690. get captureSpritesRenderTime(): boolean;
  52691. /**
  52692. * Enable or disable the sprites render time capture
  52693. */
  52694. set captureSpritesRenderTime(value: boolean);
  52695. /**
  52696. * Gets the perf counter used for physics time
  52697. */
  52698. get physicsTimeCounter(): PerfCounter;
  52699. /**
  52700. * Gets the physics time capture status
  52701. */
  52702. get capturePhysicsTime(): boolean;
  52703. /**
  52704. * Enable or disable the physics time capture
  52705. */
  52706. set capturePhysicsTime(value: boolean);
  52707. /**
  52708. * Gets the perf counter used for animations time
  52709. */
  52710. get animationsTimeCounter(): PerfCounter;
  52711. /**
  52712. * Gets the animations time capture status
  52713. */
  52714. get captureAnimationsTime(): boolean;
  52715. /**
  52716. * Enable or disable the animations time capture
  52717. */
  52718. set captureAnimationsTime(value: boolean);
  52719. /**
  52720. * Gets the perf counter used for frame time capture
  52721. */
  52722. get frameTimeCounter(): PerfCounter;
  52723. /**
  52724. * Gets the frame time capture status
  52725. */
  52726. get captureFrameTime(): boolean;
  52727. /**
  52728. * Enable or disable the frame time capture
  52729. */
  52730. set captureFrameTime(value: boolean);
  52731. /**
  52732. * Gets the perf counter used for inter-frames time capture
  52733. */
  52734. get interFrameTimeCounter(): PerfCounter;
  52735. /**
  52736. * Gets the inter-frames time capture status
  52737. */
  52738. get captureInterFrameTime(): boolean;
  52739. /**
  52740. * Enable or disable the inter-frames time capture
  52741. */
  52742. set captureInterFrameTime(value: boolean);
  52743. /**
  52744. * Gets the perf counter used for render time capture
  52745. */
  52746. get renderTimeCounter(): PerfCounter;
  52747. /**
  52748. * Gets the render time capture status
  52749. */
  52750. get captureRenderTime(): boolean;
  52751. /**
  52752. * Enable or disable the render time capture
  52753. */
  52754. set captureRenderTime(value: boolean);
  52755. /**
  52756. * Gets the perf counter used for camera render time capture
  52757. */
  52758. get cameraRenderTimeCounter(): PerfCounter;
  52759. /**
  52760. * Gets the camera render time capture status
  52761. */
  52762. get captureCameraRenderTime(): boolean;
  52763. /**
  52764. * Enable or disable the camera render time capture
  52765. */
  52766. set captureCameraRenderTime(value: boolean);
  52767. /**
  52768. * Gets the perf counter used for draw calls
  52769. */
  52770. get drawCallsCounter(): PerfCounter;
  52771. /**
  52772. * Instantiates a new scene instrumentation.
  52773. * This class can be used to get instrumentation data from a Babylon engine
  52774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52775. * @param scene Defines the scene to instrument
  52776. */
  52777. constructor(
  52778. /**
  52779. * Defines the scene to instrument
  52780. */
  52781. scene: Scene);
  52782. /**
  52783. * Dispose and release associated resources.
  52784. */
  52785. dispose(): void;
  52786. }
  52787. }
  52788. declare module BABYLON {
  52789. /** @hidden */
  52790. export var glowMapGenerationPixelShader: {
  52791. name: string;
  52792. shader: string;
  52793. };
  52794. }
  52795. declare module BABYLON {
  52796. /** @hidden */
  52797. export var glowMapGenerationVertexShader: {
  52798. name: string;
  52799. shader: string;
  52800. };
  52801. }
  52802. declare module BABYLON {
  52803. /**
  52804. * Effect layer options. This helps customizing the behaviour
  52805. * of the effect layer.
  52806. */
  52807. export interface IEffectLayerOptions {
  52808. /**
  52809. * Multiplication factor apply to the canvas size to compute the render target size
  52810. * used to generated the objects (the smaller the faster).
  52811. */
  52812. mainTextureRatio: number;
  52813. /**
  52814. * Enforces a fixed size texture to ensure effect stability across devices.
  52815. */
  52816. mainTextureFixedSize?: number;
  52817. /**
  52818. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52819. */
  52820. alphaBlendingMode: number;
  52821. /**
  52822. * The camera attached to the layer.
  52823. */
  52824. camera: Nullable<Camera>;
  52825. /**
  52826. * The rendering group to draw the layer in.
  52827. */
  52828. renderingGroupId: number;
  52829. }
  52830. /**
  52831. * The effect layer Helps adding post process effect blended with the main pass.
  52832. *
  52833. * This can be for instance use to generate glow or higlight effects on the scene.
  52834. *
  52835. * The effect layer class can not be used directly and is intented to inherited from to be
  52836. * customized per effects.
  52837. */
  52838. export abstract class EffectLayer {
  52839. private _vertexBuffers;
  52840. private _indexBuffer;
  52841. private _cachedDefines;
  52842. private _effectLayerMapGenerationEffect;
  52843. private _effectLayerOptions;
  52844. private _mergeEffect;
  52845. protected _scene: Scene;
  52846. protected _engine: Engine;
  52847. protected _maxSize: number;
  52848. protected _mainTextureDesiredSize: ISize;
  52849. protected _mainTexture: RenderTargetTexture;
  52850. protected _shouldRender: boolean;
  52851. protected _postProcesses: PostProcess[];
  52852. protected _textures: BaseTexture[];
  52853. protected _emissiveTextureAndColor: {
  52854. texture: Nullable<BaseTexture>;
  52855. color: Color4;
  52856. };
  52857. /**
  52858. * The name of the layer
  52859. */
  52860. name: string;
  52861. /**
  52862. * The clear color of the texture used to generate the glow map.
  52863. */
  52864. neutralColor: Color4;
  52865. /**
  52866. * Specifies wether the highlight layer is enabled or not.
  52867. */
  52868. isEnabled: boolean;
  52869. /**
  52870. * Gets the camera attached to the layer.
  52871. */
  52872. get camera(): Nullable<Camera>;
  52873. /**
  52874. * Gets the rendering group id the layer should render in.
  52875. */
  52876. get renderingGroupId(): number;
  52877. set renderingGroupId(renderingGroupId: number);
  52878. /**
  52879. * An event triggered when the effect layer has been disposed.
  52880. */
  52881. onDisposeObservable: Observable<EffectLayer>;
  52882. /**
  52883. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52884. */
  52885. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52886. /**
  52887. * An event triggered when the generated texture is being merged in the scene.
  52888. */
  52889. onBeforeComposeObservable: Observable<EffectLayer>;
  52890. /**
  52891. * An event triggered when the mesh is rendered into the effect render target.
  52892. */
  52893. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52894. /**
  52895. * An event triggered after the mesh has been rendered into the effect render target.
  52896. */
  52897. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52898. /**
  52899. * An event triggered when the generated texture has been merged in the scene.
  52900. */
  52901. onAfterComposeObservable: Observable<EffectLayer>;
  52902. /**
  52903. * An event triggered when the efffect layer changes its size.
  52904. */
  52905. onSizeChangedObservable: Observable<EffectLayer>;
  52906. /** @hidden */
  52907. static _SceneComponentInitialization: (scene: Scene) => void;
  52908. /**
  52909. * Instantiates a new effect Layer and references it in the scene.
  52910. * @param name The name of the layer
  52911. * @param scene The scene to use the layer in
  52912. */
  52913. constructor(
  52914. /** The Friendly of the effect in the scene */
  52915. name: string, scene: Scene);
  52916. /**
  52917. * Get the effect name of the layer.
  52918. * @return The effect name
  52919. */
  52920. abstract getEffectName(): string;
  52921. /**
  52922. * Checks for the readiness of the element composing the layer.
  52923. * @param subMesh the mesh to check for
  52924. * @param useInstances specify wether or not to use instances to render the mesh
  52925. * @return true if ready otherwise, false
  52926. */
  52927. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52928. /**
  52929. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52930. * @returns true if the effect requires stencil during the main canvas render pass.
  52931. */
  52932. abstract needStencil(): boolean;
  52933. /**
  52934. * Create the merge effect. This is the shader use to blit the information back
  52935. * to the main canvas at the end of the scene rendering.
  52936. * @returns The effect containing the shader used to merge the effect on the main canvas
  52937. */
  52938. protected abstract _createMergeEffect(): Effect;
  52939. /**
  52940. * Creates the render target textures and post processes used in the effect layer.
  52941. */
  52942. protected abstract _createTextureAndPostProcesses(): void;
  52943. /**
  52944. * Implementation specific of rendering the generating effect on the main canvas.
  52945. * @param effect The effect used to render through
  52946. */
  52947. protected abstract _internalRender(effect: Effect): void;
  52948. /**
  52949. * Sets the required values for both the emissive texture and and the main color.
  52950. */
  52951. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52952. /**
  52953. * Free any resources and references associated to a mesh.
  52954. * Internal use
  52955. * @param mesh The mesh to free.
  52956. */
  52957. abstract _disposeMesh(mesh: Mesh): void;
  52958. /**
  52959. * Serializes this layer (Glow or Highlight for example)
  52960. * @returns a serialized layer object
  52961. */
  52962. abstract serialize?(): any;
  52963. /**
  52964. * Initializes the effect layer with the required options.
  52965. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52966. */
  52967. protected _init(options: Partial<IEffectLayerOptions>): void;
  52968. /**
  52969. * Generates the index buffer of the full screen quad blending to the main canvas.
  52970. */
  52971. private _generateIndexBuffer;
  52972. /**
  52973. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52974. */
  52975. private _generateVertexBuffer;
  52976. /**
  52977. * Sets the main texture desired size which is the closest power of two
  52978. * of the engine canvas size.
  52979. */
  52980. private _setMainTextureSize;
  52981. /**
  52982. * Creates the main texture for the effect layer.
  52983. */
  52984. protected _createMainTexture(): void;
  52985. /**
  52986. * Adds specific effects defines.
  52987. * @param defines The defines to add specifics to.
  52988. */
  52989. protected _addCustomEffectDefines(defines: string[]): void;
  52990. /**
  52991. * Checks for the readiness of the element composing the layer.
  52992. * @param subMesh the mesh to check for
  52993. * @param useInstances specify wether or not to use instances to render the mesh
  52994. * @param emissiveTexture the associated emissive texture used to generate the glow
  52995. * @return true if ready otherwise, false
  52996. */
  52997. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52998. /**
  52999. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53000. */
  53001. render(): void;
  53002. /**
  53003. * Determine if a given mesh will be used in the current effect.
  53004. * @param mesh mesh to test
  53005. * @returns true if the mesh will be used
  53006. */
  53007. hasMesh(mesh: AbstractMesh): boolean;
  53008. /**
  53009. * Returns true if the layer contains information to display, otherwise false.
  53010. * @returns true if the glow layer should be rendered
  53011. */
  53012. shouldRender(): boolean;
  53013. /**
  53014. * Returns true if the mesh should render, otherwise false.
  53015. * @param mesh The mesh to render
  53016. * @returns true if it should render otherwise false
  53017. */
  53018. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53019. /**
  53020. * Returns true if the mesh can be rendered, otherwise false.
  53021. * @param mesh The mesh to render
  53022. * @param material The material used on the mesh
  53023. * @returns true if it can be rendered otherwise false
  53024. */
  53025. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53026. /**
  53027. * Returns true if the mesh should render, otherwise false.
  53028. * @param mesh The mesh to render
  53029. * @returns true if it should render otherwise false
  53030. */
  53031. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53032. /**
  53033. * Renders the submesh passed in parameter to the generation map.
  53034. */
  53035. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53036. /**
  53037. * Defines wether the current material of the mesh should be use to render the effect.
  53038. * @param mesh defines the current mesh to render
  53039. */
  53040. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53041. /**
  53042. * Rebuild the required buffers.
  53043. * @hidden Internal use only.
  53044. */
  53045. _rebuild(): void;
  53046. /**
  53047. * Dispose only the render target textures and post process.
  53048. */
  53049. private _disposeTextureAndPostProcesses;
  53050. /**
  53051. * Dispose the highlight layer and free resources.
  53052. */
  53053. dispose(): void;
  53054. /**
  53055. * Gets the class name of the effect layer
  53056. * @returns the string with the class name of the effect layer
  53057. */
  53058. getClassName(): string;
  53059. /**
  53060. * Creates an effect layer from parsed effect layer data
  53061. * @param parsedEffectLayer defines effect layer data
  53062. * @param scene defines the current scene
  53063. * @param rootUrl defines the root URL containing the effect layer information
  53064. * @returns a parsed effect Layer
  53065. */
  53066. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53067. }
  53068. }
  53069. declare module BABYLON {
  53070. interface AbstractScene {
  53071. /**
  53072. * The list of effect layers (highlights/glow) added to the scene
  53073. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53074. * @see http://doc.babylonjs.com/how_to/glow_layer
  53075. */
  53076. effectLayers: Array<EffectLayer>;
  53077. /**
  53078. * Removes the given effect layer from this scene.
  53079. * @param toRemove defines the effect layer to remove
  53080. * @returns the index of the removed effect layer
  53081. */
  53082. removeEffectLayer(toRemove: EffectLayer): number;
  53083. /**
  53084. * Adds the given effect layer to this scene
  53085. * @param newEffectLayer defines the effect layer to add
  53086. */
  53087. addEffectLayer(newEffectLayer: EffectLayer): void;
  53088. }
  53089. /**
  53090. * Defines the layer scene component responsible to manage any effect layers
  53091. * in a given scene.
  53092. */
  53093. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53094. /**
  53095. * The component name helpfull to identify the component in the list of scene components.
  53096. */
  53097. readonly name: string;
  53098. /**
  53099. * The scene the component belongs to.
  53100. */
  53101. scene: Scene;
  53102. private _engine;
  53103. private _renderEffects;
  53104. private _needStencil;
  53105. private _previousStencilState;
  53106. /**
  53107. * Creates a new instance of the component for the given scene
  53108. * @param scene Defines the scene to register the component in
  53109. */
  53110. constructor(scene: Scene);
  53111. /**
  53112. * Registers the component in a given scene
  53113. */
  53114. register(): void;
  53115. /**
  53116. * Rebuilds the elements related to this component in case of
  53117. * context lost for instance.
  53118. */
  53119. rebuild(): void;
  53120. /**
  53121. * Serializes the component data to the specified json object
  53122. * @param serializationObject The object to serialize to
  53123. */
  53124. serialize(serializationObject: any): void;
  53125. /**
  53126. * Adds all the elements from the container to the scene
  53127. * @param container the container holding the elements
  53128. */
  53129. addFromContainer(container: AbstractScene): void;
  53130. /**
  53131. * Removes all the elements in the container from the scene
  53132. * @param container contains the elements to remove
  53133. * @param dispose if the removed element should be disposed (default: false)
  53134. */
  53135. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53136. /**
  53137. * Disposes the component and the associated ressources.
  53138. */
  53139. dispose(): void;
  53140. private _isReadyForMesh;
  53141. private _renderMainTexture;
  53142. private _setStencil;
  53143. private _setStencilBack;
  53144. private _draw;
  53145. private _drawCamera;
  53146. private _drawRenderingGroup;
  53147. }
  53148. }
  53149. declare module BABYLON {
  53150. /** @hidden */
  53151. export var glowMapMergePixelShader: {
  53152. name: string;
  53153. shader: string;
  53154. };
  53155. }
  53156. declare module BABYLON {
  53157. /** @hidden */
  53158. export var glowMapMergeVertexShader: {
  53159. name: string;
  53160. shader: string;
  53161. };
  53162. }
  53163. declare module BABYLON {
  53164. interface AbstractScene {
  53165. /**
  53166. * Return a the first highlight layer of the scene with a given name.
  53167. * @param name The name of the highlight layer to look for.
  53168. * @return The highlight layer if found otherwise null.
  53169. */
  53170. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53171. }
  53172. /**
  53173. * Glow layer options. This helps customizing the behaviour
  53174. * of the glow layer.
  53175. */
  53176. export interface IGlowLayerOptions {
  53177. /**
  53178. * Multiplication factor apply to the canvas size to compute the render target size
  53179. * used to generated the glowing objects (the smaller the faster).
  53180. */
  53181. mainTextureRatio: number;
  53182. /**
  53183. * Enforces a fixed size texture to ensure resize independant blur.
  53184. */
  53185. mainTextureFixedSize?: number;
  53186. /**
  53187. * How big is the kernel of the blur texture.
  53188. */
  53189. blurKernelSize: number;
  53190. /**
  53191. * The camera attached to the layer.
  53192. */
  53193. camera: Nullable<Camera>;
  53194. /**
  53195. * Enable MSAA by chosing the number of samples.
  53196. */
  53197. mainTextureSamples?: number;
  53198. /**
  53199. * The rendering group to draw the layer in.
  53200. */
  53201. renderingGroupId: number;
  53202. }
  53203. /**
  53204. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53205. *
  53206. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53207. *
  53208. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53209. */
  53210. export class GlowLayer extends EffectLayer {
  53211. /**
  53212. * Effect Name of the layer.
  53213. */
  53214. static readonly EffectName: string;
  53215. /**
  53216. * The default blur kernel size used for the glow.
  53217. */
  53218. static DefaultBlurKernelSize: number;
  53219. /**
  53220. * The default texture size ratio used for the glow.
  53221. */
  53222. static DefaultTextureRatio: number;
  53223. /**
  53224. * Sets the kernel size of the blur.
  53225. */
  53226. set blurKernelSize(value: number);
  53227. /**
  53228. * Gets the kernel size of the blur.
  53229. */
  53230. get blurKernelSize(): number;
  53231. /**
  53232. * Sets the glow intensity.
  53233. */
  53234. set intensity(value: number);
  53235. /**
  53236. * Gets the glow intensity.
  53237. */
  53238. get intensity(): number;
  53239. private _options;
  53240. private _intensity;
  53241. private _horizontalBlurPostprocess1;
  53242. private _verticalBlurPostprocess1;
  53243. private _horizontalBlurPostprocess2;
  53244. private _verticalBlurPostprocess2;
  53245. private _blurTexture1;
  53246. private _blurTexture2;
  53247. private _postProcesses1;
  53248. private _postProcesses2;
  53249. private _includedOnlyMeshes;
  53250. private _excludedMeshes;
  53251. private _meshesUsingTheirOwnMaterials;
  53252. /**
  53253. * Callback used to let the user override the color selection on a per mesh basis
  53254. */
  53255. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53256. /**
  53257. * Callback used to let the user override the texture selection on a per mesh basis
  53258. */
  53259. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53260. /**
  53261. * Instantiates a new glow Layer and references it to the scene.
  53262. * @param name The name of the layer
  53263. * @param scene The scene to use the layer in
  53264. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53265. */
  53266. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53267. /**
  53268. * Get the effect name of the layer.
  53269. * @return The effect name
  53270. */
  53271. getEffectName(): string;
  53272. /**
  53273. * Create the merge effect. This is the shader use to blit the information back
  53274. * to the main canvas at the end of the scene rendering.
  53275. */
  53276. protected _createMergeEffect(): Effect;
  53277. /**
  53278. * Creates the render target textures and post processes used in the glow layer.
  53279. */
  53280. protected _createTextureAndPostProcesses(): void;
  53281. /**
  53282. * Checks for the readiness of the element composing the layer.
  53283. * @param subMesh the mesh to check for
  53284. * @param useInstances specify wether or not to use instances to render the mesh
  53285. * @param emissiveTexture the associated emissive texture used to generate the glow
  53286. * @return true if ready otherwise, false
  53287. */
  53288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53289. /**
  53290. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53291. */
  53292. needStencil(): boolean;
  53293. /**
  53294. * Returns true if the mesh can be rendered, otherwise false.
  53295. * @param mesh The mesh to render
  53296. * @param material The material used on the mesh
  53297. * @returns true if it can be rendered otherwise false
  53298. */
  53299. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53300. /**
  53301. * Implementation specific of rendering the generating effect on the main canvas.
  53302. * @param effect The effect used to render through
  53303. */
  53304. protected _internalRender(effect: Effect): void;
  53305. /**
  53306. * Sets the required values for both the emissive texture and and the main color.
  53307. */
  53308. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53309. /**
  53310. * Returns true if the mesh should render, otherwise false.
  53311. * @param mesh The mesh to render
  53312. * @returns true if it should render otherwise false
  53313. */
  53314. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53315. /**
  53316. * Adds specific effects defines.
  53317. * @param defines The defines to add specifics to.
  53318. */
  53319. protected _addCustomEffectDefines(defines: string[]): void;
  53320. /**
  53321. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53322. * @param mesh The mesh to exclude from the glow layer
  53323. */
  53324. addExcludedMesh(mesh: Mesh): void;
  53325. /**
  53326. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53327. * @param mesh The mesh to remove
  53328. */
  53329. removeExcludedMesh(mesh: Mesh): void;
  53330. /**
  53331. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53332. * @param mesh The mesh to include in the glow layer
  53333. */
  53334. addIncludedOnlyMesh(mesh: Mesh): void;
  53335. /**
  53336. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53337. * @param mesh The mesh to remove
  53338. */
  53339. removeIncludedOnlyMesh(mesh: Mesh): void;
  53340. /**
  53341. * Determine if a given mesh will be used in the glow layer
  53342. * @param mesh The mesh to test
  53343. * @returns true if the mesh will be highlighted by the current glow layer
  53344. */
  53345. hasMesh(mesh: AbstractMesh): boolean;
  53346. /**
  53347. * Defines wether the current material of the mesh should be use to render the effect.
  53348. * @param mesh defines the current mesh to render
  53349. */
  53350. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53351. /**
  53352. * Add a mesh to be rendered through its own material and not with emissive only.
  53353. * @param mesh The mesh for which we need to use its material
  53354. */
  53355. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53356. /**
  53357. * Remove a mesh from being rendered through its own material and not with emissive only.
  53358. * @param mesh The mesh for which we need to not use its material
  53359. */
  53360. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53361. /**
  53362. * Free any resources and references associated to a mesh.
  53363. * Internal use
  53364. * @param mesh The mesh to free.
  53365. * @hidden
  53366. */
  53367. _disposeMesh(mesh: Mesh): void;
  53368. /**
  53369. * Gets the class name of the effect layer
  53370. * @returns the string with the class name of the effect layer
  53371. */
  53372. getClassName(): string;
  53373. /**
  53374. * Serializes this glow layer
  53375. * @returns a serialized glow layer object
  53376. */
  53377. serialize(): any;
  53378. /**
  53379. * Creates a Glow Layer from parsed glow layer data
  53380. * @param parsedGlowLayer defines glow layer data
  53381. * @param scene defines the current scene
  53382. * @param rootUrl defines the root URL containing the glow layer information
  53383. * @returns a parsed Glow Layer
  53384. */
  53385. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53386. }
  53387. }
  53388. declare module BABYLON {
  53389. /** @hidden */
  53390. export var glowBlurPostProcessPixelShader: {
  53391. name: string;
  53392. shader: string;
  53393. };
  53394. }
  53395. declare module BABYLON {
  53396. interface AbstractScene {
  53397. /**
  53398. * Return a the first highlight layer of the scene with a given name.
  53399. * @param name The name of the highlight layer to look for.
  53400. * @return The highlight layer if found otherwise null.
  53401. */
  53402. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53403. }
  53404. /**
  53405. * Highlight layer options. This helps customizing the behaviour
  53406. * of the highlight layer.
  53407. */
  53408. export interface IHighlightLayerOptions {
  53409. /**
  53410. * Multiplication factor apply to the canvas size to compute the render target size
  53411. * used to generated the glowing objects (the smaller the faster).
  53412. */
  53413. mainTextureRatio: number;
  53414. /**
  53415. * Enforces a fixed size texture to ensure resize independant blur.
  53416. */
  53417. mainTextureFixedSize?: number;
  53418. /**
  53419. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53420. * of the picture to blur (the smaller the faster).
  53421. */
  53422. blurTextureSizeRatio: number;
  53423. /**
  53424. * How big in texel of the blur texture is the vertical blur.
  53425. */
  53426. blurVerticalSize: number;
  53427. /**
  53428. * How big in texel of the blur texture is the horizontal blur.
  53429. */
  53430. blurHorizontalSize: number;
  53431. /**
  53432. * Alpha blending mode used to apply the blur. Default is combine.
  53433. */
  53434. alphaBlendingMode: number;
  53435. /**
  53436. * The camera attached to the layer.
  53437. */
  53438. camera: Nullable<Camera>;
  53439. /**
  53440. * Should we display highlight as a solid stroke?
  53441. */
  53442. isStroke?: boolean;
  53443. /**
  53444. * The rendering group to draw the layer in.
  53445. */
  53446. renderingGroupId: number;
  53447. }
  53448. /**
  53449. * The highlight layer Helps adding a glow effect around a mesh.
  53450. *
  53451. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53452. * glowy meshes to your scene.
  53453. *
  53454. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53455. */
  53456. export class HighlightLayer extends EffectLayer {
  53457. name: string;
  53458. /**
  53459. * Effect Name of the highlight layer.
  53460. */
  53461. static readonly EffectName: string;
  53462. /**
  53463. * The neutral color used during the preparation of the glow effect.
  53464. * This is black by default as the blend operation is a blend operation.
  53465. */
  53466. static NeutralColor: Color4;
  53467. /**
  53468. * Stencil value used for glowing meshes.
  53469. */
  53470. static GlowingMeshStencilReference: number;
  53471. /**
  53472. * Stencil value used for the other meshes in the scene.
  53473. */
  53474. static NormalMeshStencilReference: number;
  53475. /**
  53476. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53477. */
  53478. innerGlow: boolean;
  53479. /**
  53480. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53481. */
  53482. outerGlow: boolean;
  53483. /**
  53484. * Specifies the horizontal size of the blur.
  53485. */
  53486. set blurHorizontalSize(value: number);
  53487. /**
  53488. * Specifies the vertical size of the blur.
  53489. */
  53490. set blurVerticalSize(value: number);
  53491. /**
  53492. * Gets the horizontal size of the blur.
  53493. */
  53494. get blurHorizontalSize(): number;
  53495. /**
  53496. * Gets the vertical size of the blur.
  53497. */
  53498. get blurVerticalSize(): number;
  53499. /**
  53500. * An event triggered when the highlight layer is being blurred.
  53501. */
  53502. onBeforeBlurObservable: Observable<HighlightLayer>;
  53503. /**
  53504. * An event triggered when the highlight layer has been blurred.
  53505. */
  53506. onAfterBlurObservable: Observable<HighlightLayer>;
  53507. private _instanceGlowingMeshStencilReference;
  53508. private _options;
  53509. private _downSamplePostprocess;
  53510. private _horizontalBlurPostprocess;
  53511. private _verticalBlurPostprocess;
  53512. private _blurTexture;
  53513. private _meshes;
  53514. private _excludedMeshes;
  53515. /**
  53516. * Instantiates a new highlight Layer and references it to the scene..
  53517. * @param name The name of the layer
  53518. * @param scene The scene to use the layer in
  53519. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53520. */
  53521. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53522. /**
  53523. * Get the effect name of the layer.
  53524. * @return The effect name
  53525. */
  53526. getEffectName(): string;
  53527. /**
  53528. * Create the merge effect. This is the shader use to blit the information back
  53529. * to the main canvas at the end of the scene rendering.
  53530. */
  53531. protected _createMergeEffect(): Effect;
  53532. /**
  53533. * Creates the render target textures and post processes used in the highlight layer.
  53534. */
  53535. protected _createTextureAndPostProcesses(): void;
  53536. /**
  53537. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53538. */
  53539. needStencil(): boolean;
  53540. /**
  53541. * Checks for the readiness of the element composing the layer.
  53542. * @param subMesh the mesh to check for
  53543. * @param useInstances specify wether or not to use instances to render the mesh
  53544. * @param emissiveTexture the associated emissive texture used to generate the glow
  53545. * @return true if ready otherwise, false
  53546. */
  53547. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53548. /**
  53549. * Implementation specific of rendering the generating effect on the main canvas.
  53550. * @param effect The effect used to render through
  53551. */
  53552. protected _internalRender(effect: Effect): void;
  53553. /**
  53554. * Returns true if the layer contains information to display, otherwise false.
  53555. */
  53556. shouldRender(): boolean;
  53557. /**
  53558. * Returns true if the mesh should render, otherwise false.
  53559. * @param mesh The mesh to render
  53560. * @returns true if it should render otherwise false
  53561. */
  53562. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53563. /**
  53564. * Sets the required values for both the emissive texture and and the main color.
  53565. */
  53566. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53567. /**
  53568. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53569. * @param mesh The mesh to exclude from the highlight layer
  53570. */
  53571. addExcludedMesh(mesh: Mesh): void;
  53572. /**
  53573. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53574. * @param mesh The mesh to highlight
  53575. */
  53576. removeExcludedMesh(mesh: Mesh): void;
  53577. /**
  53578. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53579. * @param mesh mesh to test
  53580. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53581. */
  53582. hasMesh(mesh: AbstractMesh): boolean;
  53583. /**
  53584. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53585. * @param mesh The mesh to highlight
  53586. * @param color The color of the highlight
  53587. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53588. */
  53589. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53590. /**
  53591. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53592. * @param mesh The mesh to highlight
  53593. */
  53594. removeMesh(mesh: Mesh): void;
  53595. /**
  53596. * Force the stencil to the normal expected value for none glowing parts
  53597. */
  53598. private _defaultStencilReference;
  53599. /**
  53600. * Free any resources and references associated to a mesh.
  53601. * Internal use
  53602. * @param mesh The mesh to free.
  53603. * @hidden
  53604. */
  53605. _disposeMesh(mesh: Mesh): void;
  53606. /**
  53607. * Dispose the highlight layer and free resources.
  53608. */
  53609. dispose(): void;
  53610. /**
  53611. * Gets the class name of the effect layer
  53612. * @returns the string with the class name of the effect layer
  53613. */
  53614. getClassName(): string;
  53615. /**
  53616. * Serializes this Highlight layer
  53617. * @returns a serialized Highlight layer object
  53618. */
  53619. serialize(): any;
  53620. /**
  53621. * Creates a Highlight layer from parsed Highlight layer data
  53622. * @param parsedHightlightLayer defines the Highlight layer data
  53623. * @param scene defines the current scene
  53624. * @param rootUrl defines the root URL containing the Highlight layer information
  53625. * @returns a parsed Highlight layer
  53626. */
  53627. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53628. }
  53629. }
  53630. declare module BABYLON {
  53631. interface AbstractScene {
  53632. /**
  53633. * The list of layers (background and foreground) of the scene
  53634. */
  53635. layers: Array<Layer>;
  53636. }
  53637. /**
  53638. * Defines the layer scene component responsible to manage any layers
  53639. * in a given scene.
  53640. */
  53641. export class LayerSceneComponent implements ISceneComponent {
  53642. /**
  53643. * The component name helpfull to identify the component in the list of scene components.
  53644. */
  53645. readonly name: string;
  53646. /**
  53647. * The scene the component belongs to.
  53648. */
  53649. scene: Scene;
  53650. private _engine;
  53651. /**
  53652. * Creates a new instance of the component for the given scene
  53653. * @param scene Defines the scene to register the component in
  53654. */
  53655. constructor(scene: Scene);
  53656. /**
  53657. * Registers the component in a given scene
  53658. */
  53659. register(): void;
  53660. /**
  53661. * Rebuilds the elements related to this component in case of
  53662. * context lost for instance.
  53663. */
  53664. rebuild(): void;
  53665. /**
  53666. * Disposes the component and the associated ressources.
  53667. */
  53668. dispose(): void;
  53669. private _draw;
  53670. private _drawCameraPredicate;
  53671. private _drawCameraBackground;
  53672. private _drawCameraForeground;
  53673. private _drawRenderTargetPredicate;
  53674. private _drawRenderTargetBackground;
  53675. private _drawRenderTargetForeground;
  53676. /**
  53677. * Adds all the elements from the container to the scene
  53678. * @param container the container holding the elements
  53679. */
  53680. addFromContainer(container: AbstractScene): void;
  53681. /**
  53682. * Removes all the elements in the container from the scene
  53683. * @param container contains the elements to remove
  53684. * @param dispose if the removed element should be disposed (default: false)
  53685. */
  53686. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53687. }
  53688. }
  53689. declare module BABYLON {
  53690. /** @hidden */
  53691. export var layerPixelShader: {
  53692. name: string;
  53693. shader: string;
  53694. };
  53695. }
  53696. declare module BABYLON {
  53697. /** @hidden */
  53698. export var layerVertexShader: {
  53699. name: string;
  53700. shader: string;
  53701. };
  53702. }
  53703. declare module BABYLON {
  53704. /**
  53705. * This represents a full screen 2d layer.
  53706. * This can be useful to display a picture in the background of your scene for instance.
  53707. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53708. */
  53709. export class Layer {
  53710. /**
  53711. * Define the name of the layer.
  53712. */
  53713. name: string;
  53714. /**
  53715. * Define the texture the layer should display.
  53716. */
  53717. texture: Nullable<Texture>;
  53718. /**
  53719. * Is the layer in background or foreground.
  53720. */
  53721. isBackground: boolean;
  53722. /**
  53723. * Define the color of the layer (instead of texture).
  53724. */
  53725. color: Color4;
  53726. /**
  53727. * Define the scale of the layer in order to zoom in out of the texture.
  53728. */
  53729. scale: Vector2;
  53730. /**
  53731. * Define an offset for the layer in order to shift the texture.
  53732. */
  53733. offset: Vector2;
  53734. /**
  53735. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53736. */
  53737. alphaBlendingMode: number;
  53738. /**
  53739. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53740. * Alpha test will not mix with the background color in case of transparency.
  53741. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53742. */
  53743. alphaTest: boolean;
  53744. /**
  53745. * Define a mask to restrict the layer to only some of the scene cameras.
  53746. */
  53747. layerMask: number;
  53748. /**
  53749. * Define the list of render target the layer is visible into.
  53750. */
  53751. renderTargetTextures: RenderTargetTexture[];
  53752. /**
  53753. * Define if the layer is only used in renderTarget or if it also
  53754. * renders in the main frame buffer of the canvas.
  53755. */
  53756. renderOnlyInRenderTargetTextures: boolean;
  53757. private _scene;
  53758. private _vertexBuffers;
  53759. private _indexBuffer;
  53760. private _effect;
  53761. private _previousDefines;
  53762. /**
  53763. * An event triggered when the layer is disposed.
  53764. */
  53765. onDisposeObservable: Observable<Layer>;
  53766. private _onDisposeObserver;
  53767. /**
  53768. * Back compatibility with callback before the onDisposeObservable existed.
  53769. * The set callback will be triggered when the layer has been disposed.
  53770. */
  53771. set onDispose(callback: () => void);
  53772. /**
  53773. * An event triggered before rendering the scene
  53774. */
  53775. onBeforeRenderObservable: Observable<Layer>;
  53776. private _onBeforeRenderObserver;
  53777. /**
  53778. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53779. * The set callback will be triggered just before rendering the layer.
  53780. */
  53781. set onBeforeRender(callback: () => void);
  53782. /**
  53783. * An event triggered after rendering the scene
  53784. */
  53785. onAfterRenderObservable: Observable<Layer>;
  53786. private _onAfterRenderObserver;
  53787. /**
  53788. * Back compatibility with callback before the onAfterRenderObservable existed.
  53789. * The set callback will be triggered just after rendering the layer.
  53790. */
  53791. set onAfterRender(callback: () => void);
  53792. /**
  53793. * Instantiates a new layer.
  53794. * This represents a full screen 2d layer.
  53795. * This can be useful to display a picture in the background of your scene for instance.
  53796. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53797. * @param name Define the name of the layer in the scene
  53798. * @param imgUrl Define the url of the texture to display in the layer
  53799. * @param scene Define the scene the layer belongs to
  53800. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53801. * @param color Defines a color for the layer
  53802. */
  53803. constructor(
  53804. /**
  53805. * Define the name of the layer.
  53806. */
  53807. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53808. private _createIndexBuffer;
  53809. /** @hidden */
  53810. _rebuild(): void;
  53811. /**
  53812. * Renders the layer in the scene.
  53813. */
  53814. render(): void;
  53815. /**
  53816. * Disposes and releases the associated ressources.
  53817. */
  53818. dispose(): void;
  53819. }
  53820. }
  53821. declare module BABYLON {
  53822. /** @hidden */
  53823. export var lensFlarePixelShader: {
  53824. name: string;
  53825. shader: string;
  53826. };
  53827. }
  53828. declare module BABYLON {
  53829. /** @hidden */
  53830. export var lensFlareVertexShader: {
  53831. name: string;
  53832. shader: string;
  53833. };
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53838. * It is usually composed of several `lensFlare`.
  53839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53840. */
  53841. export class LensFlareSystem {
  53842. /**
  53843. * Define the name of the lens flare system
  53844. */
  53845. name: string;
  53846. /**
  53847. * List of lens flares used in this system.
  53848. */
  53849. lensFlares: LensFlare[];
  53850. /**
  53851. * Define a limit from the border the lens flare can be visible.
  53852. */
  53853. borderLimit: number;
  53854. /**
  53855. * Define a viewport border we do not want to see the lens flare in.
  53856. */
  53857. viewportBorder: number;
  53858. /**
  53859. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53860. */
  53861. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53862. /**
  53863. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53864. */
  53865. layerMask: number;
  53866. /**
  53867. * Define the id of the lens flare system in the scene.
  53868. * (equal to name by default)
  53869. */
  53870. id: string;
  53871. private _scene;
  53872. private _emitter;
  53873. private _vertexBuffers;
  53874. private _indexBuffer;
  53875. private _effect;
  53876. private _positionX;
  53877. private _positionY;
  53878. private _isEnabled;
  53879. /** @hidden */
  53880. static _SceneComponentInitialization: (scene: Scene) => void;
  53881. /**
  53882. * Instantiates a lens flare system.
  53883. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53884. * It is usually composed of several `lensFlare`.
  53885. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53886. * @param name Define the name of the lens flare system in the scene
  53887. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53888. * @param scene Define the scene the lens flare system belongs to
  53889. */
  53890. constructor(
  53891. /**
  53892. * Define the name of the lens flare system
  53893. */
  53894. name: string, emitter: any, scene: Scene);
  53895. /**
  53896. * Define if the lens flare system is enabled.
  53897. */
  53898. get isEnabled(): boolean;
  53899. set isEnabled(value: boolean);
  53900. /**
  53901. * Get the scene the effects belongs to.
  53902. * @returns the scene holding the lens flare system
  53903. */
  53904. getScene(): Scene;
  53905. /**
  53906. * Get the emitter of the lens flare system.
  53907. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53908. * @returns the emitter of the lens flare system
  53909. */
  53910. getEmitter(): any;
  53911. /**
  53912. * Set the emitter of the lens flare system.
  53913. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53914. * @param newEmitter Define the new emitter of the system
  53915. */
  53916. setEmitter(newEmitter: any): void;
  53917. /**
  53918. * Get the lens flare system emitter position.
  53919. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53920. * @returns the position
  53921. */
  53922. getEmitterPosition(): Vector3;
  53923. /**
  53924. * @hidden
  53925. */
  53926. computeEffectivePosition(globalViewport: Viewport): boolean;
  53927. /** @hidden */
  53928. _isVisible(): boolean;
  53929. /**
  53930. * @hidden
  53931. */
  53932. render(): boolean;
  53933. /**
  53934. * Dispose and release the lens flare with its associated resources.
  53935. */
  53936. dispose(): void;
  53937. /**
  53938. * Parse a lens flare system from a JSON repressentation
  53939. * @param parsedLensFlareSystem Define the JSON to parse
  53940. * @param scene Define the scene the parsed system should be instantiated in
  53941. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53942. * @returns the parsed system
  53943. */
  53944. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53945. /**
  53946. * Serialize the current Lens Flare System into a JSON representation.
  53947. * @returns the serialized JSON
  53948. */
  53949. serialize(): any;
  53950. }
  53951. }
  53952. declare module BABYLON {
  53953. /**
  53954. * This represents one of the lens effect in a `lensFlareSystem`.
  53955. * It controls one of the indiviual texture used in the effect.
  53956. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53957. */
  53958. export class LensFlare {
  53959. /**
  53960. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53961. */
  53962. size: number;
  53963. /**
  53964. * 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.
  53965. */
  53966. position: number;
  53967. /**
  53968. * Define the lens color.
  53969. */
  53970. color: Color3;
  53971. /**
  53972. * Define the lens texture.
  53973. */
  53974. texture: Nullable<Texture>;
  53975. /**
  53976. * Define the alpha mode to render this particular lens.
  53977. */
  53978. alphaMode: number;
  53979. private _system;
  53980. /**
  53981. * Creates a new Lens Flare.
  53982. * This represents one of the lens effect in a `lensFlareSystem`.
  53983. * It controls one of the indiviual texture used in the effect.
  53984. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53985. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53986. * @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.
  53987. * @param color Define the lens color
  53988. * @param imgUrl Define the lens texture url
  53989. * @param system Define the `lensFlareSystem` this flare is part of
  53990. * @returns The newly created Lens Flare
  53991. */
  53992. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53993. /**
  53994. * Instantiates a new Lens Flare.
  53995. * This represents one of the lens effect in a `lensFlareSystem`.
  53996. * It controls one of the indiviual texture used in the effect.
  53997. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53998. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53999. * @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.
  54000. * @param color Define the lens color
  54001. * @param imgUrl Define the lens texture url
  54002. * @param system Define the `lensFlareSystem` this flare is part of
  54003. */
  54004. constructor(
  54005. /**
  54006. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54007. */
  54008. size: number,
  54009. /**
  54010. * 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.
  54011. */
  54012. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54013. /**
  54014. * Dispose and release the lens flare with its associated resources.
  54015. */
  54016. dispose(): void;
  54017. }
  54018. }
  54019. declare module BABYLON {
  54020. interface AbstractScene {
  54021. /**
  54022. * The list of lens flare system added to the scene
  54023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54024. */
  54025. lensFlareSystems: Array<LensFlareSystem>;
  54026. /**
  54027. * Removes the given lens flare system from this scene.
  54028. * @param toRemove The lens flare system to remove
  54029. * @returns The index of the removed lens flare system
  54030. */
  54031. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54032. /**
  54033. * Adds the given lens flare system to this scene
  54034. * @param newLensFlareSystem The lens flare system to add
  54035. */
  54036. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54037. /**
  54038. * Gets a lens flare system using its name
  54039. * @param name defines the name to look for
  54040. * @returns the lens flare system or null if not found
  54041. */
  54042. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54043. /**
  54044. * Gets a lens flare system using its id
  54045. * @param id defines the id to look for
  54046. * @returns the lens flare system or null if not found
  54047. */
  54048. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54049. }
  54050. /**
  54051. * Defines the lens flare scene component responsible to manage any lens flares
  54052. * in a given scene.
  54053. */
  54054. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54055. /**
  54056. * The component name helpfull to identify the component in the list of scene components.
  54057. */
  54058. readonly name: string;
  54059. /**
  54060. * The scene the component belongs to.
  54061. */
  54062. scene: Scene;
  54063. /**
  54064. * Creates a new instance of the component for the given scene
  54065. * @param scene Defines the scene to register the component in
  54066. */
  54067. constructor(scene: Scene);
  54068. /**
  54069. * Registers the component in a given scene
  54070. */
  54071. register(): void;
  54072. /**
  54073. * Rebuilds the elements related to this component in case of
  54074. * context lost for instance.
  54075. */
  54076. rebuild(): void;
  54077. /**
  54078. * Adds all the elements from the container to the scene
  54079. * @param container the container holding the elements
  54080. */
  54081. addFromContainer(container: AbstractScene): void;
  54082. /**
  54083. * Removes all the elements in the container from the scene
  54084. * @param container contains the elements to remove
  54085. * @param dispose if the removed element should be disposed (default: false)
  54086. */
  54087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54088. /**
  54089. * Serializes the component data to the specified json object
  54090. * @param serializationObject The object to serialize to
  54091. */
  54092. serialize(serializationObject: any): void;
  54093. /**
  54094. * Disposes the component and the associated ressources.
  54095. */
  54096. dispose(): void;
  54097. private _draw;
  54098. }
  54099. }
  54100. declare module BABYLON {
  54101. /** @hidden */
  54102. export var depthPixelShader: {
  54103. name: string;
  54104. shader: string;
  54105. };
  54106. }
  54107. declare module BABYLON {
  54108. /** @hidden */
  54109. export var depthVertexShader: {
  54110. name: string;
  54111. shader: string;
  54112. };
  54113. }
  54114. declare module BABYLON {
  54115. /**
  54116. * This represents a depth renderer in Babylon.
  54117. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54118. */
  54119. export class DepthRenderer {
  54120. private _scene;
  54121. private _depthMap;
  54122. private _effect;
  54123. private readonly _storeNonLinearDepth;
  54124. private readonly _clearColor;
  54125. /** Get if the depth renderer is using packed depth or not */
  54126. readonly isPacked: boolean;
  54127. private _cachedDefines;
  54128. private _camera;
  54129. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54130. enabled: boolean;
  54131. /**
  54132. * Specifiess that the depth renderer will only be used within
  54133. * the camera it is created for.
  54134. * This can help forcing its rendering during the camera processing.
  54135. */
  54136. useOnlyInActiveCamera: boolean;
  54137. /** @hidden */
  54138. static _SceneComponentInitialization: (scene: Scene) => void;
  54139. /**
  54140. * Instantiates a depth renderer
  54141. * @param scene The scene the renderer belongs to
  54142. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54143. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54144. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54145. */
  54146. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54147. /**
  54148. * Creates the depth rendering effect and checks if the effect is ready.
  54149. * @param subMesh The submesh to be used to render the depth map of
  54150. * @param useInstances If multiple world instances should be used
  54151. * @returns if the depth renderer is ready to render the depth map
  54152. */
  54153. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54154. /**
  54155. * Gets the texture which the depth map will be written to.
  54156. * @returns The depth map texture
  54157. */
  54158. getDepthMap(): RenderTargetTexture;
  54159. /**
  54160. * Disposes of the depth renderer.
  54161. */
  54162. dispose(): void;
  54163. }
  54164. }
  54165. declare module BABYLON {
  54166. /** @hidden */
  54167. export var minmaxReduxPixelShader: {
  54168. name: string;
  54169. shader: string;
  54170. };
  54171. }
  54172. declare module BABYLON {
  54173. /**
  54174. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54175. * and maximum values from all values of the texture.
  54176. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54177. * The source values are read from the red channel of the texture.
  54178. */
  54179. export class MinMaxReducer {
  54180. /**
  54181. * Observable triggered when the computation has been performed
  54182. */
  54183. onAfterReductionPerformed: Observable<{
  54184. min: number;
  54185. max: number;
  54186. }>;
  54187. protected _camera: Camera;
  54188. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54189. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54190. protected _postProcessManager: PostProcessManager;
  54191. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54192. protected _forceFullscreenViewport: boolean;
  54193. /**
  54194. * Creates a min/max reducer
  54195. * @param camera The camera to use for the post processes
  54196. */
  54197. constructor(camera: Camera);
  54198. /**
  54199. * Gets the texture used to read the values from.
  54200. */
  54201. get sourceTexture(): Nullable<RenderTargetTexture>;
  54202. /**
  54203. * Sets the source texture to read the values from.
  54204. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54205. * because in such textures '1' value must not be taken into account to compute the maximum
  54206. * as this value is used to clear the texture.
  54207. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54208. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54209. * @param depthRedux Indicates if the texture is a depth texture or not
  54210. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54211. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54212. */
  54213. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54214. /**
  54215. * Defines the refresh rate of the computation.
  54216. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54217. */
  54218. get refreshRate(): number;
  54219. set refreshRate(value: number);
  54220. protected _activated: boolean;
  54221. /**
  54222. * Gets the activation status of the reducer
  54223. */
  54224. get activated(): boolean;
  54225. /**
  54226. * Activates the reduction computation.
  54227. * When activated, the observers registered in onAfterReductionPerformed are
  54228. * called after the compuation is performed
  54229. */
  54230. activate(): void;
  54231. /**
  54232. * Deactivates the reduction computation.
  54233. */
  54234. deactivate(): void;
  54235. /**
  54236. * Disposes the min/max reducer
  54237. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54238. */
  54239. dispose(disposeAll?: boolean): void;
  54240. }
  54241. }
  54242. declare module BABYLON {
  54243. /**
  54244. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54245. */
  54246. export class DepthReducer extends MinMaxReducer {
  54247. private _depthRenderer;
  54248. private _depthRendererId;
  54249. /**
  54250. * Gets the depth renderer used for the computation.
  54251. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54252. */
  54253. get depthRenderer(): Nullable<DepthRenderer>;
  54254. /**
  54255. * Creates a depth reducer
  54256. * @param camera The camera used to render the depth texture
  54257. */
  54258. constructor(camera: Camera);
  54259. /**
  54260. * Sets the depth renderer to use to generate the depth map
  54261. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54262. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54263. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54264. */
  54265. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54266. /** @hidden */
  54267. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54268. /**
  54269. * Activates the reduction computation.
  54270. * When activated, the observers registered in onAfterReductionPerformed are
  54271. * called after the compuation is performed
  54272. */
  54273. activate(): void;
  54274. /**
  54275. * Deactivates the reduction computation.
  54276. */
  54277. deactivate(): void;
  54278. /**
  54279. * Disposes the depth reducer
  54280. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54281. */
  54282. dispose(disposeAll?: boolean): void;
  54283. }
  54284. }
  54285. declare module BABYLON {
  54286. /**
  54287. * A CSM implementation allowing casting shadows on large scenes.
  54288. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54289. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54290. */
  54291. export class CascadedShadowGenerator implements IShadowGenerator {
  54292. private static readonly frustumCornersNDCSpace;
  54293. /**
  54294. * Name of the CSM class
  54295. */
  54296. static readonly CLASSNAME: string;
  54297. /**
  54298. * Defines the default number of cascades used by the CSM.
  54299. */
  54300. static readonly DEFAULT_CASCADES_COUNT: number;
  54301. /**
  54302. * Defines the minimum number of cascades used by the CSM.
  54303. */
  54304. static readonly MIN_CASCADES_COUNT: number;
  54305. /**
  54306. * Defines the maximum number of cascades used by the CSM.
  54307. */
  54308. static readonly MAX_CASCADES_COUNT: number;
  54309. /**
  54310. * Shadow generator mode None: no filtering applied.
  54311. */
  54312. static readonly FILTER_NONE: number;
  54313. /**
  54314. * Shadow generator mode PCF: Percentage Closer Filtering
  54315. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  54316. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  54317. */
  54318. static readonly FILTER_PCF: number;
  54319. /**
  54320. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  54321. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  54322. * Contact Hardening
  54323. */
  54324. static readonly FILTER_PCSS: number;
  54325. /**
  54326. * Reserved for PCF and PCSS
  54327. * Highest Quality.
  54328. *
  54329. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  54330. *
  54331. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  54332. */
  54333. static readonly QUALITY_HIGH: number;
  54334. /**
  54335. * Reserved for PCF and PCSS
  54336. * Good tradeoff for quality/perf cross devices
  54337. *
  54338. * Execute PCF on a 3*3 kernel.
  54339. *
  54340. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  54341. */
  54342. static readonly QUALITY_MEDIUM: number;
  54343. /**
  54344. * Reserved for PCF and PCSS
  54345. * The lowest quality but the fastest.
  54346. *
  54347. * Execute PCF on a 1*1 kernel.
  54348. *
  54349. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  54350. */
  54351. static readonly QUALITY_LOW: number;
  54352. private static readonly _CLEARONE;
  54353. /**
  54354. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  54355. */
  54356. onBeforeShadowMapRenderObservable: Observable<Effect>;
  54357. /**
  54358. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  54359. */
  54360. onAfterShadowMapRenderObservable: Observable<Effect>;
  54361. /**
  54362. * Observable triggered before a mesh is rendered in the shadow map.
  54363. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  54364. */
  54365. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  54366. /**
  54367. * Observable triggered after a mesh is rendered in the shadow map.
  54368. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  54369. */
  54370. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  54371. private _bias;
  54372. /**
  54373. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  54374. */
  54375. get bias(): number;
  54376. /**
  54377. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  54378. */
  54379. set bias(bias: number);
  54380. private _normalBias;
  54381. /**
  54382. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  54383. */
  54384. get normalBias(): number;
  54385. /**
  54386. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  54387. */
  54388. set normalBias(normalBias: number);
  54389. private _filter;
  54390. /**
  54391. * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
  54392. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  54393. */
  54394. get filter(): number;
  54395. /**
  54396. * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
  54397. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  54398. */
  54399. set filter(value: number);
  54400. /**
  54401. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  54402. */
  54403. get usePercentageCloserFiltering(): boolean;
  54404. /**
  54405. * Sets the current filter to "PCF" (percentage closer filtering).
  54406. */
  54407. set usePercentageCloserFiltering(value: boolean);
  54408. private _filteringQuality;
  54409. /**
  54410. * Gets the PCF or PCSS Quality.
  54411. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  54412. */
  54413. get filteringQuality(): number;
  54414. /**
  54415. * Sets the PCF or PCSS Quality.
  54416. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  54417. */
  54418. set filteringQuality(filteringQuality: number);
  54419. /**
  54420. * Gets if the current filter is set to "PCSS" (contact hardening).
  54421. */
  54422. get useContactHardeningShadow(): boolean;
  54423. /**
  54424. * Sets the current filter to "PCSS" (contact hardening).
  54425. */
  54426. set useContactHardeningShadow(value: boolean);
  54427. private _contactHardeningLightSizeUVRatio;
  54428. /**
  54429. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  54430. * Using a ratio helps keeping shape stability independently of the map size.
  54431. *
  54432. * It does not account for the light projection as it was having too much
  54433. * instability during the light setup or during light position changes.
  54434. *
  54435. * Only valid if useContactHardeningShadow is true.
  54436. */
  54437. get contactHardeningLightSizeUVRatio(): number;
  54438. /**
  54439. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  54440. * Using a ratio helps keeping shape stability independently of the map size.
  54441. *
  54442. * It does not account for the light projection as it was having too much
  54443. * instability during the light setup or during light position changes.
  54444. *
  54445. * Only valid if useContactHardeningShadow is true.
  54446. */
  54447. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  54448. private _darkness;
  54449. /** Gets or sets the actual darkness of a shadow */
  54450. get darkness(): number;
  54451. set darkness(value: number);
  54452. /**
  54453. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  54454. * 0 means strongest and 1 would means no shadow.
  54455. * @returns the darkness.
  54456. */
  54457. getDarkness(): number;
  54458. /**
  54459. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  54460. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  54461. * @returns the shadow generator allowing fluent coding.
  54462. */
  54463. setDarkness(darkness: number): CascadedShadowGenerator;
  54464. /**
  54465. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54466. */
  54467. penumbraDarkness: number;
  54468. private _transparencyShadow;
  54469. /** Gets or sets the ability to have transparent shadow */
  54470. get transparencyShadow(): boolean;
  54471. set transparencyShadow(value: boolean);
  54472. /**
  54473. * Sets the ability to have transparent shadow (boolean).
  54474. * @param transparent True if transparent else False
  54475. * @returns the shadow generator allowing fluent coding
  54476. */
  54477. setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
  54478. private _numCascades;
  54479. /**
  54480. * Gets or set the number of cascades used by the CSM.
  54481. */
  54482. get numCascades(): number;
  54483. set numCascades(value: number);
  54484. /**
  54485. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54486. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54487. */
  54488. stabilizeCascades: boolean;
  54489. private _shadowMap;
  54490. /**
  54491. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  54492. * @returns The render target texture if present otherwise, null
  54493. */
  54494. getShadowMap(): Nullable<RenderTargetTexture>;
  54495. protected _freezeShadowCastersBoundingInfo: boolean;
  54496. private _freezeShadowCastersBoundingInfoObservable;
  54497. /**
  54498. * Enables or disables the shadow casters bounding info computation.
  54499. * If your shadow casters don't move, you can disable this feature.
  54500. * If it is enabled, the bounding box computation is done every frame.
  54501. */
  54502. get freezeShadowCastersBoundingInfo(): boolean;
  54503. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54504. private _scbiMin;
  54505. private _scbiMax;
  54506. protected _computeShadowCastersBoundingInfo(): void;
  54507. protected _shadowCastersBoundingInfo: BoundingInfo;
  54508. /**
  54509. * Gets or sets the shadow casters bounding info.
  54510. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54511. * so that the system won't overwrite the bounds you provide
  54512. */
  54513. get shadowCastersBoundingInfo(): BoundingInfo;
  54514. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54515. protected _breaksAreDirty: boolean;
  54516. protected _minDistance: number;
  54517. protected _maxDistance: number;
  54518. /**
  54519. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54520. *
  54521. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54522. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54523. * @param min minimal distance for the breaks (default to 0.)
  54524. * @param max maximal distance for the breaks (default to 1.)
  54525. */
  54526. setMinMaxDistance(min: number, max: number): void;
  54527. /** Gets the minimal distance used in the cascade break computation */
  54528. get minDistance(): number;
  54529. /** Gets the maximal distance used in the cascade break computation */
  54530. get maxDistance(): number;
  54531. /**
  54532. * Gets the class name of that object
  54533. * @returns "ShadowGenerator"
  54534. */
  54535. getClassName(): string;
  54536. /**
  54537. * Helper function to add a mesh and its descendants to the list of shadow casters.
  54538. * @param mesh Mesh to add
  54539. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  54540. * @returns the Shadow Generator itself
  54541. */
  54542. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  54543. /**
  54544. * Helper function to remove a mesh and its descendants from the list of shadow casters
  54545. * @param mesh Mesh to remove
  54546. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  54547. * @returns the Shadow Generator itself
  54548. */
  54549. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  54550. /**
  54551. * Controls the extent to which the shadows fade out at the edge of the frustum
  54552. */
  54553. frustumEdgeFalloff: number;
  54554. private _light;
  54555. /**
  54556. * Returns the associated light object.
  54557. * @returns the light generating the shadow
  54558. */
  54559. getLight(): DirectionalLight;
  54560. /**
  54561. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  54562. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  54563. * It might on the other hand introduce peter panning.
  54564. */
  54565. forceBackFacesOnly: boolean;
  54566. private _cascadeMinExtents;
  54567. private _cascadeMaxExtents;
  54568. /**
  54569. * Gets a cascade minimum extents
  54570. * @param cascadeIndex index of the cascade
  54571. * @returns the minimum cascade extents
  54572. */
  54573. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54574. /**
  54575. * Gets a cascade maximum extents
  54576. * @param cascadeIndex index of the cascade
  54577. * @returns the maximum cascade extents
  54578. */
  54579. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54580. private _scene;
  54581. private _lightDirection;
  54582. private _effect;
  54583. private _cascades;
  54584. private _cachedDirection;
  54585. private _cachedDefines;
  54586. private _mapSize;
  54587. private _currentLayer;
  54588. private _textureType;
  54589. private _defaultTextureMatrix;
  54590. private _storedUniqueId;
  54591. private _viewSpaceFrustumsZ;
  54592. private _viewMatrices;
  54593. private _projectionMatrices;
  54594. private _transformMatrices;
  54595. private _transformMatricesAsArray;
  54596. private _frustumLengths;
  54597. private _lightSizeUVCorrection;
  54598. private _depthCorrection;
  54599. private _frustumCornersWorldSpace;
  54600. private _frustumCenter;
  54601. private _shadowCameraPos;
  54602. private _shadowMaxZ;
  54603. /**
  54604. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54605. * It defaults to camera.maxZ
  54606. */
  54607. get shadowMaxZ(): number;
  54608. /**
  54609. * Sets the shadow max z distance.
  54610. */
  54611. set shadowMaxZ(value: number);
  54612. protected _debug: boolean;
  54613. /**
  54614. * Gets or sets the debug flag.
  54615. * When enabled, the cascades are materialized by different colors on the screen.
  54616. */
  54617. get debug(): boolean;
  54618. set debug(dbg: boolean);
  54619. private _depthClamp;
  54620. /**
  54621. * Gets or sets the depth clamping value.
  54622. *
  54623. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54624. * to account for the shadow casters far away.
  54625. *
  54626. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54627. */
  54628. get depthClamp(): boolean;
  54629. set depthClamp(value: boolean);
  54630. private _cascadeBlendPercentage;
  54631. /**
  54632. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54633. * It defaults to 0.1 (10% blending).
  54634. */
  54635. get cascadeBlendPercentage(): number;
  54636. set cascadeBlendPercentage(value: number);
  54637. private _lambda;
  54638. /**
  54639. * Gets or set the lambda parameter.
  54640. * This parameter is used to split the camera frustum and create the cascades.
  54641. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54642. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54643. */
  54644. get lambda(): number;
  54645. set lambda(value: number);
  54646. /**
  54647. * Gets the view matrix corresponding to a given cascade
  54648. * @param cascadeNum cascade to retrieve the view matrix from
  54649. * @returns the cascade view matrix
  54650. */
  54651. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54652. /**
  54653. * Gets the projection matrix corresponding to a given cascade
  54654. * @param cascadeNum cascade to retrieve the projection matrix from
  54655. * @returns the cascade projection matrix
  54656. */
  54657. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54658. private _depthRenderer;
  54659. /**
  54660. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54661. *
  54662. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54663. *
  54664. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54665. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54666. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54667. */
  54668. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54669. private _depthReducer;
  54670. private _autoCalcDepthBounds;
  54671. /**
  54672. * Gets or sets the autoCalcDepthBounds property.
  54673. *
  54674. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54675. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54676. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54677. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54678. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54679. */
  54680. get autoCalcDepthBounds(): boolean;
  54681. set autoCalcDepthBounds(value: boolean);
  54682. /**
  54683. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54684. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54685. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54686. * for setting the refresh rate on the renderer yourself!
  54687. */
  54688. get autoCalcDepthBoundsRefreshRate(): number;
  54689. set autoCalcDepthBoundsRefreshRate(value: number);
  54690. /**
  54691. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54692. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54693. * you change the camera near/far planes!
  54694. */
  54695. splitFrustum(): void;
  54696. private _splitFrustum;
  54697. /**
  54698. * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
  54699. * (eq to view projection * shadow projection matrices)
  54700. * @param cascadeIndex index number of the cascaded shadow map
  54701. * @returns The transform matrix used to create the CSM shadow map
  54702. */
  54703. getCSMTransformMatrix(cascadeIndex: number): Matrix;
  54704. private _computeMatrices;
  54705. private _computeFrustumInWorldSpace;
  54706. private _computeCascadeFrustum;
  54707. /** @hidden */
  54708. static _SceneComponentInitialization: (scene: Scene) => void;
  54709. /**
  54710. * Creates a Cascaded Shadow Generator object.
  54711. * A ShadowGenerator is the required tool to use the shadows.
  54712. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54713. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54714. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54715. * @param light The directional light object generating the shadows.
  54716. * @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.
  54717. */
  54718. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54719. private _initializeGenerator;
  54720. private _initializeShadowMap;
  54721. private _renderForShadowMap;
  54722. private _renderSubMeshForShadowMap;
  54723. private _applyFilterValues;
  54724. /**
  54725. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  54726. * @param onCompiled Callback triggered at the and of the effects compilation
  54727. * @param options Sets of optional options forcing the compilation with different modes
  54728. */
  54729. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  54730. useInstances: boolean;
  54731. }>): void;
  54732. /**
  54733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  54734. * @param options Sets of optional options forcing the compilation with different modes
  54735. * @returns A promise that resolves when the compilation completes
  54736. */
  54737. forceCompilationAsync(options?: Partial<{
  54738. useInstances: boolean;
  54739. }>): Promise<void>;
  54740. /**
  54741. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  54742. * @param subMesh The submesh we want to render in the shadow map
  54743. * @param useInstances Defines wether will draw in the map using instances
  54744. * @returns true if ready otherwise, false
  54745. */
  54746. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54747. /**
  54748. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54749. * @param defines Defines of the material we want to update
  54750. * @param lightIndex Index of the light in the enabled light list of the material
  54751. */
  54752. prepareDefines(defines: any, lightIndex: number): void;
  54753. /**
  54754. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54755. * defined in the generator but impacting the effect).
  54756. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54757. * @param effect The effect we are binfing the information for
  54758. */
  54759. bindShadowLight(lightIndex: string, effect: Effect): void;
  54760. /**
  54761. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54762. * (eq to view projection * shadow projection matrices)
  54763. * @returns The transform matrix used to create the shadow map
  54764. */
  54765. getTransformMatrix(): Matrix;
  54766. /**
  54767. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  54768. * Cube and 2D textures for instance.
  54769. */
  54770. recreateShadowMap(): void;
  54771. private _disposeRTT;
  54772. /**
  54773. * Disposes the ShadowGenerator.
  54774. * Returns nothing.
  54775. */
  54776. dispose(): void;
  54777. /**
  54778. * Serializes the shadow generator setup to a json object.
  54779. * @returns The serialized JSON object
  54780. */
  54781. serialize(): any;
  54782. /**
  54783. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54784. * @param parsedShadowGenerator The JSON object to parse
  54785. * @param scene The scene to create the shadow map for
  54786. * @returns The parsed shadow generator
  54787. */
  54788. static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
  54789. }
  54790. }
  54791. declare module BABYLON {
  54792. /**
  54793. * Defines the shadow generator component responsible to manage any shadow generators
  54794. * in a given scene.
  54795. */
  54796. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54797. /**
  54798. * The component name helpfull to identify the component in the list of scene components.
  54799. */
  54800. readonly name: string;
  54801. /**
  54802. * The scene the component belongs to.
  54803. */
  54804. scene: Scene;
  54805. /**
  54806. * Creates a new instance of the component for the given scene
  54807. * @param scene Defines the scene to register the component in
  54808. */
  54809. constructor(scene: Scene);
  54810. /**
  54811. * Registers the component in a given scene
  54812. */
  54813. register(): void;
  54814. /**
  54815. * Rebuilds the elements related to this component in case of
  54816. * context lost for instance.
  54817. */
  54818. rebuild(): void;
  54819. /**
  54820. * Serializes the component data to the specified json object
  54821. * @param serializationObject The object to serialize to
  54822. */
  54823. serialize(serializationObject: any): void;
  54824. /**
  54825. * Adds all the elements from the container to the scene
  54826. * @param container the container holding the elements
  54827. */
  54828. addFromContainer(container: AbstractScene): void;
  54829. /**
  54830. * Removes all the elements in the container from the scene
  54831. * @param container contains the elements to remove
  54832. * @param dispose if the removed element should be disposed (default: false)
  54833. */
  54834. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54835. /**
  54836. * Rebuilds the elements related to this component in case of
  54837. * context lost for instance.
  54838. */
  54839. dispose(): void;
  54840. private _gatherRenderTargets;
  54841. }
  54842. }
  54843. declare module BABYLON {
  54844. /**
  54845. * A point light is a light defined by an unique point in world space.
  54846. * The light is emitted in every direction from this point.
  54847. * A good example of a point light is a standard light bulb.
  54848. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54849. */
  54850. export class PointLight extends ShadowLight {
  54851. private _shadowAngle;
  54852. /**
  54853. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54854. * This specifies what angle the shadow will use to be created.
  54855. *
  54856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54857. */
  54858. get shadowAngle(): number;
  54859. /**
  54860. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54861. * This specifies what angle the shadow will use to be created.
  54862. *
  54863. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54864. */
  54865. set shadowAngle(value: number);
  54866. /**
  54867. * Gets the direction if it has been set.
  54868. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54869. */
  54870. get direction(): Vector3;
  54871. /**
  54872. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54873. */
  54874. set direction(value: Vector3);
  54875. /**
  54876. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54877. * A PointLight emits the light in every direction.
  54878. * It can cast shadows.
  54879. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54880. * ```javascript
  54881. * var pointLight = new PointLight("pl", camera.position, scene);
  54882. * ```
  54883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54884. * @param name The light friendly name
  54885. * @param position The position of the point light in the scene
  54886. * @param scene The scene the lights belongs to
  54887. */
  54888. constructor(name: string, position: Vector3, scene: Scene);
  54889. /**
  54890. * Returns the string "PointLight"
  54891. * @returns the class name
  54892. */
  54893. getClassName(): string;
  54894. /**
  54895. * Returns the integer 0.
  54896. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54897. */
  54898. getTypeID(): number;
  54899. /**
  54900. * Specifies wether or not the shadowmap should be a cube texture.
  54901. * @returns true if the shadowmap needs to be a cube texture.
  54902. */
  54903. needCube(): boolean;
  54904. /**
  54905. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54906. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54907. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54908. */
  54909. getShadowDirection(faceIndex?: number): Vector3;
  54910. /**
  54911. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54912. * - fov = PI / 2
  54913. * - aspect ratio : 1.0
  54914. * - z-near and far equal to the active camera minZ and maxZ.
  54915. * Returns the PointLight.
  54916. */
  54917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54918. protected _buildUniformLayout(): void;
  54919. /**
  54920. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54921. * @param effect The effect to update
  54922. * @param lightIndex The index of the light in the effect to update
  54923. * @returns The point light
  54924. */
  54925. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54926. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54927. /**
  54928. * Prepares the list of defines specific to the light type.
  54929. * @param defines the list of defines
  54930. * @param lightIndex defines the index of the light for the effect
  54931. */
  54932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54933. }
  54934. }
  54935. declare module BABYLON {
  54936. /**
  54937. * Header information of HDR texture files.
  54938. */
  54939. export interface HDRInfo {
  54940. /**
  54941. * The height of the texture in pixels.
  54942. */
  54943. height: number;
  54944. /**
  54945. * The width of the texture in pixels.
  54946. */
  54947. width: number;
  54948. /**
  54949. * The index of the beginning of the data in the binary file.
  54950. */
  54951. dataPosition: number;
  54952. }
  54953. /**
  54954. * This groups tools to convert HDR texture to native colors array.
  54955. */
  54956. export class HDRTools {
  54957. private static Ldexp;
  54958. private static Rgbe2float;
  54959. private static readStringLine;
  54960. /**
  54961. * Reads header information from an RGBE texture stored in a native array.
  54962. * More information on this format are available here:
  54963. * https://en.wikipedia.org/wiki/RGBE_image_format
  54964. *
  54965. * @param uint8array The binary file stored in native array.
  54966. * @return The header information.
  54967. */
  54968. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54969. /**
  54970. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54971. * This RGBE texture needs to store the information as a panorama.
  54972. *
  54973. * More information on this format are available here:
  54974. * https://en.wikipedia.org/wiki/RGBE_image_format
  54975. *
  54976. * @param buffer The binary file stored in an array buffer.
  54977. * @param size The expected size of the extracted cubemap.
  54978. * @return The Cube Map information.
  54979. */
  54980. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54981. /**
  54982. * Returns the pixels data extracted from an RGBE texture.
  54983. * This pixels will be stored left to right up to down in the R G B order in one array.
  54984. *
  54985. * More information on this format are available here:
  54986. * https://en.wikipedia.org/wiki/RGBE_image_format
  54987. *
  54988. * @param uint8array The binary file stored in an array buffer.
  54989. * @param hdrInfo The header information of the file.
  54990. * @return The pixels data in RGB right to left up to down order.
  54991. */
  54992. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54993. private static RGBE_ReadPixels_RLE;
  54994. }
  54995. }
  54996. declare module BABYLON {
  54997. /**
  54998. * This represents a texture coming from an HDR input.
  54999. *
  55000. * The only supported format is currently panorama picture stored in RGBE format.
  55001. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55002. */
  55003. export class HDRCubeTexture extends BaseTexture {
  55004. private static _facesMapping;
  55005. private _generateHarmonics;
  55006. private _noMipmap;
  55007. private _textureMatrix;
  55008. private _size;
  55009. private _onLoad;
  55010. private _onError;
  55011. /**
  55012. * The texture URL.
  55013. */
  55014. url: string;
  55015. /**
  55016. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55017. */
  55018. coordinatesMode: number;
  55019. protected _isBlocking: boolean;
  55020. /**
  55021. * Sets wether or not the texture is blocking during loading.
  55022. */
  55023. set isBlocking(value: boolean);
  55024. /**
  55025. * Gets wether or not the texture is blocking during loading.
  55026. */
  55027. get isBlocking(): boolean;
  55028. protected _rotationY: number;
  55029. /**
  55030. * Sets texture matrix rotation angle around Y axis in radians.
  55031. */
  55032. set rotationY(value: number);
  55033. /**
  55034. * Gets texture matrix rotation angle around Y axis radians.
  55035. */
  55036. get rotationY(): number;
  55037. /**
  55038. * Gets or sets the center of the bounding box associated with the cube texture
  55039. * It must define where the camera used to render the texture was set
  55040. */
  55041. boundingBoxPosition: Vector3;
  55042. private _boundingBoxSize;
  55043. /**
  55044. * Gets or sets the size of the bounding box associated with the cube texture
  55045. * When defined, the cubemap will switch to local mode
  55046. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55047. * @example https://www.babylonjs-playground.com/#RNASML
  55048. */
  55049. set boundingBoxSize(value: Vector3);
  55050. get boundingBoxSize(): Vector3;
  55051. /**
  55052. * Instantiates an HDRTexture from the following parameters.
  55053. *
  55054. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55055. * @param scene The scene the texture will be used in
  55056. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55057. * @param noMipmap Forces to not generate the mipmap if true
  55058. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55059. * @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)
  55060. * @param reserved Reserved flag for internal use.
  55061. */
  55062. 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>);
  55063. /**
  55064. * Get the current class name of the texture useful for serialization or dynamic coding.
  55065. * @returns "HDRCubeTexture"
  55066. */
  55067. getClassName(): string;
  55068. /**
  55069. * Occurs when the file is raw .hdr file.
  55070. */
  55071. private loadTexture;
  55072. clone(): HDRCubeTexture;
  55073. delayLoad(): void;
  55074. /**
  55075. * Get the texture reflection matrix used to rotate/transform the reflection.
  55076. * @returns the reflection matrix
  55077. */
  55078. getReflectionTextureMatrix(): Matrix;
  55079. /**
  55080. * Set the texture reflection matrix used to rotate/transform the reflection.
  55081. * @param value Define the reflection matrix to set
  55082. */
  55083. setReflectionTextureMatrix(value: Matrix): void;
  55084. /**
  55085. * Parses a JSON representation of an HDR Texture in order to create the texture
  55086. * @param parsedTexture Define the JSON representation
  55087. * @param scene Define the scene the texture should be created in
  55088. * @param rootUrl Define the root url in case we need to load relative dependencies
  55089. * @returns the newly created texture after parsing
  55090. */
  55091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55092. serialize(): any;
  55093. }
  55094. }
  55095. declare module BABYLON {
  55096. /**
  55097. * Class used to control physics engine
  55098. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55099. */
  55100. export class PhysicsEngine implements IPhysicsEngine {
  55101. private _physicsPlugin;
  55102. /**
  55103. * Global value used to control the smallest number supported by the simulation
  55104. */
  55105. static Epsilon: number;
  55106. private _impostors;
  55107. private _joints;
  55108. private _subTimeStep;
  55109. /**
  55110. * Gets the gravity vector used by the simulation
  55111. */
  55112. gravity: Vector3;
  55113. /**
  55114. * Factory used to create the default physics plugin.
  55115. * @returns The default physics plugin
  55116. */
  55117. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55118. /**
  55119. * Creates a new Physics Engine
  55120. * @param gravity defines the gravity vector used by the simulation
  55121. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55122. */
  55123. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55124. /**
  55125. * Sets the gravity vector used by the simulation
  55126. * @param gravity defines the gravity vector to use
  55127. */
  55128. setGravity(gravity: Vector3): void;
  55129. /**
  55130. * Set the time step of the physics engine.
  55131. * Default is 1/60.
  55132. * To slow it down, enter 1/600 for example.
  55133. * To speed it up, 1/30
  55134. * @param newTimeStep defines the new timestep to apply to this world.
  55135. */
  55136. setTimeStep(newTimeStep?: number): void;
  55137. /**
  55138. * Get the time step of the physics engine.
  55139. * @returns the current time step
  55140. */
  55141. getTimeStep(): number;
  55142. /**
  55143. * Set the sub time step of the physics engine.
  55144. * Default is 0 meaning there is no sub steps
  55145. * To increase physics resolution precision, set a small value (like 1 ms)
  55146. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55147. */
  55148. setSubTimeStep(subTimeStep?: number): void;
  55149. /**
  55150. * Get the sub time step of the physics engine.
  55151. * @returns the current sub time step
  55152. */
  55153. getSubTimeStep(): number;
  55154. /**
  55155. * Release all resources
  55156. */
  55157. dispose(): void;
  55158. /**
  55159. * Gets the name of the current physics plugin
  55160. * @returns the name of the plugin
  55161. */
  55162. getPhysicsPluginName(): string;
  55163. /**
  55164. * Adding a new impostor for the impostor tracking.
  55165. * This will be done by the impostor itself.
  55166. * @param impostor the impostor to add
  55167. */
  55168. addImpostor(impostor: PhysicsImpostor): void;
  55169. /**
  55170. * Remove an impostor from the engine.
  55171. * This impostor and its mesh will not longer be updated by the physics engine.
  55172. * @param impostor the impostor to remove
  55173. */
  55174. removeImpostor(impostor: PhysicsImpostor): void;
  55175. /**
  55176. * Add a joint to the physics engine
  55177. * @param mainImpostor defines the main impostor to which the joint is added.
  55178. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55179. * @param joint defines the joint that will connect both impostors.
  55180. */
  55181. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55182. /**
  55183. * Removes a joint from the simulation
  55184. * @param mainImpostor defines the impostor used with the joint
  55185. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55186. * @param joint defines the joint to remove
  55187. */
  55188. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55189. /**
  55190. * Called by the scene. No need to call it.
  55191. * @param delta defines the timespam between frames
  55192. */
  55193. _step(delta: number): void;
  55194. /**
  55195. * Gets the current plugin used to run the simulation
  55196. * @returns current plugin
  55197. */
  55198. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55199. /**
  55200. * Gets the list of physic impostors
  55201. * @returns an array of PhysicsImpostor
  55202. */
  55203. getImpostors(): Array<PhysicsImpostor>;
  55204. /**
  55205. * Gets the impostor for a physics enabled object
  55206. * @param object defines the object impersonated by the impostor
  55207. * @returns the PhysicsImpostor or null if not found
  55208. */
  55209. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55210. /**
  55211. * Gets the impostor for a physics body object
  55212. * @param body defines physics body used by the impostor
  55213. * @returns the PhysicsImpostor or null if not found
  55214. */
  55215. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55216. /**
  55217. * Does a raycast in the physics world
  55218. * @param from when should the ray start?
  55219. * @param to when should the ray end?
  55220. * @returns PhysicsRaycastResult
  55221. */
  55222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55223. }
  55224. }
  55225. declare module BABYLON {
  55226. /** @hidden */
  55227. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55228. private _useDeltaForWorldStep;
  55229. world: any;
  55230. name: string;
  55231. private _physicsMaterials;
  55232. private _fixedTimeStep;
  55233. private _cannonRaycastResult;
  55234. private _raycastResult;
  55235. private _physicsBodysToRemoveAfterStep;
  55236. BJSCANNON: any;
  55237. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55238. setGravity(gravity: Vector3): void;
  55239. setTimeStep(timeStep: number): void;
  55240. getTimeStep(): number;
  55241. executeStep(delta: number): void;
  55242. private _removeMarkedPhysicsBodiesFromWorld;
  55243. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55244. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55245. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55246. private _processChildMeshes;
  55247. removePhysicsBody(impostor: PhysicsImpostor): void;
  55248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55249. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55250. private _addMaterial;
  55251. private _checkWithEpsilon;
  55252. private _createShape;
  55253. private _createHeightmap;
  55254. private _minus90X;
  55255. private _plus90X;
  55256. private _tmpPosition;
  55257. private _tmpDeltaPosition;
  55258. private _tmpUnityRotation;
  55259. private _updatePhysicsBodyTransformation;
  55260. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55262. isSupported(): boolean;
  55263. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55264. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55266. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55267. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55268. getBodyMass(impostor: PhysicsImpostor): number;
  55269. getBodyFriction(impostor: PhysicsImpostor): number;
  55270. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55271. getBodyRestitution(impostor: PhysicsImpostor): number;
  55272. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55273. sleepBody(impostor: PhysicsImpostor): void;
  55274. wakeUpBody(impostor: PhysicsImpostor): void;
  55275. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55276. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55277. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55278. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55279. getRadius(impostor: PhysicsImpostor): number;
  55280. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55281. dispose(): void;
  55282. private _extendNamespace;
  55283. /**
  55284. * Does a raycast in the physics world
  55285. * @param from when should the ray start?
  55286. * @param to when should the ray end?
  55287. * @returns PhysicsRaycastResult
  55288. */
  55289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55290. }
  55291. }
  55292. declare module BABYLON {
  55293. /** @hidden */
  55294. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55295. world: any;
  55296. name: string;
  55297. BJSOIMO: any;
  55298. private _raycastResult;
  55299. constructor(iterations?: number, oimoInjection?: any);
  55300. setGravity(gravity: Vector3): void;
  55301. setTimeStep(timeStep: number): void;
  55302. getTimeStep(): number;
  55303. private _tmpImpostorsArray;
  55304. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55305. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55306. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55307. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55308. private _tmpPositionVector;
  55309. removePhysicsBody(impostor: PhysicsImpostor): void;
  55310. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55311. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55312. isSupported(): boolean;
  55313. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55314. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55315. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55316. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55317. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55318. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55319. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55320. getBodyMass(impostor: PhysicsImpostor): number;
  55321. getBodyFriction(impostor: PhysicsImpostor): number;
  55322. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55323. getBodyRestitution(impostor: PhysicsImpostor): number;
  55324. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55325. sleepBody(impostor: PhysicsImpostor): void;
  55326. wakeUpBody(impostor: PhysicsImpostor): void;
  55327. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55328. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55329. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55330. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55331. getRadius(impostor: PhysicsImpostor): number;
  55332. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55333. dispose(): void;
  55334. /**
  55335. * Does a raycast in the physics world
  55336. * @param from when should the ray start?
  55337. * @param to when should the ray end?
  55338. * @returns PhysicsRaycastResult
  55339. */
  55340. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55341. }
  55342. }
  55343. declare module BABYLON {
  55344. /**
  55345. * Class containing static functions to help procedurally build meshes
  55346. */
  55347. export class RibbonBuilder {
  55348. /**
  55349. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55350. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55351. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55352. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55353. * * 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
  55354. * * 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
  55355. * * 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
  55356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55357. * * 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
  55358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55359. * * 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
  55360. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55361. * * 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
  55362. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55364. * @param name defines the name of the mesh
  55365. * @param options defines the options used to create the mesh
  55366. * @param scene defines the hosting scene
  55367. * @returns the ribbon mesh
  55368. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55369. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55370. */
  55371. static CreateRibbon(name: string, options: {
  55372. pathArray: Vector3[][];
  55373. closeArray?: boolean;
  55374. closePath?: boolean;
  55375. offset?: number;
  55376. updatable?: boolean;
  55377. sideOrientation?: number;
  55378. frontUVs?: Vector4;
  55379. backUVs?: Vector4;
  55380. instance?: Mesh;
  55381. invertUV?: boolean;
  55382. uvs?: Vector2[];
  55383. colors?: Color4[];
  55384. }, scene?: Nullable<Scene>): Mesh;
  55385. }
  55386. }
  55387. declare module BABYLON {
  55388. /**
  55389. * Class containing static functions to help procedurally build meshes
  55390. */
  55391. export class ShapeBuilder {
  55392. /**
  55393. * 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.
  55394. * * 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.
  55395. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55396. * * 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.
  55397. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55398. * * 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
  55399. * * 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
  55400. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55402. * * 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
  55403. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55405. * @param name defines the name of the mesh
  55406. * @param options defines the options used to create the mesh
  55407. * @param scene defines the hosting scene
  55408. * @returns the extruded shape mesh
  55409. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55411. */
  55412. static ExtrudeShape(name: string, options: {
  55413. shape: Vector3[];
  55414. path: Vector3[];
  55415. scale?: number;
  55416. rotation?: number;
  55417. cap?: number;
  55418. updatable?: boolean;
  55419. sideOrientation?: number;
  55420. frontUVs?: Vector4;
  55421. backUVs?: Vector4;
  55422. instance?: Mesh;
  55423. invertUV?: boolean;
  55424. }, scene?: Nullable<Scene>): Mesh;
  55425. /**
  55426. * Creates an custom extruded shape mesh.
  55427. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55428. * * 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.
  55429. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55430. * * 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
  55431. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55432. * * 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
  55433. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55434. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55435. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55436. * * 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
  55437. * * 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
  55438. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55440. * * 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
  55441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55443. * @param name defines the name of the mesh
  55444. * @param options defines the options used to create the mesh
  55445. * @param scene defines the hosting scene
  55446. * @returns the custom extruded shape mesh
  55447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55450. */
  55451. static ExtrudeShapeCustom(name: string, options: {
  55452. shape: Vector3[];
  55453. path: Vector3[];
  55454. scaleFunction?: any;
  55455. rotationFunction?: any;
  55456. ribbonCloseArray?: boolean;
  55457. ribbonClosePath?: boolean;
  55458. cap?: number;
  55459. updatable?: boolean;
  55460. sideOrientation?: number;
  55461. frontUVs?: Vector4;
  55462. backUVs?: Vector4;
  55463. instance?: Mesh;
  55464. invertUV?: boolean;
  55465. }, scene?: Nullable<Scene>): Mesh;
  55466. private static _ExtrudeShapeGeneric;
  55467. }
  55468. }
  55469. declare module BABYLON {
  55470. /**
  55471. * AmmoJS Physics plugin
  55472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55473. * @see https://github.com/kripken/ammo.js/
  55474. */
  55475. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55476. private _useDeltaForWorldStep;
  55477. /**
  55478. * Reference to the Ammo library
  55479. */
  55480. bjsAMMO: any;
  55481. /**
  55482. * Created ammoJS world which physics bodies are added to
  55483. */
  55484. world: any;
  55485. /**
  55486. * Name of the plugin
  55487. */
  55488. name: string;
  55489. private _timeStep;
  55490. private _fixedTimeStep;
  55491. private _maxSteps;
  55492. private _tmpQuaternion;
  55493. private _tmpAmmoTransform;
  55494. private _tmpAmmoQuaternion;
  55495. private _tmpAmmoConcreteContactResultCallback;
  55496. private _collisionConfiguration;
  55497. private _dispatcher;
  55498. private _overlappingPairCache;
  55499. private _solver;
  55500. private _softBodySolver;
  55501. private _tmpAmmoVectorA;
  55502. private _tmpAmmoVectorB;
  55503. private _tmpAmmoVectorC;
  55504. private _tmpAmmoVectorD;
  55505. private _tmpContactCallbackResult;
  55506. private _tmpAmmoVectorRCA;
  55507. private _tmpAmmoVectorRCB;
  55508. private _raycastResult;
  55509. private static readonly DISABLE_COLLISION_FLAG;
  55510. private static readonly KINEMATIC_FLAG;
  55511. private static readonly DISABLE_DEACTIVATION_FLAG;
  55512. /**
  55513. * Initializes the ammoJS plugin
  55514. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55515. * @param ammoInjection can be used to inject your own ammo reference
  55516. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55517. */
  55518. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55519. /**
  55520. * Sets the gravity of the physics world (m/(s^2))
  55521. * @param gravity Gravity to set
  55522. */
  55523. setGravity(gravity: Vector3): void;
  55524. /**
  55525. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55526. * @param timeStep timestep to use in seconds
  55527. */
  55528. setTimeStep(timeStep: number): void;
  55529. /**
  55530. * 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)
  55531. * @param fixedTimeStep fixedTimeStep to use in seconds
  55532. */
  55533. setFixedTimeStep(fixedTimeStep: number): void;
  55534. /**
  55535. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55536. * @param maxSteps the maximum number of steps by the physics engine per frame
  55537. */
  55538. setMaxSteps(maxSteps: number): void;
  55539. /**
  55540. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55541. * @returns the current timestep in seconds
  55542. */
  55543. getTimeStep(): number;
  55544. /**
  55545. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55546. */
  55547. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55548. private _isImpostorInContact;
  55549. private _isImpostorPairInContact;
  55550. private _stepSimulation;
  55551. /**
  55552. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55553. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55554. * After the step the babylon meshes are set to the position of the physics imposters
  55555. * @param delta amount of time to step forward
  55556. * @param impostors array of imposters to update before/after the step
  55557. */
  55558. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55559. /**
  55560. * Update babylon mesh to match physics world object
  55561. * @param impostor imposter to match
  55562. */
  55563. private _afterSoftStep;
  55564. /**
  55565. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55566. * @param impostor imposter to match
  55567. */
  55568. private _ropeStep;
  55569. /**
  55570. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55571. * @param impostor imposter to match
  55572. */
  55573. private _softbodyOrClothStep;
  55574. private _tmpVector;
  55575. private _tmpMatrix;
  55576. /**
  55577. * Applies an impulse on the imposter
  55578. * @param impostor imposter to apply impulse to
  55579. * @param force amount of force to be applied to the imposter
  55580. * @param contactPoint the location to apply the impulse on the imposter
  55581. */
  55582. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55583. /**
  55584. * Applies a force on the imposter
  55585. * @param impostor imposter to apply force
  55586. * @param force amount of force to be applied to the imposter
  55587. * @param contactPoint the location to apply the force on the imposter
  55588. */
  55589. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55590. /**
  55591. * Creates a physics body using the plugin
  55592. * @param impostor the imposter to create the physics body on
  55593. */
  55594. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55595. /**
  55596. * Removes the physics body from the imposter and disposes of the body's memory
  55597. * @param impostor imposter to remove the physics body from
  55598. */
  55599. removePhysicsBody(impostor: PhysicsImpostor): void;
  55600. /**
  55601. * Generates a joint
  55602. * @param impostorJoint the imposter joint to create the joint with
  55603. */
  55604. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55605. /**
  55606. * Removes a joint
  55607. * @param impostorJoint the imposter joint to remove the joint from
  55608. */
  55609. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55610. private _addMeshVerts;
  55611. /**
  55612. * Initialise the soft body vertices to match its object's (mesh) vertices
  55613. * Softbody vertices (nodes) are in world space and to match this
  55614. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55615. * @param impostor to create the softbody for
  55616. */
  55617. private _softVertexData;
  55618. /**
  55619. * Create an impostor's soft body
  55620. * @param impostor to create the softbody for
  55621. */
  55622. private _createSoftbody;
  55623. /**
  55624. * Create cloth for an impostor
  55625. * @param impostor to create the softbody for
  55626. */
  55627. private _createCloth;
  55628. /**
  55629. * Create rope for an impostor
  55630. * @param impostor to create the softbody for
  55631. */
  55632. private _createRope;
  55633. /**
  55634. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55635. * @param impostor to create the custom physics shape for
  55636. */
  55637. private _createCustom;
  55638. private _addHullVerts;
  55639. private _createShape;
  55640. /**
  55641. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55642. * @param impostor imposter containing the physics body and babylon object
  55643. */
  55644. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55645. /**
  55646. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55647. * @param impostor imposter containing the physics body and babylon object
  55648. * @param newPosition new position
  55649. * @param newRotation new rotation
  55650. */
  55651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55652. /**
  55653. * If this plugin is supported
  55654. * @returns true if its supported
  55655. */
  55656. isSupported(): boolean;
  55657. /**
  55658. * Sets the linear velocity of the physics body
  55659. * @param impostor imposter to set the velocity on
  55660. * @param velocity velocity to set
  55661. */
  55662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55663. /**
  55664. * Sets the angular velocity of the physics body
  55665. * @param impostor imposter to set the velocity on
  55666. * @param velocity velocity to set
  55667. */
  55668. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55669. /**
  55670. * gets the linear velocity
  55671. * @param impostor imposter to get linear velocity from
  55672. * @returns linear velocity
  55673. */
  55674. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55675. /**
  55676. * gets the angular velocity
  55677. * @param impostor imposter to get angular velocity from
  55678. * @returns angular velocity
  55679. */
  55680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55681. /**
  55682. * Sets the mass of physics body
  55683. * @param impostor imposter to set the mass on
  55684. * @param mass mass to set
  55685. */
  55686. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55687. /**
  55688. * Gets the mass of the physics body
  55689. * @param impostor imposter to get the mass from
  55690. * @returns mass
  55691. */
  55692. getBodyMass(impostor: PhysicsImpostor): number;
  55693. /**
  55694. * Gets friction of the impostor
  55695. * @param impostor impostor to get friction from
  55696. * @returns friction value
  55697. */
  55698. getBodyFriction(impostor: PhysicsImpostor): number;
  55699. /**
  55700. * Sets friction of the impostor
  55701. * @param impostor impostor to set friction on
  55702. * @param friction friction value
  55703. */
  55704. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55705. /**
  55706. * Gets restitution of the impostor
  55707. * @param impostor impostor to get restitution from
  55708. * @returns restitution value
  55709. */
  55710. getBodyRestitution(impostor: PhysicsImpostor): number;
  55711. /**
  55712. * Sets resitution of the impostor
  55713. * @param impostor impostor to set resitution on
  55714. * @param restitution resitution value
  55715. */
  55716. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55717. /**
  55718. * Gets pressure inside the impostor
  55719. * @param impostor impostor to get pressure from
  55720. * @returns pressure value
  55721. */
  55722. getBodyPressure(impostor: PhysicsImpostor): number;
  55723. /**
  55724. * Sets pressure inside a soft body impostor
  55725. * Cloth and rope must remain 0 pressure
  55726. * @param impostor impostor to set pressure on
  55727. * @param pressure pressure value
  55728. */
  55729. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55730. /**
  55731. * Gets stiffness of the impostor
  55732. * @param impostor impostor to get stiffness from
  55733. * @returns pressure value
  55734. */
  55735. getBodyStiffness(impostor: PhysicsImpostor): number;
  55736. /**
  55737. * Sets stiffness of the impostor
  55738. * @param impostor impostor to set stiffness on
  55739. * @param stiffness stiffness value from 0 to 1
  55740. */
  55741. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55742. /**
  55743. * Gets velocityIterations of the impostor
  55744. * @param impostor impostor to get velocity iterations from
  55745. * @returns velocityIterations value
  55746. */
  55747. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55748. /**
  55749. * Sets velocityIterations of the impostor
  55750. * @param impostor impostor to set velocity iterations on
  55751. * @param velocityIterations velocityIterations value
  55752. */
  55753. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55754. /**
  55755. * Gets positionIterations of the impostor
  55756. * @param impostor impostor to get position iterations from
  55757. * @returns positionIterations value
  55758. */
  55759. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55760. /**
  55761. * Sets positionIterations of the impostor
  55762. * @param impostor impostor to set position on
  55763. * @param positionIterations positionIterations value
  55764. */
  55765. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55766. /**
  55767. * Append an anchor to a cloth object
  55768. * @param impostor is the cloth impostor to add anchor to
  55769. * @param otherImpostor is the rigid impostor to anchor to
  55770. * @param width ratio across width from 0 to 1
  55771. * @param height ratio up height from 0 to 1
  55772. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55773. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55774. */
  55775. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55776. /**
  55777. * Append an hook to a rope object
  55778. * @param impostor is the rope impostor to add hook to
  55779. * @param otherImpostor is the rigid impostor to hook to
  55780. * @param length ratio along the rope from 0 to 1
  55781. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55782. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55783. */
  55784. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55785. /**
  55786. * Sleeps the physics body and stops it from being active
  55787. * @param impostor impostor to sleep
  55788. */
  55789. sleepBody(impostor: PhysicsImpostor): void;
  55790. /**
  55791. * Activates the physics body
  55792. * @param impostor impostor to activate
  55793. */
  55794. wakeUpBody(impostor: PhysicsImpostor): void;
  55795. /**
  55796. * Updates the distance parameters of the joint
  55797. * @param joint joint to update
  55798. * @param maxDistance maximum distance of the joint
  55799. * @param minDistance minimum distance of the joint
  55800. */
  55801. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55802. /**
  55803. * Sets a motor on the joint
  55804. * @param joint joint to set motor on
  55805. * @param speed speed of the motor
  55806. * @param maxForce maximum force of the motor
  55807. * @param motorIndex index of the motor
  55808. */
  55809. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55810. /**
  55811. * Sets the motors limit
  55812. * @param joint joint to set limit on
  55813. * @param upperLimit upper limit
  55814. * @param lowerLimit lower limit
  55815. */
  55816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55817. /**
  55818. * Syncs the position and rotation of a mesh with the impostor
  55819. * @param mesh mesh to sync
  55820. * @param impostor impostor to update the mesh with
  55821. */
  55822. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55823. /**
  55824. * Gets the radius of the impostor
  55825. * @param impostor impostor to get radius from
  55826. * @returns the radius
  55827. */
  55828. getRadius(impostor: PhysicsImpostor): number;
  55829. /**
  55830. * Gets the box size of the impostor
  55831. * @param impostor impostor to get box size from
  55832. * @param result the resulting box size
  55833. */
  55834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55835. /**
  55836. * Disposes of the impostor
  55837. */
  55838. dispose(): void;
  55839. /**
  55840. * Does a raycast in the physics world
  55841. * @param from when should the ray start?
  55842. * @param to when should the ray end?
  55843. * @returns PhysicsRaycastResult
  55844. */
  55845. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55846. }
  55847. }
  55848. declare module BABYLON {
  55849. interface AbstractScene {
  55850. /**
  55851. * The list of reflection probes added to the scene
  55852. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55853. */
  55854. reflectionProbes: Array<ReflectionProbe>;
  55855. /**
  55856. * Removes the given reflection probe from this scene.
  55857. * @param toRemove The reflection probe to remove
  55858. * @returns The index of the removed reflection probe
  55859. */
  55860. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55861. /**
  55862. * Adds the given reflection probe to this scene.
  55863. * @param newReflectionProbe The reflection probe to add
  55864. */
  55865. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55866. }
  55867. /**
  55868. * Class used to generate realtime reflection / refraction cube textures
  55869. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55870. */
  55871. export class ReflectionProbe {
  55872. /** defines the name of the probe */
  55873. name: string;
  55874. private _scene;
  55875. private _renderTargetTexture;
  55876. private _projectionMatrix;
  55877. private _viewMatrix;
  55878. private _target;
  55879. private _add;
  55880. private _attachedMesh;
  55881. private _invertYAxis;
  55882. /** Gets or sets probe position (center of the cube map) */
  55883. position: Vector3;
  55884. /**
  55885. * Creates a new reflection probe
  55886. * @param name defines the name of the probe
  55887. * @param size defines the texture resolution (for each face)
  55888. * @param scene defines the hosting scene
  55889. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55890. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55891. */
  55892. constructor(
  55893. /** defines the name of the probe */
  55894. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55895. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55896. get samples(): number;
  55897. set samples(value: number);
  55898. /** Gets or sets the refresh rate to use (on every frame by default) */
  55899. get refreshRate(): number;
  55900. set refreshRate(value: number);
  55901. /**
  55902. * Gets the hosting scene
  55903. * @returns a Scene
  55904. */
  55905. getScene(): Scene;
  55906. /** Gets the internal CubeTexture used to render to */
  55907. get cubeTexture(): RenderTargetTexture;
  55908. /** Gets the list of meshes to render */
  55909. get renderList(): Nullable<AbstractMesh[]>;
  55910. /**
  55911. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55912. * @param mesh defines the mesh to attach to
  55913. */
  55914. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55915. /**
  55916. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55917. * @param renderingGroupId The rendering group id corresponding to its index
  55918. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55919. */
  55920. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55921. /**
  55922. * Clean all associated resources
  55923. */
  55924. dispose(): void;
  55925. /**
  55926. * Converts the reflection probe information to a readable string for debug purpose.
  55927. * @param fullDetails Supports for multiple levels of logging within scene loading
  55928. * @returns the human readable reflection probe info
  55929. */
  55930. toString(fullDetails?: boolean): string;
  55931. /**
  55932. * Get the class name of the relfection probe.
  55933. * @returns "ReflectionProbe"
  55934. */
  55935. getClassName(): string;
  55936. /**
  55937. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55938. * @returns The JSON representation of the texture
  55939. */
  55940. serialize(): any;
  55941. /**
  55942. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55943. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55944. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55945. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55946. * @returns The parsed reflection probe if successful
  55947. */
  55948. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55949. }
  55950. }
  55951. declare module BABYLON {
  55952. /** @hidden */
  55953. export var _BabylonLoaderRegistered: boolean;
  55954. /**
  55955. * Helps setting up some configuration for the babylon file loader.
  55956. */
  55957. export class BabylonFileLoaderConfiguration {
  55958. /**
  55959. * The loader does not allow injecting custom physix engine into the plugins.
  55960. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55961. * So you could set this variable to your engine import to make it work.
  55962. */
  55963. static LoaderInjectedPhysicsEngine: any;
  55964. }
  55965. }
  55966. declare module BABYLON {
  55967. /**
  55968. * The Physically based simple base material of BJS.
  55969. *
  55970. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55971. * It is used as the base class for both the specGloss and metalRough conventions.
  55972. */
  55973. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55974. /**
  55975. * Number of Simultaneous lights allowed on the material.
  55976. */
  55977. maxSimultaneousLights: number;
  55978. /**
  55979. * If sets to true, disables all the lights affecting the material.
  55980. */
  55981. disableLighting: boolean;
  55982. /**
  55983. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55984. */
  55985. environmentTexture: BaseTexture;
  55986. /**
  55987. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55988. */
  55989. invertNormalMapX: boolean;
  55990. /**
  55991. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55992. */
  55993. invertNormalMapY: boolean;
  55994. /**
  55995. * Normal map used in the model.
  55996. */
  55997. normalTexture: BaseTexture;
  55998. /**
  55999. * Emissivie color used to self-illuminate the model.
  56000. */
  56001. emissiveColor: Color3;
  56002. /**
  56003. * Emissivie texture used to self-illuminate the model.
  56004. */
  56005. emissiveTexture: BaseTexture;
  56006. /**
  56007. * Occlusion Channel Strenght.
  56008. */
  56009. occlusionStrength: number;
  56010. /**
  56011. * Occlusion Texture of the material (adding extra occlusion effects).
  56012. */
  56013. occlusionTexture: BaseTexture;
  56014. /**
  56015. * Defines the alpha limits in alpha test mode.
  56016. */
  56017. alphaCutOff: number;
  56018. /**
  56019. * Gets the current double sided mode.
  56020. */
  56021. get doubleSided(): boolean;
  56022. /**
  56023. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56024. */
  56025. set doubleSided(value: boolean);
  56026. /**
  56027. * Stores the pre-calculated light information of a mesh in a texture.
  56028. */
  56029. lightmapTexture: BaseTexture;
  56030. /**
  56031. * If true, the light map contains occlusion information instead of lighting info.
  56032. */
  56033. useLightmapAsShadowmap: boolean;
  56034. /**
  56035. * Instantiates a new PBRMaterial instance.
  56036. *
  56037. * @param name The material name
  56038. * @param scene The scene the material will be use in.
  56039. */
  56040. constructor(name: string, scene: Scene);
  56041. getClassName(): string;
  56042. }
  56043. }
  56044. declare module BABYLON {
  56045. /**
  56046. * The PBR material of BJS following the metal roughness convention.
  56047. *
  56048. * This fits to the PBR convention in the GLTF definition:
  56049. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56050. */
  56051. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56052. /**
  56053. * The base color has two different interpretations depending on the value of metalness.
  56054. * When the material is a metal, the base color is the specific measured reflectance value
  56055. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56056. * of the material.
  56057. */
  56058. baseColor: Color3;
  56059. /**
  56060. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56061. * well as opacity information in the alpha channel.
  56062. */
  56063. baseTexture: BaseTexture;
  56064. /**
  56065. * Specifies the metallic scalar value of the material.
  56066. * Can also be used to scale the metalness values of the metallic texture.
  56067. */
  56068. metallic: number;
  56069. /**
  56070. * Specifies the roughness scalar value of the material.
  56071. * Can also be used to scale the roughness values of the metallic texture.
  56072. */
  56073. roughness: number;
  56074. /**
  56075. * Texture containing both the metallic value in the B channel and the
  56076. * roughness value in the G channel to keep better precision.
  56077. */
  56078. metallicRoughnessTexture: BaseTexture;
  56079. /**
  56080. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56081. *
  56082. * @param name The material name
  56083. * @param scene The scene the material will be use in.
  56084. */
  56085. constructor(name: string, scene: Scene);
  56086. /**
  56087. * Return the currrent class name of the material.
  56088. */
  56089. getClassName(): string;
  56090. /**
  56091. * Makes a duplicate of the current material.
  56092. * @param name - name to use for the new material.
  56093. */
  56094. clone(name: string): PBRMetallicRoughnessMaterial;
  56095. /**
  56096. * Serialize the material to a parsable JSON object.
  56097. */
  56098. serialize(): any;
  56099. /**
  56100. * Parses a JSON object correponding to the serialize function.
  56101. */
  56102. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56103. }
  56104. }
  56105. declare module BABYLON {
  56106. /**
  56107. * The PBR material of BJS following the specular glossiness convention.
  56108. *
  56109. * This fits to the PBR convention in the GLTF definition:
  56110. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56111. */
  56112. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56113. /**
  56114. * Specifies the diffuse color of the material.
  56115. */
  56116. diffuseColor: Color3;
  56117. /**
  56118. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56119. * channel.
  56120. */
  56121. diffuseTexture: BaseTexture;
  56122. /**
  56123. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56124. */
  56125. specularColor: Color3;
  56126. /**
  56127. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56128. */
  56129. glossiness: number;
  56130. /**
  56131. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56132. */
  56133. specularGlossinessTexture: BaseTexture;
  56134. /**
  56135. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56136. *
  56137. * @param name The material name
  56138. * @param scene The scene the material will be use in.
  56139. */
  56140. constructor(name: string, scene: Scene);
  56141. /**
  56142. * Return the currrent class name of the material.
  56143. */
  56144. getClassName(): string;
  56145. /**
  56146. * Makes a duplicate of the current material.
  56147. * @param name - name to use for the new material.
  56148. */
  56149. clone(name: string): PBRSpecularGlossinessMaterial;
  56150. /**
  56151. * Serialize the material to a parsable JSON object.
  56152. */
  56153. serialize(): any;
  56154. /**
  56155. * Parses a JSON object correponding to the serialize function.
  56156. */
  56157. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56158. }
  56159. }
  56160. declare module BABYLON {
  56161. /**
  56162. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56163. * It can help converting any input color in a desired output one. This can then be used to create effects
  56164. * from sepia, black and white to sixties or futuristic rendering...
  56165. *
  56166. * The only supported format is currently 3dl.
  56167. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56168. */
  56169. export class ColorGradingTexture extends BaseTexture {
  56170. /**
  56171. * The current texture matrix. (will always be identity in color grading texture)
  56172. */
  56173. private _textureMatrix;
  56174. /**
  56175. * The texture URL.
  56176. */
  56177. url: string;
  56178. /**
  56179. * Empty line regex stored for GC.
  56180. */
  56181. private static _noneEmptyLineRegex;
  56182. private _engine;
  56183. /**
  56184. * Instantiates a ColorGradingTexture from the following parameters.
  56185. *
  56186. * @param url The location of the color gradind data (currently only supporting 3dl)
  56187. * @param scene The scene the texture will be used in
  56188. */
  56189. constructor(url: string, scene: Scene);
  56190. /**
  56191. * Returns the texture matrix used in most of the material.
  56192. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56193. */
  56194. getTextureMatrix(): Matrix;
  56195. /**
  56196. * Occurs when the file being loaded is a .3dl LUT file.
  56197. */
  56198. private load3dlTexture;
  56199. /**
  56200. * Starts the loading process of the texture.
  56201. */
  56202. private loadTexture;
  56203. /**
  56204. * Clones the color gradind texture.
  56205. */
  56206. clone(): ColorGradingTexture;
  56207. /**
  56208. * Called during delayed load for textures.
  56209. */
  56210. delayLoad(): void;
  56211. /**
  56212. * Parses a color grading texture serialized by Babylon.
  56213. * @param parsedTexture The texture information being parsedTexture
  56214. * @param scene The scene to load the texture in
  56215. * @param rootUrl The root url of the data assets to load
  56216. * @return A color gradind texture
  56217. */
  56218. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56219. /**
  56220. * Serializes the LUT texture to json format.
  56221. */
  56222. serialize(): any;
  56223. }
  56224. }
  56225. declare module BABYLON {
  56226. /**
  56227. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56228. */
  56229. export class EquiRectangularCubeTexture extends BaseTexture {
  56230. /** The six faces of the cube. */
  56231. private static _FacesMapping;
  56232. private _noMipmap;
  56233. private _onLoad;
  56234. private _onError;
  56235. /** The size of the cubemap. */
  56236. private _size;
  56237. /** The buffer of the image. */
  56238. private _buffer;
  56239. /** The width of the input image. */
  56240. private _width;
  56241. /** The height of the input image. */
  56242. private _height;
  56243. /** The URL to the image. */
  56244. url: string;
  56245. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56246. coordinatesMode: number;
  56247. /**
  56248. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56249. * @param url The location of the image
  56250. * @param scene The scene the texture will be used in
  56251. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56252. * @param noMipmap Forces to not generate the mipmap if true
  56253. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56254. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56255. * @param onLoad — defines a callback called when texture is loaded
  56256. * @param onError — defines a callback called if there is an error
  56257. */
  56258. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56259. /**
  56260. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56261. */
  56262. private loadImage;
  56263. /**
  56264. * Convert the image buffer into a cubemap and create a CubeTexture.
  56265. */
  56266. private loadTexture;
  56267. /**
  56268. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56269. * @param buffer The ArrayBuffer that should be converted.
  56270. * @returns The buffer as Float32Array.
  56271. */
  56272. private getFloat32ArrayFromArrayBuffer;
  56273. /**
  56274. * Get the current class name of the texture useful for serialization or dynamic coding.
  56275. * @returns "EquiRectangularCubeTexture"
  56276. */
  56277. getClassName(): string;
  56278. /**
  56279. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56280. * @returns A clone of the current EquiRectangularCubeTexture.
  56281. */
  56282. clone(): EquiRectangularCubeTexture;
  56283. }
  56284. }
  56285. declare module BABYLON {
  56286. /**
  56287. * Based on jsTGALoader - Javascript loader for TGA file
  56288. * By Vincent Thibault
  56289. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56290. */
  56291. export class TGATools {
  56292. private static _TYPE_INDEXED;
  56293. private static _TYPE_RGB;
  56294. private static _TYPE_GREY;
  56295. private static _TYPE_RLE_INDEXED;
  56296. private static _TYPE_RLE_RGB;
  56297. private static _TYPE_RLE_GREY;
  56298. private static _ORIGIN_MASK;
  56299. private static _ORIGIN_SHIFT;
  56300. private static _ORIGIN_BL;
  56301. private static _ORIGIN_BR;
  56302. private static _ORIGIN_UL;
  56303. private static _ORIGIN_UR;
  56304. /**
  56305. * Gets the header of a TGA file
  56306. * @param data defines the TGA data
  56307. * @returns the header
  56308. */
  56309. static GetTGAHeader(data: Uint8Array): any;
  56310. /**
  56311. * Uploads TGA content to a Babylon Texture
  56312. * @hidden
  56313. */
  56314. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56315. /** @hidden */
  56316. 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;
  56317. /** @hidden */
  56318. 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;
  56319. /** @hidden */
  56320. 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;
  56321. /** @hidden */
  56322. 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;
  56323. /** @hidden */
  56324. 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;
  56325. /** @hidden */
  56326. 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;
  56327. }
  56328. }
  56329. declare module BABYLON {
  56330. /**
  56331. * Implementation of the TGA Texture Loader.
  56332. * @hidden
  56333. */
  56334. export class _TGATextureLoader implements IInternalTextureLoader {
  56335. /**
  56336. * Defines wether the loader supports cascade loading the different faces.
  56337. */
  56338. readonly supportCascades: boolean;
  56339. /**
  56340. * This returns if the loader support the current file information.
  56341. * @param extension defines the file extension of the file being loaded
  56342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56343. * @param fallback defines the fallback internal texture if any
  56344. * @param isBase64 defines whether the texture is encoded as a base64
  56345. * @param isBuffer defines whether the texture data are stored as a buffer
  56346. * @returns true if the loader can load the specified file
  56347. */
  56348. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56349. /**
  56350. * Transform the url before loading if required.
  56351. * @param rootUrl the url of the texture
  56352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56353. * @returns the transformed texture
  56354. */
  56355. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56356. /**
  56357. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56358. * @param rootUrl the url of the texture
  56359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56360. * @returns the fallback texture
  56361. */
  56362. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56363. /**
  56364. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56365. * @param data contains the texture data
  56366. * @param texture defines the BabylonJS internal texture
  56367. * @param createPolynomials will be true if polynomials have been requested
  56368. * @param onLoad defines the callback to trigger once the texture is ready
  56369. * @param onError defines the callback to trigger in case of error
  56370. */
  56371. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56372. /**
  56373. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56374. * @param data contains the texture data
  56375. * @param texture defines the BabylonJS internal texture
  56376. * @param callback defines the method to call once ready to upload
  56377. */
  56378. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56379. }
  56380. }
  56381. declare module BABYLON {
  56382. /**
  56383. * Info about the .basis files
  56384. */
  56385. class BasisFileInfo {
  56386. /**
  56387. * If the file has alpha
  56388. */
  56389. hasAlpha: boolean;
  56390. /**
  56391. * Info about each image of the basis file
  56392. */
  56393. images: Array<{
  56394. levels: Array<{
  56395. width: number;
  56396. height: number;
  56397. transcodedPixels: ArrayBufferView;
  56398. }>;
  56399. }>;
  56400. }
  56401. /**
  56402. * Result of transcoding a basis file
  56403. */
  56404. class TranscodeResult {
  56405. /**
  56406. * Info about the .basis file
  56407. */
  56408. fileInfo: BasisFileInfo;
  56409. /**
  56410. * Format to use when loading the file
  56411. */
  56412. format: number;
  56413. }
  56414. /**
  56415. * Configuration options for the Basis transcoder
  56416. */
  56417. export class BasisTranscodeConfiguration {
  56418. /**
  56419. * Supported compression formats used to determine the supported output format of the transcoder
  56420. */
  56421. supportedCompressionFormats?: {
  56422. /**
  56423. * etc1 compression format
  56424. */
  56425. etc1?: boolean;
  56426. /**
  56427. * s3tc compression format
  56428. */
  56429. s3tc?: boolean;
  56430. /**
  56431. * pvrtc compression format
  56432. */
  56433. pvrtc?: boolean;
  56434. /**
  56435. * etc2 compression format
  56436. */
  56437. etc2?: boolean;
  56438. };
  56439. /**
  56440. * If mipmap levels should be loaded for transcoded images (Default: true)
  56441. */
  56442. loadMipmapLevels?: boolean;
  56443. /**
  56444. * Index of a single image to load (Default: all images)
  56445. */
  56446. loadSingleImage?: number;
  56447. }
  56448. /**
  56449. * Used to load .Basis files
  56450. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56451. */
  56452. export class BasisTools {
  56453. private static _IgnoreSupportedFormats;
  56454. /**
  56455. * URL to use when loading the basis transcoder
  56456. */
  56457. static JSModuleURL: string;
  56458. /**
  56459. * URL to use when loading the wasm module for the transcoder
  56460. */
  56461. static WasmModuleURL: string;
  56462. /**
  56463. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56464. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56465. * @returns internal format corresponding to the Basis format
  56466. */
  56467. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56468. private static _WorkerPromise;
  56469. private static _Worker;
  56470. private static _actionId;
  56471. private static _CreateWorkerAsync;
  56472. /**
  56473. * Transcodes a loaded image file to compressed pixel data
  56474. * @param imageData image data to transcode
  56475. * @param config configuration options for the transcoding
  56476. * @returns a promise resulting in the transcoded image
  56477. */
  56478. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56479. /**
  56480. * Loads a texture from the transcode result
  56481. * @param texture texture load to
  56482. * @param transcodeResult the result of transcoding the basis file to load from
  56483. */
  56484. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56485. }
  56486. }
  56487. declare module BABYLON {
  56488. /**
  56489. * Loader for .basis file format
  56490. */
  56491. export class _BasisTextureLoader implements IInternalTextureLoader {
  56492. /**
  56493. * Defines whether the loader supports cascade loading the different faces.
  56494. */
  56495. readonly supportCascades: boolean;
  56496. /**
  56497. * This returns if the loader support the current file information.
  56498. * @param extension defines the file extension of the file being loaded
  56499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56500. * @param fallback defines the fallback internal texture if any
  56501. * @param isBase64 defines whether the texture is encoded as a base64
  56502. * @param isBuffer defines whether the texture data are stored as a buffer
  56503. * @returns true if the loader can load the specified file
  56504. */
  56505. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56506. /**
  56507. * Transform the url before loading if required.
  56508. * @param rootUrl the url of the texture
  56509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56510. * @returns the transformed texture
  56511. */
  56512. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56513. /**
  56514. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56515. * @param rootUrl the url of the texture
  56516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56517. * @returns the fallback texture
  56518. */
  56519. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56520. /**
  56521. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56522. * @param data contains the texture data
  56523. * @param texture defines the BabylonJS internal texture
  56524. * @param createPolynomials will be true if polynomials have been requested
  56525. * @param onLoad defines the callback to trigger once the texture is ready
  56526. * @param onError defines the callback to trigger in case of error
  56527. */
  56528. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56529. /**
  56530. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56531. * @param data contains the texture data
  56532. * @param texture defines the BabylonJS internal texture
  56533. * @param callback defines the method to call once ready to upload
  56534. */
  56535. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56536. }
  56537. }
  56538. declare module BABYLON {
  56539. /**
  56540. * 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.
  56541. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56542. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56543. */
  56544. export class CustomProceduralTexture extends ProceduralTexture {
  56545. private _animate;
  56546. private _time;
  56547. private _config;
  56548. private _texturePath;
  56549. /**
  56550. * Instantiates a new Custom Procedural Texture.
  56551. * 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.
  56552. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56553. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56554. * @param name Define the name of the texture
  56555. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56556. * @param size Define the size of the texture to create
  56557. * @param scene Define the scene the texture belongs to
  56558. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56559. * @param generateMipMaps Define if the texture should creates mip maps or not
  56560. */
  56561. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56562. private _loadJson;
  56563. /**
  56564. * Is the texture ready to be used ? (rendered at least once)
  56565. * @returns true if ready, otherwise, false.
  56566. */
  56567. isReady(): boolean;
  56568. /**
  56569. * Render the texture to its associated render target.
  56570. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56571. */
  56572. render(useCameraPostProcess?: boolean): void;
  56573. /**
  56574. * Update the list of dependant textures samplers in the shader.
  56575. */
  56576. updateTextures(): void;
  56577. /**
  56578. * Update the uniform values of the procedural texture in the shader.
  56579. */
  56580. updateShaderUniforms(): void;
  56581. /**
  56582. * Define if the texture animates or not.
  56583. */
  56584. get animate(): boolean;
  56585. set animate(value: boolean);
  56586. }
  56587. }
  56588. declare module BABYLON {
  56589. /** @hidden */
  56590. export var noisePixelShader: {
  56591. name: string;
  56592. shader: string;
  56593. };
  56594. }
  56595. declare module BABYLON {
  56596. /**
  56597. * Class used to generate noise procedural textures
  56598. */
  56599. export class NoiseProceduralTexture extends ProceduralTexture {
  56600. private _time;
  56601. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56602. brightness: number;
  56603. /** Defines the number of octaves to process */
  56604. octaves: number;
  56605. /** Defines the level of persistence (0.8 by default) */
  56606. persistence: number;
  56607. /** Gets or sets animation speed factor (default is 1) */
  56608. animationSpeedFactor: number;
  56609. /**
  56610. * Creates a new NoiseProceduralTexture
  56611. * @param name defines the name fo the texture
  56612. * @param size defines the size of the texture (default is 256)
  56613. * @param scene defines the hosting scene
  56614. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56615. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56616. */
  56617. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56618. private _updateShaderUniforms;
  56619. protected _getDefines(): string;
  56620. /** Generate the current state of the procedural texture */
  56621. render(useCameraPostProcess?: boolean): void;
  56622. /**
  56623. * Serializes this noise procedural texture
  56624. * @returns a serialized noise procedural texture object
  56625. */
  56626. serialize(): any;
  56627. /**
  56628. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56629. * @param parsedTexture defines parsed texture data
  56630. * @param scene defines the current scene
  56631. * @param rootUrl defines the root URL containing noise procedural texture information
  56632. * @returns a parsed NoiseProceduralTexture
  56633. */
  56634. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56635. }
  56636. }
  56637. declare module BABYLON {
  56638. /**
  56639. * Raw cube texture where the raw buffers are passed in
  56640. */
  56641. export class RawCubeTexture extends CubeTexture {
  56642. /**
  56643. * Creates a cube texture where the raw buffers are passed in.
  56644. * @param scene defines the scene the texture is attached to
  56645. * @param data defines the array of data to use to create each face
  56646. * @param size defines the size of the textures
  56647. * @param format defines the format of the data
  56648. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56649. * @param generateMipMaps defines if the engine should generate the mip levels
  56650. * @param invertY defines if data must be stored with Y axis inverted
  56651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56652. * @param compression defines the compression used (null by default)
  56653. */
  56654. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56655. /**
  56656. * Updates the raw cube texture.
  56657. * @param data defines the data to store
  56658. * @param format defines the data format
  56659. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56660. * @param invertY defines if data must be stored with Y axis inverted
  56661. * @param compression defines the compression used (null by default)
  56662. * @param level defines which level of the texture to update
  56663. */
  56664. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56665. /**
  56666. * Updates a raw cube texture with RGBD encoded data.
  56667. * @param data defines the array of data [mipmap][face] to use to create each face
  56668. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56669. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56670. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56671. * @returns a promsie that resolves when the operation is complete
  56672. */
  56673. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56674. /**
  56675. * Clones the raw cube texture.
  56676. * @return a new cube texture
  56677. */
  56678. clone(): CubeTexture;
  56679. /** @hidden */
  56680. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56681. }
  56682. }
  56683. declare module BABYLON {
  56684. /**
  56685. * Class used to store 3D textures containing user data
  56686. */
  56687. export class RawTexture3D extends Texture {
  56688. /** Gets or sets the texture format to use */
  56689. format: number;
  56690. private _engine;
  56691. /**
  56692. * Create a new RawTexture3D
  56693. * @param data defines the data of the texture
  56694. * @param width defines the width of the texture
  56695. * @param height defines the height of the texture
  56696. * @param depth defines the depth of the texture
  56697. * @param format defines the texture format to use
  56698. * @param scene defines the hosting scene
  56699. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56700. * @param invertY defines if texture must be stored with Y axis inverted
  56701. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56702. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56703. */
  56704. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56705. /** Gets or sets the texture format to use */
  56706. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56707. /**
  56708. * Update the texture with new data
  56709. * @param data defines the data to store in the texture
  56710. */
  56711. update(data: ArrayBufferView): void;
  56712. }
  56713. }
  56714. declare module BABYLON {
  56715. /**
  56716. * Class used to store 2D array textures containing user data
  56717. */
  56718. export class RawTexture2DArray extends Texture {
  56719. /** Gets or sets the texture format to use */
  56720. format: number;
  56721. private _engine;
  56722. /**
  56723. * Create a new RawTexture2DArray
  56724. * @param data defines the data of the texture
  56725. * @param width defines the width of the texture
  56726. * @param height defines the height of the texture
  56727. * @param depth defines the number of layers of the texture
  56728. * @param format defines the texture format to use
  56729. * @param scene defines the hosting scene
  56730. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56731. * @param invertY defines if texture must be stored with Y axis inverted
  56732. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56733. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56734. */
  56735. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56736. /** Gets or sets the texture format to use */
  56737. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56738. /**
  56739. * Update the texture with new data
  56740. * @param data defines the data to store in the texture
  56741. */
  56742. update(data: ArrayBufferView): void;
  56743. }
  56744. }
  56745. declare module BABYLON {
  56746. /**
  56747. * Creates a refraction texture used by refraction channel of the standard material.
  56748. * It is like a mirror but to see through a material.
  56749. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56750. */
  56751. export class RefractionTexture extends RenderTargetTexture {
  56752. /**
  56753. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56754. * 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.
  56755. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56756. */
  56757. refractionPlane: Plane;
  56758. /**
  56759. * Define how deep under the surface we should see.
  56760. */
  56761. depth: number;
  56762. /**
  56763. * Creates a refraction texture used by refraction channel of the standard material.
  56764. * It is like a mirror but to see through a material.
  56765. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56766. * @param name Define the texture name
  56767. * @param size Define the size of the underlying texture
  56768. * @param scene Define the scene the refraction belongs to
  56769. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56770. */
  56771. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56772. /**
  56773. * Clone the refraction texture.
  56774. * @returns the cloned texture
  56775. */
  56776. clone(): RefractionTexture;
  56777. /**
  56778. * Serialize the texture to a JSON representation you could use in Parse later on
  56779. * @returns the serialized JSON representation
  56780. */
  56781. serialize(): any;
  56782. }
  56783. }
  56784. declare module BABYLON {
  56785. /**
  56786. * Defines the options related to the creation of an HtmlElementTexture
  56787. */
  56788. export interface IHtmlElementTextureOptions {
  56789. /**
  56790. * Defines wether mip maps should be created or not.
  56791. */
  56792. generateMipMaps?: boolean;
  56793. /**
  56794. * Defines the sampling mode of the texture.
  56795. */
  56796. samplingMode?: number;
  56797. /**
  56798. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56799. */
  56800. engine: Nullable<ThinEngine>;
  56801. /**
  56802. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56803. */
  56804. scene: Nullable<Scene>;
  56805. }
  56806. /**
  56807. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56808. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56809. * is automatically managed.
  56810. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56811. * in your application.
  56812. *
  56813. * As the update is not automatic, you need to call them manually.
  56814. */
  56815. export class HtmlElementTexture extends BaseTexture {
  56816. /**
  56817. * The texture URL.
  56818. */
  56819. element: HTMLVideoElement | HTMLCanvasElement;
  56820. private static readonly DefaultOptions;
  56821. private _textureMatrix;
  56822. private _engine;
  56823. private _isVideo;
  56824. private _generateMipMaps;
  56825. private _samplingMode;
  56826. /**
  56827. * Instantiates a HtmlElementTexture from the following parameters.
  56828. *
  56829. * @param name Defines the name of the texture
  56830. * @param element Defines the video or canvas the texture is filled with
  56831. * @param options Defines the other none mandatory texture creation options
  56832. */
  56833. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56834. private _createInternalTexture;
  56835. /**
  56836. * Returns the texture matrix used in most of the material.
  56837. */
  56838. getTextureMatrix(): Matrix;
  56839. /**
  56840. * Updates the content of the texture.
  56841. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56842. */
  56843. update(invertY?: Nullable<boolean>): void;
  56844. }
  56845. }
  56846. declare module BABYLON {
  56847. /**
  56848. * Enum used to define the target of a block
  56849. */
  56850. export enum NodeMaterialBlockTargets {
  56851. /** Vertex shader */
  56852. Vertex = 1,
  56853. /** Fragment shader */
  56854. Fragment = 2,
  56855. /** Neutral */
  56856. Neutral = 4,
  56857. /** Vertex and Fragment */
  56858. VertexAndFragment = 3
  56859. }
  56860. }
  56861. declare module BABYLON {
  56862. /**
  56863. * Defines the kind of connection point for node based material
  56864. */
  56865. export enum NodeMaterialBlockConnectionPointTypes {
  56866. /** Float */
  56867. Float = 1,
  56868. /** Int */
  56869. Int = 2,
  56870. /** Vector2 */
  56871. Vector2 = 4,
  56872. /** Vector3 */
  56873. Vector3 = 8,
  56874. /** Vector4 */
  56875. Vector4 = 16,
  56876. /** Color3 */
  56877. Color3 = 32,
  56878. /** Color4 */
  56879. Color4 = 64,
  56880. /** Matrix */
  56881. Matrix = 128,
  56882. /** Detect type based on connection */
  56883. AutoDetect = 1024,
  56884. /** Output type that will be defined by input type */
  56885. BasedOnInput = 2048
  56886. }
  56887. }
  56888. declare module BABYLON {
  56889. /**
  56890. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56891. */
  56892. export enum NodeMaterialBlockConnectionPointMode {
  56893. /** Value is an uniform */
  56894. Uniform = 0,
  56895. /** Value is a mesh attribute */
  56896. Attribute = 1,
  56897. /** Value is a varying between vertex and fragment shaders */
  56898. Varying = 2,
  56899. /** Mode is undefined */
  56900. Undefined = 3
  56901. }
  56902. }
  56903. declare module BABYLON {
  56904. /**
  56905. * Enum used to define system values e.g. values automatically provided by the system
  56906. */
  56907. export enum NodeMaterialSystemValues {
  56908. /** World */
  56909. World = 1,
  56910. /** View */
  56911. View = 2,
  56912. /** Projection */
  56913. Projection = 3,
  56914. /** ViewProjection */
  56915. ViewProjection = 4,
  56916. /** WorldView */
  56917. WorldView = 5,
  56918. /** WorldViewProjection */
  56919. WorldViewProjection = 6,
  56920. /** CameraPosition */
  56921. CameraPosition = 7,
  56922. /** Fog Color */
  56923. FogColor = 8,
  56924. /** Delta time */
  56925. DeltaTime = 9
  56926. }
  56927. }
  56928. declare module BABYLON {
  56929. /**
  56930. * Root class for all node material optimizers
  56931. */
  56932. export class NodeMaterialOptimizer {
  56933. /**
  56934. * Function used to optimize a NodeMaterial graph
  56935. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56936. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56937. */
  56938. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56939. }
  56940. }
  56941. declare module BABYLON {
  56942. /**
  56943. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56944. */
  56945. export class TransformBlock extends NodeMaterialBlock {
  56946. /**
  56947. * Defines the value to use to complement W value to transform it to a Vector4
  56948. */
  56949. complementW: number;
  56950. /**
  56951. * Defines the value to use to complement z value to transform it to a Vector4
  56952. */
  56953. complementZ: number;
  56954. /**
  56955. * Creates a new TransformBlock
  56956. * @param name defines the block name
  56957. */
  56958. constructor(name: string);
  56959. /**
  56960. * Gets the current class name
  56961. * @returns the class name
  56962. */
  56963. getClassName(): string;
  56964. /**
  56965. * Gets the vector input
  56966. */
  56967. get vector(): NodeMaterialConnectionPoint;
  56968. /**
  56969. * Gets the output component
  56970. */
  56971. get output(): NodeMaterialConnectionPoint;
  56972. /**
  56973. * Gets the matrix transform input
  56974. */
  56975. get transform(): NodeMaterialConnectionPoint;
  56976. protected _buildBlock(state: NodeMaterialBuildState): this;
  56977. serialize(): any;
  56978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56979. protected _dumpPropertiesCode(): string;
  56980. }
  56981. }
  56982. declare module BABYLON {
  56983. /**
  56984. * Block used to output the vertex position
  56985. */
  56986. export class VertexOutputBlock extends NodeMaterialBlock {
  56987. /**
  56988. * Creates a new VertexOutputBlock
  56989. * @param name defines the block name
  56990. */
  56991. constructor(name: string);
  56992. /**
  56993. * Gets the current class name
  56994. * @returns the class name
  56995. */
  56996. getClassName(): string;
  56997. /**
  56998. * Gets the vector input component
  56999. */
  57000. get vector(): NodeMaterialConnectionPoint;
  57001. protected _buildBlock(state: NodeMaterialBuildState): this;
  57002. }
  57003. }
  57004. declare module BABYLON {
  57005. /**
  57006. * Block used to output the final color
  57007. */
  57008. export class FragmentOutputBlock extends NodeMaterialBlock {
  57009. /**
  57010. * Create a new FragmentOutputBlock
  57011. * @param name defines the block name
  57012. */
  57013. constructor(name: string);
  57014. /**
  57015. * Gets the current class name
  57016. * @returns the class name
  57017. */
  57018. getClassName(): string;
  57019. /**
  57020. * Gets the rgba input component
  57021. */
  57022. get rgba(): NodeMaterialConnectionPoint;
  57023. /**
  57024. * Gets the rgb input component
  57025. */
  57026. get rgb(): NodeMaterialConnectionPoint;
  57027. /**
  57028. * Gets the a input component
  57029. */
  57030. get a(): NodeMaterialConnectionPoint;
  57031. protected _buildBlock(state: NodeMaterialBuildState): this;
  57032. }
  57033. }
  57034. declare module BABYLON {
  57035. /**
  57036. * Block used to read a reflection texture from a sampler
  57037. */
  57038. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57039. private _define3DName;
  57040. private _defineCubicName;
  57041. private _defineExplicitName;
  57042. private _defineProjectionName;
  57043. private _defineLocalCubicName;
  57044. private _defineSphericalName;
  57045. private _definePlanarName;
  57046. private _defineEquirectangularName;
  57047. private _defineMirroredEquirectangularFixedName;
  57048. private _defineEquirectangularFixedName;
  57049. private _defineSkyboxName;
  57050. private _cubeSamplerName;
  57051. private _2DSamplerName;
  57052. private _positionUVWName;
  57053. private _directionWName;
  57054. private _reflectionCoordsName;
  57055. private _reflection2DCoordsName;
  57056. private _reflectionColorName;
  57057. private _reflectionMatrixName;
  57058. /**
  57059. * Gets or sets the texture associated with the node
  57060. */
  57061. texture: Nullable<BaseTexture>;
  57062. /**
  57063. * Create a new TextureBlock
  57064. * @param name defines the block name
  57065. */
  57066. constructor(name: string);
  57067. /**
  57068. * Gets the current class name
  57069. * @returns the class name
  57070. */
  57071. getClassName(): string;
  57072. /**
  57073. * Gets the world position input component
  57074. */
  57075. get position(): NodeMaterialConnectionPoint;
  57076. /**
  57077. * Gets the world position input component
  57078. */
  57079. get worldPosition(): NodeMaterialConnectionPoint;
  57080. /**
  57081. * Gets the world normal input component
  57082. */
  57083. get worldNormal(): NodeMaterialConnectionPoint;
  57084. /**
  57085. * Gets the world input component
  57086. */
  57087. get world(): NodeMaterialConnectionPoint;
  57088. /**
  57089. * Gets the camera (or eye) position component
  57090. */
  57091. get cameraPosition(): NodeMaterialConnectionPoint;
  57092. /**
  57093. * Gets the view input component
  57094. */
  57095. get view(): NodeMaterialConnectionPoint;
  57096. /**
  57097. * Gets the rgb output component
  57098. */
  57099. get rgb(): NodeMaterialConnectionPoint;
  57100. /**
  57101. * Gets the r output component
  57102. */
  57103. get r(): NodeMaterialConnectionPoint;
  57104. /**
  57105. * Gets the g output component
  57106. */
  57107. get g(): NodeMaterialConnectionPoint;
  57108. /**
  57109. * Gets the b output component
  57110. */
  57111. get b(): NodeMaterialConnectionPoint;
  57112. autoConfigure(material: NodeMaterial): void;
  57113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57114. isReady(): boolean;
  57115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57116. private _injectVertexCode;
  57117. private _writeOutput;
  57118. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57119. protected _dumpPropertiesCode(): string;
  57120. serialize(): any;
  57121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57122. }
  57123. }
  57124. declare module BABYLON {
  57125. /**
  57126. * Interface used to configure the node material editor
  57127. */
  57128. export interface INodeMaterialEditorOptions {
  57129. /** Define the URl to load node editor script */
  57130. editorURL?: string;
  57131. }
  57132. /** @hidden */
  57133. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57134. NORMAL: boolean;
  57135. TANGENT: boolean;
  57136. UV1: boolean;
  57137. /** BONES */
  57138. NUM_BONE_INFLUENCERS: number;
  57139. BonesPerMesh: number;
  57140. BONETEXTURE: boolean;
  57141. /** MORPH TARGETS */
  57142. MORPHTARGETS: boolean;
  57143. MORPHTARGETS_NORMAL: boolean;
  57144. MORPHTARGETS_TANGENT: boolean;
  57145. MORPHTARGETS_UV: boolean;
  57146. NUM_MORPH_INFLUENCERS: number;
  57147. /** IMAGE PROCESSING */
  57148. IMAGEPROCESSING: boolean;
  57149. VIGNETTE: boolean;
  57150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57151. VIGNETTEBLENDMODEOPAQUE: boolean;
  57152. TONEMAPPING: boolean;
  57153. TONEMAPPING_ACES: boolean;
  57154. CONTRAST: boolean;
  57155. EXPOSURE: boolean;
  57156. COLORCURVES: boolean;
  57157. COLORGRADING: boolean;
  57158. COLORGRADING3D: boolean;
  57159. SAMPLER3DGREENDEPTH: boolean;
  57160. SAMPLER3DBGRMAP: boolean;
  57161. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57162. /** MISC. */
  57163. BUMPDIRECTUV: number;
  57164. constructor();
  57165. setValue(name: string, value: boolean): void;
  57166. }
  57167. /**
  57168. * Class used to configure NodeMaterial
  57169. */
  57170. export interface INodeMaterialOptions {
  57171. /**
  57172. * Defines if blocks should emit comments
  57173. */
  57174. emitComments: boolean;
  57175. }
  57176. /**
  57177. * Class used to create a node based material built by assembling shader blocks
  57178. */
  57179. export class NodeMaterial extends PushMaterial {
  57180. private static _BuildIdGenerator;
  57181. private _options;
  57182. private _vertexCompilationState;
  57183. private _fragmentCompilationState;
  57184. private _sharedData;
  57185. private _buildId;
  57186. private _buildWasSuccessful;
  57187. private _cachedWorldViewMatrix;
  57188. private _cachedWorldViewProjectionMatrix;
  57189. private _optimizers;
  57190. private _animationFrame;
  57191. /** Define the Url to load node editor script */
  57192. static EditorURL: string;
  57193. /** Define the Url to load snippets */
  57194. static SnippetUrl: string;
  57195. private BJSNODEMATERIALEDITOR;
  57196. /** Get the inspector from bundle or global */
  57197. private _getGlobalNodeMaterialEditor;
  57198. /**
  57199. * Gets or sets data used by visual editor
  57200. * @see https://nme.babylonjs.com
  57201. */
  57202. editorData: any;
  57203. /**
  57204. * 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)
  57205. */
  57206. ignoreAlpha: boolean;
  57207. /**
  57208. * Defines the maximum number of lights that can be used in the material
  57209. */
  57210. maxSimultaneousLights: number;
  57211. /**
  57212. * Observable raised when the material is built
  57213. */
  57214. onBuildObservable: Observable<NodeMaterial>;
  57215. /**
  57216. * Gets or sets the root nodes of the material vertex shader
  57217. */
  57218. _vertexOutputNodes: NodeMaterialBlock[];
  57219. /**
  57220. * Gets or sets the root nodes of the material fragment (pixel) shader
  57221. */
  57222. _fragmentOutputNodes: NodeMaterialBlock[];
  57223. /** Gets or sets options to control the node material overall behavior */
  57224. get options(): INodeMaterialOptions;
  57225. set options(options: INodeMaterialOptions);
  57226. /**
  57227. * Default configuration related to image processing available in the standard Material.
  57228. */
  57229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57230. /**
  57231. * Gets the image processing configuration used either in this material.
  57232. */
  57233. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57234. /**
  57235. * Sets the Default image processing configuration used either in the this material.
  57236. *
  57237. * If sets to null, the scene one is in use.
  57238. */
  57239. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57240. /**
  57241. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57242. */
  57243. attachedBlocks: NodeMaterialBlock[];
  57244. /**
  57245. * Create a new node based material
  57246. * @param name defines the material name
  57247. * @param scene defines the hosting scene
  57248. * @param options defines creation option
  57249. */
  57250. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57251. /**
  57252. * Gets the current class name of the material e.g. "NodeMaterial"
  57253. * @returns the class name
  57254. */
  57255. getClassName(): string;
  57256. /**
  57257. * Keep track of the image processing observer to allow dispose and replace.
  57258. */
  57259. private _imageProcessingObserver;
  57260. /**
  57261. * Attaches a new image processing configuration to the Standard Material.
  57262. * @param configuration
  57263. */
  57264. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57265. /**
  57266. * Get a block by its name
  57267. * @param name defines the name of the block to retrieve
  57268. * @returns the required block or null if not found
  57269. */
  57270. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57271. /**
  57272. * Get a block by its name
  57273. * @param predicate defines the predicate used to find the good candidate
  57274. * @returns the required block or null if not found
  57275. */
  57276. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57277. /**
  57278. * Get an input block by its name
  57279. * @param predicate defines the predicate used to find the good candidate
  57280. * @returns the required input block or null if not found
  57281. */
  57282. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57283. /**
  57284. * Gets the list of input blocks attached to this material
  57285. * @returns an array of InputBlocks
  57286. */
  57287. getInputBlocks(): InputBlock[];
  57288. /**
  57289. * Adds a new optimizer to the list of optimizers
  57290. * @param optimizer defines the optimizers to add
  57291. * @returns the current material
  57292. */
  57293. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57294. /**
  57295. * Remove an optimizer from the list of optimizers
  57296. * @param optimizer defines the optimizers to remove
  57297. * @returns the current material
  57298. */
  57299. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57300. /**
  57301. * Add a new block to the list of output nodes
  57302. * @param node defines the node to add
  57303. * @returns the current material
  57304. */
  57305. addOutputNode(node: NodeMaterialBlock): this;
  57306. /**
  57307. * Remove a block from the list of root nodes
  57308. * @param node defines the node to remove
  57309. * @returns the current material
  57310. */
  57311. removeOutputNode(node: NodeMaterialBlock): this;
  57312. private _addVertexOutputNode;
  57313. private _removeVertexOutputNode;
  57314. private _addFragmentOutputNode;
  57315. private _removeFragmentOutputNode;
  57316. /**
  57317. * Specifies if the material will require alpha blending
  57318. * @returns a boolean specifying if alpha blending is needed
  57319. */
  57320. needAlphaBlending(): boolean;
  57321. /**
  57322. * Specifies if this material should be rendered in alpha test mode
  57323. * @returns a boolean specifying if an alpha test is needed.
  57324. */
  57325. needAlphaTesting(): boolean;
  57326. private _initializeBlock;
  57327. private _resetDualBlocks;
  57328. /**
  57329. * Remove a block from the current node material
  57330. * @param block defines the block to remove
  57331. */
  57332. removeBlock(block: NodeMaterialBlock): void;
  57333. /**
  57334. * Build the material and generates the inner effect
  57335. * @param verbose defines if the build should log activity
  57336. */
  57337. build(verbose?: boolean): void;
  57338. /**
  57339. * Runs an otpimization phase to try to improve the shader code
  57340. */
  57341. optimize(): void;
  57342. private _prepareDefinesForAttributes;
  57343. /**
  57344. * Get if the submesh is ready to be used and all its information available.
  57345. * Child classes can use it to update shaders
  57346. * @param mesh defines the mesh to check
  57347. * @param subMesh defines which submesh to check
  57348. * @param useInstances specifies that instances should be used
  57349. * @returns a boolean indicating that the submesh is ready or not
  57350. */
  57351. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57352. /**
  57353. * Get a string representing the shaders built by the current node graph
  57354. */
  57355. get compiledShaders(): string;
  57356. /**
  57357. * Binds the world matrix to the material
  57358. * @param world defines the world transformation matrix
  57359. */
  57360. bindOnlyWorldMatrix(world: Matrix): void;
  57361. /**
  57362. * Binds the submesh to this material by preparing the effect and shader to draw
  57363. * @param world defines the world transformation matrix
  57364. * @param mesh defines the mesh containing the submesh
  57365. * @param subMesh defines the submesh to bind the material to
  57366. */
  57367. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57368. /**
  57369. * Gets the active textures from the material
  57370. * @returns an array of textures
  57371. */
  57372. getActiveTextures(): BaseTexture[];
  57373. /**
  57374. * Gets the list of texture blocks
  57375. * @returns an array of texture blocks
  57376. */
  57377. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57378. /**
  57379. * Specifies if the material uses a texture
  57380. * @param texture defines the texture to check against the material
  57381. * @returns a boolean specifying if the material uses the texture
  57382. */
  57383. hasTexture(texture: BaseTexture): boolean;
  57384. /**
  57385. * Disposes the material
  57386. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57387. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57388. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57389. */
  57390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57391. /** Creates the node editor window. */
  57392. private _createNodeEditor;
  57393. /**
  57394. * Launch the node material editor
  57395. * @param config Define the configuration of the editor
  57396. * @return a promise fulfilled when the node editor is visible
  57397. */
  57398. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57399. /**
  57400. * Clear the current material
  57401. */
  57402. clear(): void;
  57403. /**
  57404. * Clear the current material and set it to a default state
  57405. */
  57406. setToDefault(): void;
  57407. /**
  57408. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57409. * @param url defines the url to load from
  57410. * @returns a promise that will fullfil when the material is fully loaded
  57411. */
  57412. loadAsync(url: string): Promise<void>;
  57413. private _gatherBlocks;
  57414. /**
  57415. * Generate a string containing the code declaration required to create an equivalent of this material
  57416. * @returns a string
  57417. */
  57418. generateCode(): string;
  57419. /**
  57420. * Serializes this material in a JSON representation
  57421. * @returns the serialized material object
  57422. */
  57423. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57424. private _restoreConnections;
  57425. /**
  57426. * Clear the current graph and load a new one from a serialization object
  57427. * @param source defines the JSON representation of the material
  57428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57429. */
  57430. loadFromSerialization(source: any, rootUrl?: string): void;
  57431. /**
  57432. * Creates a node material from parsed material data
  57433. * @param source defines the JSON representation of the material
  57434. * @param scene defines the hosting scene
  57435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57436. * @returns a new node material
  57437. */
  57438. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57439. /**
  57440. * Creates a node material from a snippet saved by the node material editor
  57441. * @param snippetId defines the snippet to load
  57442. * @param scene defines the hosting scene
  57443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57444. * @returns a promise that will resolve to the new node material
  57445. */
  57446. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57447. /**
  57448. * Creates a new node material set to default basic configuration
  57449. * @param name defines the name of the material
  57450. * @param scene defines the hosting scene
  57451. * @returns a new NodeMaterial
  57452. */
  57453. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57454. }
  57455. }
  57456. declare module BABYLON {
  57457. /**
  57458. * Block used to read a texture from a sampler
  57459. */
  57460. export class TextureBlock extends NodeMaterialBlock {
  57461. private _defineName;
  57462. private _linearDefineName;
  57463. private _tempTextureRead;
  57464. private _samplerName;
  57465. private _transformedUVName;
  57466. private _textureTransformName;
  57467. private _textureInfoName;
  57468. private _mainUVName;
  57469. private _mainUVDefineName;
  57470. /**
  57471. * Gets or sets the texture associated with the node
  57472. */
  57473. texture: Nullable<Texture>;
  57474. /**
  57475. * Create a new TextureBlock
  57476. * @param name defines the block name
  57477. */
  57478. constructor(name: string);
  57479. /**
  57480. * Gets the current class name
  57481. * @returns the class name
  57482. */
  57483. getClassName(): string;
  57484. /**
  57485. * Gets the uv input component
  57486. */
  57487. get uv(): NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the rgba output component
  57490. */
  57491. get rgba(): NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the rgb output component
  57494. */
  57495. get rgb(): NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the r output component
  57498. */
  57499. get r(): NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the g output component
  57502. */
  57503. get g(): NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the b output component
  57506. */
  57507. get b(): NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the a output component
  57510. */
  57511. get a(): NodeMaterialConnectionPoint;
  57512. get target(): NodeMaterialBlockTargets;
  57513. autoConfigure(material: NodeMaterial): void;
  57514. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57516. isReady(): boolean;
  57517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57518. private get _isMixed();
  57519. private _injectVertexCode;
  57520. private _writeTextureRead;
  57521. private _writeOutput;
  57522. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57523. protected _dumpPropertiesCode(): string;
  57524. serialize(): any;
  57525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57526. }
  57527. }
  57528. declare module BABYLON {
  57529. /**
  57530. * Class used to store shared data between 2 NodeMaterialBuildState
  57531. */
  57532. export class NodeMaterialBuildStateSharedData {
  57533. /**
  57534. * Gets the list of emitted varyings
  57535. */
  57536. temps: string[];
  57537. /**
  57538. * Gets the list of emitted varyings
  57539. */
  57540. varyings: string[];
  57541. /**
  57542. * Gets the varying declaration string
  57543. */
  57544. varyingDeclaration: string;
  57545. /**
  57546. * Input blocks
  57547. */
  57548. inputBlocks: InputBlock[];
  57549. /**
  57550. * Input blocks
  57551. */
  57552. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57553. /**
  57554. * Bindable blocks (Blocks that need to set data to the effect)
  57555. */
  57556. bindableBlocks: NodeMaterialBlock[];
  57557. /**
  57558. * List of blocks that can provide a compilation fallback
  57559. */
  57560. blocksWithFallbacks: NodeMaterialBlock[];
  57561. /**
  57562. * List of blocks that can provide a define update
  57563. */
  57564. blocksWithDefines: NodeMaterialBlock[];
  57565. /**
  57566. * List of blocks that can provide a repeatable content
  57567. */
  57568. repeatableContentBlocks: NodeMaterialBlock[];
  57569. /**
  57570. * List of blocks that can provide a dynamic list of uniforms
  57571. */
  57572. dynamicUniformBlocks: NodeMaterialBlock[];
  57573. /**
  57574. * List of blocks that can block the isReady function for the material
  57575. */
  57576. blockingBlocks: NodeMaterialBlock[];
  57577. /**
  57578. * Gets the list of animated inputs
  57579. */
  57580. animatedInputs: InputBlock[];
  57581. /**
  57582. * Build Id used to avoid multiple recompilations
  57583. */
  57584. buildId: number;
  57585. /** List of emitted variables */
  57586. variableNames: {
  57587. [key: string]: number;
  57588. };
  57589. /** List of emitted defines */
  57590. defineNames: {
  57591. [key: string]: number;
  57592. };
  57593. /** Should emit comments? */
  57594. emitComments: boolean;
  57595. /** Emit build activity */
  57596. verbose: boolean;
  57597. /** Gets or sets the hosting scene */
  57598. scene: Scene;
  57599. /**
  57600. * Gets the compilation hints emitted at compilation time
  57601. */
  57602. hints: {
  57603. needWorldViewMatrix: boolean;
  57604. needWorldViewProjectionMatrix: boolean;
  57605. needAlphaBlending: boolean;
  57606. needAlphaTesting: boolean;
  57607. };
  57608. /**
  57609. * List of compilation checks
  57610. */
  57611. checks: {
  57612. emitVertex: boolean;
  57613. emitFragment: boolean;
  57614. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57615. };
  57616. /** Creates a new shared data */
  57617. constructor();
  57618. /**
  57619. * Emits console errors and exceptions if there is a failing check
  57620. */
  57621. emitErrors(): void;
  57622. }
  57623. }
  57624. declare module BABYLON {
  57625. /**
  57626. * Class used to store node based material build state
  57627. */
  57628. export class NodeMaterialBuildState {
  57629. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57630. supportUniformBuffers: boolean;
  57631. /**
  57632. * Gets the list of emitted attributes
  57633. */
  57634. attributes: string[];
  57635. /**
  57636. * Gets the list of emitted uniforms
  57637. */
  57638. uniforms: string[];
  57639. /**
  57640. * Gets the list of emitted constants
  57641. */
  57642. constants: string[];
  57643. /**
  57644. * Gets the list of emitted samplers
  57645. */
  57646. samplers: string[];
  57647. /**
  57648. * Gets the list of emitted functions
  57649. */
  57650. functions: {
  57651. [key: string]: string;
  57652. };
  57653. /**
  57654. * Gets the list of emitted extensions
  57655. */
  57656. extensions: {
  57657. [key: string]: string;
  57658. };
  57659. /**
  57660. * Gets the target of the compilation state
  57661. */
  57662. target: NodeMaterialBlockTargets;
  57663. /**
  57664. * Gets the list of emitted counters
  57665. */
  57666. counters: {
  57667. [key: string]: number;
  57668. };
  57669. /**
  57670. * Shared data between multiple NodeMaterialBuildState instances
  57671. */
  57672. sharedData: NodeMaterialBuildStateSharedData;
  57673. /** @hidden */
  57674. _vertexState: NodeMaterialBuildState;
  57675. /** @hidden */
  57676. _attributeDeclaration: string;
  57677. /** @hidden */
  57678. _uniformDeclaration: string;
  57679. /** @hidden */
  57680. _constantDeclaration: string;
  57681. /** @hidden */
  57682. _samplerDeclaration: string;
  57683. /** @hidden */
  57684. _varyingTransfer: string;
  57685. private _repeatableContentAnchorIndex;
  57686. /** @hidden */
  57687. _builtCompilationString: string;
  57688. /**
  57689. * Gets the emitted compilation strings
  57690. */
  57691. compilationString: string;
  57692. /**
  57693. * Finalize the compilation strings
  57694. * @param state defines the current compilation state
  57695. */
  57696. finalize(state: NodeMaterialBuildState): void;
  57697. /** @hidden */
  57698. get _repeatableContentAnchor(): string;
  57699. /** @hidden */
  57700. _getFreeVariableName(prefix: string): string;
  57701. /** @hidden */
  57702. _getFreeDefineName(prefix: string): string;
  57703. /** @hidden */
  57704. _excludeVariableName(name: string): void;
  57705. /** @hidden */
  57706. _emit2DSampler(name: string): void;
  57707. /** @hidden */
  57708. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57709. /** @hidden */
  57710. _emitExtension(name: string, extension: string): void;
  57711. /** @hidden */
  57712. _emitFunction(name: string, code: string, comments: string): void;
  57713. /** @hidden */
  57714. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57715. replaceStrings?: {
  57716. search: RegExp;
  57717. replace: string;
  57718. }[];
  57719. repeatKey?: string;
  57720. }): string;
  57721. /** @hidden */
  57722. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57723. repeatKey?: string;
  57724. removeAttributes?: boolean;
  57725. removeUniforms?: boolean;
  57726. removeVaryings?: boolean;
  57727. removeIfDef?: boolean;
  57728. replaceStrings?: {
  57729. search: RegExp;
  57730. replace: string;
  57731. }[];
  57732. }, storeKey?: string): void;
  57733. /** @hidden */
  57734. _registerTempVariable(name: string): boolean;
  57735. /** @hidden */
  57736. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57737. /** @hidden */
  57738. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57739. /** @hidden */
  57740. _emitFloat(value: number): string;
  57741. }
  57742. }
  57743. declare module BABYLON {
  57744. /**
  57745. * Defines a block that can be used inside a node based material
  57746. */
  57747. export class NodeMaterialBlock {
  57748. private _buildId;
  57749. private _buildTarget;
  57750. private _target;
  57751. private _isFinalMerger;
  57752. private _isInput;
  57753. protected _isUnique: boolean;
  57754. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57755. inputsAreExclusive: boolean;
  57756. /** @hidden */
  57757. _codeVariableName: string;
  57758. /** @hidden */
  57759. _inputs: NodeMaterialConnectionPoint[];
  57760. /** @hidden */
  57761. _outputs: NodeMaterialConnectionPoint[];
  57762. /** @hidden */
  57763. _preparationId: number;
  57764. /**
  57765. * Gets or sets the name of the block
  57766. */
  57767. name: string;
  57768. /**
  57769. * Gets or sets the unique id of the node
  57770. */
  57771. uniqueId: number;
  57772. /**
  57773. * Gets or sets the comments associated with this block
  57774. */
  57775. comments: string;
  57776. /**
  57777. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57778. */
  57779. get isUnique(): boolean;
  57780. /**
  57781. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57782. */
  57783. get isFinalMerger(): boolean;
  57784. /**
  57785. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57786. */
  57787. get isInput(): boolean;
  57788. /**
  57789. * Gets or sets the build Id
  57790. */
  57791. get buildId(): number;
  57792. set buildId(value: number);
  57793. /**
  57794. * Gets or sets the target of the block
  57795. */
  57796. get target(): NodeMaterialBlockTargets;
  57797. set target(value: NodeMaterialBlockTargets);
  57798. /**
  57799. * Gets the list of input points
  57800. */
  57801. get inputs(): NodeMaterialConnectionPoint[];
  57802. /** Gets the list of output points */
  57803. get outputs(): NodeMaterialConnectionPoint[];
  57804. /**
  57805. * Find an input by its name
  57806. * @param name defines the name of the input to look for
  57807. * @returns the input or null if not found
  57808. */
  57809. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57810. /**
  57811. * Find an output by its name
  57812. * @param name defines the name of the outputto look for
  57813. * @returns the output or null if not found
  57814. */
  57815. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57816. /**
  57817. * Creates a new NodeMaterialBlock
  57818. * @param name defines the block name
  57819. * @param target defines the target of that block (Vertex by default)
  57820. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57821. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57822. */
  57823. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57824. /**
  57825. * Initialize the block and prepare the context for build
  57826. * @param state defines the state that will be used for the build
  57827. */
  57828. initialize(state: NodeMaterialBuildState): void;
  57829. /**
  57830. * Bind data to effect. Will only be called for blocks with isBindable === true
  57831. * @param effect defines the effect to bind data to
  57832. * @param nodeMaterial defines the hosting NodeMaterial
  57833. * @param mesh defines the mesh that will be rendered
  57834. */
  57835. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57836. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57837. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57838. protected _writeFloat(value: number): string;
  57839. /**
  57840. * Gets the current class name e.g. "NodeMaterialBlock"
  57841. * @returns the class name
  57842. */
  57843. getClassName(): string;
  57844. /**
  57845. * Register a new input. Must be called inside a block constructor
  57846. * @param name defines the connection point name
  57847. * @param type defines the connection point type
  57848. * @param isOptional defines a boolean indicating that this input can be omitted
  57849. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57850. * @returns the current block
  57851. */
  57852. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57853. /**
  57854. * Register a new output. Must be called inside a block constructor
  57855. * @param name defines the connection point name
  57856. * @param type defines the connection point type
  57857. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57858. * @returns the current block
  57859. */
  57860. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57861. /**
  57862. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57863. * @param forOutput defines an optional connection point to check compatibility with
  57864. * @returns the first available input or null
  57865. */
  57866. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57867. /**
  57868. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57869. * @param forBlock defines an optional block to check compatibility with
  57870. * @returns the first available input or null
  57871. */
  57872. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57873. /**
  57874. * Gets the sibling of the given output
  57875. * @param current defines the current output
  57876. * @returns the next output in the list or null
  57877. */
  57878. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57879. /**
  57880. * Connect current block with another block
  57881. * @param other defines the block to connect with
  57882. * @param options define the various options to help pick the right connections
  57883. * @returns the current block
  57884. */
  57885. connectTo(other: NodeMaterialBlock, options?: {
  57886. input?: string;
  57887. output?: string;
  57888. outputSwizzle?: string;
  57889. }): this | undefined;
  57890. protected _buildBlock(state: NodeMaterialBuildState): void;
  57891. /**
  57892. * Add uniforms, samplers and uniform buffers at compilation time
  57893. * @param state defines the state to update
  57894. * @param nodeMaterial defines the node material requesting the update
  57895. * @param defines defines the material defines to update
  57896. * @param uniformBuffers defines the list of uniform buffer names
  57897. */
  57898. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57899. /**
  57900. * Add potential fallbacks if shader compilation fails
  57901. * @param mesh defines the mesh to be rendered
  57902. * @param fallbacks defines the current prioritized list of fallbacks
  57903. */
  57904. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57905. /**
  57906. * Initialize defines for shader compilation
  57907. * @param mesh defines the mesh to be rendered
  57908. * @param nodeMaterial defines the node material requesting the update
  57909. * @param defines defines the material defines to update
  57910. * @param useInstances specifies that instances should be used
  57911. */
  57912. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57913. /**
  57914. * Update defines for shader compilation
  57915. * @param mesh defines the mesh to be rendered
  57916. * @param nodeMaterial defines the node material requesting the update
  57917. * @param defines defines the material defines to update
  57918. * @param useInstances specifies that instances should be used
  57919. */
  57920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57921. /**
  57922. * Lets the block try to connect some inputs automatically
  57923. * @param material defines the hosting NodeMaterial
  57924. */
  57925. autoConfigure(material: NodeMaterial): void;
  57926. /**
  57927. * Function called when a block is declared as repeatable content generator
  57928. * @param vertexShaderState defines the current compilation state for the vertex shader
  57929. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57930. * @param mesh defines the mesh to be rendered
  57931. * @param defines defines the material defines to update
  57932. */
  57933. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57934. /**
  57935. * Checks if the block is ready
  57936. * @param mesh defines the mesh to be rendered
  57937. * @param nodeMaterial defines the node material requesting the update
  57938. * @param defines defines the material defines to update
  57939. * @param useInstances specifies that instances should be used
  57940. * @returns true if the block is ready
  57941. */
  57942. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57943. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57944. private _processBuild;
  57945. /**
  57946. * Compile the current node and generate the shader code
  57947. * @param state defines the current compilation state (uniforms, samplers, current string)
  57948. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57949. * @returns true if already built
  57950. */
  57951. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57952. protected _inputRename(name: string): string;
  57953. protected _outputRename(name: string): string;
  57954. protected _dumpPropertiesCode(): string;
  57955. /** @hidden */
  57956. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57957. /** @hidden */
  57958. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57959. /**
  57960. * Clone the current block to a new identical block
  57961. * @param scene defines the hosting scene
  57962. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57963. * @returns a copy of the current block
  57964. */
  57965. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57966. /**
  57967. * Serializes this block in a JSON representation
  57968. * @returns the serialized block object
  57969. */
  57970. serialize(): any;
  57971. /** @hidden */
  57972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57973. /**
  57974. * Release resources
  57975. */
  57976. dispose(): void;
  57977. }
  57978. }
  57979. declare module BABYLON {
  57980. /**
  57981. * Enum defining the type of animations supported by InputBlock
  57982. */
  57983. export enum AnimatedInputBlockTypes {
  57984. /** No animation */
  57985. None = 0,
  57986. /** Time based animation. Will only work for floats */
  57987. Time = 1
  57988. }
  57989. }
  57990. declare module BABYLON {
  57991. /**
  57992. * Block used to expose an input value
  57993. */
  57994. export class InputBlock extends NodeMaterialBlock {
  57995. private _mode;
  57996. private _associatedVariableName;
  57997. private _storedValue;
  57998. private _valueCallback;
  57999. private _type;
  58000. private _animationType;
  58001. /** Gets or set a value used to limit the range of float values */
  58002. min: number;
  58003. /** Gets or set a value used to limit the range of float values */
  58004. max: number;
  58005. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58006. isBoolean: boolean;
  58007. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58008. matrixMode: number;
  58009. /** @hidden */
  58010. _systemValue: Nullable<NodeMaterialSystemValues>;
  58011. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58012. visibleInInspector: boolean;
  58013. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58014. isConstant: boolean;
  58015. /** Gets or sets the group to use to display this block in the Inspector */
  58016. groupInInspector: string;
  58017. /**
  58018. * Gets or sets the connection point type (default is float)
  58019. */
  58020. get type(): NodeMaterialBlockConnectionPointTypes;
  58021. /**
  58022. * Creates a new InputBlock
  58023. * @param name defines the block name
  58024. * @param target defines the target of that block (Vertex by default)
  58025. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58026. */
  58027. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58028. /**
  58029. * Gets the output component
  58030. */
  58031. get output(): NodeMaterialConnectionPoint;
  58032. /**
  58033. * Set the source of this connection point to a vertex attribute
  58034. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58035. * @returns the current connection point
  58036. */
  58037. setAsAttribute(attributeName?: string): InputBlock;
  58038. /**
  58039. * Set the source of this connection point to a system value
  58040. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58041. * @returns the current connection point
  58042. */
  58043. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58044. /**
  58045. * Gets or sets the value of that point.
  58046. * Please note that this value will be ignored if valueCallback is defined
  58047. */
  58048. get value(): any;
  58049. set value(value: any);
  58050. /**
  58051. * Gets or sets a callback used to get the value of that point.
  58052. * Please note that setting this value will force the connection point to ignore the value property
  58053. */
  58054. get valueCallback(): () => any;
  58055. set valueCallback(value: () => any);
  58056. /**
  58057. * Gets or sets the associated variable name in the shader
  58058. */
  58059. get associatedVariableName(): string;
  58060. set associatedVariableName(value: string);
  58061. /** Gets or sets the type of animation applied to the input */
  58062. get animationType(): AnimatedInputBlockTypes;
  58063. set animationType(value: AnimatedInputBlockTypes);
  58064. /**
  58065. * Gets a boolean indicating that this connection point not defined yet
  58066. */
  58067. get isUndefined(): boolean;
  58068. /**
  58069. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58070. * In this case the connection point name must be the name of the uniform to use.
  58071. * Can only be set on inputs
  58072. */
  58073. get isUniform(): boolean;
  58074. set isUniform(value: boolean);
  58075. /**
  58076. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58077. * In this case the connection point name must be the name of the attribute to use
  58078. * Can only be set on inputs
  58079. */
  58080. get isAttribute(): boolean;
  58081. set isAttribute(value: boolean);
  58082. /**
  58083. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58084. * Can only be set on exit points
  58085. */
  58086. get isVarying(): boolean;
  58087. set isVarying(value: boolean);
  58088. /**
  58089. * Gets a boolean indicating that the current connection point is a system value
  58090. */
  58091. get isSystemValue(): boolean;
  58092. /**
  58093. * Gets or sets the current well known value or null if not defined as a system value
  58094. */
  58095. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58096. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58097. /**
  58098. * Gets the current class name
  58099. * @returns the class name
  58100. */
  58101. getClassName(): string;
  58102. /**
  58103. * Animate the input if animationType !== None
  58104. * @param scene defines the rendering scene
  58105. */
  58106. animate(scene: Scene): void;
  58107. private _emitDefine;
  58108. initialize(state: NodeMaterialBuildState): void;
  58109. /**
  58110. * Set the input block to its default value (based on its type)
  58111. */
  58112. setDefaultValue(): void;
  58113. private _emitConstant;
  58114. private _emit;
  58115. /** @hidden */
  58116. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58117. /** @hidden */
  58118. _transmit(effect: Effect, scene: Scene): void;
  58119. protected _buildBlock(state: NodeMaterialBuildState): void;
  58120. protected _dumpPropertiesCode(): string;
  58121. serialize(): any;
  58122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58123. }
  58124. }
  58125. declare module BABYLON {
  58126. /**
  58127. * Enum used to define the compatibility state between two connection points
  58128. */
  58129. export enum NodeMaterialConnectionPointCompatibilityStates {
  58130. /** Points are compatibles */
  58131. Compatible = 0,
  58132. /** Points are incompatible because of their types */
  58133. TypeIncompatible = 1,
  58134. /** Points are incompatible because of their targets (vertex vs fragment) */
  58135. TargetIncompatible = 2
  58136. }
  58137. /**
  58138. * Defines the direction of a connection point
  58139. */
  58140. export enum NodeMaterialConnectionPointDirection {
  58141. /** Input */
  58142. Input = 0,
  58143. /** Output */
  58144. Output = 1
  58145. }
  58146. /**
  58147. * Defines a connection point for a block
  58148. */
  58149. export class NodeMaterialConnectionPoint {
  58150. /** @hidden */
  58151. _ownerBlock: NodeMaterialBlock;
  58152. /** @hidden */
  58153. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58154. private _endpoints;
  58155. private _associatedVariableName;
  58156. private _direction;
  58157. /** @hidden */
  58158. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58159. /** @hidden */
  58160. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58161. private _type;
  58162. /** @hidden */
  58163. _enforceAssociatedVariableName: boolean;
  58164. /** Gets the direction of the point */
  58165. get direction(): NodeMaterialConnectionPointDirection;
  58166. /**
  58167. * Gets or sets the additional types supported by this connection point
  58168. */
  58169. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58170. /**
  58171. * Gets or sets the additional types excluded by this connection point
  58172. */
  58173. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58174. /**
  58175. * Observable triggered when this point is connected
  58176. */
  58177. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58178. /**
  58179. * Gets or sets the associated variable name in the shader
  58180. */
  58181. get associatedVariableName(): string;
  58182. set associatedVariableName(value: string);
  58183. /**
  58184. * Gets or sets the connection point type (default is float)
  58185. */
  58186. get type(): NodeMaterialBlockConnectionPointTypes;
  58187. set type(value: NodeMaterialBlockConnectionPointTypes);
  58188. /**
  58189. * Gets or sets the connection point name
  58190. */
  58191. name: string;
  58192. /**
  58193. * Gets or sets a boolean indicating that this connection point can be omitted
  58194. */
  58195. isOptional: boolean;
  58196. /**
  58197. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58198. */
  58199. define: string;
  58200. /** @hidden */
  58201. _prioritizeVertex: boolean;
  58202. private _target;
  58203. /** Gets or sets the target of that connection point */
  58204. get target(): NodeMaterialBlockTargets;
  58205. set target(value: NodeMaterialBlockTargets);
  58206. /**
  58207. * Gets a boolean indicating that the current point is connected
  58208. */
  58209. get isConnected(): boolean;
  58210. /**
  58211. * Gets a boolean indicating that the current point is connected to an input block
  58212. */
  58213. get isConnectedToInputBlock(): boolean;
  58214. /**
  58215. * Gets a the connected input block (if any)
  58216. */
  58217. get connectInputBlock(): Nullable<InputBlock>;
  58218. /** Get the other side of the connection (if any) */
  58219. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58220. /** Get the block that owns this connection point */
  58221. get ownerBlock(): NodeMaterialBlock;
  58222. /** Get the block connected on the other side of this connection (if any) */
  58223. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58224. /** Get the block connected on the endpoints of this connection (if any) */
  58225. get connectedBlocks(): Array<NodeMaterialBlock>;
  58226. /** Gets the list of connected endpoints */
  58227. get endpoints(): NodeMaterialConnectionPoint[];
  58228. /** Gets a boolean indicating if that output point is connected to at least one input */
  58229. get hasEndpoints(): boolean;
  58230. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58231. get isConnectedInVertexShader(): boolean;
  58232. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58233. get isConnectedInFragmentShader(): boolean;
  58234. /**
  58235. * Creates a new connection point
  58236. * @param name defines the connection point name
  58237. * @param ownerBlock defines the block hosting this connection point
  58238. * @param direction defines the direction of the connection point
  58239. */
  58240. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58241. /**
  58242. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58243. * @returns the class name
  58244. */
  58245. getClassName(): string;
  58246. /**
  58247. * Gets a boolean indicating if the current point can be connected to another point
  58248. * @param connectionPoint defines the other connection point
  58249. * @returns a boolean
  58250. */
  58251. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58252. /**
  58253. * Gets a number indicating if the current point can be connected to another point
  58254. * @param connectionPoint defines the other connection point
  58255. * @returns a number defining the compatibility state
  58256. */
  58257. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58258. /**
  58259. * Connect this point to another connection point
  58260. * @param connectionPoint defines the other connection point
  58261. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58262. * @returns the current connection point
  58263. */
  58264. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58265. /**
  58266. * Disconnect this point from one of his endpoint
  58267. * @param endpoint defines the other connection point
  58268. * @returns the current connection point
  58269. */
  58270. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58271. /**
  58272. * Serializes this point in a JSON representation
  58273. * @returns the serialized point object
  58274. */
  58275. serialize(): any;
  58276. /**
  58277. * Release resources
  58278. */
  58279. dispose(): void;
  58280. }
  58281. }
  58282. declare module BABYLON {
  58283. /**
  58284. * Block used to add support for vertex skinning (bones)
  58285. */
  58286. export class BonesBlock extends NodeMaterialBlock {
  58287. /**
  58288. * Creates a new BonesBlock
  58289. * @param name defines the block name
  58290. */
  58291. constructor(name: string);
  58292. /**
  58293. * Initialize the block and prepare the context for build
  58294. * @param state defines the state that will be used for the build
  58295. */
  58296. initialize(state: NodeMaterialBuildState): void;
  58297. /**
  58298. * Gets the current class name
  58299. * @returns the class name
  58300. */
  58301. getClassName(): string;
  58302. /**
  58303. * Gets the matrix indices input component
  58304. */
  58305. get matricesIndices(): NodeMaterialConnectionPoint;
  58306. /**
  58307. * Gets the matrix weights input component
  58308. */
  58309. get matricesWeights(): NodeMaterialConnectionPoint;
  58310. /**
  58311. * Gets the extra matrix indices input component
  58312. */
  58313. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58314. /**
  58315. * Gets the extra matrix weights input component
  58316. */
  58317. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58318. /**
  58319. * Gets the world input component
  58320. */
  58321. get world(): NodeMaterialConnectionPoint;
  58322. /**
  58323. * Gets the output component
  58324. */
  58325. get output(): NodeMaterialConnectionPoint;
  58326. autoConfigure(material: NodeMaterial): void;
  58327. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58330. protected _buildBlock(state: NodeMaterialBuildState): this;
  58331. }
  58332. }
  58333. declare module BABYLON {
  58334. /**
  58335. * Block used to add support for instances
  58336. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58337. */
  58338. export class InstancesBlock extends NodeMaterialBlock {
  58339. /**
  58340. * Creates a new InstancesBlock
  58341. * @param name defines the block name
  58342. */
  58343. constructor(name: string);
  58344. /**
  58345. * Gets the current class name
  58346. * @returns the class name
  58347. */
  58348. getClassName(): string;
  58349. /**
  58350. * Gets the first world row input component
  58351. */
  58352. get world0(): NodeMaterialConnectionPoint;
  58353. /**
  58354. * Gets the second world row input component
  58355. */
  58356. get world1(): NodeMaterialConnectionPoint;
  58357. /**
  58358. * Gets the third world row input component
  58359. */
  58360. get world2(): NodeMaterialConnectionPoint;
  58361. /**
  58362. * Gets the forth world row input component
  58363. */
  58364. get world3(): NodeMaterialConnectionPoint;
  58365. /**
  58366. * Gets the world input component
  58367. */
  58368. get world(): NodeMaterialConnectionPoint;
  58369. /**
  58370. * Gets the output component
  58371. */
  58372. get output(): NodeMaterialConnectionPoint;
  58373. autoConfigure(material: NodeMaterial): void;
  58374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58375. protected _buildBlock(state: NodeMaterialBuildState): this;
  58376. }
  58377. }
  58378. declare module BABYLON {
  58379. /**
  58380. * Block used to add morph targets support to vertex shader
  58381. */
  58382. export class MorphTargetsBlock extends NodeMaterialBlock {
  58383. private _repeatableContentAnchor;
  58384. /**
  58385. * Create a new MorphTargetsBlock
  58386. * @param name defines the block name
  58387. */
  58388. constructor(name: string);
  58389. /**
  58390. * Gets the current class name
  58391. * @returns the class name
  58392. */
  58393. getClassName(): string;
  58394. /**
  58395. * Gets the position input component
  58396. */
  58397. get position(): NodeMaterialConnectionPoint;
  58398. /**
  58399. * Gets the normal input component
  58400. */
  58401. get normal(): NodeMaterialConnectionPoint;
  58402. /**
  58403. * Gets the tangent input component
  58404. */
  58405. get tangent(): NodeMaterialConnectionPoint;
  58406. /**
  58407. * Gets the tangent input component
  58408. */
  58409. get uv(): NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the position output component
  58412. */
  58413. get positionOutput(): NodeMaterialConnectionPoint;
  58414. /**
  58415. * Gets the normal output component
  58416. */
  58417. get normalOutput(): NodeMaterialConnectionPoint;
  58418. /**
  58419. * Gets the tangent output component
  58420. */
  58421. get tangentOutput(): NodeMaterialConnectionPoint;
  58422. /**
  58423. * Gets the tangent output component
  58424. */
  58425. get uvOutput(): NodeMaterialConnectionPoint;
  58426. initialize(state: NodeMaterialBuildState): void;
  58427. autoConfigure(material: NodeMaterial): void;
  58428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58430. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58431. protected _buildBlock(state: NodeMaterialBuildState): this;
  58432. }
  58433. }
  58434. declare module BABYLON {
  58435. /**
  58436. * Block used to get data information from a light
  58437. */
  58438. export class LightInformationBlock extends NodeMaterialBlock {
  58439. private _lightDataUniformName;
  58440. private _lightColorUniformName;
  58441. private _lightTypeDefineName;
  58442. /**
  58443. * Gets or sets the light associated with this block
  58444. */
  58445. light: Nullable<Light>;
  58446. /**
  58447. * Creates a new LightInformationBlock
  58448. * @param name defines the block name
  58449. */
  58450. constructor(name: string);
  58451. /**
  58452. * Gets the current class name
  58453. * @returns the class name
  58454. */
  58455. getClassName(): string;
  58456. /**
  58457. * Gets the world position input component
  58458. */
  58459. get worldPosition(): NodeMaterialConnectionPoint;
  58460. /**
  58461. * Gets the direction output component
  58462. */
  58463. get direction(): NodeMaterialConnectionPoint;
  58464. /**
  58465. * Gets the direction output component
  58466. */
  58467. get color(): NodeMaterialConnectionPoint;
  58468. /**
  58469. * Gets the direction output component
  58470. */
  58471. get intensity(): NodeMaterialConnectionPoint;
  58472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58474. protected _buildBlock(state: NodeMaterialBuildState): this;
  58475. serialize(): any;
  58476. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58477. }
  58478. }
  58479. declare module BABYLON {
  58480. /**
  58481. * Block used to add image processing support to fragment shader
  58482. */
  58483. export class ImageProcessingBlock extends NodeMaterialBlock {
  58484. /**
  58485. * Create a new ImageProcessingBlock
  58486. * @param name defines the block name
  58487. */
  58488. constructor(name: string);
  58489. /**
  58490. * Gets the current class name
  58491. * @returns the class name
  58492. */
  58493. getClassName(): string;
  58494. /**
  58495. * Gets the color input component
  58496. */
  58497. get color(): NodeMaterialConnectionPoint;
  58498. /**
  58499. * Gets the output component
  58500. */
  58501. get output(): NodeMaterialConnectionPoint;
  58502. /**
  58503. * Initialize the block and prepare the context for build
  58504. * @param state defines the state that will be used for the build
  58505. */
  58506. initialize(state: NodeMaterialBuildState): void;
  58507. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58510. protected _buildBlock(state: NodeMaterialBuildState): this;
  58511. }
  58512. }
  58513. declare module BABYLON {
  58514. /**
  58515. * Block used to pertub normals based on a normal map
  58516. */
  58517. export class PerturbNormalBlock extends NodeMaterialBlock {
  58518. private _tangentSpaceParameterName;
  58519. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58520. invertX: boolean;
  58521. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58522. invertY: boolean;
  58523. /**
  58524. * Create a new PerturbNormalBlock
  58525. * @param name defines the block name
  58526. */
  58527. constructor(name: string);
  58528. /**
  58529. * Gets the current class name
  58530. * @returns the class name
  58531. */
  58532. getClassName(): string;
  58533. /**
  58534. * Gets the world position input component
  58535. */
  58536. get worldPosition(): NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the world normal input component
  58539. */
  58540. get worldNormal(): NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the uv input component
  58543. */
  58544. get uv(): NodeMaterialConnectionPoint;
  58545. /**
  58546. * Gets the normal map color input component
  58547. */
  58548. get normalMapColor(): NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the strength input component
  58551. */
  58552. get strength(): NodeMaterialConnectionPoint;
  58553. /**
  58554. * Gets the output component
  58555. */
  58556. get output(): NodeMaterialConnectionPoint;
  58557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58559. autoConfigure(material: NodeMaterial): void;
  58560. protected _buildBlock(state: NodeMaterialBuildState): this;
  58561. protected _dumpPropertiesCode(): string;
  58562. serialize(): any;
  58563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58564. }
  58565. }
  58566. declare module BABYLON {
  58567. /**
  58568. * Block used to discard a pixel if a value is smaller than a cutoff
  58569. */
  58570. export class DiscardBlock extends NodeMaterialBlock {
  58571. /**
  58572. * Create a new DiscardBlock
  58573. * @param name defines the block name
  58574. */
  58575. constructor(name: string);
  58576. /**
  58577. * Gets the current class name
  58578. * @returns the class name
  58579. */
  58580. getClassName(): string;
  58581. /**
  58582. * Gets the color input component
  58583. */
  58584. get value(): NodeMaterialConnectionPoint;
  58585. /**
  58586. * Gets the cutoff input component
  58587. */
  58588. get cutoff(): NodeMaterialConnectionPoint;
  58589. protected _buildBlock(state: NodeMaterialBuildState): this;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * Block used to test if the fragment shader is front facing
  58595. */
  58596. export class FrontFacingBlock extends NodeMaterialBlock {
  58597. /**
  58598. * Creates a new FrontFacingBlock
  58599. * @param name defines the block name
  58600. */
  58601. constructor(name: string);
  58602. /**
  58603. * Gets the current class name
  58604. * @returns the class name
  58605. */
  58606. getClassName(): string;
  58607. /**
  58608. * Gets the output component
  58609. */
  58610. get output(): NodeMaterialConnectionPoint;
  58611. protected _buildBlock(state: NodeMaterialBuildState): this;
  58612. }
  58613. }
  58614. declare module BABYLON {
  58615. /**
  58616. * Block used to get the derivative value on x and y of a given input
  58617. */
  58618. export class DerivativeBlock extends NodeMaterialBlock {
  58619. /**
  58620. * Create a new DerivativeBlock
  58621. * @param name defines the block name
  58622. */
  58623. constructor(name: string);
  58624. /**
  58625. * Gets the current class name
  58626. * @returns the class name
  58627. */
  58628. getClassName(): string;
  58629. /**
  58630. * Gets the input component
  58631. */
  58632. get input(): NodeMaterialConnectionPoint;
  58633. /**
  58634. * Gets the derivative output on x
  58635. */
  58636. get dx(): NodeMaterialConnectionPoint;
  58637. /**
  58638. * Gets the derivative output on y
  58639. */
  58640. get dy(): NodeMaterialConnectionPoint;
  58641. protected _buildBlock(state: NodeMaterialBuildState): this;
  58642. }
  58643. }
  58644. declare module BABYLON {
  58645. /**
  58646. * Block used to add support for scene fog
  58647. */
  58648. export class FogBlock extends NodeMaterialBlock {
  58649. private _fogDistanceName;
  58650. private _fogParameters;
  58651. /**
  58652. * Create a new FogBlock
  58653. * @param name defines the block name
  58654. */
  58655. constructor(name: string);
  58656. /**
  58657. * Gets the current class name
  58658. * @returns the class name
  58659. */
  58660. getClassName(): string;
  58661. /**
  58662. * Gets the world position input component
  58663. */
  58664. get worldPosition(): NodeMaterialConnectionPoint;
  58665. /**
  58666. * Gets the view input component
  58667. */
  58668. get view(): NodeMaterialConnectionPoint;
  58669. /**
  58670. * Gets the color input component
  58671. */
  58672. get input(): NodeMaterialConnectionPoint;
  58673. /**
  58674. * Gets the fog color input component
  58675. */
  58676. get fogColor(): NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the output component
  58679. */
  58680. get output(): NodeMaterialConnectionPoint;
  58681. autoConfigure(material: NodeMaterial): void;
  58682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58683. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58684. protected _buildBlock(state: NodeMaterialBuildState): this;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Block used to add light in the fragment shader
  58690. */
  58691. export class LightBlock extends NodeMaterialBlock {
  58692. private _lightId;
  58693. /**
  58694. * Gets or sets the light associated with this block
  58695. */
  58696. light: Nullable<Light>;
  58697. /**
  58698. * Create a new LightBlock
  58699. * @param name defines the block name
  58700. */
  58701. constructor(name: string);
  58702. /**
  58703. * Gets the current class name
  58704. * @returns the class name
  58705. */
  58706. getClassName(): string;
  58707. /**
  58708. * Gets the world position input component
  58709. */
  58710. get worldPosition(): NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the world normal input component
  58713. */
  58714. get worldNormal(): NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the camera (or eye) position component
  58717. */
  58718. get cameraPosition(): NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the glossiness component
  58721. */
  58722. get glossiness(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the glossinness power component
  58725. */
  58726. get glossPower(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the diffuse color component
  58729. */
  58730. get diffuseColor(): NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the specular color component
  58733. */
  58734. get specularColor(): NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the diffuse output component
  58737. */
  58738. get diffuseOutput(): NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the specular output component
  58741. */
  58742. get specularOutput(): NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the shadow output component
  58745. */
  58746. get shadow(): NodeMaterialConnectionPoint;
  58747. autoConfigure(material: NodeMaterial): void;
  58748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58749. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58751. private _injectVertexCode;
  58752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58753. serialize(): any;
  58754. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58755. }
  58756. }
  58757. declare module BABYLON {
  58758. /**
  58759. * Block used to multiply 2 values
  58760. */
  58761. export class MultiplyBlock extends NodeMaterialBlock {
  58762. /**
  58763. * Creates a new MultiplyBlock
  58764. * @param name defines the block name
  58765. */
  58766. constructor(name: string);
  58767. /**
  58768. * Gets the current class name
  58769. * @returns the class name
  58770. */
  58771. getClassName(): string;
  58772. /**
  58773. * Gets the left operand input component
  58774. */
  58775. get left(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the right operand input component
  58778. */
  58779. get right(): NodeMaterialConnectionPoint;
  58780. /**
  58781. * Gets the output component
  58782. */
  58783. get output(): NodeMaterialConnectionPoint;
  58784. protected _buildBlock(state: NodeMaterialBuildState): this;
  58785. }
  58786. }
  58787. declare module BABYLON {
  58788. /**
  58789. * Block used to add 2 vectors
  58790. */
  58791. export class AddBlock extends NodeMaterialBlock {
  58792. /**
  58793. * Creates a new AddBlock
  58794. * @param name defines the block name
  58795. */
  58796. constructor(name: string);
  58797. /**
  58798. * Gets the current class name
  58799. * @returns the class name
  58800. */
  58801. getClassName(): string;
  58802. /**
  58803. * Gets the left operand input component
  58804. */
  58805. get left(): NodeMaterialConnectionPoint;
  58806. /**
  58807. * Gets the right operand input component
  58808. */
  58809. get right(): NodeMaterialConnectionPoint;
  58810. /**
  58811. * Gets the output component
  58812. */
  58813. get output(): NodeMaterialConnectionPoint;
  58814. protected _buildBlock(state: NodeMaterialBuildState): this;
  58815. }
  58816. }
  58817. declare module BABYLON {
  58818. /**
  58819. * Block used to scale a vector by a float
  58820. */
  58821. export class ScaleBlock extends NodeMaterialBlock {
  58822. /**
  58823. * Creates a new ScaleBlock
  58824. * @param name defines the block name
  58825. */
  58826. constructor(name: string);
  58827. /**
  58828. * Gets the current class name
  58829. * @returns the class name
  58830. */
  58831. getClassName(): string;
  58832. /**
  58833. * Gets the input component
  58834. */
  58835. get input(): NodeMaterialConnectionPoint;
  58836. /**
  58837. * Gets the factor input component
  58838. */
  58839. get factor(): NodeMaterialConnectionPoint;
  58840. /**
  58841. * Gets the output component
  58842. */
  58843. get output(): NodeMaterialConnectionPoint;
  58844. protected _buildBlock(state: NodeMaterialBuildState): this;
  58845. }
  58846. }
  58847. declare module BABYLON {
  58848. /**
  58849. * Block used to clamp a float
  58850. */
  58851. export class ClampBlock extends NodeMaterialBlock {
  58852. /** Gets or sets the minimum range */
  58853. minimum: number;
  58854. /** Gets or sets the maximum range */
  58855. maximum: number;
  58856. /**
  58857. * Creates a new ClampBlock
  58858. * @param name defines the block name
  58859. */
  58860. constructor(name: string);
  58861. /**
  58862. * Gets the current class name
  58863. * @returns the class name
  58864. */
  58865. getClassName(): string;
  58866. /**
  58867. * Gets the value input component
  58868. */
  58869. get value(): NodeMaterialConnectionPoint;
  58870. /**
  58871. * Gets the output component
  58872. */
  58873. get output(): NodeMaterialConnectionPoint;
  58874. protected _buildBlock(state: NodeMaterialBuildState): this;
  58875. protected _dumpPropertiesCode(): string;
  58876. serialize(): any;
  58877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58878. }
  58879. }
  58880. declare module BABYLON {
  58881. /**
  58882. * Block used to apply a cross product between 2 vectors
  58883. */
  58884. export class CrossBlock extends NodeMaterialBlock {
  58885. /**
  58886. * Creates a new CrossBlock
  58887. * @param name defines the block name
  58888. */
  58889. constructor(name: string);
  58890. /**
  58891. * Gets the current class name
  58892. * @returns the class name
  58893. */
  58894. getClassName(): string;
  58895. /**
  58896. * Gets the left operand input component
  58897. */
  58898. get left(): NodeMaterialConnectionPoint;
  58899. /**
  58900. * Gets the right operand input component
  58901. */
  58902. get right(): NodeMaterialConnectionPoint;
  58903. /**
  58904. * Gets the output component
  58905. */
  58906. get output(): NodeMaterialConnectionPoint;
  58907. protected _buildBlock(state: NodeMaterialBuildState): this;
  58908. }
  58909. }
  58910. declare module BABYLON {
  58911. /**
  58912. * Block used to apply a dot product between 2 vectors
  58913. */
  58914. export class DotBlock extends NodeMaterialBlock {
  58915. /**
  58916. * Creates a new DotBlock
  58917. * @param name defines the block name
  58918. */
  58919. constructor(name: string);
  58920. /**
  58921. * Gets the current class name
  58922. * @returns the class name
  58923. */
  58924. getClassName(): string;
  58925. /**
  58926. * Gets the left operand input component
  58927. */
  58928. get left(): NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the right operand input component
  58931. */
  58932. get right(): NodeMaterialConnectionPoint;
  58933. /**
  58934. * Gets the output component
  58935. */
  58936. get output(): NodeMaterialConnectionPoint;
  58937. protected _buildBlock(state: NodeMaterialBuildState): this;
  58938. }
  58939. }
  58940. declare module BABYLON {
  58941. /**
  58942. * Block used to remap a float from a range to a new one
  58943. */
  58944. export class RemapBlock extends NodeMaterialBlock {
  58945. /**
  58946. * Gets or sets the source range
  58947. */
  58948. sourceRange: Vector2;
  58949. /**
  58950. * Gets or sets the target range
  58951. */
  58952. targetRange: Vector2;
  58953. /**
  58954. * Creates a new RemapBlock
  58955. * @param name defines the block name
  58956. */
  58957. constructor(name: string);
  58958. /**
  58959. * Gets the current class name
  58960. * @returns the class name
  58961. */
  58962. getClassName(): string;
  58963. /**
  58964. * Gets the input component
  58965. */
  58966. get input(): NodeMaterialConnectionPoint;
  58967. /**
  58968. * Gets the source min input component
  58969. */
  58970. get sourceMin(): NodeMaterialConnectionPoint;
  58971. /**
  58972. * Gets the source max input component
  58973. */
  58974. get sourceMax(): NodeMaterialConnectionPoint;
  58975. /**
  58976. * Gets the target min input component
  58977. */
  58978. get targetMin(): NodeMaterialConnectionPoint;
  58979. /**
  58980. * Gets the target max input component
  58981. */
  58982. get targetMax(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the output component
  58985. */
  58986. get output(): NodeMaterialConnectionPoint;
  58987. protected _buildBlock(state: NodeMaterialBuildState): this;
  58988. protected _dumpPropertiesCode(): string;
  58989. serialize(): any;
  58990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * Block used to normalize a vector
  58996. */
  58997. export class NormalizeBlock extends NodeMaterialBlock {
  58998. /**
  58999. * Creates a new NormalizeBlock
  59000. * @param name defines the block name
  59001. */
  59002. constructor(name: string);
  59003. /**
  59004. * Gets the current class name
  59005. * @returns the class name
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Gets the input component
  59010. */
  59011. get input(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the output component
  59014. */
  59015. get output(): NodeMaterialConnectionPoint;
  59016. protected _buildBlock(state: NodeMaterialBuildState): this;
  59017. }
  59018. }
  59019. declare module BABYLON {
  59020. /**
  59021. * Operations supported by the Trigonometry block
  59022. */
  59023. export enum TrigonometryBlockOperations {
  59024. /** Cos */
  59025. Cos = 0,
  59026. /** Sin */
  59027. Sin = 1,
  59028. /** Abs */
  59029. Abs = 2,
  59030. /** Exp */
  59031. Exp = 3,
  59032. /** Exp2 */
  59033. Exp2 = 4,
  59034. /** Round */
  59035. Round = 5,
  59036. /** Floor */
  59037. Floor = 6,
  59038. /** Ceiling */
  59039. Ceiling = 7,
  59040. /** Square root */
  59041. Sqrt = 8,
  59042. /** Log */
  59043. Log = 9,
  59044. /** Tangent */
  59045. Tan = 10,
  59046. /** Arc tangent */
  59047. ArcTan = 11,
  59048. /** Arc cosinus */
  59049. ArcCos = 12,
  59050. /** Arc sinus */
  59051. ArcSin = 13,
  59052. /** Fraction */
  59053. Fract = 14,
  59054. /** Sign */
  59055. Sign = 15,
  59056. /** To radians (from degrees) */
  59057. Radians = 16,
  59058. /** To degrees (from radians) */
  59059. Degrees = 17
  59060. }
  59061. /**
  59062. * Block used to apply trigonometry operation to floats
  59063. */
  59064. export class TrigonometryBlock extends NodeMaterialBlock {
  59065. /**
  59066. * Gets or sets the operation applied by the block
  59067. */
  59068. operation: TrigonometryBlockOperations;
  59069. /**
  59070. * Creates a new TrigonometryBlock
  59071. * @param name defines the block name
  59072. */
  59073. constructor(name: string);
  59074. /**
  59075. * Gets the current class name
  59076. * @returns the class name
  59077. */
  59078. getClassName(): string;
  59079. /**
  59080. * Gets the input component
  59081. */
  59082. get input(): NodeMaterialConnectionPoint;
  59083. /**
  59084. * Gets the output component
  59085. */
  59086. get output(): NodeMaterialConnectionPoint;
  59087. protected _buildBlock(state: NodeMaterialBuildState): this;
  59088. serialize(): any;
  59089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59090. protected _dumpPropertiesCode(): string;
  59091. }
  59092. }
  59093. declare module BABYLON {
  59094. /**
  59095. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59096. */
  59097. export class ColorMergerBlock extends NodeMaterialBlock {
  59098. /**
  59099. * Create a new ColorMergerBlock
  59100. * @param name defines the block name
  59101. */
  59102. constructor(name: string);
  59103. /**
  59104. * Gets the current class name
  59105. * @returns the class name
  59106. */
  59107. getClassName(): string;
  59108. /**
  59109. * Gets the rgb component (input)
  59110. */
  59111. get rgbIn(): NodeMaterialConnectionPoint;
  59112. /**
  59113. * Gets the r component (input)
  59114. */
  59115. get r(): NodeMaterialConnectionPoint;
  59116. /**
  59117. * Gets the g component (input)
  59118. */
  59119. get g(): NodeMaterialConnectionPoint;
  59120. /**
  59121. * Gets the b component (input)
  59122. */
  59123. get b(): NodeMaterialConnectionPoint;
  59124. /**
  59125. * Gets the a component (input)
  59126. */
  59127. get a(): NodeMaterialConnectionPoint;
  59128. /**
  59129. * Gets the rgba component (output)
  59130. */
  59131. get rgba(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the rgb component (output)
  59134. */
  59135. get rgbOut(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the rgb component (output)
  59138. * @deprecated Please use rgbOut instead.
  59139. */
  59140. get rgb(): NodeMaterialConnectionPoint;
  59141. protected _buildBlock(state: NodeMaterialBuildState): this;
  59142. }
  59143. }
  59144. declare module BABYLON {
  59145. /**
  59146. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59147. */
  59148. export class VectorMergerBlock extends NodeMaterialBlock {
  59149. /**
  59150. * Create a new VectorMergerBlock
  59151. * @param name defines the block name
  59152. */
  59153. constructor(name: string);
  59154. /**
  59155. * Gets the current class name
  59156. * @returns the class name
  59157. */
  59158. getClassName(): string;
  59159. /**
  59160. * Gets the xyz component (input)
  59161. */
  59162. get xyzIn(): NodeMaterialConnectionPoint;
  59163. /**
  59164. * Gets the xy component (input)
  59165. */
  59166. get xyIn(): NodeMaterialConnectionPoint;
  59167. /**
  59168. * Gets the x component (input)
  59169. */
  59170. get x(): NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the y component (input)
  59173. */
  59174. get y(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the z component (input)
  59177. */
  59178. get z(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the w component (input)
  59181. */
  59182. get w(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the xyzw component (output)
  59185. */
  59186. get xyzw(): NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the xyz component (output)
  59189. */
  59190. get xyzOut(): NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the xy component (output)
  59193. */
  59194. get xyOut(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the xy component (output)
  59197. * @deprecated Please use xyOut instead.
  59198. */
  59199. get xy(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the xyz component (output)
  59202. * @deprecated Please use xyzOut instead.
  59203. */
  59204. get xyz(): NodeMaterialConnectionPoint;
  59205. protected _buildBlock(state: NodeMaterialBuildState): this;
  59206. }
  59207. }
  59208. declare module BABYLON {
  59209. /**
  59210. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59211. */
  59212. export class ColorSplitterBlock extends NodeMaterialBlock {
  59213. /**
  59214. * Create a new ColorSplitterBlock
  59215. * @param name defines the block name
  59216. */
  59217. constructor(name: string);
  59218. /**
  59219. * Gets the current class name
  59220. * @returns the class name
  59221. */
  59222. getClassName(): string;
  59223. /**
  59224. * Gets the rgba component (input)
  59225. */
  59226. get rgba(): NodeMaterialConnectionPoint;
  59227. /**
  59228. * Gets the rgb component (input)
  59229. */
  59230. get rgbIn(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the rgb component (output)
  59233. */
  59234. get rgbOut(): NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the r component (output)
  59237. */
  59238. get r(): NodeMaterialConnectionPoint;
  59239. /**
  59240. * Gets the g component (output)
  59241. */
  59242. get g(): NodeMaterialConnectionPoint;
  59243. /**
  59244. * Gets the b component (output)
  59245. */
  59246. get b(): NodeMaterialConnectionPoint;
  59247. /**
  59248. * Gets the a component (output)
  59249. */
  59250. get a(): NodeMaterialConnectionPoint;
  59251. protected _inputRename(name: string): string;
  59252. protected _outputRename(name: string): string;
  59253. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59254. }
  59255. }
  59256. declare module BABYLON {
  59257. /**
  59258. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59259. */
  59260. export class VectorSplitterBlock extends NodeMaterialBlock {
  59261. /**
  59262. * Create a new VectorSplitterBlock
  59263. * @param name defines the block name
  59264. */
  59265. constructor(name: string);
  59266. /**
  59267. * Gets the current class name
  59268. * @returns the class name
  59269. */
  59270. getClassName(): string;
  59271. /**
  59272. * Gets the xyzw component (input)
  59273. */
  59274. get xyzw(): NodeMaterialConnectionPoint;
  59275. /**
  59276. * Gets the xyz component (input)
  59277. */
  59278. get xyzIn(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the xy component (input)
  59281. */
  59282. get xyIn(): NodeMaterialConnectionPoint;
  59283. /**
  59284. * Gets the xyz component (output)
  59285. */
  59286. get xyzOut(): NodeMaterialConnectionPoint;
  59287. /**
  59288. * Gets the xy component (output)
  59289. */
  59290. get xyOut(): NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the x component (output)
  59293. */
  59294. get x(): NodeMaterialConnectionPoint;
  59295. /**
  59296. * Gets the y component (output)
  59297. */
  59298. get y(): NodeMaterialConnectionPoint;
  59299. /**
  59300. * Gets the z component (output)
  59301. */
  59302. get z(): NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the w component (output)
  59305. */
  59306. get w(): NodeMaterialConnectionPoint;
  59307. protected _inputRename(name: string): string;
  59308. protected _outputRename(name: string): string;
  59309. protected _buildBlock(state: NodeMaterialBuildState): this;
  59310. }
  59311. }
  59312. declare module BABYLON {
  59313. /**
  59314. * Block used to lerp between 2 values
  59315. */
  59316. export class LerpBlock extends NodeMaterialBlock {
  59317. /**
  59318. * Creates a new LerpBlock
  59319. * @param name defines the block name
  59320. */
  59321. constructor(name: string);
  59322. /**
  59323. * Gets the current class name
  59324. * @returns the class name
  59325. */
  59326. getClassName(): string;
  59327. /**
  59328. * Gets the left operand input component
  59329. */
  59330. get left(): NodeMaterialConnectionPoint;
  59331. /**
  59332. * Gets the right operand input component
  59333. */
  59334. get right(): NodeMaterialConnectionPoint;
  59335. /**
  59336. * Gets the gradient operand input component
  59337. */
  59338. get gradient(): NodeMaterialConnectionPoint;
  59339. /**
  59340. * Gets the output component
  59341. */
  59342. get output(): NodeMaterialConnectionPoint;
  59343. protected _buildBlock(state: NodeMaterialBuildState): this;
  59344. }
  59345. }
  59346. declare module BABYLON {
  59347. /**
  59348. * Block used to divide 2 vectors
  59349. */
  59350. export class DivideBlock extends NodeMaterialBlock {
  59351. /**
  59352. * Creates a new DivideBlock
  59353. * @param name defines the block name
  59354. */
  59355. constructor(name: string);
  59356. /**
  59357. * Gets the current class name
  59358. * @returns the class name
  59359. */
  59360. getClassName(): string;
  59361. /**
  59362. * Gets the left operand input component
  59363. */
  59364. get left(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the right operand input component
  59367. */
  59368. get right(): NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the output component
  59371. */
  59372. get output(): NodeMaterialConnectionPoint;
  59373. protected _buildBlock(state: NodeMaterialBuildState): this;
  59374. }
  59375. }
  59376. declare module BABYLON {
  59377. /**
  59378. * Block used to subtract 2 vectors
  59379. */
  59380. export class SubtractBlock extends NodeMaterialBlock {
  59381. /**
  59382. * Creates a new SubtractBlock
  59383. * @param name defines the block name
  59384. */
  59385. constructor(name: string);
  59386. /**
  59387. * Gets the current class name
  59388. * @returns the class name
  59389. */
  59390. getClassName(): string;
  59391. /**
  59392. * Gets the left operand input component
  59393. */
  59394. get left(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the right operand input component
  59397. */
  59398. get right(): NodeMaterialConnectionPoint;
  59399. /**
  59400. * Gets the output component
  59401. */
  59402. get output(): NodeMaterialConnectionPoint;
  59403. protected _buildBlock(state: NodeMaterialBuildState): this;
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /**
  59408. * Block used to step a value
  59409. */
  59410. export class StepBlock extends NodeMaterialBlock {
  59411. /**
  59412. * Creates a new StepBlock
  59413. * @param name defines the block name
  59414. */
  59415. constructor(name: string);
  59416. /**
  59417. * Gets the current class name
  59418. * @returns the class name
  59419. */
  59420. getClassName(): string;
  59421. /**
  59422. * Gets the value operand input component
  59423. */
  59424. get value(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the edge operand input component
  59427. */
  59428. get edge(): NodeMaterialConnectionPoint;
  59429. /**
  59430. * Gets the output component
  59431. */
  59432. get output(): NodeMaterialConnectionPoint;
  59433. protected _buildBlock(state: NodeMaterialBuildState): this;
  59434. }
  59435. }
  59436. declare module BABYLON {
  59437. /**
  59438. * Block used to get the opposite (1 - x) of a value
  59439. */
  59440. export class OneMinusBlock extends NodeMaterialBlock {
  59441. /**
  59442. * Creates a new OneMinusBlock
  59443. * @param name defines the block name
  59444. */
  59445. constructor(name: string);
  59446. /**
  59447. * Gets the current class name
  59448. * @returns the class name
  59449. */
  59450. getClassName(): string;
  59451. /**
  59452. * Gets the input component
  59453. */
  59454. get input(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the output component
  59457. */
  59458. get output(): NodeMaterialConnectionPoint;
  59459. protected _buildBlock(state: NodeMaterialBuildState): this;
  59460. }
  59461. }
  59462. declare module BABYLON {
  59463. /**
  59464. * Block used to get the view direction
  59465. */
  59466. export class ViewDirectionBlock extends NodeMaterialBlock {
  59467. /**
  59468. * Creates a new ViewDirectionBlock
  59469. * @param name defines the block name
  59470. */
  59471. constructor(name: string);
  59472. /**
  59473. * Gets the current class name
  59474. * @returns the class name
  59475. */
  59476. getClassName(): string;
  59477. /**
  59478. * Gets the world position component
  59479. */
  59480. get worldPosition(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the camera position component
  59483. */
  59484. get cameraPosition(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the output component
  59487. */
  59488. get output(): NodeMaterialConnectionPoint;
  59489. autoConfigure(material: NodeMaterial): void;
  59490. protected _buildBlock(state: NodeMaterialBuildState): this;
  59491. }
  59492. }
  59493. declare module BABYLON {
  59494. /**
  59495. * Block used to compute fresnel value
  59496. */
  59497. export class FresnelBlock extends NodeMaterialBlock {
  59498. /**
  59499. * Create a new FresnelBlock
  59500. * @param name defines the block name
  59501. */
  59502. constructor(name: string);
  59503. /**
  59504. * Gets the current class name
  59505. * @returns the class name
  59506. */
  59507. getClassName(): string;
  59508. /**
  59509. * Gets the world normal input component
  59510. */
  59511. get worldNormal(): NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the view direction input component
  59514. */
  59515. get viewDirection(): NodeMaterialConnectionPoint;
  59516. /**
  59517. * Gets the bias input component
  59518. */
  59519. get bias(): NodeMaterialConnectionPoint;
  59520. /**
  59521. * Gets the camera (or eye) position component
  59522. */
  59523. get power(): NodeMaterialConnectionPoint;
  59524. /**
  59525. * Gets the fresnel output component
  59526. */
  59527. get fresnel(): NodeMaterialConnectionPoint;
  59528. autoConfigure(material: NodeMaterial): void;
  59529. protected _buildBlock(state: NodeMaterialBuildState): this;
  59530. }
  59531. }
  59532. declare module BABYLON {
  59533. /**
  59534. * Block used to get the max of 2 values
  59535. */
  59536. export class MaxBlock extends NodeMaterialBlock {
  59537. /**
  59538. * Creates a new MaxBlock
  59539. * @param name defines the block name
  59540. */
  59541. constructor(name: string);
  59542. /**
  59543. * Gets the current class name
  59544. * @returns the class name
  59545. */
  59546. getClassName(): string;
  59547. /**
  59548. * Gets the left operand input component
  59549. */
  59550. get left(): NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the right operand input component
  59553. */
  59554. get right(): NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the output component
  59557. */
  59558. get output(): NodeMaterialConnectionPoint;
  59559. protected _buildBlock(state: NodeMaterialBuildState): this;
  59560. }
  59561. }
  59562. declare module BABYLON {
  59563. /**
  59564. * Block used to get the min of 2 values
  59565. */
  59566. export class MinBlock extends NodeMaterialBlock {
  59567. /**
  59568. * Creates a new MinBlock
  59569. * @param name defines the block name
  59570. */
  59571. constructor(name: string);
  59572. /**
  59573. * Gets the current class name
  59574. * @returns the class name
  59575. */
  59576. getClassName(): string;
  59577. /**
  59578. * Gets the left operand input component
  59579. */
  59580. get left(): NodeMaterialConnectionPoint;
  59581. /**
  59582. * Gets the right operand input component
  59583. */
  59584. get right(): NodeMaterialConnectionPoint;
  59585. /**
  59586. * Gets the output component
  59587. */
  59588. get output(): NodeMaterialConnectionPoint;
  59589. protected _buildBlock(state: NodeMaterialBuildState): this;
  59590. }
  59591. }
  59592. declare module BABYLON {
  59593. /**
  59594. * Block used to get the distance between 2 values
  59595. */
  59596. export class DistanceBlock extends NodeMaterialBlock {
  59597. /**
  59598. * Creates a new DistanceBlock
  59599. * @param name defines the block name
  59600. */
  59601. constructor(name: string);
  59602. /**
  59603. * Gets the current class name
  59604. * @returns the class name
  59605. */
  59606. getClassName(): string;
  59607. /**
  59608. * Gets the left operand input component
  59609. */
  59610. get left(): NodeMaterialConnectionPoint;
  59611. /**
  59612. * Gets the right operand input component
  59613. */
  59614. get right(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the output component
  59617. */
  59618. get output(): NodeMaterialConnectionPoint;
  59619. protected _buildBlock(state: NodeMaterialBuildState): this;
  59620. }
  59621. }
  59622. declare module BABYLON {
  59623. /**
  59624. * Block used to get the length of a vector
  59625. */
  59626. export class LengthBlock extends NodeMaterialBlock {
  59627. /**
  59628. * Creates a new LengthBlock
  59629. * @param name defines the block name
  59630. */
  59631. constructor(name: string);
  59632. /**
  59633. * Gets the current class name
  59634. * @returns the class name
  59635. */
  59636. getClassName(): string;
  59637. /**
  59638. * Gets the value input component
  59639. */
  59640. get value(): NodeMaterialConnectionPoint;
  59641. /**
  59642. * Gets the output component
  59643. */
  59644. get output(): NodeMaterialConnectionPoint;
  59645. protected _buildBlock(state: NodeMaterialBuildState): this;
  59646. }
  59647. }
  59648. declare module BABYLON {
  59649. /**
  59650. * Block used to get negative version of a value (i.e. x * -1)
  59651. */
  59652. export class NegateBlock extends NodeMaterialBlock {
  59653. /**
  59654. * Creates a new NegateBlock
  59655. * @param name defines the block name
  59656. */
  59657. constructor(name: string);
  59658. /**
  59659. * Gets the current class name
  59660. * @returns the class name
  59661. */
  59662. getClassName(): string;
  59663. /**
  59664. * Gets the value input component
  59665. */
  59666. get value(): NodeMaterialConnectionPoint;
  59667. /**
  59668. * Gets the output component
  59669. */
  59670. get output(): NodeMaterialConnectionPoint;
  59671. protected _buildBlock(state: NodeMaterialBuildState): this;
  59672. }
  59673. }
  59674. declare module BABYLON {
  59675. /**
  59676. * Block used to get the value of the first parameter raised to the power of the second
  59677. */
  59678. export class PowBlock extends NodeMaterialBlock {
  59679. /**
  59680. * Creates a new PowBlock
  59681. * @param name defines the block name
  59682. */
  59683. constructor(name: string);
  59684. /**
  59685. * Gets the current class name
  59686. * @returns the class name
  59687. */
  59688. getClassName(): string;
  59689. /**
  59690. * Gets the value operand input component
  59691. */
  59692. get value(): NodeMaterialConnectionPoint;
  59693. /**
  59694. * Gets the power operand input component
  59695. */
  59696. get power(): NodeMaterialConnectionPoint;
  59697. /**
  59698. * Gets the output component
  59699. */
  59700. get output(): NodeMaterialConnectionPoint;
  59701. protected _buildBlock(state: NodeMaterialBuildState): this;
  59702. }
  59703. }
  59704. declare module BABYLON {
  59705. /**
  59706. * Block used to get a random number
  59707. */
  59708. export class RandomNumberBlock extends NodeMaterialBlock {
  59709. /**
  59710. * Creates a new RandomNumberBlock
  59711. * @param name defines the block name
  59712. */
  59713. constructor(name: string);
  59714. /**
  59715. * Gets the current class name
  59716. * @returns the class name
  59717. */
  59718. getClassName(): string;
  59719. /**
  59720. * Gets the seed input component
  59721. */
  59722. get seed(): NodeMaterialConnectionPoint;
  59723. /**
  59724. * Gets the output component
  59725. */
  59726. get output(): NodeMaterialConnectionPoint;
  59727. protected _buildBlock(state: NodeMaterialBuildState): this;
  59728. }
  59729. }
  59730. declare module BABYLON {
  59731. /**
  59732. * Block used to compute arc tangent of 2 values
  59733. */
  59734. export class ArcTan2Block extends NodeMaterialBlock {
  59735. /**
  59736. * Creates a new ArcTan2Block
  59737. * @param name defines the block name
  59738. */
  59739. constructor(name: string);
  59740. /**
  59741. * Gets the current class name
  59742. * @returns the class name
  59743. */
  59744. getClassName(): string;
  59745. /**
  59746. * Gets the x operand input component
  59747. */
  59748. get x(): NodeMaterialConnectionPoint;
  59749. /**
  59750. * Gets the y operand input component
  59751. */
  59752. get y(): NodeMaterialConnectionPoint;
  59753. /**
  59754. * Gets the output component
  59755. */
  59756. get output(): NodeMaterialConnectionPoint;
  59757. protected _buildBlock(state: NodeMaterialBuildState): this;
  59758. }
  59759. }
  59760. declare module BABYLON {
  59761. /**
  59762. * Block used to smooth step a value
  59763. */
  59764. export class SmoothStepBlock extends NodeMaterialBlock {
  59765. /**
  59766. * Creates a new SmoothStepBlock
  59767. * @param name defines the block name
  59768. */
  59769. constructor(name: string);
  59770. /**
  59771. * Gets the current class name
  59772. * @returns the class name
  59773. */
  59774. getClassName(): string;
  59775. /**
  59776. * Gets the value operand input component
  59777. */
  59778. get value(): NodeMaterialConnectionPoint;
  59779. /**
  59780. * Gets the first edge operand input component
  59781. */
  59782. get edge0(): NodeMaterialConnectionPoint;
  59783. /**
  59784. * Gets the second edge operand input component
  59785. */
  59786. get edge1(): NodeMaterialConnectionPoint;
  59787. /**
  59788. * Gets the output component
  59789. */
  59790. get output(): NodeMaterialConnectionPoint;
  59791. protected _buildBlock(state: NodeMaterialBuildState): this;
  59792. }
  59793. }
  59794. declare module BABYLON {
  59795. /**
  59796. * Block used to get the reciprocal (1 / x) of a value
  59797. */
  59798. export class ReciprocalBlock extends NodeMaterialBlock {
  59799. /**
  59800. * Creates a new ReciprocalBlock
  59801. * @param name defines the block name
  59802. */
  59803. constructor(name: string);
  59804. /**
  59805. * Gets the current class name
  59806. * @returns the class name
  59807. */
  59808. getClassName(): string;
  59809. /**
  59810. * Gets the input component
  59811. */
  59812. get input(): NodeMaterialConnectionPoint;
  59813. /**
  59814. * Gets the output component
  59815. */
  59816. get output(): NodeMaterialConnectionPoint;
  59817. protected _buildBlock(state: NodeMaterialBuildState): this;
  59818. }
  59819. }
  59820. declare module BABYLON {
  59821. /**
  59822. * Block used to replace a color by another one
  59823. */
  59824. export class ReplaceColorBlock extends NodeMaterialBlock {
  59825. /**
  59826. * Creates a new ReplaceColorBlock
  59827. * @param name defines the block name
  59828. */
  59829. constructor(name: string);
  59830. /**
  59831. * Gets the current class name
  59832. * @returns the class name
  59833. */
  59834. getClassName(): string;
  59835. /**
  59836. * Gets the value input component
  59837. */
  59838. get value(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the reference input component
  59841. */
  59842. get reference(): NodeMaterialConnectionPoint;
  59843. /**
  59844. * Gets the distance input component
  59845. */
  59846. get distance(): NodeMaterialConnectionPoint;
  59847. /**
  59848. * Gets the replacement input component
  59849. */
  59850. get replacement(): NodeMaterialConnectionPoint;
  59851. /**
  59852. * Gets the output component
  59853. */
  59854. get output(): NodeMaterialConnectionPoint;
  59855. protected _buildBlock(state: NodeMaterialBuildState): this;
  59856. }
  59857. }
  59858. declare module BABYLON {
  59859. /**
  59860. * Block used to posterize a value
  59861. * @see https://en.wikipedia.org/wiki/Posterization
  59862. */
  59863. export class PosterizeBlock extends NodeMaterialBlock {
  59864. /**
  59865. * Creates a new PosterizeBlock
  59866. * @param name defines the block name
  59867. */
  59868. constructor(name: string);
  59869. /**
  59870. * Gets the current class name
  59871. * @returns the class name
  59872. */
  59873. getClassName(): string;
  59874. /**
  59875. * Gets the value input component
  59876. */
  59877. get value(): NodeMaterialConnectionPoint;
  59878. /**
  59879. * Gets the steps input component
  59880. */
  59881. get steps(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the output component
  59884. */
  59885. get output(): NodeMaterialConnectionPoint;
  59886. protected _buildBlock(state: NodeMaterialBuildState): this;
  59887. }
  59888. }
  59889. declare module BABYLON {
  59890. /**
  59891. * Operations supported by the Wave block
  59892. */
  59893. export enum WaveBlockKind {
  59894. /** SawTooth */
  59895. SawTooth = 0,
  59896. /** Square */
  59897. Square = 1,
  59898. /** Triangle */
  59899. Triangle = 2
  59900. }
  59901. /**
  59902. * Block used to apply wave operation to floats
  59903. */
  59904. export class WaveBlock extends NodeMaterialBlock {
  59905. /**
  59906. * Gets or sets the kibnd of wave to be applied by the block
  59907. */
  59908. kind: WaveBlockKind;
  59909. /**
  59910. * Creates a new WaveBlock
  59911. * @param name defines the block name
  59912. */
  59913. constructor(name: string);
  59914. /**
  59915. * Gets the current class name
  59916. * @returns the class name
  59917. */
  59918. getClassName(): string;
  59919. /**
  59920. * Gets the input component
  59921. */
  59922. get input(): NodeMaterialConnectionPoint;
  59923. /**
  59924. * Gets the output component
  59925. */
  59926. get output(): NodeMaterialConnectionPoint;
  59927. protected _buildBlock(state: NodeMaterialBuildState): this;
  59928. serialize(): any;
  59929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59930. }
  59931. }
  59932. declare module BABYLON {
  59933. /**
  59934. * Class used to store a color step for the GradientBlock
  59935. */
  59936. export class GradientBlockColorStep {
  59937. /**
  59938. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59939. */
  59940. step: number;
  59941. /**
  59942. * Gets or sets the color associated with this step
  59943. */
  59944. color: Color3;
  59945. /**
  59946. * Creates a new GradientBlockColorStep
  59947. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59948. * @param color defines the color associated with this step
  59949. */
  59950. constructor(
  59951. /**
  59952. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59953. */
  59954. step: number,
  59955. /**
  59956. * Gets or sets the color associated with this step
  59957. */
  59958. color: Color3);
  59959. }
  59960. /**
  59961. * Block used to return a color from a gradient based on an input value between 0 and 1
  59962. */
  59963. export class GradientBlock extends NodeMaterialBlock {
  59964. /**
  59965. * Gets or sets the list of color steps
  59966. */
  59967. colorSteps: GradientBlockColorStep[];
  59968. /**
  59969. * Creates a new GradientBlock
  59970. * @param name defines the block name
  59971. */
  59972. constructor(name: string);
  59973. /**
  59974. * Gets the current class name
  59975. * @returns the class name
  59976. */
  59977. getClassName(): string;
  59978. /**
  59979. * Gets the gradient input component
  59980. */
  59981. get gradient(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the output component
  59984. */
  59985. get output(): NodeMaterialConnectionPoint;
  59986. private _writeColorConstant;
  59987. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59988. serialize(): any;
  59989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59990. protected _dumpPropertiesCode(): string;
  59991. }
  59992. }
  59993. declare module BABYLON {
  59994. /**
  59995. * Block used to normalize lerp between 2 values
  59996. */
  59997. export class NLerpBlock extends NodeMaterialBlock {
  59998. /**
  59999. * Creates a new NLerpBlock
  60000. * @param name defines the block name
  60001. */
  60002. constructor(name: string);
  60003. /**
  60004. * Gets the current class name
  60005. * @returns the class name
  60006. */
  60007. getClassName(): string;
  60008. /**
  60009. * Gets the left operand input component
  60010. */
  60011. get left(): NodeMaterialConnectionPoint;
  60012. /**
  60013. * Gets the right operand input component
  60014. */
  60015. get right(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the gradient operand input component
  60018. */
  60019. get gradient(): NodeMaterialConnectionPoint;
  60020. /**
  60021. * Gets the output component
  60022. */
  60023. get output(): NodeMaterialConnectionPoint;
  60024. protected _buildBlock(state: NodeMaterialBuildState): this;
  60025. }
  60026. }
  60027. declare module BABYLON {
  60028. /**
  60029. * block used to Generate a Worley Noise 3D Noise Pattern
  60030. */
  60031. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60032. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60033. manhattanDistance: boolean;
  60034. /**
  60035. * Creates a new WorleyNoise3DBlock
  60036. * @param name defines the block name
  60037. */
  60038. constructor(name: string);
  60039. /**
  60040. * Gets the current class name
  60041. * @returns the class name
  60042. */
  60043. getClassName(): string;
  60044. /**
  60045. * Gets the seed input component
  60046. */
  60047. get seed(): NodeMaterialConnectionPoint;
  60048. /**
  60049. * Gets the jitter input component
  60050. */
  60051. get jitter(): NodeMaterialConnectionPoint;
  60052. /**
  60053. * Gets the output component
  60054. */
  60055. get output(): NodeMaterialConnectionPoint;
  60056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60057. /**
  60058. * Exposes the properties to the UI?
  60059. */
  60060. protected _dumpPropertiesCode(): string;
  60061. /**
  60062. * Exposes the properties to the Seralize?
  60063. */
  60064. serialize(): any;
  60065. /**
  60066. * Exposes the properties to the deseralize?
  60067. */
  60068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /**
  60073. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60074. */
  60075. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Creates a new SimplexPerlin3DBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the seed operand input component
  60088. */
  60089. get seed(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the output component
  60092. */
  60093. get output(): NodeMaterialConnectionPoint;
  60094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60095. }
  60096. }
  60097. declare module BABYLON {
  60098. /**
  60099. * Block used to blend normals
  60100. */
  60101. export class NormalBlendBlock extends NodeMaterialBlock {
  60102. /**
  60103. * Creates a new NormalBlendBlock
  60104. * @param name defines the block name
  60105. */
  60106. constructor(name: string);
  60107. /**
  60108. * Gets the current class name
  60109. * @returns the class name
  60110. */
  60111. getClassName(): string;
  60112. /**
  60113. * Gets the first input component
  60114. */
  60115. get normalMap0(): NodeMaterialConnectionPoint;
  60116. /**
  60117. * Gets the second input component
  60118. */
  60119. get normalMap1(): NodeMaterialConnectionPoint;
  60120. /**
  60121. * Gets the output component
  60122. */
  60123. get output(): NodeMaterialConnectionPoint;
  60124. protected _buildBlock(state: NodeMaterialBuildState): this;
  60125. }
  60126. }
  60127. declare module BABYLON {
  60128. /**
  60129. * Block used to rotate a 2d vector by a given angle
  60130. */
  60131. export class Rotate2dBlock extends NodeMaterialBlock {
  60132. /**
  60133. * Creates a new Rotate2dBlock
  60134. * @param name defines the block name
  60135. */
  60136. constructor(name: string);
  60137. /**
  60138. * Gets the current class name
  60139. * @returns the class name
  60140. */
  60141. getClassName(): string;
  60142. /**
  60143. * Gets the input vector
  60144. */
  60145. get input(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the input angle
  60148. */
  60149. get angle(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the output component
  60152. */
  60153. get output(): NodeMaterialConnectionPoint;
  60154. autoConfigure(material: NodeMaterial): void;
  60155. protected _buildBlock(state: NodeMaterialBuildState): this;
  60156. }
  60157. }
  60158. declare module BABYLON {
  60159. /**
  60160. * Block used to get the reflected vector from a direction and a normal
  60161. */
  60162. export class ReflectBlock extends NodeMaterialBlock {
  60163. /**
  60164. * Creates a new ReflectBlock
  60165. * @param name defines the block name
  60166. */
  60167. constructor(name: string);
  60168. /**
  60169. * Gets the current class name
  60170. * @returns the class name
  60171. */
  60172. getClassName(): string;
  60173. /**
  60174. * Gets the incident component
  60175. */
  60176. get incident(): NodeMaterialConnectionPoint;
  60177. /**
  60178. * Gets the normal component
  60179. */
  60180. get normal(): NodeMaterialConnectionPoint;
  60181. /**
  60182. * Gets the output component
  60183. */
  60184. get output(): NodeMaterialConnectionPoint;
  60185. protected _buildBlock(state: NodeMaterialBuildState): this;
  60186. }
  60187. }
  60188. declare module BABYLON {
  60189. /**
  60190. * Block used to get the refracted vector from a direction and a normal
  60191. */
  60192. export class RefractBlock extends NodeMaterialBlock {
  60193. /**
  60194. * Creates a new RefractBlock
  60195. * @param name defines the block name
  60196. */
  60197. constructor(name: string);
  60198. /**
  60199. * Gets the current class name
  60200. * @returns the class name
  60201. */
  60202. getClassName(): string;
  60203. /**
  60204. * Gets the incident component
  60205. */
  60206. get incident(): NodeMaterialConnectionPoint;
  60207. /**
  60208. * Gets the normal component
  60209. */
  60210. get normal(): NodeMaterialConnectionPoint;
  60211. /**
  60212. * Gets the index of refraction component
  60213. */
  60214. get ior(): NodeMaterialConnectionPoint;
  60215. /**
  60216. * Gets the output component
  60217. */
  60218. get output(): NodeMaterialConnectionPoint;
  60219. protected _buildBlock(state: NodeMaterialBuildState): this;
  60220. }
  60221. }
  60222. declare module BABYLON {
  60223. /**
  60224. * Block used to desaturate a color
  60225. */
  60226. export class DesaturateBlock extends NodeMaterialBlock {
  60227. /**
  60228. * Creates a new DesaturateBlock
  60229. * @param name defines the block name
  60230. */
  60231. constructor(name: string);
  60232. /**
  60233. * Gets the current class name
  60234. * @returns the class name
  60235. */
  60236. getClassName(): string;
  60237. /**
  60238. * Gets the color operand input component
  60239. */
  60240. get color(): NodeMaterialConnectionPoint;
  60241. /**
  60242. * Gets the level operand input component
  60243. */
  60244. get level(): NodeMaterialConnectionPoint;
  60245. /**
  60246. * Gets the output component
  60247. */
  60248. get output(): NodeMaterialConnectionPoint;
  60249. protected _buildBlock(state: NodeMaterialBuildState): this;
  60250. }
  60251. }
  60252. declare module BABYLON {
  60253. /**
  60254. * Effect Render Options
  60255. */
  60256. export interface IEffectRendererOptions {
  60257. /**
  60258. * Defines the vertices positions.
  60259. */
  60260. positions?: number[];
  60261. /**
  60262. * Defines the indices.
  60263. */
  60264. indices?: number[];
  60265. }
  60266. /**
  60267. * Helper class to render one or more effects
  60268. */
  60269. export class EffectRenderer {
  60270. private engine;
  60271. private static _DefaultOptions;
  60272. private _vertexBuffers;
  60273. private _indexBuffer;
  60274. private _ringBufferIndex;
  60275. private _ringScreenBuffer;
  60276. private _fullscreenViewport;
  60277. private _getNextFrameBuffer;
  60278. /**
  60279. * Creates an effect renderer
  60280. * @param engine the engine to use for rendering
  60281. * @param options defines the options of the effect renderer
  60282. */
  60283. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60284. /**
  60285. * Sets the current viewport in normalized coordinates 0-1
  60286. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60287. */
  60288. setViewport(viewport?: Viewport): void;
  60289. /**
  60290. * Binds the embedded attributes buffer to the effect.
  60291. * @param effect Defines the effect to bind the attributes for
  60292. */
  60293. bindBuffers(effect: Effect): void;
  60294. /**
  60295. * Sets the current effect wrapper to use during draw.
  60296. * The effect needs to be ready before calling this api.
  60297. * This also sets the default full screen position attribute.
  60298. * @param effectWrapper Defines the effect to draw with
  60299. */
  60300. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60301. /**
  60302. * Draws a full screen quad.
  60303. */
  60304. draw(): void;
  60305. /**
  60306. * renders one or more effects to a specified texture
  60307. * @param effectWrappers list of effects to renderer
  60308. * @param outputTexture texture to draw to, if null it will render to the screen
  60309. */
  60310. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60311. /**
  60312. * Disposes of the effect renderer
  60313. */
  60314. dispose(): void;
  60315. }
  60316. /**
  60317. * Options to create an EffectWrapper
  60318. */
  60319. interface EffectWrapperCreationOptions {
  60320. /**
  60321. * Engine to use to create the effect
  60322. */
  60323. engine: ThinEngine;
  60324. /**
  60325. * Fragment shader for the effect
  60326. */
  60327. fragmentShader: string;
  60328. /**
  60329. * Vertex shader for the effect
  60330. */
  60331. vertexShader?: string;
  60332. /**
  60333. * Attributes to use in the shader
  60334. */
  60335. attributeNames?: Array<string>;
  60336. /**
  60337. * Uniforms to use in the shader
  60338. */
  60339. uniformNames?: Array<string>;
  60340. /**
  60341. * Texture sampler names to use in the shader
  60342. */
  60343. samplerNames?: Array<string>;
  60344. /**
  60345. * The friendly name of the effect displayed in Spector.
  60346. */
  60347. name?: string;
  60348. }
  60349. /**
  60350. * Wraps an effect to be used for rendering
  60351. */
  60352. export class EffectWrapper {
  60353. /**
  60354. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60355. */
  60356. onApplyObservable: Observable<{}>;
  60357. /**
  60358. * The underlying effect
  60359. */
  60360. effect: Effect;
  60361. /**
  60362. * Creates an effect to be renderer
  60363. * @param creationOptions options to create the effect
  60364. */
  60365. constructor(creationOptions: EffectWrapperCreationOptions);
  60366. /**
  60367. * Disposes of the effect wrapper
  60368. */
  60369. dispose(): void;
  60370. }
  60371. }
  60372. declare module BABYLON {
  60373. /**
  60374. * Helper class to push actions to a pool of workers.
  60375. */
  60376. export class WorkerPool implements IDisposable {
  60377. private _workerInfos;
  60378. private _pendingActions;
  60379. /**
  60380. * Constructor
  60381. * @param workers Array of workers to use for actions
  60382. */
  60383. constructor(workers: Array<Worker>);
  60384. /**
  60385. * Terminates all workers and clears any pending actions.
  60386. */
  60387. dispose(): void;
  60388. /**
  60389. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60390. * pended until a worker has completed its action.
  60391. * @param action The action to perform. Call onComplete when the action is complete.
  60392. */
  60393. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60394. private _execute;
  60395. }
  60396. }
  60397. declare module BABYLON {
  60398. /**
  60399. * Configuration for Draco compression
  60400. */
  60401. export interface IDracoCompressionConfiguration {
  60402. /**
  60403. * Configuration for the decoder.
  60404. */
  60405. decoder: {
  60406. /**
  60407. * The url to the WebAssembly module.
  60408. */
  60409. wasmUrl?: string;
  60410. /**
  60411. * The url to the WebAssembly binary.
  60412. */
  60413. wasmBinaryUrl?: string;
  60414. /**
  60415. * The url to the fallback JavaScript module.
  60416. */
  60417. fallbackUrl?: string;
  60418. };
  60419. }
  60420. /**
  60421. * Draco compression (https://google.github.io/draco/)
  60422. *
  60423. * This class wraps the Draco module.
  60424. *
  60425. * **Encoder**
  60426. *
  60427. * The encoder is not currently implemented.
  60428. *
  60429. * **Decoder**
  60430. *
  60431. * 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.
  60432. *
  60433. * To update the configuration, use the following code:
  60434. * ```javascript
  60435. * DracoCompression.Configuration = {
  60436. * decoder: {
  60437. * wasmUrl: "<url to the WebAssembly library>",
  60438. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60439. * fallbackUrl: "<url to the fallback JavaScript library>",
  60440. * }
  60441. * };
  60442. * ```
  60443. *
  60444. * 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.
  60445. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60446. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60447. *
  60448. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60449. * ```javascript
  60450. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60451. * ```
  60452. *
  60453. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60454. */
  60455. export class DracoCompression implements IDisposable {
  60456. private _workerPoolPromise?;
  60457. private _decoderModulePromise?;
  60458. /**
  60459. * The configuration. Defaults to the following urls:
  60460. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60461. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60462. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60463. */
  60464. static Configuration: IDracoCompressionConfiguration;
  60465. /**
  60466. * Returns true if the decoder configuration is available.
  60467. */
  60468. static get DecoderAvailable(): boolean;
  60469. /**
  60470. * Default number of workers to create when creating the draco compression object.
  60471. */
  60472. static DefaultNumWorkers: number;
  60473. private static GetDefaultNumWorkers;
  60474. private static _Default;
  60475. /**
  60476. * Default instance for the draco compression object.
  60477. */
  60478. static get Default(): DracoCompression;
  60479. /**
  60480. * Constructor
  60481. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60482. */
  60483. constructor(numWorkers?: number);
  60484. /**
  60485. * Stop all async operations and release resources.
  60486. */
  60487. dispose(): void;
  60488. /**
  60489. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60490. * @returns a promise that resolves when ready
  60491. */
  60492. whenReadyAsync(): Promise<void>;
  60493. /**
  60494. * Decode Draco compressed mesh data to vertex data.
  60495. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60496. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60497. * @returns A promise that resolves with the decoded vertex data
  60498. */
  60499. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60500. [kind: string]: number;
  60501. }): Promise<VertexData>;
  60502. }
  60503. }
  60504. declare module BABYLON {
  60505. /**
  60506. * Class for building Constructive Solid Geometry
  60507. */
  60508. export class CSG {
  60509. private polygons;
  60510. /**
  60511. * The world matrix
  60512. */
  60513. matrix: Matrix;
  60514. /**
  60515. * Stores the position
  60516. */
  60517. position: Vector3;
  60518. /**
  60519. * Stores the rotation
  60520. */
  60521. rotation: Vector3;
  60522. /**
  60523. * Stores the rotation quaternion
  60524. */
  60525. rotationQuaternion: Nullable<Quaternion>;
  60526. /**
  60527. * Stores the scaling vector
  60528. */
  60529. scaling: Vector3;
  60530. /**
  60531. * Convert the Mesh to CSG
  60532. * @param mesh The Mesh to convert to CSG
  60533. * @returns A new CSG from the Mesh
  60534. */
  60535. static FromMesh(mesh: Mesh): CSG;
  60536. /**
  60537. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60538. * @param polygons Polygons used to construct a CSG solid
  60539. */
  60540. private static FromPolygons;
  60541. /**
  60542. * Clones, or makes a deep copy, of the CSG
  60543. * @returns A new CSG
  60544. */
  60545. clone(): CSG;
  60546. /**
  60547. * Unions this CSG with another CSG
  60548. * @param csg The CSG to union against this CSG
  60549. * @returns The unioned CSG
  60550. */
  60551. union(csg: CSG): CSG;
  60552. /**
  60553. * Unions this CSG with another CSG in place
  60554. * @param csg The CSG to union against this CSG
  60555. */
  60556. unionInPlace(csg: CSG): void;
  60557. /**
  60558. * Subtracts this CSG with another CSG
  60559. * @param csg The CSG to subtract against this CSG
  60560. * @returns A new CSG
  60561. */
  60562. subtract(csg: CSG): CSG;
  60563. /**
  60564. * Subtracts this CSG with another CSG in place
  60565. * @param csg The CSG to subtact against this CSG
  60566. */
  60567. subtractInPlace(csg: CSG): void;
  60568. /**
  60569. * Intersect this CSG with another CSG
  60570. * @param csg The CSG to intersect against this CSG
  60571. * @returns A new CSG
  60572. */
  60573. intersect(csg: CSG): CSG;
  60574. /**
  60575. * Intersects this CSG with another CSG in place
  60576. * @param csg The CSG to intersect against this CSG
  60577. */
  60578. intersectInPlace(csg: CSG): void;
  60579. /**
  60580. * Return a new CSG solid with solid and empty space switched. This solid is
  60581. * not modified.
  60582. * @returns A new CSG solid with solid and empty space switched
  60583. */
  60584. inverse(): CSG;
  60585. /**
  60586. * Inverses the CSG in place
  60587. */
  60588. inverseInPlace(): void;
  60589. /**
  60590. * This is used to keep meshes transformations so they can be restored
  60591. * when we build back a Babylon Mesh
  60592. * NB : All CSG operations are performed in world coordinates
  60593. * @param csg The CSG to copy the transform attributes from
  60594. * @returns This CSG
  60595. */
  60596. copyTransformAttributes(csg: CSG): CSG;
  60597. /**
  60598. * Build Raw mesh from CSG
  60599. * Coordinates here are in world space
  60600. * @param name The name of the mesh geometry
  60601. * @param scene The Scene
  60602. * @param keepSubMeshes Specifies if the submeshes should be kept
  60603. * @returns A new Mesh
  60604. */
  60605. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60606. /**
  60607. * Build Mesh from CSG taking material and transforms into account
  60608. * @param name The name of the Mesh
  60609. * @param material The material of the Mesh
  60610. * @param scene The Scene
  60611. * @param keepSubMeshes Specifies if submeshes should be kept
  60612. * @returns The new Mesh
  60613. */
  60614. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60615. }
  60616. }
  60617. declare module BABYLON {
  60618. /**
  60619. * Class used to create a trail following a mesh
  60620. */
  60621. export class TrailMesh extends Mesh {
  60622. private _generator;
  60623. private _autoStart;
  60624. private _running;
  60625. private _diameter;
  60626. private _length;
  60627. private _sectionPolygonPointsCount;
  60628. private _sectionVectors;
  60629. private _sectionNormalVectors;
  60630. private _beforeRenderObserver;
  60631. /**
  60632. * @constructor
  60633. * @param name The value used by scene.getMeshByName() to do a lookup.
  60634. * @param generator The mesh to generate a trail.
  60635. * @param scene The scene to add this mesh to.
  60636. * @param diameter Diameter of trailing mesh. Default is 1.
  60637. * @param length Length of trailing mesh. Default is 60.
  60638. * @param autoStart Automatically start trailing mesh. Default true.
  60639. */
  60640. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60641. /**
  60642. * "TrailMesh"
  60643. * @returns "TrailMesh"
  60644. */
  60645. getClassName(): string;
  60646. private _createMesh;
  60647. /**
  60648. * Start trailing mesh.
  60649. */
  60650. start(): void;
  60651. /**
  60652. * Stop trailing mesh.
  60653. */
  60654. stop(): void;
  60655. /**
  60656. * Update trailing mesh geometry.
  60657. */
  60658. update(): void;
  60659. /**
  60660. * Returns a new TrailMesh object.
  60661. * @param name is a string, the name given to the new mesh
  60662. * @param newGenerator use new generator object for cloned trail mesh
  60663. * @returns a new mesh
  60664. */
  60665. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60666. /**
  60667. * Serializes this trail mesh
  60668. * @param serializationObject object to write serialization to
  60669. */
  60670. serialize(serializationObject: any): void;
  60671. /**
  60672. * Parses a serialized trail mesh
  60673. * @param parsedMesh the serialized mesh
  60674. * @param scene the scene to create the trail mesh in
  60675. * @returns the created trail mesh
  60676. */
  60677. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60678. }
  60679. }
  60680. declare module BABYLON {
  60681. /**
  60682. * Class containing static functions to help procedurally build meshes
  60683. */
  60684. export class TiledBoxBuilder {
  60685. /**
  60686. * Creates a box mesh
  60687. * 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)
  60688. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60690. * * 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
  60691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60692. * @param name defines the name of the mesh
  60693. * @param options defines the options used to create the mesh
  60694. * @param scene defines the hosting scene
  60695. * @returns the box mesh
  60696. */
  60697. static CreateTiledBox(name: string, options: {
  60698. pattern?: number;
  60699. width?: number;
  60700. height?: number;
  60701. depth?: number;
  60702. tileSize?: number;
  60703. tileWidth?: number;
  60704. tileHeight?: number;
  60705. alignHorizontal?: number;
  60706. alignVertical?: number;
  60707. faceUV?: Vector4[];
  60708. faceColors?: Color4[];
  60709. sideOrientation?: number;
  60710. updatable?: boolean;
  60711. }, scene?: Nullable<Scene>): Mesh;
  60712. }
  60713. }
  60714. declare module BABYLON {
  60715. /**
  60716. * Class containing static functions to help procedurally build meshes
  60717. */
  60718. export class TorusKnotBuilder {
  60719. /**
  60720. * Creates a torus knot mesh
  60721. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60722. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60723. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60724. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60726. * * 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
  60727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60728. * @param name defines the name of the mesh
  60729. * @param options defines the options used to create the mesh
  60730. * @param scene defines the hosting scene
  60731. * @returns the torus knot mesh
  60732. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60733. */
  60734. static CreateTorusKnot(name: string, options: {
  60735. radius?: number;
  60736. tube?: number;
  60737. radialSegments?: number;
  60738. tubularSegments?: number;
  60739. p?: number;
  60740. q?: number;
  60741. updatable?: boolean;
  60742. sideOrientation?: number;
  60743. frontUVs?: Vector4;
  60744. backUVs?: Vector4;
  60745. }, scene: any): Mesh;
  60746. }
  60747. }
  60748. declare module BABYLON {
  60749. /**
  60750. * Polygon
  60751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60752. */
  60753. export class Polygon {
  60754. /**
  60755. * Creates a rectangle
  60756. * @param xmin bottom X coord
  60757. * @param ymin bottom Y coord
  60758. * @param xmax top X coord
  60759. * @param ymax top Y coord
  60760. * @returns points that make the resulting rectation
  60761. */
  60762. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60763. /**
  60764. * Creates a circle
  60765. * @param radius radius of circle
  60766. * @param cx scale in x
  60767. * @param cy scale in y
  60768. * @param numberOfSides number of sides that make up the circle
  60769. * @returns points that make the resulting circle
  60770. */
  60771. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60772. /**
  60773. * Creates a polygon from input string
  60774. * @param input Input polygon data
  60775. * @returns the parsed points
  60776. */
  60777. static Parse(input: string): Vector2[];
  60778. /**
  60779. * Starts building a polygon from x and y coordinates
  60780. * @param x x coordinate
  60781. * @param y y coordinate
  60782. * @returns the started path2
  60783. */
  60784. static StartingAt(x: number, y: number): Path2;
  60785. }
  60786. /**
  60787. * Builds a polygon
  60788. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60789. */
  60790. export class PolygonMeshBuilder {
  60791. private _points;
  60792. private _outlinepoints;
  60793. private _holes;
  60794. private _name;
  60795. private _scene;
  60796. private _epoints;
  60797. private _eholes;
  60798. private _addToepoint;
  60799. /**
  60800. * Babylon reference to the earcut plugin.
  60801. */
  60802. bjsEarcut: any;
  60803. /**
  60804. * Creates a PolygonMeshBuilder
  60805. * @param name name of the builder
  60806. * @param contours Path of the polygon
  60807. * @param scene scene to add to when creating the mesh
  60808. * @param earcutInjection can be used to inject your own earcut reference
  60809. */
  60810. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60811. /**
  60812. * Adds a whole within the polygon
  60813. * @param hole Array of points defining the hole
  60814. * @returns this
  60815. */
  60816. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60817. /**
  60818. * Creates the polygon
  60819. * @param updatable If the mesh should be updatable
  60820. * @param depth The depth of the mesh created
  60821. * @returns the created mesh
  60822. */
  60823. build(updatable?: boolean, depth?: number): Mesh;
  60824. /**
  60825. * Creates the polygon
  60826. * @param depth The depth of the mesh created
  60827. * @returns the created VertexData
  60828. */
  60829. buildVertexData(depth?: number): VertexData;
  60830. /**
  60831. * Adds a side to the polygon
  60832. * @param positions points that make the polygon
  60833. * @param normals normals of the polygon
  60834. * @param uvs uvs of the polygon
  60835. * @param indices indices of the polygon
  60836. * @param bounds bounds of the polygon
  60837. * @param points points of the polygon
  60838. * @param depth depth of the polygon
  60839. * @param flip flip of the polygon
  60840. */
  60841. private addSide;
  60842. }
  60843. }
  60844. declare module BABYLON {
  60845. /**
  60846. * Class containing static functions to help procedurally build meshes
  60847. */
  60848. export class PolygonBuilder {
  60849. /**
  60850. * Creates a polygon mesh
  60851. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60852. * * 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
  60853. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60855. * * 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)
  60856. * * Remember you can only change the shape positions, not their number when updating a polygon
  60857. * @param name defines the name of the mesh
  60858. * @param options defines the options used to create the mesh
  60859. * @param scene defines the hosting scene
  60860. * @param earcutInjection can be used to inject your own earcut reference
  60861. * @returns the polygon mesh
  60862. */
  60863. static CreatePolygon(name: string, options: {
  60864. shape: Vector3[];
  60865. holes?: Vector3[][];
  60866. depth?: number;
  60867. faceUV?: Vector4[];
  60868. faceColors?: Color4[];
  60869. updatable?: boolean;
  60870. sideOrientation?: number;
  60871. frontUVs?: Vector4;
  60872. backUVs?: Vector4;
  60873. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60874. /**
  60875. * Creates an extruded polygon mesh, with depth in the Y direction.
  60876. * * 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)
  60877. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60878. * @param name defines the name of the mesh
  60879. * @param options defines the options used to create the mesh
  60880. * @param scene defines the hosting scene
  60881. * @param earcutInjection can be used to inject your own earcut reference
  60882. * @returns the polygon mesh
  60883. */
  60884. static ExtrudePolygon(name: string, options: {
  60885. shape: Vector3[];
  60886. holes?: Vector3[][];
  60887. depth?: number;
  60888. faceUV?: Vector4[];
  60889. faceColors?: Color4[];
  60890. updatable?: boolean;
  60891. sideOrientation?: number;
  60892. frontUVs?: Vector4;
  60893. backUVs?: Vector4;
  60894. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60895. }
  60896. }
  60897. declare module BABYLON {
  60898. /**
  60899. * Class containing static functions to help procedurally build meshes
  60900. */
  60901. export class LatheBuilder {
  60902. /**
  60903. * Creates lathe mesh.
  60904. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60905. * * 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
  60906. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60907. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60908. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60909. * * 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
  60910. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60911. * * 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
  60912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60913. * * 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
  60914. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60916. * @param name defines the name of the mesh
  60917. * @param options defines the options used to create the mesh
  60918. * @param scene defines the hosting scene
  60919. * @returns the lathe mesh
  60920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60921. */
  60922. static CreateLathe(name: string, options: {
  60923. shape: Vector3[];
  60924. radius?: number;
  60925. tessellation?: number;
  60926. clip?: number;
  60927. arc?: number;
  60928. closed?: boolean;
  60929. updatable?: boolean;
  60930. sideOrientation?: number;
  60931. frontUVs?: Vector4;
  60932. backUVs?: Vector4;
  60933. cap?: number;
  60934. invertUV?: boolean;
  60935. }, scene?: Nullable<Scene>): Mesh;
  60936. }
  60937. }
  60938. declare module BABYLON {
  60939. /**
  60940. * Class containing static functions to help procedurally build meshes
  60941. */
  60942. export class TiledPlaneBuilder {
  60943. /**
  60944. * Creates a tiled plane mesh
  60945. * * The parameter `pattern` will, depending on value, do nothing or
  60946. * * * flip (reflect about central vertical) alternate tiles across and up
  60947. * * * flip every tile on alternate rows
  60948. * * * rotate (180 degs) alternate tiles across and up
  60949. * * * rotate every tile on alternate rows
  60950. * * * flip and rotate alternate tiles across and up
  60951. * * * flip and rotate every tile on alternate rows
  60952. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60953. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60954. * * 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
  60955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60956. * * 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)
  60957. * * 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)
  60958. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60959. * @param name defines the name of the mesh
  60960. * @param options defines the options used to create the mesh
  60961. * @param scene defines the hosting scene
  60962. * @returns the box mesh
  60963. */
  60964. static CreateTiledPlane(name: string, options: {
  60965. pattern?: number;
  60966. tileSize?: number;
  60967. tileWidth?: number;
  60968. tileHeight?: number;
  60969. size?: number;
  60970. width?: number;
  60971. height?: number;
  60972. alignHorizontal?: number;
  60973. alignVertical?: number;
  60974. sideOrientation?: number;
  60975. frontUVs?: Vector4;
  60976. backUVs?: Vector4;
  60977. updatable?: boolean;
  60978. }, scene?: Nullable<Scene>): Mesh;
  60979. }
  60980. }
  60981. declare module BABYLON {
  60982. /**
  60983. * Class containing static functions to help procedurally build meshes
  60984. */
  60985. export class TubeBuilder {
  60986. /**
  60987. * Creates a tube mesh.
  60988. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60989. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60990. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60991. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60992. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60993. * * 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)
  60994. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60995. * * 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
  60996. * * 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
  60997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60998. * * 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
  60999. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61001. * @param name defines the name of the mesh
  61002. * @param options defines the options used to create the mesh
  61003. * @param scene defines the hosting scene
  61004. * @returns the tube mesh
  61005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61006. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61007. */
  61008. static CreateTube(name: string, options: {
  61009. path: Vector3[];
  61010. radius?: number;
  61011. tessellation?: number;
  61012. radiusFunction?: {
  61013. (i: number, distance: number): number;
  61014. };
  61015. cap?: number;
  61016. arc?: number;
  61017. updatable?: boolean;
  61018. sideOrientation?: number;
  61019. frontUVs?: Vector4;
  61020. backUVs?: Vector4;
  61021. instance?: Mesh;
  61022. invertUV?: boolean;
  61023. }, scene?: Nullable<Scene>): Mesh;
  61024. }
  61025. }
  61026. declare module BABYLON {
  61027. /**
  61028. * Class containing static functions to help procedurally build meshes
  61029. */
  61030. export class IcoSphereBuilder {
  61031. /**
  61032. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61033. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61034. * * 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`)
  61035. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61036. * * 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
  61037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61038. * * 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
  61039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61040. * @param name defines the name of the mesh
  61041. * @param options defines the options used to create the mesh
  61042. * @param scene defines the hosting scene
  61043. * @returns the icosahedron mesh
  61044. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61045. */
  61046. static CreateIcoSphere(name: string, options: {
  61047. radius?: number;
  61048. radiusX?: number;
  61049. radiusY?: number;
  61050. radiusZ?: number;
  61051. flat?: boolean;
  61052. subdivisions?: number;
  61053. sideOrientation?: number;
  61054. frontUVs?: Vector4;
  61055. backUVs?: Vector4;
  61056. updatable?: boolean;
  61057. }, scene?: Nullable<Scene>): Mesh;
  61058. }
  61059. }
  61060. declare module BABYLON {
  61061. /**
  61062. * Class containing static functions to help procedurally build meshes
  61063. */
  61064. export class DecalBuilder {
  61065. /**
  61066. * Creates a decal mesh.
  61067. * 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
  61068. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61069. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61070. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61071. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61072. * @param name defines the name of the mesh
  61073. * @param sourceMesh defines the mesh where the decal must be applied
  61074. * @param options defines the options used to create the mesh
  61075. * @param scene defines the hosting scene
  61076. * @returns the decal mesh
  61077. * @see https://doc.babylonjs.com/how_to/decals
  61078. */
  61079. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61080. position?: Vector3;
  61081. normal?: Vector3;
  61082. size?: Vector3;
  61083. angle?: number;
  61084. }): Mesh;
  61085. }
  61086. }
  61087. declare module BABYLON {
  61088. /**
  61089. * Class containing static functions to help procedurally build meshes
  61090. */
  61091. export class MeshBuilder {
  61092. /**
  61093. * Creates a box mesh
  61094. * * The parameter `size` sets the size (float) of each box side (default 1)
  61095. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61096. * * 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)
  61097. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61099. * * 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
  61100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61101. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61102. * @param name defines the name of the mesh
  61103. * @param options defines the options used to create the mesh
  61104. * @param scene defines the hosting scene
  61105. * @returns the box mesh
  61106. */
  61107. static CreateBox(name: string, options: {
  61108. size?: number;
  61109. width?: number;
  61110. height?: number;
  61111. depth?: number;
  61112. faceUV?: Vector4[];
  61113. faceColors?: Color4[];
  61114. sideOrientation?: number;
  61115. frontUVs?: Vector4;
  61116. backUVs?: Vector4;
  61117. updatable?: boolean;
  61118. }, scene?: Nullable<Scene>): Mesh;
  61119. /**
  61120. * Creates a tiled box mesh
  61121. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61123. * @param name defines the name of the mesh
  61124. * @param options defines the options used to create the mesh
  61125. * @param scene defines the hosting scene
  61126. * @returns the tiled box mesh
  61127. */
  61128. static CreateTiledBox(name: string, options: {
  61129. pattern?: number;
  61130. size?: number;
  61131. width?: number;
  61132. height?: number;
  61133. depth: number;
  61134. tileSize?: number;
  61135. tileWidth?: number;
  61136. tileHeight?: number;
  61137. faceUV?: Vector4[];
  61138. faceColors?: Color4[];
  61139. alignHorizontal?: number;
  61140. alignVertical?: number;
  61141. sideOrientation?: number;
  61142. updatable?: boolean;
  61143. }, scene?: Nullable<Scene>): Mesh;
  61144. /**
  61145. * Creates a sphere mesh
  61146. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61147. * * 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`)
  61148. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61149. * * 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
  61150. * * 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)
  61151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61152. * * 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
  61153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61154. * @param name defines the name of the mesh
  61155. * @param options defines the options used to create the mesh
  61156. * @param scene defines the hosting scene
  61157. * @returns the sphere mesh
  61158. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61159. */
  61160. static CreateSphere(name: string, options: {
  61161. segments?: number;
  61162. diameter?: number;
  61163. diameterX?: number;
  61164. diameterY?: number;
  61165. diameterZ?: number;
  61166. arc?: number;
  61167. slice?: number;
  61168. sideOrientation?: number;
  61169. frontUVs?: Vector4;
  61170. backUVs?: Vector4;
  61171. updatable?: boolean;
  61172. }, scene?: Nullable<Scene>): Mesh;
  61173. /**
  61174. * Creates a plane polygonal mesh. By default, this is a disc
  61175. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61176. * * 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
  61177. * * 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
  61178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61179. * * 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
  61180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61181. * @param name defines the name of the mesh
  61182. * @param options defines the options used to create the mesh
  61183. * @param scene defines the hosting scene
  61184. * @returns the plane polygonal mesh
  61185. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61186. */
  61187. static CreateDisc(name: string, options: {
  61188. radius?: number;
  61189. tessellation?: number;
  61190. arc?: number;
  61191. updatable?: boolean;
  61192. sideOrientation?: number;
  61193. frontUVs?: Vector4;
  61194. backUVs?: Vector4;
  61195. }, scene?: Nullable<Scene>): Mesh;
  61196. /**
  61197. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61198. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61199. * * 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`)
  61200. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61201. * * 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
  61202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61203. * * 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
  61204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61205. * @param name defines the name of the mesh
  61206. * @param options defines the options used to create the mesh
  61207. * @param scene defines the hosting scene
  61208. * @returns the icosahedron mesh
  61209. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61210. */
  61211. static CreateIcoSphere(name: string, options: {
  61212. radius?: number;
  61213. radiusX?: number;
  61214. radiusY?: number;
  61215. radiusZ?: number;
  61216. flat?: boolean;
  61217. subdivisions?: number;
  61218. sideOrientation?: number;
  61219. frontUVs?: Vector4;
  61220. backUVs?: Vector4;
  61221. updatable?: boolean;
  61222. }, scene?: Nullable<Scene>): Mesh;
  61223. /**
  61224. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61225. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61226. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61227. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61228. * * 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
  61229. * * 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
  61230. * * 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
  61231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61232. * * 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
  61233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61234. * * 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
  61235. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61236. * * 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
  61237. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61239. * @param name defines the name of the mesh
  61240. * @param options defines the options used to create the mesh
  61241. * @param scene defines the hosting scene
  61242. * @returns the ribbon mesh
  61243. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61245. */
  61246. static CreateRibbon(name: string, options: {
  61247. pathArray: Vector3[][];
  61248. closeArray?: boolean;
  61249. closePath?: boolean;
  61250. offset?: number;
  61251. updatable?: boolean;
  61252. sideOrientation?: number;
  61253. frontUVs?: Vector4;
  61254. backUVs?: Vector4;
  61255. instance?: Mesh;
  61256. invertUV?: boolean;
  61257. uvs?: Vector2[];
  61258. colors?: Color4[];
  61259. }, scene?: Nullable<Scene>): Mesh;
  61260. /**
  61261. * Creates a cylinder or a cone mesh
  61262. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61263. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61264. * * 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.
  61265. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61266. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61267. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61268. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61269. * * 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).
  61270. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61271. * * 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).
  61272. * * 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
  61273. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61274. * * 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
  61275. * * 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.
  61276. * * If `enclose` is false, a ring surface is one element.
  61277. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61278. * * 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
  61279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61280. * * 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
  61281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61282. * @param name defines the name of the mesh
  61283. * @param options defines the options used to create the mesh
  61284. * @param scene defines the hosting scene
  61285. * @returns the cylinder mesh
  61286. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61287. */
  61288. static CreateCylinder(name: string, options: {
  61289. height?: number;
  61290. diameterTop?: number;
  61291. diameterBottom?: number;
  61292. diameter?: number;
  61293. tessellation?: number;
  61294. subdivisions?: number;
  61295. arc?: number;
  61296. faceColors?: Color4[];
  61297. faceUV?: Vector4[];
  61298. updatable?: boolean;
  61299. hasRings?: boolean;
  61300. enclose?: boolean;
  61301. cap?: number;
  61302. sideOrientation?: number;
  61303. frontUVs?: Vector4;
  61304. backUVs?: Vector4;
  61305. }, scene?: Nullable<Scene>): Mesh;
  61306. /**
  61307. * Creates a torus mesh
  61308. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61309. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61310. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61312. * * 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
  61313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61314. * @param name defines the name of the mesh
  61315. * @param options defines the options used to create the mesh
  61316. * @param scene defines the hosting scene
  61317. * @returns the torus mesh
  61318. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61319. */
  61320. static CreateTorus(name: string, options: {
  61321. diameter?: number;
  61322. thickness?: number;
  61323. tessellation?: number;
  61324. updatable?: boolean;
  61325. sideOrientation?: number;
  61326. frontUVs?: Vector4;
  61327. backUVs?: Vector4;
  61328. }, scene?: Nullable<Scene>): Mesh;
  61329. /**
  61330. * Creates a torus knot mesh
  61331. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61332. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61333. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61334. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61336. * * 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
  61337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61338. * @param name defines the name of the mesh
  61339. * @param options defines the options used to create the mesh
  61340. * @param scene defines the hosting scene
  61341. * @returns the torus knot mesh
  61342. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61343. */
  61344. static CreateTorusKnot(name: string, options: {
  61345. radius?: number;
  61346. tube?: number;
  61347. radialSegments?: number;
  61348. tubularSegments?: number;
  61349. p?: number;
  61350. q?: number;
  61351. updatable?: boolean;
  61352. sideOrientation?: number;
  61353. frontUVs?: Vector4;
  61354. backUVs?: Vector4;
  61355. }, scene?: Nullable<Scene>): Mesh;
  61356. /**
  61357. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61358. * * 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
  61359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61360. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61361. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61362. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61363. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61364. * * 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
  61365. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61368. * @param name defines the name of the new line system
  61369. * @param options defines the options used to create the line system
  61370. * @param scene defines the hosting scene
  61371. * @returns a new line system mesh
  61372. */
  61373. static CreateLineSystem(name: string, options: {
  61374. lines: Vector3[][];
  61375. updatable?: boolean;
  61376. instance?: Nullable<LinesMesh>;
  61377. colors?: Nullable<Color4[][]>;
  61378. useVertexAlpha?: boolean;
  61379. }, scene: Nullable<Scene>): LinesMesh;
  61380. /**
  61381. * Creates a line mesh
  61382. * 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
  61383. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61384. * * The parameter `points` is an array successive Vector3
  61385. * * 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
  61386. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61387. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61388. * * When updating an instance, remember that only point positions can change, not the number of points
  61389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61391. * @param name defines the name of the new line system
  61392. * @param options defines the options used to create the line system
  61393. * @param scene defines the hosting scene
  61394. * @returns a new line mesh
  61395. */
  61396. static CreateLines(name: string, options: {
  61397. points: Vector3[];
  61398. updatable?: boolean;
  61399. instance?: Nullable<LinesMesh>;
  61400. colors?: Color4[];
  61401. useVertexAlpha?: boolean;
  61402. }, scene?: Nullable<Scene>): LinesMesh;
  61403. /**
  61404. * Creates a dashed line mesh
  61405. * * 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
  61406. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61407. * * The parameter `points` is an array successive Vector3
  61408. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61409. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61410. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61411. * * 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
  61412. * * When updating an instance, remember that only point positions can change, not the number of points
  61413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61414. * @param name defines the name of the mesh
  61415. * @param options defines the options used to create the mesh
  61416. * @param scene defines the hosting scene
  61417. * @returns the dashed line mesh
  61418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61419. */
  61420. static CreateDashedLines(name: string, options: {
  61421. points: Vector3[];
  61422. dashSize?: number;
  61423. gapSize?: number;
  61424. dashNb?: number;
  61425. updatable?: boolean;
  61426. instance?: LinesMesh;
  61427. }, scene?: Nullable<Scene>): LinesMesh;
  61428. /**
  61429. * 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.
  61430. * * 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.
  61431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61432. * * 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.
  61433. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61434. * * 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
  61435. * * 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
  61436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61438. * * 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
  61439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61441. * @param name defines the name of the mesh
  61442. * @param options defines the options used to create the mesh
  61443. * @param scene defines the hosting scene
  61444. * @returns the extruded shape mesh
  61445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61447. */
  61448. static ExtrudeShape(name: string, options: {
  61449. shape: Vector3[];
  61450. path: Vector3[];
  61451. scale?: number;
  61452. rotation?: number;
  61453. cap?: number;
  61454. updatable?: boolean;
  61455. sideOrientation?: number;
  61456. frontUVs?: Vector4;
  61457. backUVs?: Vector4;
  61458. instance?: Mesh;
  61459. invertUV?: boolean;
  61460. }, scene?: Nullable<Scene>): Mesh;
  61461. /**
  61462. * Creates an custom extruded shape mesh.
  61463. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61464. * * 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.
  61465. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61466. * * 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
  61467. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61468. * * 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
  61469. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61470. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61471. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61472. * * 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
  61473. * * 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
  61474. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61476. * * 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
  61477. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61479. * @param name defines the name of the mesh
  61480. * @param options defines the options used to create the mesh
  61481. * @param scene defines the hosting scene
  61482. * @returns the custom extruded shape mesh
  61483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61486. */
  61487. static ExtrudeShapeCustom(name: string, options: {
  61488. shape: Vector3[];
  61489. path: Vector3[];
  61490. scaleFunction?: any;
  61491. rotationFunction?: any;
  61492. ribbonCloseArray?: boolean;
  61493. ribbonClosePath?: boolean;
  61494. cap?: number;
  61495. updatable?: boolean;
  61496. sideOrientation?: number;
  61497. frontUVs?: Vector4;
  61498. backUVs?: Vector4;
  61499. instance?: Mesh;
  61500. invertUV?: boolean;
  61501. }, scene?: Nullable<Scene>): Mesh;
  61502. /**
  61503. * Creates lathe mesh.
  61504. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61505. * * 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
  61506. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61507. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61508. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61509. * * 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
  61510. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61511. * * 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
  61512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61513. * * 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
  61514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61516. * @param name defines the name of the mesh
  61517. * @param options defines the options used to create the mesh
  61518. * @param scene defines the hosting scene
  61519. * @returns the lathe mesh
  61520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61521. */
  61522. static CreateLathe(name: string, options: {
  61523. shape: Vector3[];
  61524. radius?: number;
  61525. tessellation?: number;
  61526. clip?: number;
  61527. arc?: number;
  61528. closed?: boolean;
  61529. updatable?: boolean;
  61530. sideOrientation?: number;
  61531. frontUVs?: Vector4;
  61532. backUVs?: Vector4;
  61533. cap?: number;
  61534. invertUV?: boolean;
  61535. }, scene?: Nullable<Scene>): Mesh;
  61536. /**
  61537. * Creates a tiled plane mesh
  61538. * * You can set a limited pattern arrangement with the tiles
  61539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61540. * * 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
  61541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61542. * @param name defines the name of the mesh
  61543. * @param options defines the options used to create the mesh
  61544. * @param scene defines the hosting scene
  61545. * @returns the plane mesh
  61546. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61547. */
  61548. static CreateTiledPlane(name: string, options: {
  61549. pattern?: number;
  61550. tileSize?: number;
  61551. tileWidth?: number;
  61552. tileHeight?: number;
  61553. size?: number;
  61554. width?: number;
  61555. height?: number;
  61556. alignHorizontal?: number;
  61557. alignVertical?: number;
  61558. sideOrientation?: number;
  61559. frontUVs?: Vector4;
  61560. backUVs?: Vector4;
  61561. updatable?: boolean;
  61562. }, scene?: Nullable<Scene>): Mesh;
  61563. /**
  61564. * Creates a plane mesh
  61565. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61566. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61567. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61569. * * 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
  61570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61571. * @param name defines the name of the mesh
  61572. * @param options defines the options used to create the mesh
  61573. * @param scene defines the hosting scene
  61574. * @returns the plane mesh
  61575. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61576. */
  61577. static CreatePlane(name: string, options: {
  61578. size?: number;
  61579. width?: number;
  61580. height?: number;
  61581. sideOrientation?: number;
  61582. frontUVs?: Vector4;
  61583. backUVs?: Vector4;
  61584. updatable?: boolean;
  61585. sourcePlane?: Plane;
  61586. }, scene?: Nullable<Scene>): Mesh;
  61587. /**
  61588. * Creates a ground mesh
  61589. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61590. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61592. * @param name defines the name of the mesh
  61593. * @param options defines the options used to create the mesh
  61594. * @param scene defines the hosting scene
  61595. * @returns the ground mesh
  61596. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61597. */
  61598. static CreateGround(name: string, options: {
  61599. width?: number;
  61600. height?: number;
  61601. subdivisions?: number;
  61602. subdivisionsX?: number;
  61603. subdivisionsY?: number;
  61604. updatable?: boolean;
  61605. }, scene?: Nullable<Scene>): Mesh;
  61606. /**
  61607. * Creates a tiled ground mesh
  61608. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61609. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61610. * * 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
  61611. * * 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
  61612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61613. * @param name defines the name of the mesh
  61614. * @param options defines the options used to create the mesh
  61615. * @param scene defines the hosting scene
  61616. * @returns the tiled ground mesh
  61617. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61618. */
  61619. static CreateTiledGround(name: string, options: {
  61620. xmin: number;
  61621. zmin: number;
  61622. xmax: number;
  61623. zmax: number;
  61624. subdivisions?: {
  61625. w: number;
  61626. h: number;
  61627. };
  61628. precision?: {
  61629. w: number;
  61630. h: number;
  61631. };
  61632. updatable?: boolean;
  61633. }, scene?: Nullable<Scene>): Mesh;
  61634. /**
  61635. * Creates a ground mesh from a height map
  61636. * * The parameter `url` sets the URL of the height map image resource.
  61637. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61638. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61639. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61640. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61641. * * 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.
  61642. * * 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).
  61643. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61645. * @param name defines the name of the mesh
  61646. * @param url defines the url to the height map
  61647. * @param options defines the options used to create the mesh
  61648. * @param scene defines the hosting scene
  61649. * @returns the ground mesh
  61650. * @see https://doc.babylonjs.com/babylon101/height_map
  61651. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61652. */
  61653. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61654. width?: number;
  61655. height?: number;
  61656. subdivisions?: number;
  61657. minHeight?: number;
  61658. maxHeight?: number;
  61659. colorFilter?: Color3;
  61660. alphaFilter?: number;
  61661. updatable?: boolean;
  61662. onReady?: (mesh: GroundMesh) => void;
  61663. }, scene?: Nullable<Scene>): GroundMesh;
  61664. /**
  61665. * Creates a polygon mesh
  61666. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61667. * * 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
  61668. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61670. * * 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)
  61671. * * Remember you can only change the shape positions, not their number when updating a polygon
  61672. * @param name defines the name of the mesh
  61673. * @param options defines the options used to create the mesh
  61674. * @param scene defines the hosting scene
  61675. * @param earcutInjection can be used to inject your own earcut reference
  61676. * @returns the polygon mesh
  61677. */
  61678. static CreatePolygon(name: string, options: {
  61679. shape: Vector3[];
  61680. holes?: Vector3[][];
  61681. depth?: number;
  61682. faceUV?: Vector4[];
  61683. faceColors?: Color4[];
  61684. updatable?: boolean;
  61685. sideOrientation?: number;
  61686. frontUVs?: Vector4;
  61687. backUVs?: Vector4;
  61688. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61689. /**
  61690. * Creates an extruded polygon mesh, with depth in the Y direction.
  61691. * * 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)
  61692. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61693. * @param name defines the name of the mesh
  61694. * @param options defines the options used to create the mesh
  61695. * @param scene defines the hosting scene
  61696. * @param earcutInjection can be used to inject your own earcut reference
  61697. * @returns the polygon mesh
  61698. */
  61699. static ExtrudePolygon(name: string, options: {
  61700. shape: Vector3[];
  61701. holes?: Vector3[][];
  61702. depth?: number;
  61703. faceUV?: Vector4[];
  61704. faceColors?: Color4[];
  61705. updatable?: boolean;
  61706. sideOrientation?: number;
  61707. frontUVs?: Vector4;
  61708. backUVs?: Vector4;
  61709. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61710. /**
  61711. * Creates a tube mesh.
  61712. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61713. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61714. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61715. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61716. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61717. * * 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)
  61718. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61719. * * 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
  61720. * * 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
  61721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61722. * * 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
  61723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61725. * @param name defines the name of the mesh
  61726. * @param options defines the options used to create the mesh
  61727. * @param scene defines the hosting scene
  61728. * @returns the tube mesh
  61729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61730. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61731. */
  61732. static CreateTube(name: string, options: {
  61733. path: Vector3[];
  61734. radius?: number;
  61735. tessellation?: number;
  61736. radiusFunction?: {
  61737. (i: number, distance: number): number;
  61738. };
  61739. cap?: number;
  61740. arc?: number;
  61741. updatable?: boolean;
  61742. sideOrientation?: number;
  61743. frontUVs?: Vector4;
  61744. backUVs?: Vector4;
  61745. instance?: Mesh;
  61746. invertUV?: boolean;
  61747. }, scene?: Nullable<Scene>): Mesh;
  61748. /**
  61749. * Creates a polyhedron mesh
  61750. * * 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
  61751. * * The parameter `size` (positive float, default 1) sets the polygon size
  61752. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61753. * * 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`
  61754. * * 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
  61755. * * 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)`)
  61756. * * 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
  61757. * * 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
  61758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61759. * * 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
  61760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61761. * @param name defines the name of the mesh
  61762. * @param options defines the options used to create the mesh
  61763. * @param scene defines the hosting scene
  61764. * @returns the polyhedron mesh
  61765. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61766. */
  61767. static CreatePolyhedron(name: string, options: {
  61768. type?: number;
  61769. size?: number;
  61770. sizeX?: number;
  61771. sizeY?: number;
  61772. sizeZ?: number;
  61773. custom?: any;
  61774. faceUV?: Vector4[];
  61775. faceColors?: Color4[];
  61776. flat?: boolean;
  61777. updatable?: boolean;
  61778. sideOrientation?: number;
  61779. frontUVs?: Vector4;
  61780. backUVs?: Vector4;
  61781. }, scene?: Nullable<Scene>): Mesh;
  61782. /**
  61783. * Creates a decal mesh.
  61784. * 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
  61785. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61786. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61787. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61788. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61789. * @param name defines the name of the mesh
  61790. * @param sourceMesh defines the mesh where the decal must be applied
  61791. * @param options defines the options used to create the mesh
  61792. * @param scene defines the hosting scene
  61793. * @returns the decal mesh
  61794. * @see https://doc.babylonjs.com/how_to/decals
  61795. */
  61796. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61797. position?: Vector3;
  61798. normal?: Vector3;
  61799. size?: Vector3;
  61800. angle?: number;
  61801. }): Mesh;
  61802. }
  61803. }
  61804. declare module BABYLON {
  61805. /**
  61806. * A simplifier interface for future simplification implementations
  61807. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61808. */
  61809. export interface ISimplifier {
  61810. /**
  61811. * Simplification of a given mesh according to the given settings.
  61812. * Since this requires computation, it is assumed that the function runs async.
  61813. * @param settings The settings of the simplification, including quality and distance
  61814. * @param successCallback A callback that will be called after the mesh was simplified.
  61815. * @param errorCallback in case of an error, this callback will be called. optional.
  61816. */
  61817. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61818. }
  61819. /**
  61820. * Expected simplification settings.
  61821. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61822. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61823. */
  61824. export interface ISimplificationSettings {
  61825. /**
  61826. * Gets or sets the expected quality
  61827. */
  61828. quality: number;
  61829. /**
  61830. * Gets or sets the distance when this optimized version should be used
  61831. */
  61832. distance: number;
  61833. /**
  61834. * Gets an already optimized mesh
  61835. */
  61836. optimizeMesh?: boolean;
  61837. }
  61838. /**
  61839. * Class used to specify simplification options
  61840. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61841. */
  61842. export class SimplificationSettings implements ISimplificationSettings {
  61843. /** expected quality */
  61844. quality: number;
  61845. /** distance when this optimized version should be used */
  61846. distance: number;
  61847. /** already optimized mesh */
  61848. optimizeMesh?: boolean | undefined;
  61849. /**
  61850. * Creates a SimplificationSettings
  61851. * @param quality expected quality
  61852. * @param distance distance when this optimized version should be used
  61853. * @param optimizeMesh already optimized mesh
  61854. */
  61855. constructor(
  61856. /** expected quality */
  61857. quality: number,
  61858. /** distance when this optimized version should be used */
  61859. distance: number,
  61860. /** already optimized mesh */
  61861. optimizeMesh?: boolean | undefined);
  61862. }
  61863. /**
  61864. * Interface used to define a simplification task
  61865. */
  61866. export interface ISimplificationTask {
  61867. /**
  61868. * Array of settings
  61869. */
  61870. settings: Array<ISimplificationSettings>;
  61871. /**
  61872. * Simplification type
  61873. */
  61874. simplificationType: SimplificationType;
  61875. /**
  61876. * Mesh to simplify
  61877. */
  61878. mesh: Mesh;
  61879. /**
  61880. * Callback called on success
  61881. */
  61882. successCallback?: () => void;
  61883. /**
  61884. * Defines if parallel processing can be used
  61885. */
  61886. parallelProcessing: boolean;
  61887. }
  61888. /**
  61889. * Queue used to order the simplification tasks
  61890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61891. */
  61892. export class SimplificationQueue {
  61893. private _simplificationArray;
  61894. /**
  61895. * Gets a boolean indicating that the process is still running
  61896. */
  61897. running: boolean;
  61898. /**
  61899. * Creates a new queue
  61900. */
  61901. constructor();
  61902. /**
  61903. * Adds a new simplification task
  61904. * @param task defines a task to add
  61905. */
  61906. addTask(task: ISimplificationTask): void;
  61907. /**
  61908. * Execute next task
  61909. */
  61910. executeNext(): void;
  61911. /**
  61912. * Execute a simplification task
  61913. * @param task defines the task to run
  61914. */
  61915. runSimplification(task: ISimplificationTask): void;
  61916. private getSimplifier;
  61917. }
  61918. /**
  61919. * The implemented types of simplification
  61920. * At the moment only Quadratic Error Decimation is implemented
  61921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61922. */
  61923. export enum SimplificationType {
  61924. /** Quadratic error decimation */
  61925. QUADRATIC = 0
  61926. }
  61927. }
  61928. declare module BABYLON {
  61929. interface Scene {
  61930. /** @hidden (Backing field) */
  61931. _simplificationQueue: SimplificationQueue;
  61932. /**
  61933. * Gets or sets the simplification queue attached to the scene
  61934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61935. */
  61936. simplificationQueue: SimplificationQueue;
  61937. }
  61938. interface Mesh {
  61939. /**
  61940. * Simplify the mesh according to the given array of settings.
  61941. * Function will return immediately and will simplify async
  61942. * @param settings a collection of simplification settings
  61943. * @param parallelProcessing should all levels calculate parallel or one after the other
  61944. * @param simplificationType the type of simplification to run
  61945. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61946. * @returns the current mesh
  61947. */
  61948. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61949. }
  61950. /**
  61951. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61952. * created in a scene
  61953. */
  61954. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61955. /**
  61956. * The component name helpfull to identify the component in the list of scene components.
  61957. */
  61958. readonly name: string;
  61959. /**
  61960. * The scene the component belongs to.
  61961. */
  61962. scene: Scene;
  61963. /**
  61964. * Creates a new instance of the component for the given scene
  61965. * @param scene Defines the scene to register the component in
  61966. */
  61967. constructor(scene: Scene);
  61968. /**
  61969. * Registers the component in a given scene
  61970. */
  61971. register(): void;
  61972. /**
  61973. * Rebuilds the elements related to this component in case of
  61974. * context lost for instance.
  61975. */
  61976. rebuild(): void;
  61977. /**
  61978. * Disposes the component and the associated ressources
  61979. */
  61980. dispose(): void;
  61981. private _beforeCameraUpdate;
  61982. }
  61983. }
  61984. declare module BABYLON {
  61985. /**
  61986. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61987. */
  61988. export interface INavigationEnginePlugin {
  61989. /**
  61990. * plugin name
  61991. */
  61992. name: string;
  61993. /**
  61994. * Creates a navigation mesh
  61995. * @param meshes array of all the geometry used to compute the navigatio mesh
  61996. * @param parameters bunch of parameters used to filter geometry
  61997. */
  61998. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61999. /**
  62000. * Create a navigation mesh debug mesh
  62001. * @param scene is where the mesh will be added
  62002. * @returns debug display mesh
  62003. */
  62004. createDebugNavMesh(scene: Scene): Mesh;
  62005. /**
  62006. * Get a navigation mesh constrained position, closest to the parameter position
  62007. * @param position world position
  62008. * @returns the closest point to position constrained by the navigation mesh
  62009. */
  62010. getClosestPoint(position: Vector3): Vector3;
  62011. /**
  62012. * Get a navigation mesh constrained position, within a particular radius
  62013. * @param position world position
  62014. * @param maxRadius the maximum distance to the constrained world position
  62015. * @returns the closest point to position constrained by the navigation mesh
  62016. */
  62017. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62018. /**
  62019. * Compute the final position from a segment made of destination-position
  62020. * @param position world position
  62021. * @param destination world position
  62022. * @returns the resulting point along the navmesh
  62023. */
  62024. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62025. /**
  62026. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62027. * @param start world position
  62028. * @param end world position
  62029. * @returns array containing world position composing the path
  62030. */
  62031. computePath(start: Vector3, end: Vector3): Vector3[];
  62032. /**
  62033. * If this plugin is supported
  62034. * @returns true if plugin is supported
  62035. */
  62036. isSupported(): boolean;
  62037. /**
  62038. * Create a new Crowd so you can add agents
  62039. * @param maxAgents the maximum agent count in the crowd
  62040. * @param maxAgentRadius the maximum radius an agent can have
  62041. * @param scene to attach the crowd to
  62042. * @returns the crowd you can add agents to
  62043. */
  62044. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62045. /**
  62046. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62047. * The queries will try to find a solution within those bounds
  62048. * default is (1,1,1)
  62049. * @param extent x,y,z value that define the extent around the queries point of reference
  62050. */
  62051. setDefaultQueryExtent(extent: Vector3): void;
  62052. /**
  62053. * Get the Bounding box extent specified by setDefaultQueryExtent
  62054. * @returns the box extent values
  62055. */
  62056. getDefaultQueryExtent(): Vector3;
  62057. /**
  62058. * Release all resources
  62059. */
  62060. dispose(): void;
  62061. }
  62062. /**
  62063. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62064. */
  62065. export interface ICrowd {
  62066. /**
  62067. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62068. * You can attach anything to that node. The node position is updated in the scene update tick.
  62069. * @param pos world position that will be constrained by the navigation mesh
  62070. * @param parameters agent parameters
  62071. * @param transform hooked to the agent that will be update by the scene
  62072. * @returns agent index
  62073. */
  62074. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62075. /**
  62076. * Returns the agent position in world space
  62077. * @param index agent index returned by addAgent
  62078. * @returns world space position
  62079. */
  62080. getAgentPosition(index: number): Vector3;
  62081. /**
  62082. * Gets the agent velocity in world space
  62083. * @param index agent index returned by addAgent
  62084. * @returns world space velocity
  62085. */
  62086. getAgentVelocity(index: number): Vector3;
  62087. /**
  62088. * remove a particular agent previously created
  62089. * @param index agent index returned by addAgent
  62090. */
  62091. removeAgent(index: number): void;
  62092. /**
  62093. * get the list of all agents attached to this crowd
  62094. * @returns list of agent indices
  62095. */
  62096. getAgents(): number[];
  62097. /**
  62098. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62099. * @param deltaTime in seconds
  62100. */
  62101. update(deltaTime: number): void;
  62102. /**
  62103. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62104. * @param index agent index returned by addAgent
  62105. * @param destination targeted world position
  62106. */
  62107. agentGoto(index: number, destination: Vector3): void;
  62108. /**
  62109. * Teleport the agent to a new position
  62110. * @param index agent index returned by addAgent
  62111. * @param destination targeted world position
  62112. */
  62113. agentTeleport(index: number, destination: Vector3): void;
  62114. /**
  62115. * Update agent parameters
  62116. * @param index agent index returned by addAgent
  62117. * @param parameters agent parameters
  62118. */
  62119. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62120. /**
  62121. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62122. * The queries will try to find a solution within those bounds
  62123. * default is (1,1,1)
  62124. * @param extent x,y,z value that define the extent around the queries point of reference
  62125. */
  62126. setDefaultQueryExtent(extent: Vector3): void;
  62127. /**
  62128. * Get the Bounding box extent specified by setDefaultQueryExtent
  62129. * @returns the box extent values
  62130. */
  62131. getDefaultQueryExtent(): Vector3;
  62132. /**
  62133. * Release all resources
  62134. */
  62135. dispose(): void;
  62136. }
  62137. /**
  62138. * Configures an agent
  62139. */
  62140. export interface IAgentParameters {
  62141. /**
  62142. * Agent radius. [Limit: >= 0]
  62143. */
  62144. radius: number;
  62145. /**
  62146. * Agent height. [Limit: > 0]
  62147. */
  62148. height: number;
  62149. /**
  62150. * Maximum allowed acceleration. [Limit: >= 0]
  62151. */
  62152. maxAcceleration: number;
  62153. /**
  62154. * Maximum allowed speed. [Limit: >= 0]
  62155. */
  62156. maxSpeed: number;
  62157. /**
  62158. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62159. */
  62160. collisionQueryRange: number;
  62161. /**
  62162. * The path visibility optimization range. [Limit: > 0]
  62163. */
  62164. pathOptimizationRange: number;
  62165. /**
  62166. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62167. */
  62168. separationWeight: number;
  62169. }
  62170. /**
  62171. * Configures the navigation mesh creation
  62172. */
  62173. export interface INavMeshParameters {
  62174. /**
  62175. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62176. */
  62177. cs: number;
  62178. /**
  62179. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62180. */
  62181. ch: number;
  62182. /**
  62183. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62184. */
  62185. walkableSlopeAngle: number;
  62186. /**
  62187. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62188. * be considered walkable. [Limit: >= 3] [Units: vx]
  62189. */
  62190. walkableHeight: number;
  62191. /**
  62192. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62193. */
  62194. walkableClimb: number;
  62195. /**
  62196. * The distance to erode/shrink the walkable area of the heightfield away from
  62197. * obstructions. [Limit: >=0] [Units: vx]
  62198. */
  62199. walkableRadius: number;
  62200. /**
  62201. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62202. */
  62203. maxEdgeLen: number;
  62204. /**
  62205. * The maximum distance a simplfied contour's border edges should deviate
  62206. * the original raw contour. [Limit: >=0] [Units: vx]
  62207. */
  62208. maxSimplificationError: number;
  62209. /**
  62210. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62211. */
  62212. minRegionArea: number;
  62213. /**
  62214. * Any regions with a span count smaller than this value will, if possible,
  62215. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62216. */
  62217. mergeRegionArea: number;
  62218. /**
  62219. * The maximum number of vertices allowed for polygons generated during the
  62220. * contour to polygon conversion process. [Limit: >= 3]
  62221. */
  62222. maxVertsPerPoly: number;
  62223. /**
  62224. * Sets the sampling distance to use when generating the detail mesh.
  62225. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62226. */
  62227. detailSampleDist: number;
  62228. /**
  62229. * The maximum distance the detail mesh surface should deviate from heightfield
  62230. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62231. */
  62232. detailSampleMaxError: number;
  62233. }
  62234. }
  62235. declare module BABYLON {
  62236. /**
  62237. * RecastJS navigation plugin
  62238. */
  62239. export class RecastJSPlugin implements INavigationEnginePlugin {
  62240. /**
  62241. * Reference to the Recast library
  62242. */
  62243. bjsRECAST: any;
  62244. /**
  62245. * plugin name
  62246. */
  62247. name: string;
  62248. /**
  62249. * the first navmesh created. We might extend this to support multiple navmeshes
  62250. */
  62251. navMesh: any;
  62252. /**
  62253. * Initializes the recastJS plugin
  62254. * @param recastInjection can be used to inject your own recast reference
  62255. */
  62256. constructor(recastInjection?: any);
  62257. /**
  62258. * Creates a navigation mesh
  62259. * @param meshes array of all the geometry used to compute the navigatio mesh
  62260. * @param parameters bunch of parameters used to filter geometry
  62261. */
  62262. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62263. /**
  62264. * Create a navigation mesh debug mesh
  62265. * @param scene is where the mesh will be added
  62266. * @returns debug display mesh
  62267. */
  62268. createDebugNavMesh(scene: Scene): Mesh;
  62269. /**
  62270. * Get a navigation mesh constrained position, closest to the parameter position
  62271. * @param position world position
  62272. * @returns the closest point to position constrained by the navigation mesh
  62273. */
  62274. getClosestPoint(position: Vector3): Vector3;
  62275. /**
  62276. * Get a navigation mesh constrained position, within a particular radius
  62277. * @param position world position
  62278. * @param maxRadius the maximum distance to the constrained world position
  62279. * @returns the closest point to position constrained by the navigation mesh
  62280. */
  62281. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62282. /**
  62283. * Compute the final position from a segment made of destination-position
  62284. * @param position world position
  62285. * @param destination world position
  62286. * @returns the resulting point along the navmesh
  62287. */
  62288. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62289. /**
  62290. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62291. * @param start world position
  62292. * @param end world position
  62293. * @returns array containing world position composing the path
  62294. */
  62295. computePath(start: Vector3, end: Vector3): Vector3[];
  62296. /**
  62297. * Create a new Crowd so you can add agents
  62298. * @param maxAgents the maximum agent count in the crowd
  62299. * @param maxAgentRadius the maximum radius an agent can have
  62300. * @param scene to attach the crowd to
  62301. * @returns the crowd you can add agents to
  62302. */
  62303. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62304. /**
  62305. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62306. * The queries will try to find a solution within those bounds
  62307. * default is (1,1,1)
  62308. * @param extent x,y,z value that define the extent around the queries point of reference
  62309. */
  62310. setDefaultQueryExtent(extent: Vector3): void;
  62311. /**
  62312. * Get the Bounding box extent specified by setDefaultQueryExtent
  62313. * @returns the box extent values
  62314. */
  62315. getDefaultQueryExtent(): Vector3;
  62316. /**
  62317. * Disposes
  62318. */
  62319. dispose(): void;
  62320. /**
  62321. * If this plugin is supported
  62322. * @returns true if plugin is supported
  62323. */
  62324. isSupported(): boolean;
  62325. }
  62326. /**
  62327. * Recast detour crowd implementation
  62328. */
  62329. export class RecastJSCrowd implements ICrowd {
  62330. /**
  62331. * Recast/detour plugin
  62332. */
  62333. bjsRECASTPlugin: RecastJSPlugin;
  62334. /**
  62335. * Link to the detour crowd
  62336. */
  62337. recastCrowd: any;
  62338. /**
  62339. * One transform per agent
  62340. */
  62341. transforms: TransformNode[];
  62342. /**
  62343. * All agents created
  62344. */
  62345. agents: number[];
  62346. /**
  62347. * Link to the scene is kept to unregister the crowd from the scene
  62348. */
  62349. private _scene;
  62350. /**
  62351. * Observer for crowd updates
  62352. */
  62353. private _onBeforeAnimationsObserver;
  62354. /**
  62355. * Constructor
  62356. * @param plugin recastJS plugin
  62357. * @param maxAgents the maximum agent count in the crowd
  62358. * @param maxAgentRadius the maximum radius an agent can have
  62359. * @param scene to attach the crowd to
  62360. * @returns the crowd you can add agents to
  62361. */
  62362. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62363. /**
  62364. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62365. * You can attach anything to that node. The node position is updated in the scene update tick.
  62366. * @param pos world position that will be constrained by the navigation mesh
  62367. * @param parameters agent parameters
  62368. * @param transform hooked to the agent that will be update by the scene
  62369. * @returns agent index
  62370. */
  62371. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62372. /**
  62373. * Returns the agent position in world space
  62374. * @param index agent index returned by addAgent
  62375. * @returns world space position
  62376. */
  62377. getAgentPosition(index: number): Vector3;
  62378. /**
  62379. * Returns the agent velocity in world space
  62380. * @param index agent index returned by addAgent
  62381. * @returns world space velocity
  62382. */
  62383. getAgentVelocity(index: number): Vector3;
  62384. /**
  62385. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62386. * @param index agent index returned by addAgent
  62387. * @param destination targeted world position
  62388. */
  62389. agentGoto(index: number, destination: Vector3): void;
  62390. /**
  62391. * Teleport the agent to a new position
  62392. * @param index agent index returned by addAgent
  62393. * @param destination targeted world position
  62394. */
  62395. agentTeleport(index: number, destination: Vector3): void;
  62396. /**
  62397. * Update agent parameters
  62398. * @param index agent index returned by addAgent
  62399. * @param parameters agent parameters
  62400. */
  62401. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62402. /**
  62403. * remove a particular agent previously created
  62404. * @param index agent index returned by addAgent
  62405. */
  62406. removeAgent(index: number): void;
  62407. /**
  62408. * get the list of all agents attached to this crowd
  62409. * @returns list of agent indices
  62410. */
  62411. getAgents(): number[];
  62412. /**
  62413. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62414. * @param deltaTime in seconds
  62415. */
  62416. update(deltaTime: number): void;
  62417. /**
  62418. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62419. * The queries will try to find a solution within those bounds
  62420. * default is (1,1,1)
  62421. * @param extent x,y,z value that define the extent around the queries point of reference
  62422. */
  62423. setDefaultQueryExtent(extent: Vector3): void;
  62424. /**
  62425. * Get the Bounding box extent specified by setDefaultQueryExtent
  62426. * @returns the box extent values
  62427. */
  62428. getDefaultQueryExtent(): Vector3;
  62429. /**
  62430. * Release all resources
  62431. */
  62432. dispose(): void;
  62433. }
  62434. }
  62435. declare module BABYLON {
  62436. /**
  62437. * Class used to enable access to IndexedDB
  62438. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62439. */
  62440. export class Database implements IOfflineProvider {
  62441. private _callbackManifestChecked;
  62442. private _currentSceneUrl;
  62443. private _db;
  62444. private _enableSceneOffline;
  62445. private _enableTexturesOffline;
  62446. private _manifestVersionFound;
  62447. private _mustUpdateRessources;
  62448. private _hasReachedQuota;
  62449. private _isSupported;
  62450. private _idbFactory;
  62451. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62452. private static IsUASupportingBlobStorage;
  62453. /**
  62454. * Gets a boolean indicating if Database storate is enabled (off by default)
  62455. */
  62456. static IDBStorageEnabled: boolean;
  62457. /**
  62458. * Gets a boolean indicating if scene must be saved in the database
  62459. */
  62460. get enableSceneOffline(): boolean;
  62461. /**
  62462. * Gets a boolean indicating if textures must be saved in the database
  62463. */
  62464. get enableTexturesOffline(): boolean;
  62465. /**
  62466. * Creates a new Database
  62467. * @param urlToScene defines the url to load the scene
  62468. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62469. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62470. */
  62471. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62472. private static _ParseURL;
  62473. private static _ReturnFullUrlLocation;
  62474. private _checkManifestFile;
  62475. /**
  62476. * Open the database and make it available
  62477. * @param successCallback defines the callback to call on success
  62478. * @param errorCallback defines the callback to call on error
  62479. */
  62480. open(successCallback: () => void, errorCallback: () => void): void;
  62481. /**
  62482. * Loads an image from the database
  62483. * @param url defines the url to load from
  62484. * @param image defines the target DOM image
  62485. */
  62486. loadImage(url: string, image: HTMLImageElement): void;
  62487. private _loadImageFromDBAsync;
  62488. private _saveImageIntoDBAsync;
  62489. private _checkVersionFromDB;
  62490. private _loadVersionFromDBAsync;
  62491. private _saveVersionIntoDBAsync;
  62492. /**
  62493. * Loads a file from database
  62494. * @param url defines the URL to load from
  62495. * @param sceneLoaded defines a callback to call on success
  62496. * @param progressCallBack defines a callback to call when progress changed
  62497. * @param errorCallback defines a callback to call on error
  62498. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62499. */
  62500. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62501. private _loadFileAsync;
  62502. private _saveFileAsync;
  62503. /**
  62504. * Validates if xhr data is correct
  62505. * @param xhr defines the request to validate
  62506. * @param dataType defines the expected data type
  62507. * @returns true if data is correct
  62508. */
  62509. private static _ValidateXHRData;
  62510. }
  62511. }
  62512. declare module BABYLON {
  62513. /** @hidden */
  62514. export var gpuUpdateParticlesPixelShader: {
  62515. name: string;
  62516. shader: string;
  62517. };
  62518. }
  62519. declare module BABYLON {
  62520. /** @hidden */
  62521. export var gpuUpdateParticlesVertexShader: {
  62522. name: string;
  62523. shader: string;
  62524. };
  62525. }
  62526. declare module BABYLON {
  62527. /** @hidden */
  62528. export var clipPlaneFragmentDeclaration2: {
  62529. name: string;
  62530. shader: string;
  62531. };
  62532. }
  62533. declare module BABYLON {
  62534. /** @hidden */
  62535. export var gpuRenderParticlesPixelShader: {
  62536. name: string;
  62537. shader: string;
  62538. };
  62539. }
  62540. declare module BABYLON {
  62541. /** @hidden */
  62542. export var clipPlaneVertexDeclaration2: {
  62543. name: string;
  62544. shader: string;
  62545. };
  62546. }
  62547. declare module BABYLON {
  62548. /** @hidden */
  62549. export var gpuRenderParticlesVertexShader: {
  62550. name: string;
  62551. shader: string;
  62552. };
  62553. }
  62554. declare module BABYLON {
  62555. /**
  62556. * This represents a GPU particle system in Babylon
  62557. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62558. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62559. */
  62560. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62561. /**
  62562. * The layer mask we are rendering the particles through.
  62563. */
  62564. layerMask: number;
  62565. private _capacity;
  62566. private _activeCount;
  62567. private _currentActiveCount;
  62568. private _accumulatedCount;
  62569. private _renderEffect;
  62570. private _updateEffect;
  62571. private _buffer0;
  62572. private _buffer1;
  62573. private _spriteBuffer;
  62574. private _updateVAO;
  62575. private _renderVAO;
  62576. private _targetIndex;
  62577. private _sourceBuffer;
  62578. private _targetBuffer;
  62579. private _engine;
  62580. private _currentRenderId;
  62581. private _started;
  62582. private _stopped;
  62583. private _timeDelta;
  62584. private _randomTexture;
  62585. private _randomTexture2;
  62586. private _attributesStrideSize;
  62587. private _updateEffectOptions;
  62588. private _randomTextureSize;
  62589. private _actualFrame;
  62590. private readonly _rawTextureWidth;
  62591. /**
  62592. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62593. */
  62594. static get IsSupported(): boolean;
  62595. /**
  62596. * An event triggered when the system is disposed.
  62597. */
  62598. onDisposeObservable: Observable<GPUParticleSystem>;
  62599. /**
  62600. * Gets the maximum number of particles active at the same time.
  62601. * @returns The max number of active particles.
  62602. */
  62603. getCapacity(): number;
  62604. /**
  62605. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62606. * to override the particles.
  62607. */
  62608. forceDepthWrite: boolean;
  62609. /**
  62610. * Gets or set the number of active particles
  62611. */
  62612. get activeParticleCount(): number;
  62613. set activeParticleCount(value: number);
  62614. private _preWarmDone;
  62615. /**
  62616. * Is this system ready to be used/rendered
  62617. * @return true if the system is ready
  62618. */
  62619. isReady(): boolean;
  62620. /**
  62621. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62622. * @returns True if it has been started, otherwise false.
  62623. */
  62624. isStarted(): boolean;
  62625. /**
  62626. * Starts the particle system and begins to emit
  62627. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62628. */
  62629. start(delay?: number): void;
  62630. /**
  62631. * Stops the particle system.
  62632. */
  62633. stop(): void;
  62634. /**
  62635. * Remove all active particles
  62636. */
  62637. reset(): void;
  62638. /**
  62639. * Returns the string "GPUParticleSystem"
  62640. * @returns a string containing the class name
  62641. */
  62642. getClassName(): string;
  62643. private _colorGradientsTexture;
  62644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62645. /**
  62646. * Adds a new color gradient
  62647. * @param gradient defines the gradient to use (between 0 and 1)
  62648. * @param color1 defines the color to affect to the specified gradient
  62649. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62650. * @returns the current particle system
  62651. */
  62652. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62653. /**
  62654. * Remove a specific color gradient
  62655. * @param gradient defines the gradient to remove
  62656. * @returns the current particle system
  62657. */
  62658. removeColorGradient(gradient: number): GPUParticleSystem;
  62659. private _angularSpeedGradientsTexture;
  62660. private _sizeGradientsTexture;
  62661. private _velocityGradientsTexture;
  62662. private _limitVelocityGradientsTexture;
  62663. private _dragGradientsTexture;
  62664. private _addFactorGradient;
  62665. /**
  62666. * Adds a new size gradient
  62667. * @param gradient defines the gradient to use (between 0 and 1)
  62668. * @param factor defines the size factor to affect to the specified gradient
  62669. * @returns the current particle system
  62670. */
  62671. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62672. /**
  62673. * Remove a specific size gradient
  62674. * @param gradient defines the gradient to remove
  62675. * @returns the current particle system
  62676. */
  62677. removeSizeGradient(gradient: number): GPUParticleSystem;
  62678. /**
  62679. * Adds a new angular speed gradient
  62680. * @param gradient defines the gradient to use (between 0 and 1)
  62681. * @param factor defines the angular speed to affect to the specified gradient
  62682. * @returns the current particle system
  62683. */
  62684. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62685. /**
  62686. * Remove a specific angular speed gradient
  62687. * @param gradient defines the gradient to remove
  62688. * @returns the current particle system
  62689. */
  62690. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62691. /**
  62692. * Adds a new velocity gradient
  62693. * @param gradient defines the gradient to use (between 0 and 1)
  62694. * @param factor defines the velocity to affect to the specified gradient
  62695. * @returns the current particle system
  62696. */
  62697. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62698. /**
  62699. * Remove a specific velocity gradient
  62700. * @param gradient defines the gradient to remove
  62701. * @returns the current particle system
  62702. */
  62703. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62704. /**
  62705. * Adds a new limit velocity gradient
  62706. * @param gradient defines the gradient to use (between 0 and 1)
  62707. * @param factor defines the limit velocity value to affect to the specified gradient
  62708. * @returns the current particle system
  62709. */
  62710. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62711. /**
  62712. * Remove a specific limit velocity gradient
  62713. * @param gradient defines the gradient to remove
  62714. * @returns the current particle system
  62715. */
  62716. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62717. /**
  62718. * Adds a new drag gradient
  62719. * @param gradient defines the gradient to use (between 0 and 1)
  62720. * @param factor defines the drag value to affect to the specified gradient
  62721. * @returns the current particle system
  62722. */
  62723. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62724. /**
  62725. * Remove a specific drag gradient
  62726. * @param gradient defines the gradient to remove
  62727. * @returns the current particle system
  62728. */
  62729. removeDragGradient(gradient: number): GPUParticleSystem;
  62730. /**
  62731. * Not supported by GPUParticleSystem
  62732. * @param gradient defines the gradient to use (between 0 and 1)
  62733. * @param factor defines the emit rate value to affect to the specified gradient
  62734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62735. * @returns the current particle system
  62736. */
  62737. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62738. /**
  62739. * Not supported by GPUParticleSystem
  62740. * @param gradient defines the gradient to remove
  62741. * @returns the current particle system
  62742. */
  62743. removeEmitRateGradient(gradient: number): IParticleSystem;
  62744. /**
  62745. * Not supported by GPUParticleSystem
  62746. * @param gradient defines the gradient to use (between 0 and 1)
  62747. * @param factor defines the start size value to affect to the specified gradient
  62748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62749. * @returns the current particle system
  62750. */
  62751. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62752. /**
  62753. * Not supported by GPUParticleSystem
  62754. * @param gradient defines the gradient to remove
  62755. * @returns the current particle system
  62756. */
  62757. removeStartSizeGradient(gradient: number): IParticleSystem;
  62758. /**
  62759. * Not supported by GPUParticleSystem
  62760. * @param gradient defines the gradient to use (between 0 and 1)
  62761. * @param min defines the color remap minimal range
  62762. * @param max defines the color remap maximal range
  62763. * @returns the current particle system
  62764. */
  62765. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62766. /**
  62767. * Not supported by GPUParticleSystem
  62768. * @param gradient defines the gradient to remove
  62769. * @returns the current particle system
  62770. */
  62771. removeColorRemapGradient(): IParticleSystem;
  62772. /**
  62773. * Not supported by GPUParticleSystem
  62774. * @param gradient defines the gradient to use (between 0 and 1)
  62775. * @param min defines the alpha remap minimal range
  62776. * @param max defines the alpha remap maximal range
  62777. * @returns the current particle system
  62778. */
  62779. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62780. /**
  62781. * Not supported by GPUParticleSystem
  62782. * @param gradient defines the gradient to remove
  62783. * @returns the current particle system
  62784. */
  62785. removeAlphaRemapGradient(): IParticleSystem;
  62786. /**
  62787. * Not supported by GPUParticleSystem
  62788. * @param gradient defines the gradient to use (between 0 and 1)
  62789. * @param color defines the color to affect to the specified gradient
  62790. * @returns the current particle system
  62791. */
  62792. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62793. /**
  62794. * Not supported by GPUParticleSystem
  62795. * @param gradient defines the gradient to remove
  62796. * @returns the current particle system
  62797. */
  62798. removeRampGradient(): IParticleSystem;
  62799. /**
  62800. * Not supported by GPUParticleSystem
  62801. * @returns the list of ramp gradients
  62802. */
  62803. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62804. /**
  62805. * Not supported by GPUParticleSystem
  62806. * Gets or sets a boolean indicating that ramp gradients must be used
  62807. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62808. */
  62809. get useRampGradients(): boolean;
  62810. set useRampGradients(value: boolean);
  62811. /**
  62812. * Not supported by GPUParticleSystem
  62813. * @param gradient defines the gradient to use (between 0 and 1)
  62814. * @param factor defines the life time factor to affect to the specified gradient
  62815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62816. * @returns the current particle system
  62817. */
  62818. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62819. /**
  62820. * Not supported by GPUParticleSystem
  62821. * @param gradient defines the gradient to remove
  62822. * @returns the current particle system
  62823. */
  62824. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62825. /**
  62826. * Instantiates a GPU particle system.
  62827. * 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.
  62828. * @param name The name of the particle system
  62829. * @param options The options used to create the system
  62830. * @param scene The scene the particle system belongs to
  62831. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62832. */
  62833. constructor(name: string, options: Partial<{
  62834. capacity: number;
  62835. randomTextureSize: number;
  62836. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62837. protected _reset(): void;
  62838. private _createUpdateVAO;
  62839. private _createRenderVAO;
  62840. private _initialize;
  62841. /** @hidden */
  62842. _recreateUpdateEffect(): void;
  62843. /** @hidden */
  62844. _recreateRenderEffect(): void;
  62845. /**
  62846. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62847. * @param preWarm defines if we are in the pre-warmimg phase
  62848. */
  62849. animate(preWarm?: boolean): void;
  62850. private _createFactorGradientTexture;
  62851. private _createSizeGradientTexture;
  62852. private _createAngularSpeedGradientTexture;
  62853. private _createVelocityGradientTexture;
  62854. private _createLimitVelocityGradientTexture;
  62855. private _createDragGradientTexture;
  62856. private _createColorGradientTexture;
  62857. /**
  62858. * Renders the particle system in its current state
  62859. * @param preWarm defines if the system should only update the particles but not render them
  62860. * @returns the current number of particles
  62861. */
  62862. render(preWarm?: boolean): number;
  62863. /**
  62864. * Rebuilds the particle system
  62865. */
  62866. rebuild(): void;
  62867. private _releaseBuffers;
  62868. private _releaseVAOs;
  62869. /**
  62870. * Disposes the particle system and free the associated resources
  62871. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62872. */
  62873. dispose(disposeTexture?: boolean): void;
  62874. /**
  62875. * Clones the particle system.
  62876. * @param name The name of the cloned object
  62877. * @param newEmitter The new emitter to use
  62878. * @returns the cloned particle system
  62879. */
  62880. clone(name: string, newEmitter: any): GPUParticleSystem;
  62881. /**
  62882. * Serializes the particle system to a JSON object.
  62883. * @returns the JSON object
  62884. */
  62885. serialize(): any;
  62886. /**
  62887. * Parses a JSON object to create a GPU particle system.
  62888. * @param parsedParticleSystem The JSON object to parse
  62889. * @param scene The scene to create the particle system in
  62890. * @param rootUrl The root url to use to load external dependencies like texture
  62891. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62892. * @returns the parsed GPU particle system
  62893. */
  62894. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62895. }
  62896. }
  62897. declare module BABYLON {
  62898. /**
  62899. * Represents a set of particle systems working together to create a specific effect
  62900. */
  62901. export class ParticleSystemSet implements IDisposable {
  62902. /**
  62903. * Gets or sets base Assets URL
  62904. */
  62905. static BaseAssetsUrl: string;
  62906. private _emitterCreationOptions;
  62907. private _emitterNode;
  62908. /**
  62909. * Gets the particle system list
  62910. */
  62911. systems: IParticleSystem[];
  62912. /**
  62913. * Gets the emitter node used with this set
  62914. */
  62915. get emitterNode(): Nullable<TransformNode>;
  62916. /**
  62917. * Creates a new emitter mesh as a sphere
  62918. * @param options defines the options used to create the sphere
  62919. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62920. * @param scene defines the hosting scene
  62921. */
  62922. setEmitterAsSphere(options: {
  62923. diameter: number;
  62924. segments: number;
  62925. color: Color3;
  62926. }, renderingGroupId: number, scene: Scene): void;
  62927. /**
  62928. * Starts all particle systems of the set
  62929. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62930. */
  62931. start(emitter?: AbstractMesh): void;
  62932. /**
  62933. * Release all associated resources
  62934. */
  62935. dispose(): void;
  62936. /**
  62937. * Serialize the set into a JSON compatible object
  62938. * @returns a JSON compatible representation of the set
  62939. */
  62940. serialize(): any;
  62941. /**
  62942. * Parse a new ParticleSystemSet from a serialized source
  62943. * @param data defines a JSON compatible representation of the set
  62944. * @param scene defines the hosting scene
  62945. * @param gpu defines if we want GPU particles or CPU particles
  62946. * @returns a new ParticleSystemSet
  62947. */
  62948. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62949. }
  62950. }
  62951. declare module BABYLON {
  62952. /**
  62953. * This class is made for on one-liner static method to help creating particle system set.
  62954. */
  62955. export class ParticleHelper {
  62956. /**
  62957. * Gets or sets base Assets URL
  62958. */
  62959. static BaseAssetsUrl: string;
  62960. /**
  62961. * Create a default particle system that you can tweak
  62962. * @param emitter defines the emitter to use
  62963. * @param capacity defines the system capacity (default is 500 particles)
  62964. * @param scene defines the hosting scene
  62965. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62966. * @returns the new Particle system
  62967. */
  62968. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62969. /**
  62970. * This is the main static method (one-liner) of this helper to create different particle systems
  62971. * @param type This string represents the type to the particle system to create
  62972. * @param scene The scene where the particle system should live
  62973. * @param gpu If the system will use gpu
  62974. * @returns the ParticleSystemSet created
  62975. */
  62976. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62977. /**
  62978. * Static function used to export a particle system to a ParticleSystemSet variable.
  62979. * Please note that the emitter shape is not exported
  62980. * @param systems defines the particle systems to export
  62981. * @returns the created particle system set
  62982. */
  62983. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62984. }
  62985. }
  62986. declare module BABYLON {
  62987. interface Engine {
  62988. /**
  62989. * Create an effect to use with particle systems.
  62990. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62991. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62992. * @param uniformsNames defines a list of attribute names
  62993. * @param samplers defines an array of string used to represent textures
  62994. * @param defines defines the string containing the defines to use to compile the shaders
  62995. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62996. * @param onCompiled defines a function to call when the effect creation is successful
  62997. * @param onError defines a function to call when the effect creation has failed
  62998. * @returns the new Effect
  62999. */
  63000. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63001. }
  63002. interface Mesh {
  63003. /**
  63004. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63005. * @returns an array of IParticleSystem
  63006. */
  63007. getEmittedParticleSystems(): IParticleSystem[];
  63008. /**
  63009. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63010. * @returns an array of IParticleSystem
  63011. */
  63012. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63013. }
  63014. /**
  63015. * @hidden
  63016. */
  63017. export var _IDoNeedToBeInTheBuild: number;
  63018. }
  63019. declare module BABYLON {
  63020. /** Defines the 4 color options */
  63021. export enum PointColor {
  63022. /** color value */
  63023. Color = 2,
  63024. /** uv value */
  63025. UV = 1,
  63026. /** random value */
  63027. Random = 0,
  63028. /** stated value */
  63029. Stated = 3
  63030. }
  63031. /**
  63032. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63033. * 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.
  63034. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63035. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63036. *
  63037. * Full documentation here : TO BE ENTERED
  63038. */
  63039. export class PointsCloudSystem implements IDisposable {
  63040. /**
  63041. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63042. * Example : var p = SPS.particles[i];
  63043. */
  63044. particles: CloudPoint[];
  63045. /**
  63046. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63047. */
  63048. nbParticles: number;
  63049. /**
  63050. * This a counter for your own usage. It's not set by any SPS functions.
  63051. */
  63052. counter: number;
  63053. /**
  63054. * The PCS name. This name is also given to the underlying mesh.
  63055. */
  63056. name: string;
  63057. /**
  63058. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63059. */
  63060. mesh: Mesh;
  63061. /**
  63062. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63063. * Please read :
  63064. */
  63065. vars: any;
  63066. /**
  63067. * @hidden
  63068. */
  63069. _size: number;
  63070. private _scene;
  63071. private _promises;
  63072. private _positions;
  63073. private _indices;
  63074. private _normals;
  63075. private _colors;
  63076. private _uvs;
  63077. private _indices32;
  63078. private _positions32;
  63079. private _colors32;
  63080. private _uvs32;
  63081. private _updatable;
  63082. private _isVisibilityBoxLocked;
  63083. private _alwaysVisible;
  63084. private _groups;
  63085. private _groupCounter;
  63086. private _computeParticleColor;
  63087. private _computeParticleTexture;
  63088. private _computeParticleRotation;
  63089. private _computeBoundingBox;
  63090. private _isReady;
  63091. /**
  63092. * Creates a PCS (Points Cloud System) object
  63093. * @param name (String) is the PCS name, this will be the underlying mesh name
  63094. * @param pointSize (number) is the size for each point
  63095. * @param scene (Scene) is the scene in which the PCS is added
  63096. * @param options defines the options of the PCS e.g.
  63097. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63098. */
  63099. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63100. updatable?: boolean;
  63101. });
  63102. /**
  63103. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63104. * If no points were added to the PCS, the returned mesh is just a single point.
  63105. * @returns a promise for the created mesh
  63106. */
  63107. buildMeshAsync(): Promise<Mesh>;
  63108. /**
  63109. * @hidden
  63110. */
  63111. private _buildMesh;
  63112. private _addParticle;
  63113. private _randomUnitVector;
  63114. private _getColorIndicesForCoord;
  63115. private _setPointsColorOrUV;
  63116. private _colorFromTexture;
  63117. private _calculateDensity;
  63118. /**
  63119. * Adds points to the PCS in random positions within a unit sphere
  63120. * @param nb (positive integer) the number of particles to be created from this model
  63121. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63122. * @returns the number of groups in the system
  63123. */
  63124. addPoints(nb: number, pointFunction?: any): number;
  63125. /**
  63126. * Adds points to the PCS from the surface of the model shape
  63127. * @param mesh is any Mesh object that will be used as a surface model for the points
  63128. * @param nb (positive integer) the number of particles to be created from this model
  63129. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63130. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63131. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63132. * @returns the number of groups in the system
  63133. */
  63134. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63135. /**
  63136. * Adds points to the PCS inside the model shape
  63137. * @param mesh is any Mesh object that will be used as a surface model for the points
  63138. * @param nb (positive integer) the number of particles to be created from this model
  63139. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63140. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63141. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63142. * @returns the number of groups in the system
  63143. */
  63144. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63145. /**
  63146. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63147. * This method calls `updateParticle()` for each particle of the SPS.
  63148. * For an animated SPS, it is usually called within the render loop.
  63149. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63150. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63151. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63152. * @returns the PCS.
  63153. */
  63154. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63155. /**
  63156. * Disposes the PCS.
  63157. */
  63158. dispose(): void;
  63159. /**
  63160. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63161. * doc :
  63162. * @returns the PCS.
  63163. */
  63164. refreshVisibleSize(): PointsCloudSystem;
  63165. /**
  63166. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63167. * @param size the size (float) of the visibility box
  63168. * note : this doesn't lock the PCS mesh bounding box.
  63169. * doc :
  63170. */
  63171. setVisibilityBox(size: number): void;
  63172. /**
  63173. * Gets whether the PCS is always visible or not
  63174. * doc :
  63175. */
  63176. get isAlwaysVisible(): boolean;
  63177. /**
  63178. * Sets the PCS as always visible or not
  63179. * doc :
  63180. */
  63181. set isAlwaysVisible(val: boolean);
  63182. /**
  63183. * Tells to `setParticles()` to compute the particle rotations or not
  63184. * Default value : false. The PCS is faster when it's set to false
  63185. * Note : particle rotations are only applied to parent particles
  63186. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63187. */
  63188. set computeParticleRotation(val: boolean);
  63189. /**
  63190. * Tells to `setParticles()` to compute the particle colors or not.
  63191. * Default value : true. The PCS is faster when it's set to false.
  63192. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63193. */
  63194. set computeParticleColor(val: boolean);
  63195. set computeParticleTexture(val: boolean);
  63196. /**
  63197. * Gets if `setParticles()` computes the particle colors or not.
  63198. * Default value : false. The PCS is faster when it's set to false.
  63199. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63200. */
  63201. get computeParticleColor(): boolean;
  63202. /**
  63203. * Gets if `setParticles()` computes the particle textures or not.
  63204. * Default value : false. The PCS is faster when it's set to false.
  63205. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63206. */
  63207. get computeParticleTexture(): boolean;
  63208. /**
  63209. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63210. */
  63211. set computeBoundingBox(val: boolean);
  63212. /**
  63213. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63214. */
  63215. get computeBoundingBox(): boolean;
  63216. /**
  63217. * This function does nothing. It may be overwritten to set all the particle first values.
  63218. * The PCS doesn't call this function, you may have to call it by your own.
  63219. * doc :
  63220. */
  63221. initParticles(): void;
  63222. /**
  63223. * This function does nothing. It may be overwritten to recycle a particle
  63224. * The PCS doesn't call this function, you can to call it
  63225. * doc :
  63226. * @param particle The particle to recycle
  63227. * @returns the recycled particle
  63228. */
  63229. recycleParticle(particle: CloudPoint): CloudPoint;
  63230. /**
  63231. * Updates a particle : this function should be overwritten by the user.
  63232. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63233. * doc :
  63234. * @example : just set a particle position or velocity and recycle conditions
  63235. * @param particle The particle to update
  63236. * @returns the updated particle
  63237. */
  63238. updateParticle(particle: CloudPoint): CloudPoint;
  63239. /**
  63240. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63241. * This does nothing and may be overwritten by the user.
  63242. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63243. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63244. * @param update the boolean update value actually passed to setParticles()
  63245. */
  63246. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63247. /**
  63248. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63249. * This will be passed three parameters.
  63250. * This does nothing and may be overwritten by the user.
  63251. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63252. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63253. * @param update the boolean update value actually passed to setParticles()
  63254. */
  63255. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63256. }
  63257. }
  63258. declare module BABYLON {
  63259. /**
  63260. * Represents one particle of a points cloud system.
  63261. */
  63262. export class CloudPoint {
  63263. /**
  63264. * particle global index
  63265. */
  63266. idx: number;
  63267. /**
  63268. * The color of the particle
  63269. */
  63270. color: Nullable<Color4>;
  63271. /**
  63272. * The world space position of the particle.
  63273. */
  63274. position: Vector3;
  63275. /**
  63276. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63277. */
  63278. rotation: Vector3;
  63279. /**
  63280. * The world space rotation quaternion of the particle.
  63281. */
  63282. rotationQuaternion: Nullable<Quaternion>;
  63283. /**
  63284. * The uv of the particle.
  63285. */
  63286. uv: Nullable<Vector2>;
  63287. /**
  63288. * The current speed of the particle.
  63289. */
  63290. velocity: Vector3;
  63291. /**
  63292. * The pivot point in the particle local space.
  63293. */
  63294. pivot: Vector3;
  63295. /**
  63296. * Must the particle be translated from its pivot point in its local space ?
  63297. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63298. * Default : false
  63299. */
  63300. translateFromPivot: boolean;
  63301. /**
  63302. * Index of this particle in the global "positions" array (Internal use)
  63303. * @hidden
  63304. */
  63305. _pos: number;
  63306. /**
  63307. * @hidden Index of this particle in the global "indices" array (Internal use)
  63308. */
  63309. _ind: number;
  63310. /**
  63311. * Group this particle belongs to
  63312. */
  63313. _group: PointsGroup;
  63314. /**
  63315. * Group id of this particle
  63316. */
  63317. groupId: number;
  63318. /**
  63319. * Index of the particle in its group id (Internal use)
  63320. */
  63321. idxInGroup: number;
  63322. /**
  63323. * @hidden Particle BoundingInfo object (Internal use)
  63324. */
  63325. _boundingInfo: BoundingInfo;
  63326. /**
  63327. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63328. */
  63329. _pcs: PointsCloudSystem;
  63330. /**
  63331. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63332. */
  63333. _stillInvisible: boolean;
  63334. /**
  63335. * @hidden Last computed particle rotation matrix
  63336. */
  63337. _rotationMatrix: number[];
  63338. /**
  63339. * Parent particle Id, if any.
  63340. * Default null.
  63341. */
  63342. parentId: Nullable<number>;
  63343. /**
  63344. * @hidden Internal global position in the PCS.
  63345. */
  63346. _globalPosition: Vector3;
  63347. /**
  63348. * Creates a Point Cloud object.
  63349. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63350. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63351. * @param group (PointsGroup) is the group the particle belongs to
  63352. * @param groupId (integer) is the group identifier in the PCS.
  63353. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63354. * @param pcs defines the PCS it is associated to
  63355. */
  63356. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63357. /**
  63358. * get point size
  63359. */
  63360. get size(): Vector3;
  63361. /**
  63362. * Set point size
  63363. */
  63364. set size(scale: Vector3);
  63365. /**
  63366. * Legacy support, changed quaternion to rotationQuaternion
  63367. */
  63368. get quaternion(): Nullable<Quaternion>;
  63369. /**
  63370. * Legacy support, changed quaternion to rotationQuaternion
  63371. */
  63372. set quaternion(q: Nullable<Quaternion>);
  63373. /**
  63374. * Returns a boolean. True if the particle intersects a mesh, else false
  63375. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63376. * @param target is the object (point or mesh) what the intersection is computed against
  63377. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63378. * @returns true if it intersects
  63379. */
  63380. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63381. /**
  63382. * get the rotation matrix of the particle
  63383. * @hidden
  63384. */
  63385. getRotationMatrix(m: Matrix): void;
  63386. }
  63387. /**
  63388. * Represents a group of points in a points cloud system
  63389. * * PCS internal tool, don't use it manually.
  63390. */
  63391. export class PointsGroup {
  63392. /**
  63393. * The group id
  63394. * @hidden
  63395. */
  63396. groupID: number;
  63397. /**
  63398. * image data for group (internal use)
  63399. * @hidden
  63400. */
  63401. _groupImageData: Nullable<ArrayBufferView>;
  63402. /**
  63403. * Image Width (internal use)
  63404. * @hidden
  63405. */
  63406. _groupImgWidth: number;
  63407. /**
  63408. * Image Height (internal use)
  63409. * @hidden
  63410. */
  63411. _groupImgHeight: number;
  63412. /**
  63413. * Custom position function (internal use)
  63414. * @hidden
  63415. */
  63416. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63417. /**
  63418. * density per facet for surface points
  63419. * @hidden
  63420. */
  63421. _groupDensity: number[];
  63422. /**
  63423. * Only when points are colored by texture carries pointer to texture list array
  63424. * @hidden
  63425. */
  63426. _textureNb: number;
  63427. /**
  63428. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63429. * PCS internal tool, don't use it manually.
  63430. * @hidden
  63431. */
  63432. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63433. }
  63434. }
  63435. declare module BABYLON {
  63436. interface Scene {
  63437. /** @hidden (Backing field) */
  63438. _physicsEngine: Nullable<IPhysicsEngine>;
  63439. /** @hidden */
  63440. _physicsTimeAccumulator: number;
  63441. /**
  63442. * Gets the current physics engine
  63443. * @returns a IPhysicsEngine or null if none attached
  63444. */
  63445. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63446. /**
  63447. * Enables physics to the current scene
  63448. * @param gravity defines the scene's gravity for the physics engine
  63449. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63450. * @return a boolean indicating if the physics engine was initialized
  63451. */
  63452. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63453. /**
  63454. * Disables and disposes the physics engine associated with the scene
  63455. */
  63456. disablePhysicsEngine(): void;
  63457. /**
  63458. * Gets a boolean indicating if there is an active physics engine
  63459. * @returns a boolean indicating if there is an active physics engine
  63460. */
  63461. isPhysicsEnabled(): boolean;
  63462. /**
  63463. * Deletes a physics compound impostor
  63464. * @param compound defines the compound to delete
  63465. */
  63466. deleteCompoundImpostor(compound: any): void;
  63467. /**
  63468. * An event triggered when physic simulation is about to be run
  63469. */
  63470. onBeforePhysicsObservable: Observable<Scene>;
  63471. /**
  63472. * An event triggered when physic simulation has been done
  63473. */
  63474. onAfterPhysicsObservable: Observable<Scene>;
  63475. }
  63476. interface AbstractMesh {
  63477. /** @hidden */
  63478. _physicsImpostor: Nullable<PhysicsImpostor>;
  63479. /**
  63480. * Gets or sets impostor used for physic simulation
  63481. * @see http://doc.babylonjs.com/features/physics_engine
  63482. */
  63483. physicsImpostor: Nullable<PhysicsImpostor>;
  63484. /**
  63485. * Gets the current physics impostor
  63486. * @see http://doc.babylonjs.com/features/physics_engine
  63487. * @returns a physics impostor or null
  63488. */
  63489. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63490. /** Apply a physic impulse to the mesh
  63491. * @param force defines the force to apply
  63492. * @param contactPoint defines where to apply the force
  63493. * @returns the current mesh
  63494. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63495. */
  63496. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63497. /**
  63498. * Creates a physic joint between two meshes
  63499. * @param otherMesh defines the other mesh to use
  63500. * @param pivot1 defines the pivot to use on this mesh
  63501. * @param pivot2 defines the pivot to use on the other mesh
  63502. * @param options defines additional options (can be plugin dependent)
  63503. * @returns the current mesh
  63504. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63505. */
  63506. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63507. /** @hidden */
  63508. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63509. }
  63510. /**
  63511. * Defines the physics engine scene component responsible to manage a physics engine
  63512. */
  63513. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63514. /**
  63515. * The component name helpful to identify the component in the list of scene components.
  63516. */
  63517. readonly name: string;
  63518. /**
  63519. * The scene the component belongs to.
  63520. */
  63521. scene: Scene;
  63522. /**
  63523. * Creates a new instance of the component for the given scene
  63524. * @param scene Defines the scene to register the component in
  63525. */
  63526. constructor(scene: Scene);
  63527. /**
  63528. * Registers the component in a given scene
  63529. */
  63530. register(): void;
  63531. /**
  63532. * Rebuilds the elements related to this component in case of
  63533. * context lost for instance.
  63534. */
  63535. rebuild(): void;
  63536. /**
  63537. * Disposes the component and the associated ressources
  63538. */
  63539. dispose(): void;
  63540. }
  63541. }
  63542. declare module BABYLON {
  63543. /**
  63544. * A helper for physics simulations
  63545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63546. */
  63547. export class PhysicsHelper {
  63548. private _scene;
  63549. private _physicsEngine;
  63550. /**
  63551. * Initializes the Physics helper
  63552. * @param scene Babylon.js scene
  63553. */
  63554. constructor(scene: Scene);
  63555. /**
  63556. * Applies a radial explosion impulse
  63557. * @param origin the origin of the explosion
  63558. * @param radiusOrEventOptions the radius or the options of radial explosion
  63559. * @param strength the explosion strength
  63560. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63561. * @returns A physics radial explosion event, or null
  63562. */
  63563. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63564. /**
  63565. * Applies a radial explosion force
  63566. * @param origin the origin of the explosion
  63567. * @param radiusOrEventOptions the radius or the options of radial explosion
  63568. * @param strength the explosion strength
  63569. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63570. * @returns A physics radial explosion event, or null
  63571. */
  63572. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63573. /**
  63574. * Creates a gravitational field
  63575. * @param origin the origin of the explosion
  63576. * @param radiusOrEventOptions the radius or the options of radial explosion
  63577. * @param strength the explosion strength
  63578. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63579. * @returns A physics gravitational field event, or null
  63580. */
  63581. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63582. /**
  63583. * Creates a physics updraft event
  63584. * @param origin the origin of the updraft
  63585. * @param radiusOrEventOptions the radius or the options of the updraft
  63586. * @param strength the strength of the updraft
  63587. * @param height the height of the updraft
  63588. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63589. * @returns A physics updraft event, or null
  63590. */
  63591. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63592. /**
  63593. * Creates a physics vortex event
  63594. * @param origin the of the vortex
  63595. * @param radiusOrEventOptions the radius or the options of the vortex
  63596. * @param strength the strength of the vortex
  63597. * @param height the height of the vortex
  63598. * @returns a Physics vortex event, or null
  63599. * A physics vortex event or null
  63600. */
  63601. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63602. }
  63603. /**
  63604. * Represents a physics radial explosion event
  63605. */
  63606. class PhysicsRadialExplosionEvent {
  63607. private _scene;
  63608. private _options;
  63609. private _sphere;
  63610. private _dataFetched;
  63611. /**
  63612. * Initializes a radial explosioin event
  63613. * @param _scene BabylonJS scene
  63614. * @param _options The options for the vortex event
  63615. */
  63616. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63617. /**
  63618. * Returns the data related to the radial explosion event (sphere).
  63619. * @returns The radial explosion event data
  63620. */
  63621. getData(): PhysicsRadialExplosionEventData;
  63622. /**
  63623. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63624. * @param impostor A physics imposter
  63625. * @param origin the origin of the explosion
  63626. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63627. */
  63628. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63629. /**
  63630. * Triggers affecterd impostors callbacks
  63631. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63632. */
  63633. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63634. /**
  63635. * Disposes the sphere.
  63636. * @param force Specifies if the sphere should be disposed by force
  63637. */
  63638. dispose(force?: boolean): void;
  63639. /*** Helpers ***/
  63640. private _prepareSphere;
  63641. private _intersectsWithSphere;
  63642. }
  63643. /**
  63644. * Represents a gravitational field event
  63645. */
  63646. class PhysicsGravitationalFieldEvent {
  63647. private _physicsHelper;
  63648. private _scene;
  63649. private _origin;
  63650. private _options;
  63651. private _tickCallback;
  63652. private _sphere;
  63653. private _dataFetched;
  63654. /**
  63655. * Initializes the physics gravitational field event
  63656. * @param _physicsHelper A physics helper
  63657. * @param _scene BabylonJS scene
  63658. * @param _origin The origin position of the gravitational field event
  63659. * @param _options The options for the vortex event
  63660. */
  63661. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63662. /**
  63663. * Returns the data related to the gravitational field event (sphere).
  63664. * @returns A gravitational field event
  63665. */
  63666. getData(): PhysicsGravitationalFieldEventData;
  63667. /**
  63668. * Enables the gravitational field.
  63669. */
  63670. enable(): void;
  63671. /**
  63672. * Disables the gravitational field.
  63673. */
  63674. disable(): void;
  63675. /**
  63676. * Disposes the sphere.
  63677. * @param force The force to dispose from the gravitational field event
  63678. */
  63679. dispose(force?: boolean): void;
  63680. private _tick;
  63681. }
  63682. /**
  63683. * Represents a physics updraft event
  63684. */
  63685. class PhysicsUpdraftEvent {
  63686. private _scene;
  63687. private _origin;
  63688. private _options;
  63689. private _physicsEngine;
  63690. private _originTop;
  63691. private _originDirection;
  63692. private _tickCallback;
  63693. private _cylinder;
  63694. private _cylinderPosition;
  63695. private _dataFetched;
  63696. /**
  63697. * Initializes the physics updraft event
  63698. * @param _scene BabylonJS scene
  63699. * @param _origin The origin position of the updraft
  63700. * @param _options The options for the updraft event
  63701. */
  63702. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63703. /**
  63704. * Returns the data related to the updraft event (cylinder).
  63705. * @returns A physics updraft event
  63706. */
  63707. getData(): PhysicsUpdraftEventData;
  63708. /**
  63709. * Enables the updraft.
  63710. */
  63711. enable(): void;
  63712. /**
  63713. * Disables the updraft.
  63714. */
  63715. disable(): void;
  63716. /**
  63717. * Disposes the cylinder.
  63718. * @param force Specifies if the updraft should be disposed by force
  63719. */
  63720. dispose(force?: boolean): void;
  63721. private getImpostorHitData;
  63722. private _tick;
  63723. /*** Helpers ***/
  63724. private _prepareCylinder;
  63725. private _intersectsWithCylinder;
  63726. }
  63727. /**
  63728. * Represents a physics vortex event
  63729. */
  63730. class PhysicsVortexEvent {
  63731. private _scene;
  63732. private _origin;
  63733. private _options;
  63734. private _physicsEngine;
  63735. private _originTop;
  63736. private _tickCallback;
  63737. private _cylinder;
  63738. private _cylinderPosition;
  63739. private _dataFetched;
  63740. /**
  63741. * Initializes the physics vortex event
  63742. * @param _scene The BabylonJS scene
  63743. * @param _origin The origin position of the vortex
  63744. * @param _options The options for the vortex event
  63745. */
  63746. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63747. /**
  63748. * Returns the data related to the vortex event (cylinder).
  63749. * @returns The physics vortex event data
  63750. */
  63751. getData(): PhysicsVortexEventData;
  63752. /**
  63753. * Enables the vortex.
  63754. */
  63755. enable(): void;
  63756. /**
  63757. * Disables the cortex.
  63758. */
  63759. disable(): void;
  63760. /**
  63761. * Disposes the sphere.
  63762. * @param force
  63763. */
  63764. dispose(force?: boolean): void;
  63765. private getImpostorHitData;
  63766. private _tick;
  63767. /*** Helpers ***/
  63768. private _prepareCylinder;
  63769. private _intersectsWithCylinder;
  63770. }
  63771. /**
  63772. * Options fot the radial explosion event
  63773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63774. */
  63775. export class PhysicsRadialExplosionEventOptions {
  63776. /**
  63777. * The radius of the sphere for the radial explosion.
  63778. */
  63779. radius: number;
  63780. /**
  63781. * The strenth of the explosion.
  63782. */
  63783. strength: number;
  63784. /**
  63785. * The strenght of the force in correspondence to the distance of the affected object
  63786. */
  63787. falloff: PhysicsRadialImpulseFalloff;
  63788. /**
  63789. * Sphere options for the radial explosion.
  63790. */
  63791. sphere: {
  63792. segments: number;
  63793. diameter: number;
  63794. };
  63795. /**
  63796. * Sphere options for the radial explosion.
  63797. */
  63798. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63799. }
  63800. /**
  63801. * Options fot the updraft event
  63802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63803. */
  63804. export class PhysicsUpdraftEventOptions {
  63805. /**
  63806. * The radius of the cylinder for the vortex
  63807. */
  63808. radius: number;
  63809. /**
  63810. * The strenth of the updraft.
  63811. */
  63812. strength: number;
  63813. /**
  63814. * The height of the cylinder for the updraft.
  63815. */
  63816. height: number;
  63817. /**
  63818. * The mode for the the updraft.
  63819. */
  63820. updraftMode: PhysicsUpdraftMode;
  63821. }
  63822. /**
  63823. * Options fot the vortex event
  63824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63825. */
  63826. export class PhysicsVortexEventOptions {
  63827. /**
  63828. * The radius of the cylinder for the vortex
  63829. */
  63830. radius: number;
  63831. /**
  63832. * The strenth of the vortex.
  63833. */
  63834. strength: number;
  63835. /**
  63836. * The height of the cylinder for the vortex.
  63837. */
  63838. height: number;
  63839. /**
  63840. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63841. */
  63842. centripetalForceThreshold: number;
  63843. /**
  63844. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63845. */
  63846. centripetalForceMultiplier: number;
  63847. /**
  63848. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63849. */
  63850. centrifugalForceMultiplier: number;
  63851. /**
  63852. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63853. */
  63854. updraftForceMultiplier: number;
  63855. }
  63856. /**
  63857. * The strenght of the force in correspondence to the distance of the affected object
  63858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63859. */
  63860. export enum PhysicsRadialImpulseFalloff {
  63861. /** Defines that impulse is constant in strength across it's whole radius */
  63862. Constant = 0,
  63863. /** Defines that impulse gets weaker if it's further from the origin */
  63864. Linear = 1
  63865. }
  63866. /**
  63867. * The strength of the force in correspondence to the distance of the affected object
  63868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63869. */
  63870. export enum PhysicsUpdraftMode {
  63871. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63872. Center = 0,
  63873. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63874. Perpendicular = 1
  63875. }
  63876. /**
  63877. * Interface for a physics hit data
  63878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63879. */
  63880. export interface PhysicsHitData {
  63881. /**
  63882. * The force applied at the contact point
  63883. */
  63884. force: Vector3;
  63885. /**
  63886. * The contact point
  63887. */
  63888. contactPoint: Vector3;
  63889. /**
  63890. * The distance from the origin to the contact point
  63891. */
  63892. distanceFromOrigin: number;
  63893. }
  63894. /**
  63895. * Interface for radial explosion event data
  63896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63897. */
  63898. export interface PhysicsRadialExplosionEventData {
  63899. /**
  63900. * A sphere used for the radial explosion event
  63901. */
  63902. sphere: Mesh;
  63903. }
  63904. /**
  63905. * Interface for gravitational field event data
  63906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63907. */
  63908. export interface PhysicsGravitationalFieldEventData {
  63909. /**
  63910. * A sphere mesh used for the gravitational field event
  63911. */
  63912. sphere: Mesh;
  63913. }
  63914. /**
  63915. * Interface for updraft event data
  63916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63917. */
  63918. export interface PhysicsUpdraftEventData {
  63919. /**
  63920. * A cylinder used for the updraft event
  63921. */
  63922. cylinder: Mesh;
  63923. }
  63924. /**
  63925. * Interface for vortex event data
  63926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63927. */
  63928. export interface PhysicsVortexEventData {
  63929. /**
  63930. * A cylinder used for the vortex event
  63931. */
  63932. cylinder: Mesh;
  63933. }
  63934. /**
  63935. * Interface for an affected physics impostor
  63936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63937. */
  63938. export interface PhysicsAffectedImpostorWithData {
  63939. /**
  63940. * The impostor affected by the effect
  63941. */
  63942. impostor: PhysicsImpostor;
  63943. /**
  63944. * The data about the hit/horce from the explosion
  63945. */
  63946. hitData: PhysicsHitData;
  63947. }
  63948. }
  63949. declare module BABYLON {
  63950. /** @hidden */
  63951. export var blackAndWhitePixelShader: {
  63952. name: string;
  63953. shader: string;
  63954. };
  63955. }
  63956. declare module BABYLON {
  63957. /**
  63958. * Post process used to render in black and white
  63959. */
  63960. export class BlackAndWhitePostProcess extends PostProcess {
  63961. /**
  63962. * Linear about to convert he result to black and white (default: 1)
  63963. */
  63964. degree: number;
  63965. /**
  63966. * Creates a black and white post process
  63967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63968. * @param name The name of the effect.
  63969. * @param options The required width/height ratio to downsize to before computing the render pass.
  63970. * @param camera The camera to apply the render pass to.
  63971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63972. * @param engine The engine which the post process will be applied. (default: current engine)
  63973. * @param reusable If the post process can be reused on the same frame. (default: false)
  63974. */
  63975. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63976. }
  63977. }
  63978. declare module BABYLON {
  63979. /**
  63980. * This represents a set of one or more post processes in Babylon.
  63981. * A post process can be used to apply a shader to a texture after it is rendered.
  63982. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63983. */
  63984. export class PostProcessRenderEffect {
  63985. private _postProcesses;
  63986. private _getPostProcesses;
  63987. private _singleInstance;
  63988. private _cameras;
  63989. private _indicesForCamera;
  63990. /**
  63991. * Name of the effect
  63992. * @hidden
  63993. */
  63994. _name: string;
  63995. /**
  63996. * Instantiates a post process render effect.
  63997. * A post process can be used to apply a shader to a texture after it is rendered.
  63998. * @param engine The engine the effect is tied to
  63999. * @param name The name of the effect
  64000. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64001. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64002. */
  64003. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64004. /**
  64005. * Checks if all the post processes in the effect are supported.
  64006. */
  64007. get isSupported(): boolean;
  64008. /**
  64009. * Updates the current state of the effect
  64010. * @hidden
  64011. */
  64012. _update(): void;
  64013. /**
  64014. * Attaches the effect on cameras
  64015. * @param cameras The camera to attach to.
  64016. * @hidden
  64017. */
  64018. _attachCameras(cameras: Camera): void;
  64019. /**
  64020. * Attaches the effect on cameras
  64021. * @param cameras The camera to attach to.
  64022. * @hidden
  64023. */
  64024. _attachCameras(cameras: Camera[]): void;
  64025. /**
  64026. * Detaches the effect on cameras
  64027. * @param cameras The camera to detatch from.
  64028. * @hidden
  64029. */
  64030. _detachCameras(cameras: Camera): void;
  64031. /**
  64032. * Detatches the effect on cameras
  64033. * @param cameras The camera to detatch from.
  64034. * @hidden
  64035. */
  64036. _detachCameras(cameras: Camera[]): void;
  64037. /**
  64038. * Enables the effect on given cameras
  64039. * @param cameras The camera to enable.
  64040. * @hidden
  64041. */
  64042. _enable(cameras: Camera): void;
  64043. /**
  64044. * Enables the effect on given cameras
  64045. * @param cameras The camera to enable.
  64046. * @hidden
  64047. */
  64048. _enable(cameras: Nullable<Camera[]>): void;
  64049. /**
  64050. * Disables the effect on the given cameras
  64051. * @param cameras The camera to disable.
  64052. * @hidden
  64053. */
  64054. _disable(cameras: Camera): void;
  64055. /**
  64056. * Disables the effect on the given cameras
  64057. * @param cameras The camera to disable.
  64058. * @hidden
  64059. */
  64060. _disable(cameras: Nullable<Camera[]>): void;
  64061. /**
  64062. * Gets a list of the post processes contained in the effect.
  64063. * @param camera The camera to get the post processes on.
  64064. * @returns The list of the post processes in the effect.
  64065. */
  64066. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64067. }
  64068. }
  64069. declare module BABYLON {
  64070. /** @hidden */
  64071. export var extractHighlightsPixelShader: {
  64072. name: string;
  64073. shader: string;
  64074. };
  64075. }
  64076. declare module BABYLON {
  64077. /**
  64078. * 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.
  64079. */
  64080. export class ExtractHighlightsPostProcess extends PostProcess {
  64081. /**
  64082. * The luminance threshold, pixels below this value will be set to black.
  64083. */
  64084. threshold: number;
  64085. /** @hidden */
  64086. _exposure: number;
  64087. /**
  64088. * Post process which has the input texture to be used when performing highlight extraction
  64089. * @hidden
  64090. */
  64091. _inputPostProcess: Nullable<PostProcess>;
  64092. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64093. }
  64094. }
  64095. declare module BABYLON {
  64096. /** @hidden */
  64097. export var bloomMergePixelShader: {
  64098. name: string;
  64099. shader: string;
  64100. };
  64101. }
  64102. declare module BABYLON {
  64103. /**
  64104. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64105. */
  64106. export class BloomMergePostProcess extends PostProcess {
  64107. /** Weight of the bloom to be added to the original input. */
  64108. weight: number;
  64109. /**
  64110. * Creates a new instance of @see BloomMergePostProcess
  64111. * @param name The name of the effect.
  64112. * @param originalFromInput Post process which's input will be used for the merge.
  64113. * @param blurred Blurred highlights post process which's output will be used.
  64114. * @param weight Weight of the bloom to be added to the original input.
  64115. * @param options The required width/height ratio to downsize to before computing the render pass.
  64116. * @param camera The camera to apply the render pass to.
  64117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64118. * @param engine The engine which the post process will be applied. (default: current engine)
  64119. * @param reusable If the post process can be reused on the same frame. (default: false)
  64120. * @param textureType Type of textures used when performing the post process. (default: 0)
  64121. * @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)
  64122. */
  64123. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64124. /** Weight of the bloom to be added to the original input. */
  64125. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64126. }
  64127. }
  64128. declare module BABYLON {
  64129. /**
  64130. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64131. */
  64132. export class BloomEffect extends PostProcessRenderEffect {
  64133. private bloomScale;
  64134. /**
  64135. * @hidden Internal
  64136. */
  64137. _effects: Array<PostProcess>;
  64138. /**
  64139. * @hidden Internal
  64140. */
  64141. _downscale: ExtractHighlightsPostProcess;
  64142. private _blurX;
  64143. private _blurY;
  64144. private _merge;
  64145. /**
  64146. * The luminance threshold to find bright areas of the image to bloom.
  64147. */
  64148. get threshold(): number;
  64149. set threshold(value: number);
  64150. /**
  64151. * The strength of the bloom.
  64152. */
  64153. get weight(): number;
  64154. set weight(value: number);
  64155. /**
  64156. * Specifies the size of the bloom blur kernel, relative to the final output size
  64157. */
  64158. get kernel(): number;
  64159. set kernel(value: number);
  64160. /**
  64161. * Creates a new instance of @see BloomEffect
  64162. * @param scene The scene the effect belongs to.
  64163. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64164. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64165. * @param bloomWeight The the strength of bloom.
  64166. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64167. * @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)
  64168. */
  64169. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64170. /**
  64171. * Disposes each of the internal effects for a given camera.
  64172. * @param camera The camera to dispose the effect on.
  64173. */
  64174. disposeEffects(camera: Camera): void;
  64175. /**
  64176. * @hidden Internal
  64177. */
  64178. _updateEffects(): void;
  64179. /**
  64180. * Internal
  64181. * @returns if all the contained post processes are ready.
  64182. * @hidden
  64183. */
  64184. _isReady(): boolean;
  64185. }
  64186. }
  64187. declare module BABYLON {
  64188. /** @hidden */
  64189. export var chromaticAberrationPixelShader: {
  64190. name: string;
  64191. shader: string;
  64192. };
  64193. }
  64194. declare module BABYLON {
  64195. /**
  64196. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64197. */
  64198. export class ChromaticAberrationPostProcess extends PostProcess {
  64199. /**
  64200. * The amount of seperation of rgb channels (default: 30)
  64201. */
  64202. aberrationAmount: number;
  64203. /**
  64204. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64205. */
  64206. radialIntensity: number;
  64207. /**
  64208. * 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))
  64209. */
  64210. direction: Vector2;
  64211. /**
  64212. * 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))
  64213. */
  64214. centerPosition: Vector2;
  64215. /**
  64216. * Creates a new instance ChromaticAberrationPostProcess
  64217. * @param name The name of the effect.
  64218. * @param screenWidth The width of the screen to apply the effect on.
  64219. * @param screenHeight The height of the screen to apply the effect on.
  64220. * @param options The required width/height ratio to downsize to before computing the render pass.
  64221. * @param camera The camera to apply the render pass to.
  64222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64223. * @param engine The engine which the post process will be applied. (default: current engine)
  64224. * @param reusable If the post process can be reused on the same frame. (default: false)
  64225. * @param textureType Type of textures used when performing the post process. (default: 0)
  64226. * @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)
  64227. */
  64228. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64229. }
  64230. }
  64231. declare module BABYLON {
  64232. /** @hidden */
  64233. export var circleOfConfusionPixelShader: {
  64234. name: string;
  64235. shader: string;
  64236. };
  64237. }
  64238. declare module BABYLON {
  64239. /**
  64240. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64241. */
  64242. export class CircleOfConfusionPostProcess extends PostProcess {
  64243. /**
  64244. * 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.
  64245. */
  64246. lensSize: number;
  64247. /**
  64248. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64249. */
  64250. fStop: number;
  64251. /**
  64252. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64253. */
  64254. focusDistance: number;
  64255. /**
  64256. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64257. */
  64258. focalLength: number;
  64259. private _depthTexture;
  64260. /**
  64261. * Creates a new instance CircleOfConfusionPostProcess
  64262. * @param name The name of the effect.
  64263. * @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.
  64264. * @param options The required width/height ratio to downsize to before computing the render pass.
  64265. * @param camera The camera to apply the render pass to.
  64266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64267. * @param engine The engine which the post process will be applied. (default: current engine)
  64268. * @param reusable If the post process can be reused on the same frame. (default: false)
  64269. * @param textureType Type of textures used when performing the post process. (default: 0)
  64270. * @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)
  64271. */
  64272. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64273. /**
  64274. * 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.
  64275. */
  64276. set depthTexture(value: RenderTargetTexture);
  64277. }
  64278. }
  64279. declare module BABYLON {
  64280. /** @hidden */
  64281. export var colorCorrectionPixelShader: {
  64282. name: string;
  64283. shader: string;
  64284. };
  64285. }
  64286. declare module BABYLON {
  64287. /**
  64288. *
  64289. * This post-process allows the modification of rendered colors by using
  64290. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64291. *
  64292. * The object needs to be provided an url to a texture containing the color
  64293. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64294. * Use an image editing software to tweak the LUT to match your needs.
  64295. *
  64296. * For an example of a color LUT, see here:
  64297. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64298. * For explanations on color grading, see here:
  64299. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64300. *
  64301. */
  64302. export class ColorCorrectionPostProcess extends PostProcess {
  64303. private _colorTableTexture;
  64304. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64305. }
  64306. }
  64307. declare module BABYLON {
  64308. /** @hidden */
  64309. export var convolutionPixelShader: {
  64310. name: string;
  64311. shader: string;
  64312. };
  64313. }
  64314. declare module BABYLON {
  64315. /**
  64316. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64317. * input texture to perform effects such as edge detection or sharpening
  64318. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64319. */
  64320. export class ConvolutionPostProcess extends PostProcess {
  64321. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64322. kernel: number[];
  64323. /**
  64324. * Creates a new instance ConvolutionPostProcess
  64325. * @param name The name of the effect.
  64326. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64327. * @param options The required width/height ratio to downsize to before computing the render pass.
  64328. * @param camera The camera to apply the render pass to.
  64329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64330. * @param engine The engine which the post process will be applied. (default: current engine)
  64331. * @param reusable If the post process can be reused on the same frame. (default: false)
  64332. * @param textureType Type of textures used when performing the post process. (default: 0)
  64333. */
  64334. constructor(name: string,
  64335. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64336. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64337. /**
  64338. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64339. */
  64340. static EdgeDetect0Kernel: number[];
  64341. /**
  64342. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64343. */
  64344. static EdgeDetect1Kernel: number[];
  64345. /**
  64346. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64347. */
  64348. static EdgeDetect2Kernel: number[];
  64349. /**
  64350. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64351. */
  64352. static SharpenKernel: number[];
  64353. /**
  64354. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64355. */
  64356. static EmbossKernel: number[];
  64357. /**
  64358. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64359. */
  64360. static GaussianKernel: number[];
  64361. }
  64362. }
  64363. declare module BABYLON {
  64364. /**
  64365. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64366. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64367. * based on samples that have a large difference in distance than the center pixel.
  64368. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64369. */
  64370. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64371. direction: Vector2;
  64372. /**
  64373. * Creates a new instance CircleOfConfusionPostProcess
  64374. * @param name The name of the effect.
  64375. * @param scene The scene the effect belongs to.
  64376. * @param direction The direction the blur should be applied.
  64377. * @param kernel The size of the kernel used to blur.
  64378. * @param options The required width/height ratio to downsize to before computing the render pass.
  64379. * @param camera The camera to apply the render pass to.
  64380. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64381. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64383. * @param engine The engine which the post process will be applied. (default: current engine)
  64384. * @param reusable If the post process can be reused on the same frame. (default: false)
  64385. * @param textureType Type of textures used when performing the post process. (default: 0)
  64386. * @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)
  64387. */
  64388. 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);
  64389. }
  64390. }
  64391. declare module BABYLON {
  64392. /** @hidden */
  64393. export var depthOfFieldMergePixelShader: {
  64394. name: string;
  64395. shader: string;
  64396. };
  64397. }
  64398. declare module BABYLON {
  64399. /**
  64400. * Options to be set when merging outputs from the default pipeline.
  64401. */
  64402. export class DepthOfFieldMergePostProcessOptions {
  64403. /**
  64404. * The original image to merge on top of
  64405. */
  64406. originalFromInput: PostProcess;
  64407. /**
  64408. * Parameters to perform the merge of the depth of field effect
  64409. */
  64410. depthOfField?: {
  64411. circleOfConfusion: PostProcess;
  64412. blurSteps: Array<PostProcess>;
  64413. };
  64414. /**
  64415. * Parameters to perform the merge of bloom effect
  64416. */
  64417. bloom?: {
  64418. blurred: PostProcess;
  64419. weight: number;
  64420. };
  64421. }
  64422. /**
  64423. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64424. */
  64425. export class DepthOfFieldMergePostProcess extends PostProcess {
  64426. private blurSteps;
  64427. /**
  64428. * Creates a new instance of DepthOfFieldMergePostProcess
  64429. * @param name The name of the effect.
  64430. * @param originalFromInput Post process which's input will be used for the merge.
  64431. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64432. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64433. * @param options The required width/height ratio to downsize to before computing the render pass.
  64434. * @param camera The camera to apply the render pass to.
  64435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64436. * @param engine The engine which the post process will be applied. (default: current engine)
  64437. * @param reusable If the post process can be reused on the same frame. (default: false)
  64438. * @param textureType Type of textures used when performing the post process. (default: 0)
  64439. * @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)
  64440. */
  64441. 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);
  64442. /**
  64443. * Updates the effect with the current post process compile time values and recompiles the shader.
  64444. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64445. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64446. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64447. * @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
  64448. * @param onCompiled Called when the shader has been compiled.
  64449. * @param onError Called if there is an error when compiling a shader.
  64450. */
  64451. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64452. }
  64453. }
  64454. declare module BABYLON {
  64455. /**
  64456. * Specifies the level of max blur that should be applied when using the depth of field effect
  64457. */
  64458. export enum DepthOfFieldEffectBlurLevel {
  64459. /**
  64460. * Subtle blur
  64461. */
  64462. Low = 0,
  64463. /**
  64464. * Medium blur
  64465. */
  64466. Medium = 1,
  64467. /**
  64468. * Large blur
  64469. */
  64470. High = 2
  64471. }
  64472. /**
  64473. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64474. */
  64475. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64476. private _circleOfConfusion;
  64477. /**
  64478. * @hidden Internal, blurs from high to low
  64479. */
  64480. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64481. private _depthOfFieldBlurY;
  64482. private _dofMerge;
  64483. /**
  64484. * @hidden Internal post processes in depth of field effect
  64485. */
  64486. _effects: Array<PostProcess>;
  64487. /**
  64488. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64489. */
  64490. set focalLength(value: number);
  64491. get focalLength(): number;
  64492. /**
  64493. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64494. */
  64495. set fStop(value: number);
  64496. get fStop(): number;
  64497. /**
  64498. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64499. */
  64500. set focusDistance(value: number);
  64501. get focusDistance(): number;
  64502. /**
  64503. * 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.
  64504. */
  64505. set lensSize(value: number);
  64506. get lensSize(): number;
  64507. /**
  64508. * Creates a new instance DepthOfFieldEffect
  64509. * @param scene The scene the effect belongs to.
  64510. * @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.
  64511. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64512. * @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)
  64513. */
  64514. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64515. /**
  64516. * Get the current class name of the current effet
  64517. * @returns "DepthOfFieldEffect"
  64518. */
  64519. getClassName(): string;
  64520. /**
  64521. * 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.
  64522. */
  64523. set depthTexture(value: RenderTargetTexture);
  64524. /**
  64525. * Disposes each of the internal effects for a given camera.
  64526. * @param camera The camera to dispose the effect on.
  64527. */
  64528. disposeEffects(camera: Camera): void;
  64529. /**
  64530. * @hidden Internal
  64531. */
  64532. _updateEffects(): void;
  64533. /**
  64534. * Internal
  64535. * @returns if all the contained post processes are ready.
  64536. * @hidden
  64537. */
  64538. _isReady(): boolean;
  64539. }
  64540. }
  64541. declare module BABYLON {
  64542. /** @hidden */
  64543. export var displayPassPixelShader: {
  64544. name: string;
  64545. shader: string;
  64546. };
  64547. }
  64548. declare module BABYLON {
  64549. /**
  64550. * DisplayPassPostProcess which produces an output the same as it's input
  64551. */
  64552. export class DisplayPassPostProcess extends PostProcess {
  64553. /**
  64554. * Creates the DisplayPassPostProcess
  64555. * @param name The name of the effect.
  64556. * @param options The required width/height ratio to downsize to before computing the render pass.
  64557. * @param camera The camera to apply the render pass to.
  64558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64559. * @param engine The engine which the post process will be applied. (default: current engine)
  64560. * @param reusable If the post process can be reused on the same frame. (default: false)
  64561. */
  64562. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64563. }
  64564. }
  64565. declare module BABYLON {
  64566. /** @hidden */
  64567. export var filterPixelShader: {
  64568. name: string;
  64569. shader: string;
  64570. };
  64571. }
  64572. declare module BABYLON {
  64573. /**
  64574. * Applies a kernel filter to the image
  64575. */
  64576. export class FilterPostProcess extends PostProcess {
  64577. /** The matrix to be applied to the image */
  64578. kernelMatrix: Matrix;
  64579. /**
  64580. *
  64581. * @param name The name of the effect.
  64582. * @param kernelMatrix The matrix to be applied to the image
  64583. * @param options The required width/height ratio to downsize to before computing the render pass.
  64584. * @param camera The camera to apply the render pass to.
  64585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64586. * @param engine The engine which the post process will be applied. (default: current engine)
  64587. * @param reusable If the post process can be reused on the same frame. (default: false)
  64588. */
  64589. constructor(name: string,
  64590. /** The matrix to be applied to the image */
  64591. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /** @hidden */
  64596. export var fxaaPixelShader: {
  64597. name: string;
  64598. shader: string;
  64599. };
  64600. }
  64601. declare module BABYLON {
  64602. /** @hidden */
  64603. export var fxaaVertexShader: {
  64604. name: string;
  64605. shader: string;
  64606. };
  64607. }
  64608. declare module BABYLON {
  64609. /**
  64610. * Fxaa post process
  64611. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64612. */
  64613. export class FxaaPostProcess extends PostProcess {
  64614. /** @hidden */
  64615. texelWidth: number;
  64616. /** @hidden */
  64617. texelHeight: number;
  64618. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64619. private _getDefines;
  64620. }
  64621. }
  64622. declare module BABYLON {
  64623. /** @hidden */
  64624. export var grainPixelShader: {
  64625. name: string;
  64626. shader: string;
  64627. };
  64628. }
  64629. declare module BABYLON {
  64630. /**
  64631. * The GrainPostProcess adds noise to the image at mid luminance levels
  64632. */
  64633. export class GrainPostProcess extends PostProcess {
  64634. /**
  64635. * The intensity of the grain added (default: 30)
  64636. */
  64637. intensity: number;
  64638. /**
  64639. * If the grain should be randomized on every frame
  64640. */
  64641. animated: boolean;
  64642. /**
  64643. * Creates a new instance of @see GrainPostProcess
  64644. * @param name The name of the effect.
  64645. * @param options The required width/height ratio to downsize to before computing the render pass.
  64646. * @param camera The camera to apply the render pass to.
  64647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64648. * @param engine The engine which the post process will be applied. (default: current engine)
  64649. * @param reusable If the post process can be reused on the same frame. (default: false)
  64650. * @param textureType Type of textures used when performing the post process. (default: 0)
  64651. * @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)
  64652. */
  64653. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64654. }
  64655. }
  64656. declare module BABYLON {
  64657. /** @hidden */
  64658. export var highlightsPixelShader: {
  64659. name: string;
  64660. shader: string;
  64661. };
  64662. }
  64663. declare module BABYLON {
  64664. /**
  64665. * Extracts highlights from the image
  64666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64667. */
  64668. export class HighlightsPostProcess extends PostProcess {
  64669. /**
  64670. * Extracts highlights from the image
  64671. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64672. * @param name The name of the effect.
  64673. * @param options The required width/height ratio to downsize to before computing the render pass.
  64674. * @param camera The camera to apply the render pass to.
  64675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64676. * @param engine The engine which the post process will be applied. (default: current engine)
  64677. * @param reusable If the post process can be reused on the same frame. (default: false)
  64678. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64679. */
  64680. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64681. }
  64682. }
  64683. declare module BABYLON {
  64684. /** @hidden */
  64685. export var mrtFragmentDeclaration: {
  64686. name: string;
  64687. shader: string;
  64688. };
  64689. }
  64690. declare module BABYLON {
  64691. /** @hidden */
  64692. export var geometryPixelShader: {
  64693. name: string;
  64694. shader: string;
  64695. };
  64696. }
  64697. declare module BABYLON {
  64698. /** @hidden */
  64699. export var geometryVertexShader: {
  64700. name: string;
  64701. shader: string;
  64702. };
  64703. }
  64704. declare module BABYLON {
  64705. /** @hidden */
  64706. interface ISavedTransformationMatrix {
  64707. world: Matrix;
  64708. viewProjection: Matrix;
  64709. }
  64710. /**
  64711. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64712. */
  64713. export class GeometryBufferRenderer {
  64714. /**
  64715. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64716. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64717. */
  64718. static readonly POSITION_TEXTURE_TYPE: number;
  64719. /**
  64720. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64721. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64722. */
  64723. static readonly VELOCITY_TEXTURE_TYPE: number;
  64724. /**
  64725. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64726. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64727. */
  64728. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64729. /**
  64730. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64731. * in order to compute objects velocities when enableVelocity is set to "true"
  64732. * @hidden
  64733. */
  64734. _previousTransformationMatrices: {
  64735. [index: number]: ISavedTransformationMatrix;
  64736. };
  64737. /**
  64738. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64739. * in order to compute objects velocities when enableVelocity is set to "true"
  64740. * @hidden
  64741. */
  64742. _previousBonesTransformationMatrices: {
  64743. [index: number]: Float32Array;
  64744. };
  64745. /**
  64746. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64747. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64748. */
  64749. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64750. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64751. renderTransparentMeshes: boolean;
  64752. private _scene;
  64753. private _multiRenderTarget;
  64754. private _ratio;
  64755. private _enablePosition;
  64756. private _enableVelocity;
  64757. private _enableReflectivity;
  64758. private _positionIndex;
  64759. private _velocityIndex;
  64760. private _reflectivityIndex;
  64761. protected _effect: Effect;
  64762. protected _cachedDefines: string;
  64763. /**
  64764. * Set the render list (meshes to be rendered) used in the G buffer.
  64765. */
  64766. set renderList(meshes: Mesh[]);
  64767. /**
  64768. * Gets wether or not G buffer are supported by the running hardware.
  64769. * This requires draw buffer supports
  64770. */
  64771. get isSupported(): boolean;
  64772. /**
  64773. * Returns the index of the given texture type in the G-Buffer textures array
  64774. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64775. * @returns the index of the given texture type in the G-Buffer textures array
  64776. */
  64777. getTextureIndex(textureType: number): number;
  64778. /**
  64779. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64780. */
  64781. get enablePosition(): boolean;
  64782. /**
  64783. * Sets whether or not objects positions are enabled for the G buffer.
  64784. */
  64785. set enablePosition(enable: boolean);
  64786. /**
  64787. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64788. */
  64789. get enableVelocity(): boolean;
  64790. /**
  64791. * Sets wether or not objects velocities are enabled for the G buffer.
  64792. */
  64793. set enableVelocity(enable: boolean);
  64794. /**
  64795. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64796. */
  64797. get enableReflectivity(): boolean;
  64798. /**
  64799. * Sets wether or not objects roughness are enabled for the G buffer.
  64800. */
  64801. set enableReflectivity(enable: boolean);
  64802. /**
  64803. * Gets the scene associated with the buffer.
  64804. */
  64805. get scene(): Scene;
  64806. /**
  64807. * Gets the ratio used by the buffer during its creation.
  64808. * How big is the buffer related to the main canvas.
  64809. */
  64810. get ratio(): number;
  64811. /** @hidden */
  64812. static _SceneComponentInitialization: (scene: Scene) => void;
  64813. /**
  64814. * Creates a new G Buffer for the scene
  64815. * @param scene The scene the buffer belongs to
  64816. * @param ratio How big is the buffer related to the main canvas.
  64817. */
  64818. constructor(scene: Scene, ratio?: number);
  64819. /**
  64820. * Checks wether everything is ready to render a submesh to the G buffer.
  64821. * @param subMesh the submesh to check readiness for
  64822. * @param useInstances is the mesh drawn using instance or not
  64823. * @returns true if ready otherwise false
  64824. */
  64825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64826. /**
  64827. * Gets the current underlying G Buffer.
  64828. * @returns the buffer
  64829. */
  64830. getGBuffer(): MultiRenderTarget;
  64831. /**
  64832. * Gets the number of samples used to render the buffer (anti aliasing).
  64833. */
  64834. get samples(): number;
  64835. /**
  64836. * Sets the number of samples used to render the buffer (anti aliasing).
  64837. */
  64838. set samples(value: number);
  64839. /**
  64840. * Disposes the renderer and frees up associated resources.
  64841. */
  64842. dispose(): void;
  64843. protected _createRenderTargets(): void;
  64844. private _copyBonesTransformationMatrices;
  64845. }
  64846. }
  64847. declare module BABYLON {
  64848. interface Scene {
  64849. /** @hidden (Backing field) */
  64850. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64851. /**
  64852. * Gets or Sets the current geometry buffer associated to the scene.
  64853. */
  64854. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64855. /**
  64856. * Enables a GeometryBufferRender and associates it with the scene
  64857. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64858. * @returns the GeometryBufferRenderer
  64859. */
  64860. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64861. /**
  64862. * Disables the GeometryBufferRender associated with the scene
  64863. */
  64864. disableGeometryBufferRenderer(): void;
  64865. }
  64866. /**
  64867. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64868. * in several rendering techniques.
  64869. */
  64870. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64871. /**
  64872. * The component name helpful to identify the component in the list of scene components.
  64873. */
  64874. readonly name: string;
  64875. /**
  64876. * The scene the component belongs to.
  64877. */
  64878. scene: Scene;
  64879. /**
  64880. * Creates a new instance of the component for the given scene
  64881. * @param scene Defines the scene to register the component in
  64882. */
  64883. constructor(scene: Scene);
  64884. /**
  64885. * Registers the component in a given scene
  64886. */
  64887. register(): void;
  64888. /**
  64889. * Rebuilds the elements related to this component in case of
  64890. * context lost for instance.
  64891. */
  64892. rebuild(): void;
  64893. /**
  64894. * Disposes the component and the associated ressources
  64895. */
  64896. dispose(): void;
  64897. private _gatherRenderTargets;
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /** @hidden */
  64902. export var motionBlurPixelShader: {
  64903. name: string;
  64904. shader: string;
  64905. };
  64906. }
  64907. declare module BABYLON {
  64908. /**
  64909. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64910. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64911. * As an example, all you have to do is to create the post-process:
  64912. * var mb = new BABYLON.MotionBlurPostProcess(
  64913. * 'mb', // The name of the effect.
  64914. * scene, // The scene containing the objects to blur according to their velocity.
  64915. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64916. * camera // The camera to apply the render pass to.
  64917. * );
  64918. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64919. */
  64920. export class MotionBlurPostProcess extends PostProcess {
  64921. /**
  64922. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64923. */
  64924. motionStrength: number;
  64925. /**
  64926. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64927. */
  64928. get motionBlurSamples(): number;
  64929. /**
  64930. * Sets the number of iterations to be used for motion blur quality
  64931. */
  64932. set motionBlurSamples(samples: number);
  64933. private _motionBlurSamples;
  64934. private _geometryBufferRenderer;
  64935. /**
  64936. * Creates a new instance MotionBlurPostProcess
  64937. * @param name The name of the effect.
  64938. * @param scene The scene containing the objects to blur according to their velocity.
  64939. * @param options The required width/height ratio to downsize to before computing the render pass.
  64940. * @param camera The camera to apply the render pass to.
  64941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64942. * @param engine The engine which the post process will be applied. (default: current engine)
  64943. * @param reusable If the post process can be reused on the same frame. (default: false)
  64944. * @param textureType Type of textures used when performing the post process. (default: 0)
  64945. * @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)
  64946. */
  64947. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64948. /**
  64949. * Excludes the given skinned mesh from computing bones velocities.
  64950. * 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.
  64951. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64952. */
  64953. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64954. /**
  64955. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64956. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64957. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64958. */
  64959. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64960. /**
  64961. * Disposes the post process.
  64962. * @param camera The camera to dispose the post process on.
  64963. */
  64964. dispose(camera?: Camera): void;
  64965. }
  64966. }
  64967. declare module BABYLON {
  64968. /** @hidden */
  64969. export var refractionPixelShader: {
  64970. name: string;
  64971. shader: string;
  64972. };
  64973. }
  64974. declare module BABYLON {
  64975. /**
  64976. * Post process which applies a refractin texture
  64977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64978. */
  64979. export class RefractionPostProcess extends PostProcess {
  64980. /** the base color of the refraction (used to taint the rendering) */
  64981. color: Color3;
  64982. /** simulated refraction depth */
  64983. depth: number;
  64984. /** the coefficient of the base color (0 to remove base color tainting) */
  64985. colorLevel: number;
  64986. private _refTexture;
  64987. private _ownRefractionTexture;
  64988. /**
  64989. * Gets or sets the refraction texture
  64990. * Please note that you are responsible for disposing the texture if you set it manually
  64991. */
  64992. get refractionTexture(): Texture;
  64993. set refractionTexture(value: Texture);
  64994. /**
  64995. * Initializes the RefractionPostProcess
  64996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64997. * @param name The name of the effect.
  64998. * @param refractionTextureUrl Url of the refraction texture to use
  64999. * @param color the base color of the refraction (used to taint the rendering)
  65000. * @param depth simulated refraction depth
  65001. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65002. * @param camera The camera to apply the render pass to.
  65003. * @param options The required width/height ratio to downsize to before computing the render pass.
  65004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65005. * @param engine The engine which the post process will be applied. (default: current engine)
  65006. * @param reusable If the post process can be reused on the same frame. (default: false)
  65007. */
  65008. constructor(name: string, refractionTextureUrl: string,
  65009. /** the base color of the refraction (used to taint the rendering) */
  65010. color: Color3,
  65011. /** simulated refraction depth */
  65012. depth: number,
  65013. /** the coefficient of the base color (0 to remove base color tainting) */
  65014. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65015. /**
  65016. * Disposes of the post process
  65017. * @param camera Camera to dispose post process on
  65018. */
  65019. dispose(camera: Camera): void;
  65020. }
  65021. }
  65022. declare module BABYLON {
  65023. /** @hidden */
  65024. export var sharpenPixelShader: {
  65025. name: string;
  65026. shader: string;
  65027. };
  65028. }
  65029. declare module BABYLON {
  65030. /**
  65031. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65032. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65033. */
  65034. export class SharpenPostProcess extends PostProcess {
  65035. /**
  65036. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65037. */
  65038. colorAmount: number;
  65039. /**
  65040. * How much sharpness should be applied (default: 0.3)
  65041. */
  65042. edgeAmount: number;
  65043. /**
  65044. * Creates a new instance ConvolutionPostProcess
  65045. * @param name The name of the effect.
  65046. * @param options The required width/height ratio to downsize to before computing the render pass.
  65047. * @param camera The camera to apply the render pass to.
  65048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65049. * @param engine The engine which the post process will be applied. (default: current engine)
  65050. * @param reusable If the post process can be reused on the same frame. (default: false)
  65051. * @param textureType Type of textures used when performing the post process. (default: 0)
  65052. * @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)
  65053. */
  65054. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65055. }
  65056. }
  65057. declare module BABYLON {
  65058. /**
  65059. * PostProcessRenderPipeline
  65060. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65061. */
  65062. export class PostProcessRenderPipeline {
  65063. private engine;
  65064. private _renderEffects;
  65065. private _renderEffectsForIsolatedPass;
  65066. /**
  65067. * List of inspectable custom properties (used by the Inspector)
  65068. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65069. */
  65070. inspectableCustomProperties: IInspectable[];
  65071. /**
  65072. * @hidden
  65073. */
  65074. protected _cameras: Camera[];
  65075. /** @hidden */
  65076. _name: string;
  65077. /**
  65078. * Gets pipeline name
  65079. */
  65080. get name(): string;
  65081. /** Gets the list of attached cameras */
  65082. get cameras(): Camera[];
  65083. /**
  65084. * Initializes a PostProcessRenderPipeline
  65085. * @param engine engine to add the pipeline to
  65086. * @param name name of the pipeline
  65087. */
  65088. constructor(engine: Engine, name: string);
  65089. /**
  65090. * Gets the class name
  65091. * @returns "PostProcessRenderPipeline"
  65092. */
  65093. getClassName(): string;
  65094. /**
  65095. * If all the render effects in the pipeline are supported
  65096. */
  65097. get isSupported(): boolean;
  65098. /**
  65099. * Adds an effect to the pipeline
  65100. * @param renderEffect the effect to add
  65101. */
  65102. addEffect(renderEffect: PostProcessRenderEffect): void;
  65103. /** @hidden */
  65104. _rebuild(): void;
  65105. /** @hidden */
  65106. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65107. /** @hidden */
  65108. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65109. /** @hidden */
  65110. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65111. /** @hidden */
  65112. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65113. /** @hidden */
  65114. _attachCameras(cameras: Camera, unique: boolean): void;
  65115. /** @hidden */
  65116. _attachCameras(cameras: Camera[], unique: boolean): void;
  65117. /** @hidden */
  65118. _detachCameras(cameras: Camera): void;
  65119. /** @hidden */
  65120. _detachCameras(cameras: Nullable<Camera[]>): void;
  65121. /** @hidden */
  65122. _update(): void;
  65123. /** @hidden */
  65124. _reset(): void;
  65125. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65126. /**
  65127. * Disposes of the pipeline
  65128. */
  65129. dispose(): void;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * PostProcessRenderPipelineManager class
  65135. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65136. */
  65137. export class PostProcessRenderPipelineManager {
  65138. private _renderPipelines;
  65139. /**
  65140. * Initializes a PostProcessRenderPipelineManager
  65141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65142. */
  65143. constructor();
  65144. /**
  65145. * Gets the list of supported render pipelines
  65146. */
  65147. get supportedPipelines(): PostProcessRenderPipeline[];
  65148. /**
  65149. * Adds a pipeline to the manager
  65150. * @param renderPipeline The pipeline to add
  65151. */
  65152. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65153. /**
  65154. * Attaches a camera to the pipeline
  65155. * @param renderPipelineName The name of the pipeline to attach to
  65156. * @param cameras the camera to attach
  65157. * @param unique if the camera can be attached multiple times to the pipeline
  65158. */
  65159. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65160. /**
  65161. * Detaches a camera from the pipeline
  65162. * @param renderPipelineName The name of the pipeline to detach from
  65163. * @param cameras the camera to detach
  65164. */
  65165. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65166. /**
  65167. * Enables an effect by name on a pipeline
  65168. * @param renderPipelineName the name of the pipeline to enable the effect in
  65169. * @param renderEffectName the name of the effect to enable
  65170. * @param cameras the cameras that the effect should be enabled on
  65171. */
  65172. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65173. /**
  65174. * Disables an effect by name on a pipeline
  65175. * @param renderPipelineName the name of the pipeline to disable the effect in
  65176. * @param renderEffectName the name of the effect to disable
  65177. * @param cameras the cameras that the effect should be disabled on
  65178. */
  65179. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65180. /**
  65181. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65182. */
  65183. update(): void;
  65184. /** @hidden */
  65185. _rebuild(): void;
  65186. /**
  65187. * Disposes of the manager and pipelines
  65188. */
  65189. dispose(): void;
  65190. }
  65191. }
  65192. declare module BABYLON {
  65193. interface Scene {
  65194. /** @hidden (Backing field) */
  65195. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65196. /**
  65197. * Gets the postprocess render pipeline manager
  65198. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65199. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65200. */
  65201. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65202. }
  65203. /**
  65204. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65205. */
  65206. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65207. /**
  65208. * The component name helpfull to identify the component in the list of scene components.
  65209. */
  65210. readonly name: string;
  65211. /**
  65212. * The scene the component belongs to.
  65213. */
  65214. scene: Scene;
  65215. /**
  65216. * Creates a new instance of the component for the given scene
  65217. * @param scene Defines the scene to register the component in
  65218. */
  65219. constructor(scene: Scene);
  65220. /**
  65221. * Registers the component in a given scene
  65222. */
  65223. register(): void;
  65224. /**
  65225. * Rebuilds the elements related to this component in case of
  65226. * context lost for instance.
  65227. */
  65228. rebuild(): void;
  65229. /**
  65230. * Disposes the component and the associated ressources
  65231. */
  65232. dispose(): void;
  65233. private _gatherRenderTargets;
  65234. }
  65235. }
  65236. declare module BABYLON {
  65237. /**
  65238. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65239. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65240. */
  65241. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65242. private _scene;
  65243. private _camerasToBeAttached;
  65244. /**
  65245. * ID of the sharpen post process,
  65246. */
  65247. private readonly SharpenPostProcessId;
  65248. /**
  65249. * @ignore
  65250. * ID of the image processing post process;
  65251. */
  65252. readonly ImageProcessingPostProcessId: string;
  65253. /**
  65254. * @ignore
  65255. * ID of the Fast Approximate Anti-Aliasing post process;
  65256. */
  65257. readonly FxaaPostProcessId: string;
  65258. /**
  65259. * ID of the chromatic aberration post process,
  65260. */
  65261. private readonly ChromaticAberrationPostProcessId;
  65262. /**
  65263. * ID of the grain post process
  65264. */
  65265. private readonly GrainPostProcessId;
  65266. /**
  65267. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65268. */
  65269. sharpen: SharpenPostProcess;
  65270. private _sharpenEffect;
  65271. private bloom;
  65272. /**
  65273. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65274. */
  65275. depthOfField: DepthOfFieldEffect;
  65276. /**
  65277. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65278. */
  65279. fxaa: FxaaPostProcess;
  65280. /**
  65281. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65282. */
  65283. imageProcessing: ImageProcessingPostProcess;
  65284. /**
  65285. * Chromatic aberration post process which will shift rgb colors in the image
  65286. */
  65287. chromaticAberration: ChromaticAberrationPostProcess;
  65288. private _chromaticAberrationEffect;
  65289. /**
  65290. * Grain post process which add noise to the image
  65291. */
  65292. grain: GrainPostProcess;
  65293. private _grainEffect;
  65294. /**
  65295. * Glow post process which adds a glow to emissive areas of the image
  65296. */
  65297. private _glowLayer;
  65298. /**
  65299. * Animations which can be used to tweak settings over a period of time
  65300. */
  65301. animations: Animation[];
  65302. private _imageProcessingConfigurationObserver;
  65303. private _sharpenEnabled;
  65304. private _bloomEnabled;
  65305. private _depthOfFieldEnabled;
  65306. private _depthOfFieldBlurLevel;
  65307. private _fxaaEnabled;
  65308. private _imageProcessingEnabled;
  65309. private _defaultPipelineTextureType;
  65310. private _bloomScale;
  65311. private _chromaticAberrationEnabled;
  65312. private _grainEnabled;
  65313. private _buildAllowed;
  65314. /**
  65315. * Gets active scene
  65316. */
  65317. get scene(): Scene;
  65318. /**
  65319. * Enable or disable the sharpen process from the pipeline
  65320. */
  65321. set sharpenEnabled(enabled: boolean);
  65322. get sharpenEnabled(): boolean;
  65323. private _resizeObserver;
  65324. private _hardwareScaleLevel;
  65325. private _bloomKernel;
  65326. /**
  65327. * Specifies the size of the bloom blur kernel, relative to the final output size
  65328. */
  65329. get bloomKernel(): number;
  65330. set bloomKernel(value: number);
  65331. /**
  65332. * Specifies the weight of the bloom in the final rendering
  65333. */
  65334. private _bloomWeight;
  65335. /**
  65336. * Specifies the luma threshold for the area that will be blurred by the bloom
  65337. */
  65338. private _bloomThreshold;
  65339. private _hdr;
  65340. /**
  65341. * The strength of the bloom.
  65342. */
  65343. set bloomWeight(value: number);
  65344. get bloomWeight(): number;
  65345. /**
  65346. * The strength of the bloom.
  65347. */
  65348. set bloomThreshold(value: number);
  65349. get bloomThreshold(): number;
  65350. /**
  65351. * The scale of the bloom, lower value will provide better performance.
  65352. */
  65353. set bloomScale(value: number);
  65354. get bloomScale(): number;
  65355. /**
  65356. * Enable or disable the bloom from the pipeline
  65357. */
  65358. set bloomEnabled(enabled: boolean);
  65359. get bloomEnabled(): boolean;
  65360. private _rebuildBloom;
  65361. /**
  65362. * If the depth of field is enabled.
  65363. */
  65364. get depthOfFieldEnabled(): boolean;
  65365. set depthOfFieldEnabled(enabled: boolean);
  65366. /**
  65367. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65368. */
  65369. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65370. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65371. /**
  65372. * If the anti aliasing is enabled.
  65373. */
  65374. set fxaaEnabled(enabled: boolean);
  65375. get fxaaEnabled(): boolean;
  65376. private _samples;
  65377. /**
  65378. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65379. */
  65380. set samples(sampleCount: number);
  65381. get samples(): number;
  65382. /**
  65383. * If image processing is enabled.
  65384. */
  65385. set imageProcessingEnabled(enabled: boolean);
  65386. get imageProcessingEnabled(): boolean;
  65387. /**
  65388. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65389. */
  65390. set glowLayerEnabled(enabled: boolean);
  65391. get glowLayerEnabled(): boolean;
  65392. /**
  65393. * Gets the glow layer (or null if not defined)
  65394. */
  65395. get glowLayer(): Nullable<GlowLayer>;
  65396. /**
  65397. * Enable or disable the chromaticAberration process from the pipeline
  65398. */
  65399. set chromaticAberrationEnabled(enabled: boolean);
  65400. get chromaticAberrationEnabled(): boolean;
  65401. /**
  65402. * Enable or disable the grain process from the pipeline
  65403. */
  65404. set grainEnabled(enabled: boolean);
  65405. get grainEnabled(): boolean;
  65406. /**
  65407. * @constructor
  65408. * @param name - The rendering pipeline name (default: "")
  65409. * @param hdr - If high dynamic range textures should be used (default: true)
  65410. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65411. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65412. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65413. */
  65414. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65415. /**
  65416. * Get the class name
  65417. * @returns "DefaultRenderingPipeline"
  65418. */
  65419. getClassName(): string;
  65420. /**
  65421. * Force the compilation of the entire pipeline.
  65422. */
  65423. prepare(): void;
  65424. private _hasCleared;
  65425. private _prevPostProcess;
  65426. private _prevPrevPostProcess;
  65427. private _setAutoClearAndTextureSharing;
  65428. private _depthOfFieldSceneObserver;
  65429. private _buildPipeline;
  65430. private _disposePostProcesses;
  65431. /**
  65432. * Adds a camera to the pipeline
  65433. * @param camera the camera to be added
  65434. */
  65435. addCamera(camera: Camera): void;
  65436. /**
  65437. * Removes a camera from the pipeline
  65438. * @param camera the camera to remove
  65439. */
  65440. removeCamera(camera: Camera): void;
  65441. /**
  65442. * Dispose of the pipeline and stop all post processes
  65443. */
  65444. dispose(): void;
  65445. /**
  65446. * Serialize the rendering pipeline (Used when exporting)
  65447. * @returns the serialized object
  65448. */
  65449. serialize(): any;
  65450. /**
  65451. * Parse the serialized pipeline
  65452. * @param source Source pipeline.
  65453. * @param scene The scene to load the pipeline to.
  65454. * @param rootUrl The URL of the serialized pipeline.
  65455. * @returns An instantiated pipeline from the serialized object.
  65456. */
  65457. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65458. }
  65459. }
  65460. declare module BABYLON {
  65461. /** @hidden */
  65462. export var lensHighlightsPixelShader: {
  65463. name: string;
  65464. shader: string;
  65465. };
  65466. }
  65467. declare module BABYLON {
  65468. /** @hidden */
  65469. export var depthOfFieldPixelShader: {
  65470. name: string;
  65471. shader: string;
  65472. };
  65473. }
  65474. declare module BABYLON {
  65475. /**
  65476. * BABYLON.JS Chromatic Aberration GLSL Shader
  65477. * Author: Olivier Guyot
  65478. * Separates very slightly R, G and B colors on the edges of the screen
  65479. * Inspired by Francois Tarlier & Martins Upitis
  65480. */
  65481. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65482. /**
  65483. * @ignore
  65484. * The chromatic aberration PostProcess id in the pipeline
  65485. */
  65486. LensChromaticAberrationEffect: string;
  65487. /**
  65488. * @ignore
  65489. * The highlights enhancing PostProcess id in the pipeline
  65490. */
  65491. HighlightsEnhancingEffect: string;
  65492. /**
  65493. * @ignore
  65494. * The depth-of-field PostProcess id in the pipeline
  65495. */
  65496. LensDepthOfFieldEffect: string;
  65497. private _scene;
  65498. private _depthTexture;
  65499. private _grainTexture;
  65500. private _chromaticAberrationPostProcess;
  65501. private _highlightsPostProcess;
  65502. private _depthOfFieldPostProcess;
  65503. private _edgeBlur;
  65504. private _grainAmount;
  65505. private _chromaticAberration;
  65506. private _distortion;
  65507. private _highlightsGain;
  65508. private _highlightsThreshold;
  65509. private _dofDistance;
  65510. private _dofAperture;
  65511. private _dofDarken;
  65512. private _dofPentagon;
  65513. private _blurNoise;
  65514. /**
  65515. * @constructor
  65516. *
  65517. * Effect parameters are as follow:
  65518. * {
  65519. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65520. * edge_blur: number; // from 0 to x (1 for realism)
  65521. * distortion: number; // from 0 to x (1 for realism)
  65522. * grain_amount: number; // from 0 to 1
  65523. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65524. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65525. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65526. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65527. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65528. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65529. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65530. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65531. * }
  65532. * Note: if an effect parameter is unset, effect is disabled
  65533. *
  65534. * @param name The rendering pipeline name
  65535. * @param parameters - An object containing all parameters (see above)
  65536. * @param scene The scene linked to this pipeline
  65537. * @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)
  65538. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65539. */
  65540. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65541. /**
  65542. * Get the class name
  65543. * @returns "LensRenderingPipeline"
  65544. */
  65545. getClassName(): string;
  65546. /**
  65547. * Gets associated scene
  65548. */
  65549. get scene(): Scene;
  65550. /**
  65551. * Gets or sets the edge blur
  65552. */
  65553. get edgeBlur(): number;
  65554. set edgeBlur(value: number);
  65555. /**
  65556. * Gets or sets the grain amount
  65557. */
  65558. get grainAmount(): number;
  65559. set grainAmount(value: number);
  65560. /**
  65561. * Gets or sets the chromatic aberration amount
  65562. */
  65563. get chromaticAberration(): number;
  65564. set chromaticAberration(value: number);
  65565. /**
  65566. * Gets or sets the depth of field aperture
  65567. */
  65568. get dofAperture(): number;
  65569. set dofAperture(value: number);
  65570. /**
  65571. * Gets or sets the edge distortion
  65572. */
  65573. get edgeDistortion(): number;
  65574. set edgeDistortion(value: number);
  65575. /**
  65576. * Gets or sets the depth of field distortion
  65577. */
  65578. get dofDistortion(): number;
  65579. set dofDistortion(value: number);
  65580. /**
  65581. * Gets or sets the darken out of focus amount
  65582. */
  65583. get darkenOutOfFocus(): number;
  65584. set darkenOutOfFocus(value: number);
  65585. /**
  65586. * Gets or sets a boolean indicating if blur noise is enabled
  65587. */
  65588. get blurNoise(): boolean;
  65589. set blurNoise(value: boolean);
  65590. /**
  65591. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65592. */
  65593. get pentagonBokeh(): boolean;
  65594. set pentagonBokeh(value: boolean);
  65595. /**
  65596. * Gets or sets the highlight grain amount
  65597. */
  65598. get highlightsGain(): number;
  65599. set highlightsGain(value: number);
  65600. /**
  65601. * Gets or sets the highlight threshold
  65602. */
  65603. get highlightsThreshold(): number;
  65604. set highlightsThreshold(value: number);
  65605. /**
  65606. * Sets the amount of blur at the edges
  65607. * @param amount blur amount
  65608. */
  65609. setEdgeBlur(amount: number): void;
  65610. /**
  65611. * Sets edge blur to 0
  65612. */
  65613. disableEdgeBlur(): void;
  65614. /**
  65615. * Sets the amout of grain
  65616. * @param amount Amount of grain
  65617. */
  65618. setGrainAmount(amount: number): void;
  65619. /**
  65620. * Set grain amount to 0
  65621. */
  65622. disableGrain(): void;
  65623. /**
  65624. * Sets the chromatic aberration amount
  65625. * @param amount amount of chromatic aberration
  65626. */
  65627. setChromaticAberration(amount: number): void;
  65628. /**
  65629. * Sets chromatic aberration amount to 0
  65630. */
  65631. disableChromaticAberration(): void;
  65632. /**
  65633. * Sets the EdgeDistortion amount
  65634. * @param amount amount of EdgeDistortion
  65635. */
  65636. setEdgeDistortion(amount: number): void;
  65637. /**
  65638. * Sets edge distortion to 0
  65639. */
  65640. disableEdgeDistortion(): void;
  65641. /**
  65642. * Sets the FocusDistance amount
  65643. * @param amount amount of FocusDistance
  65644. */
  65645. setFocusDistance(amount: number): void;
  65646. /**
  65647. * Disables depth of field
  65648. */
  65649. disableDepthOfField(): void;
  65650. /**
  65651. * Sets the Aperture amount
  65652. * @param amount amount of Aperture
  65653. */
  65654. setAperture(amount: number): void;
  65655. /**
  65656. * Sets the DarkenOutOfFocus amount
  65657. * @param amount amount of DarkenOutOfFocus
  65658. */
  65659. setDarkenOutOfFocus(amount: number): void;
  65660. private _pentagonBokehIsEnabled;
  65661. /**
  65662. * Creates a pentagon bokeh effect
  65663. */
  65664. enablePentagonBokeh(): void;
  65665. /**
  65666. * Disables the pentagon bokeh effect
  65667. */
  65668. disablePentagonBokeh(): void;
  65669. /**
  65670. * Enables noise blur
  65671. */
  65672. enableNoiseBlur(): void;
  65673. /**
  65674. * Disables noise blur
  65675. */
  65676. disableNoiseBlur(): void;
  65677. /**
  65678. * Sets the HighlightsGain amount
  65679. * @param amount amount of HighlightsGain
  65680. */
  65681. setHighlightsGain(amount: number): void;
  65682. /**
  65683. * Sets the HighlightsThreshold amount
  65684. * @param amount amount of HighlightsThreshold
  65685. */
  65686. setHighlightsThreshold(amount: number): void;
  65687. /**
  65688. * Disables highlights
  65689. */
  65690. disableHighlights(): void;
  65691. /**
  65692. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65693. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65694. */
  65695. dispose(disableDepthRender?: boolean): void;
  65696. private _createChromaticAberrationPostProcess;
  65697. private _createHighlightsPostProcess;
  65698. private _createDepthOfFieldPostProcess;
  65699. private _createGrainTexture;
  65700. }
  65701. }
  65702. declare module BABYLON {
  65703. /** @hidden */
  65704. export var ssao2PixelShader: {
  65705. name: string;
  65706. shader: string;
  65707. };
  65708. }
  65709. declare module BABYLON {
  65710. /** @hidden */
  65711. export var ssaoCombinePixelShader: {
  65712. name: string;
  65713. shader: string;
  65714. };
  65715. }
  65716. declare module BABYLON {
  65717. /**
  65718. * Render pipeline to produce ssao effect
  65719. */
  65720. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65721. /**
  65722. * @ignore
  65723. * The PassPostProcess id in the pipeline that contains the original scene color
  65724. */
  65725. SSAOOriginalSceneColorEffect: string;
  65726. /**
  65727. * @ignore
  65728. * The SSAO PostProcess id in the pipeline
  65729. */
  65730. SSAORenderEffect: string;
  65731. /**
  65732. * @ignore
  65733. * The horizontal blur PostProcess id in the pipeline
  65734. */
  65735. SSAOBlurHRenderEffect: string;
  65736. /**
  65737. * @ignore
  65738. * The vertical blur PostProcess id in the pipeline
  65739. */
  65740. SSAOBlurVRenderEffect: string;
  65741. /**
  65742. * @ignore
  65743. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65744. */
  65745. SSAOCombineRenderEffect: string;
  65746. /**
  65747. * The output strength of the SSAO post-process. Default value is 1.0.
  65748. */
  65749. totalStrength: number;
  65750. /**
  65751. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65752. */
  65753. maxZ: number;
  65754. /**
  65755. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65756. */
  65757. minZAspect: number;
  65758. private _samples;
  65759. /**
  65760. * Number of samples used for the SSAO calculations. Default value is 8
  65761. */
  65762. set samples(n: number);
  65763. get samples(): number;
  65764. private _textureSamples;
  65765. /**
  65766. * Number of samples to use for antialiasing
  65767. */
  65768. set textureSamples(n: number);
  65769. get textureSamples(): number;
  65770. /**
  65771. * Ratio object used for SSAO ratio and blur ratio
  65772. */
  65773. private _ratio;
  65774. /**
  65775. * Dynamically generated sphere sampler.
  65776. */
  65777. private _sampleSphere;
  65778. /**
  65779. * Blur filter offsets
  65780. */
  65781. private _samplerOffsets;
  65782. private _expensiveBlur;
  65783. /**
  65784. * If bilateral blur should be used
  65785. */
  65786. set expensiveBlur(b: boolean);
  65787. get expensiveBlur(): boolean;
  65788. /**
  65789. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65790. */
  65791. radius: number;
  65792. /**
  65793. * The base color of the SSAO post-process
  65794. * The final result is "base + ssao" between [0, 1]
  65795. */
  65796. base: number;
  65797. /**
  65798. * Support test.
  65799. */
  65800. static get IsSupported(): boolean;
  65801. private _scene;
  65802. private _depthTexture;
  65803. private _normalTexture;
  65804. private _randomTexture;
  65805. private _originalColorPostProcess;
  65806. private _ssaoPostProcess;
  65807. private _blurHPostProcess;
  65808. private _blurVPostProcess;
  65809. private _ssaoCombinePostProcess;
  65810. /**
  65811. * Gets active scene
  65812. */
  65813. get scene(): Scene;
  65814. /**
  65815. * @constructor
  65816. * @param name The rendering pipeline name
  65817. * @param scene The scene linked to this pipeline
  65818. * @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 }
  65819. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65820. */
  65821. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65822. /**
  65823. * Get the class name
  65824. * @returns "SSAO2RenderingPipeline"
  65825. */
  65826. getClassName(): string;
  65827. /**
  65828. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65829. */
  65830. dispose(disableGeometryBufferRenderer?: boolean): void;
  65831. private _createBlurPostProcess;
  65832. /** @hidden */
  65833. _rebuild(): void;
  65834. private _bits;
  65835. private _radicalInverse_VdC;
  65836. private _hammersley;
  65837. private _hemisphereSample_uniform;
  65838. private _generateHemisphere;
  65839. private _createSSAOPostProcess;
  65840. private _createSSAOCombinePostProcess;
  65841. private _createRandomTexture;
  65842. /**
  65843. * Serialize the rendering pipeline (Used when exporting)
  65844. * @returns the serialized object
  65845. */
  65846. serialize(): any;
  65847. /**
  65848. * Parse the serialized pipeline
  65849. * @param source Source pipeline.
  65850. * @param scene The scene to load the pipeline to.
  65851. * @param rootUrl The URL of the serialized pipeline.
  65852. * @returns An instantiated pipeline from the serialized object.
  65853. */
  65854. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65855. }
  65856. }
  65857. declare module BABYLON {
  65858. /** @hidden */
  65859. export var ssaoPixelShader: {
  65860. name: string;
  65861. shader: string;
  65862. };
  65863. }
  65864. declare module BABYLON {
  65865. /**
  65866. * Render pipeline to produce ssao effect
  65867. */
  65868. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65869. /**
  65870. * @ignore
  65871. * The PassPostProcess id in the pipeline that contains the original scene color
  65872. */
  65873. SSAOOriginalSceneColorEffect: string;
  65874. /**
  65875. * @ignore
  65876. * The SSAO PostProcess id in the pipeline
  65877. */
  65878. SSAORenderEffect: string;
  65879. /**
  65880. * @ignore
  65881. * The horizontal blur PostProcess id in the pipeline
  65882. */
  65883. SSAOBlurHRenderEffect: string;
  65884. /**
  65885. * @ignore
  65886. * The vertical blur PostProcess id in the pipeline
  65887. */
  65888. SSAOBlurVRenderEffect: string;
  65889. /**
  65890. * @ignore
  65891. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65892. */
  65893. SSAOCombineRenderEffect: string;
  65894. /**
  65895. * The output strength of the SSAO post-process. Default value is 1.0.
  65896. */
  65897. totalStrength: number;
  65898. /**
  65899. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65900. */
  65901. radius: number;
  65902. /**
  65903. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65904. * Must not be equal to fallOff and superior to fallOff.
  65905. * Default value is 0.0075
  65906. */
  65907. area: number;
  65908. /**
  65909. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65910. * Must not be equal to area and inferior to area.
  65911. * Default value is 0.000001
  65912. */
  65913. fallOff: number;
  65914. /**
  65915. * The base color of the SSAO post-process
  65916. * The final result is "base + ssao" between [0, 1]
  65917. */
  65918. base: number;
  65919. private _scene;
  65920. private _depthTexture;
  65921. private _randomTexture;
  65922. private _originalColorPostProcess;
  65923. private _ssaoPostProcess;
  65924. private _blurHPostProcess;
  65925. private _blurVPostProcess;
  65926. private _ssaoCombinePostProcess;
  65927. private _firstUpdate;
  65928. /**
  65929. * Gets active scene
  65930. */
  65931. get scene(): Scene;
  65932. /**
  65933. * @constructor
  65934. * @param name - The rendering pipeline name
  65935. * @param scene - The scene linked to this pipeline
  65936. * @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 }
  65937. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65938. */
  65939. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65940. /**
  65941. * Get the class name
  65942. * @returns "SSAORenderingPipeline"
  65943. */
  65944. getClassName(): string;
  65945. /**
  65946. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65947. */
  65948. dispose(disableDepthRender?: boolean): void;
  65949. private _createBlurPostProcess;
  65950. /** @hidden */
  65951. _rebuild(): void;
  65952. private _createSSAOPostProcess;
  65953. private _createSSAOCombinePostProcess;
  65954. private _createRandomTexture;
  65955. }
  65956. }
  65957. declare module BABYLON {
  65958. /** @hidden */
  65959. export var screenSpaceReflectionPixelShader: {
  65960. name: string;
  65961. shader: string;
  65962. };
  65963. }
  65964. declare module BABYLON {
  65965. /**
  65966. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65967. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65968. */
  65969. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65970. /**
  65971. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65972. */
  65973. threshold: number;
  65974. /**
  65975. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65976. */
  65977. strength: number;
  65978. /**
  65979. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65980. */
  65981. reflectionSpecularFalloffExponent: number;
  65982. /**
  65983. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  65984. */
  65985. step: number;
  65986. /**
  65987. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65988. */
  65989. roughnessFactor: number;
  65990. private _geometryBufferRenderer;
  65991. private _enableSmoothReflections;
  65992. private _reflectionSamples;
  65993. private _smoothSteps;
  65994. /**
  65995. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65996. * @param name The name of the effect.
  65997. * @param scene The scene containing the objects to calculate reflections.
  65998. * @param options The required width/height ratio to downsize to before computing the render pass.
  65999. * @param camera The camera to apply the render pass to.
  66000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66001. * @param engine The engine which the post process will be applied. (default: current engine)
  66002. * @param reusable If the post process can be reused on the same frame. (default: false)
  66003. * @param textureType Type of textures used when performing the post process. (default: 0)
  66004. * @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)
  66005. */
  66006. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66007. /**
  66008. * Gets wether or not smoothing reflections is enabled.
  66009. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66010. */
  66011. get enableSmoothReflections(): boolean;
  66012. /**
  66013. * Sets wether or not smoothing reflections is enabled.
  66014. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66015. */
  66016. set enableSmoothReflections(enabled: boolean);
  66017. /**
  66018. * Gets the number of samples taken while computing reflections. More samples count is high,
  66019. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66020. */
  66021. get reflectionSamples(): number;
  66022. /**
  66023. * Sets the number of samples taken while computing reflections. More samples count is high,
  66024. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66025. */
  66026. set reflectionSamples(samples: number);
  66027. /**
  66028. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66029. * more the post-process will require GPU power and can generate a drop in FPS.
  66030. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66031. */
  66032. get smoothSteps(): number;
  66033. set smoothSteps(steps: number);
  66034. private _updateEffectDefines;
  66035. }
  66036. }
  66037. declare module BABYLON {
  66038. /** @hidden */
  66039. export var standardPixelShader: {
  66040. name: string;
  66041. shader: string;
  66042. };
  66043. }
  66044. declare module BABYLON {
  66045. /**
  66046. * Standard rendering pipeline
  66047. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66048. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66049. */
  66050. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66051. /**
  66052. * Public members
  66053. */
  66054. /**
  66055. * Post-process which contains the original scene color before the pipeline applies all the effects
  66056. */
  66057. originalPostProcess: Nullable<PostProcess>;
  66058. /**
  66059. * Post-process used to down scale an image x4
  66060. */
  66061. downSampleX4PostProcess: Nullable<PostProcess>;
  66062. /**
  66063. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66064. */
  66065. brightPassPostProcess: Nullable<PostProcess>;
  66066. /**
  66067. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66068. */
  66069. blurHPostProcesses: PostProcess[];
  66070. /**
  66071. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66072. */
  66073. blurVPostProcesses: PostProcess[];
  66074. /**
  66075. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66076. */
  66077. textureAdderPostProcess: Nullable<PostProcess>;
  66078. /**
  66079. * Post-process used to create volumetric lighting effect
  66080. */
  66081. volumetricLightPostProcess: Nullable<PostProcess>;
  66082. /**
  66083. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66084. */
  66085. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66086. /**
  66087. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66088. */
  66089. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66090. /**
  66091. * Post-process used to merge the volumetric light effect and the real scene color
  66092. */
  66093. volumetricLightMergePostProces: Nullable<PostProcess>;
  66094. /**
  66095. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66096. */
  66097. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66098. /**
  66099. * Base post-process used to calculate the average luminance of the final image for HDR
  66100. */
  66101. luminancePostProcess: Nullable<PostProcess>;
  66102. /**
  66103. * Post-processes used to create down sample post-processes in order to get
  66104. * the average luminance of the final image for HDR
  66105. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66106. */
  66107. luminanceDownSamplePostProcesses: PostProcess[];
  66108. /**
  66109. * Post-process used to create a HDR effect (light adaptation)
  66110. */
  66111. hdrPostProcess: Nullable<PostProcess>;
  66112. /**
  66113. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66114. */
  66115. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66116. /**
  66117. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66118. */
  66119. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66120. /**
  66121. * Post-process used to merge the final HDR post-process and the real scene color
  66122. */
  66123. hdrFinalPostProcess: Nullable<PostProcess>;
  66124. /**
  66125. * Post-process used to create a lens flare effect
  66126. */
  66127. lensFlarePostProcess: Nullable<PostProcess>;
  66128. /**
  66129. * Post-process that merges the result of the lens flare post-process and the real scene color
  66130. */
  66131. lensFlareComposePostProcess: Nullable<PostProcess>;
  66132. /**
  66133. * Post-process used to create a motion blur effect
  66134. */
  66135. motionBlurPostProcess: Nullable<PostProcess>;
  66136. /**
  66137. * Post-process used to create a depth of field effect
  66138. */
  66139. depthOfFieldPostProcess: Nullable<PostProcess>;
  66140. /**
  66141. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66142. */
  66143. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66144. /**
  66145. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66146. */
  66147. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66148. /**
  66149. * Represents the brightness threshold in order to configure the illuminated surfaces
  66150. */
  66151. brightThreshold: number;
  66152. /**
  66153. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66154. */
  66155. blurWidth: number;
  66156. /**
  66157. * Sets if the blur for highlighted surfaces must be only horizontal
  66158. */
  66159. horizontalBlur: boolean;
  66160. /**
  66161. * Gets the overall exposure used by the pipeline
  66162. */
  66163. get exposure(): number;
  66164. /**
  66165. * Sets the overall exposure used by the pipeline
  66166. */
  66167. set exposure(value: number);
  66168. /**
  66169. * Texture used typically to simulate "dirty" on camera lens
  66170. */
  66171. lensTexture: Nullable<Texture>;
  66172. /**
  66173. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66174. */
  66175. volumetricLightCoefficient: number;
  66176. /**
  66177. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66178. */
  66179. volumetricLightPower: number;
  66180. /**
  66181. * Used the set the blur intensity to smooth the volumetric lights
  66182. */
  66183. volumetricLightBlurScale: number;
  66184. /**
  66185. * Light (spot or directional) used to generate the volumetric lights rays
  66186. * The source light must have a shadow generate so the pipeline can get its
  66187. * depth map
  66188. */
  66189. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66190. /**
  66191. * For eye adaptation, represents the minimum luminance the eye can see
  66192. */
  66193. hdrMinimumLuminance: number;
  66194. /**
  66195. * For eye adaptation, represents the decrease luminance speed
  66196. */
  66197. hdrDecreaseRate: number;
  66198. /**
  66199. * For eye adaptation, represents the increase luminance speed
  66200. */
  66201. hdrIncreaseRate: number;
  66202. /**
  66203. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66204. */
  66205. get hdrAutoExposure(): boolean;
  66206. /**
  66207. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66208. */
  66209. set hdrAutoExposure(value: boolean);
  66210. /**
  66211. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66212. */
  66213. lensColorTexture: Nullable<Texture>;
  66214. /**
  66215. * The overall strengh for the lens flare effect
  66216. */
  66217. lensFlareStrength: number;
  66218. /**
  66219. * Dispersion coefficient for lens flare ghosts
  66220. */
  66221. lensFlareGhostDispersal: number;
  66222. /**
  66223. * Main lens flare halo width
  66224. */
  66225. lensFlareHaloWidth: number;
  66226. /**
  66227. * Based on the lens distortion effect, defines how much the lens flare result
  66228. * is distorted
  66229. */
  66230. lensFlareDistortionStrength: number;
  66231. /**
  66232. * Configures the blur intensity used for for lens flare (halo)
  66233. */
  66234. lensFlareBlurWidth: number;
  66235. /**
  66236. * Lens star texture must be used to simulate rays on the flares and is available
  66237. * in the documentation
  66238. */
  66239. lensStarTexture: Nullable<Texture>;
  66240. /**
  66241. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66242. * flare effect by taking account of the dirt texture
  66243. */
  66244. lensFlareDirtTexture: Nullable<Texture>;
  66245. /**
  66246. * Represents the focal length for the depth of field effect
  66247. */
  66248. depthOfFieldDistance: number;
  66249. /**
  66250. * Represents the blur intensity for the blurred part of the depth of field effect
  66251. */
  66252. depthOfFieldBlurWidth: number;
  66253. /**
  66254. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66255. */
  66256. get motionStrength(): number;
  66257. /**
  66258. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66259. */
  66260. set motionStrength(strength: number);
  66261. /**
  66262. * Gets wether or not the motion blur post-process is object based or screen based.
  66263. */
  66264. get objectBasedMotionBlur(): boolean;
  66265. /**
  66266. * Sets wether or not the motion blur post-process should be object based or screen based
  66267. */
  66268. set objectBasedMotionBlur(value: boolean);
  66269. /**
  66270. * List of animations for the pipeline (IAnimatable implementation)
  66271. */
  66272. animations: Animation[];
  66273. /**
  66274. * Private members
  66275. */
  66276. private _scene;
  66277. private _currentDepthOfFieldSource;
  66278. private _basePostProcess;
  66279. private _fixedExposure;
  66280. private _currentExposure;
  66281. private _hdrAutoExposure;
  66282. private _hdrCurrentLuminance;
  66283. private _motionStrength;
  66284. private _isObjectBasedMotionBlur;
  66285. private _floatTextureType;
  66286. private _camerasToBeAttached;
  66287. private _ratio;
  66288. private _bloomEnabled;
  66289. private _depthOfFieldEnabled;
  66290. private _vlsEnabled;
  66291. private _lensFlareEnabled;
  66292. private _hdrEnabled;
  66293. private _motionBlurEnabled;
  66294. private _fxaaEnabled;
  66295. private _screenSpaceReflectionsEnabled;
  66296. private _motionBlurSamples;
  66297. private _volumetricLightStepsCount;
  66298. private _samples;
  66299. /**
  66300. * @ignore
  66301. * Specifies if the bloom pipeline is enabled
  66302. */
  66303. get BloomEnabled(): boolean;
  66304. set BloomEnabled(enabled: boolean);
  66305. /**
  66306. * @ignore
  66307. * Specifies if the depth of field pipeline is enabed
  66308. */
  66309. get DepthOfFieldEnabled(): boolean;
  66310. set DepthOfFieldEnabled(enabled: boolean);
  66311. /**
  66312. * @ignore
  66313. * Specifies if the lens flare pipeline is enabed
  66314. */
  66315. get LensFlareEnabled(): boolean;
  66316. set LensFlareEnabled(enabled: boolean);
  66317. /**
  66318. * @ignore
  66319. * Specifies if the HDR pipeline is enabled
  66320. */
  66321. get HDREnabled(): boolean;
  66322. set HDREnabled(enabled: boolean);
  66323. /**
  66324. * @ignore
  66325. * Specifies if the volumetric lights scattering effect is enabled
  66326. */
  66327. get VLSEnabled(): boolean;
  66328. set VLSEnabled(enabled: boolean);
  66329. /**
  66330. * @ignore
  66331. * Specifies if the motion blur effect is enabled
  66332. */
  66333. get MotionBlurEnabled(): boolean;
  66334. set MotionBlurEnabled(enabled: boolean);
  66335. /**
  66336. * Specifies if anti-aliasing is enabled
  66337. */
  66338. get fxaaEnabled(): boolean;
  66339. set fxaaEnabled(enabled: boolean);
  66340. /**
  66341. * Specifies if screen space reflections are enabled.
  66342. */
  66343. get screenSpaceReflectionsEnabled(): boolean;
  66344. set screenSpaceReflectionsEnabled(enabled: boolean);
  66345. /**
  66346. * Specifies the number of steps used to calculate the volumetric lights
  66347. * Typically in interval [50, 200]
  66348. */
  66349. get volumetricLightStepsCount(): number;
  66350. set volumetricLightStepsCount(count: number);
  66351. /**
  66352. * Specifies the number of samples used for the motion blur effect
  66353. * Typically in interval [16, 64]
  66354. */
  66355. get motionBlurSamples(): number;
  66356. set motionBlurSamples(samples: number);
  66357. /**
  66358. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66359. */
  66360. get samples(): number;
  66361. set samples(sampleCount: number);
  66362. /**
  66363. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66364. * @constructor
  66365. * @param name The rendering pipeline name
  66366. * @param scene The scene linked to this pipeline
  66367. * @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)
  66368. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66369. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66370. */
  66371. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66372. private _buildPipeline;
  66373. private _createDownSampleX4PostProcess;
  66374. private _createBrightPassPostProcess;
  66375. private _createBlurPostProcesses;
  66376. private _createTextureAdderPostProcess;
  66377. private _createVolumetricLightPostProcess;
  66378. private _createLuminancePostProcesses;
  66379. private _createHdrPostProcess;
  66380. private _createLensFlarePostProcess;
  66381. private _createDepthOfFieldPostProcess;
  66382. private _createMotionBlurPostProcess;
  66383. private _getDepthTexture;
  66384. private _disposePostProcesses;
  66385. /**
  66386. * Dispose of the pipeline and stop all post processes
  66387. */
  66388. dispose(): void;
  66389. /**
  66390. * Serialize the rendering pipeline (Used when exporting)
  66391. * @returns the serialized object
  66392. */
  66393. serialize(): any;
  66394. /**
  66395. * Parse the serialized pipeline
  66396. * @param source Source pipeline.
  66397. * @param scene The scene to load the pipeline to.
  66398. * @param rootUrl The URL of the serialized pipeline.
  66399. * @returns An instantiated pipeline from the serialized object.
  66400. */
  66401. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66402. /**
  66403. * Luminance steps
  66404. */
  66405. static LuminanceSteps: number;
  66406. }
  66407. }
  66408. declare module BABYLON {
  66409. /** @hidden */
  66410. export var tonemapPixelShader: {
  66411. name: string;
  66412. shader: string;
  66413. };
  66414. }
  66415. declare module BABYLON {
  66416. /** Defines operator used for tonemapping */
  66417. export enum TonemappingOperator {
  66418. /** Hable */
  66419. Hable = 0,
  66420. /** Reinhard */
  66421. Reinhard = 1,
  66422. /** HejiDawson */
  66423. HejiDawson = 2,
  66424. /** Photographic */
  66425. Photographic = 3
  66426. }
  66427. /**
  66428. * Defines a post process to apply tone mapping
  66429. */
  66430. export class TonemapPostProcess extends PostProcess {
  66431. private _operator;
  66432. /** Defines the required exposure adjustement */
  66433. exposureAdjustment: number;
  66434. /**
  66435. * Creates a new TonemapPostProcess
  66436. * @param name defines the name of the postprocess
  66437. * @param _operator defines the operator to use
  66438. * @param exposureAdjustment defines the required exposure adjustement
  66439. * @param camera defines the camera to use (can be null)
  66440. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66441. * @param engine defines the hosting engine (can be ignore if camera is set)
  66442. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66443. */
  66444. constructor(name: string, _operator: TonemappingOperator,
  66445. /** Defines the required exposure adjustement */
  66446. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66447. }
  66448. }
  66449. declare module BABYLON {
  66450. /** @hidden */
  66451. export var volumetricLightScatteringPixelShader: {
  66452. name: string;
  66453. shader: string;
  66454. };
  66455. }
  66456. declare module BABYLON {
  66457. /** @hidden */
  66458. export var volumetricLightScatteringPassVertexShader: {
  66459. name: string;
  66460. shader: string;
  66461. };
  66462. }
  66463. declare module BABYLON {
  66464. /** @hidden */
  66465. export var volumetricLightScatteringPassPixelShader: {
  66466. name: string;
  66467. shader: string;
  66468. };
  66469. }
  66470. declare module BABYLON {
  66471. /**
  66472. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66473. */
  66474. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66475. private _volumetricLightScatteringPass;
  66476. private _volumetricLightScatteringRTT;
  66477. private _viewPort;
  66478. private _screenCoordinates;
  66479. private _cachedDefines;
  66480. /**
  66481. * If not undefined, the mesh position is computed from the attached node position
  66482. */
  66483. attachedNode: {
  66484. position: Vector3;
  66485. };
  66486. /**
  66487. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66488. */
  66489. customMeshPosition: Vector3;
  66490. /**
  66491. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66492. */
  66493. useCustomMeshPosition: boolean;
  66494. /**
  66495. * If the post-process should inverse the light scattering direction
  66496. */
  66497. invert: boolean;
  66498. /**
  66499. * The internal mesh used by the post-process
  66500. */
  66501. mesh: Mesh;
  66502. /**
  66503. * @hidden
  66504. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66505. */
  66506. get useDiffuseColor(): boolean;
  66507. set useDiffuseColor(useDiffuseColor: boolean);
  66508. /**
  66509. * Array containing the excluded meshes not rendered in the internal pass
  66510. */
  66511. excludedMeshes: AbstractMesh[];
  66512. /**
  66513. * Controls the overall intensity of the post-process
  66514. */
  66515. exposure: number;
  66516. /**
  66517. * Dissipates each sample's contribution in range [0, 1]
  66518. */
  66519. decay: number;
  66520. /**
  66521. * Controls the overall intensity of each sample
  66522. */
  66523. weight: number;
  66524. /**
  66525. * Controls the density of each sample
  66526. */
  66527. density: number;
  66528. /**
  66529. * @constructor
  66530. * @param name The post-process name
  66531. * @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)
  66532. * @param camera The camera that the post-process will be attached to
  66533. * @param mesh The mesh used to create the light scattering
  66534. * @param samples The post-process quality, default 100
  66535. * @param samplingModeThe post-process filtering mode
  66536. * @param engine The babylon engine
  66537. * @param reusable If the post-process is reusable
  66538. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66539. */
  66540. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66541. /**
  66542. * Returns the string "VolumetricLightScatteringPostProcess"
  66543. * @returns "VolumetricLightScatteringPostProcess"
  66544. */
  66545. getClassName(): string;
  66546. private _isReady;
  66547. /**
  66548. * Sets the new light position for light scattering effect
  66549. * @param position The new custom light position
  66550. */
  66551. setCustomMeshPosition(position: Vector3): void;
  66552. /**
  66553. * Returns the light position for light scattering effect
  66554. * @return Vector3 The custom light position
  66555. */
  66556. getCustomMeshPosition(): Vector3;
  66557. /**
  66558. * Disposes the internal assets and detaches the post-process from the camera
  66559. */
  66560. dispose(camera: Camera): void;
  66561. /**
  66562. * Returns the render target texture used by the post-process
  66563. * @return the render target texture used by the post-process
  66564. */
  66565. getPass(): RenderTargetTexture;
  66566. private _meshExcluded;
  66567. private _createPass;
  66568. private _updateMeshScreenCoordinates;
  66569. /**
  66570. * Creates a default mesh for the Volumeric Light Scattering post-process
  66571. * @param name The mesh name
  66572. * @param scene The scene where to create the mesh
  66573. * @return the default mesh
  66574. */
  66575. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66576. }
  66577. }
  66578. declare module BABYLON {
  66579. interface Scene {
  66580. /** @hidden (Backing field) */
  66581. _boundingBoxRenderer: BoundingBoxRenderer;
  66582. /** @hidden (Backing field) */
  66583. _forceShowBoundingBoxes: boolean;
  66584. /**
  66585. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66586. */
  66587. forceShowBoundingBoxes: boolean;
  66588. /**
  66589. * Gets the bounding box renderer associated with the scene
  66590. * @returns a BoundingBoxRenderer
  66591. */
  66592. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66593. }
  66594. interface AbstractMesh {
  66595. /** @hidden (Backing field) */
  66596. _showBoundingBox: boolean;
  66597. /**
  66598. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66599. */
  66600. showBoundingBox: boolean;
  66601. }
  66602. /**
  66603. * Component responsible of rendering the bounding box of the meshes in a scene.
  66604. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66605. */
  66606. export class BoundingBoxRenderer implements ISceneComponent {
  66607. /**
  66608. * The component name helpfull to identify the component in the list of scene components.
  66609. */
  66610. readonly name: string;
  66611. /**
  66612. * The scene the component belongs to.
  66613. */
  66614. scene: Scene;
  66615. /**
  66616. * Color of the bounding box lines placed in front of an object
  66617. */
  66618. frontColor: Color3;
  66619. /**
  66620. * Color of the bounding box lines placed behind an object
  66621. */
  66622. backColor: Color3;
  66623. /**
  66624. * Defines if the renderer should show the back lines or not
  66625. */
  66626. showBackLines: boolean;
  66627. /**
  66628. * @hidden
  66629. */
  66630. renderList: SmartArray<BoundingBox>;
  66631. private _colorShader;
  66632. private _vertexBuffers;
  66633. private _indexBuffer;
  66634. private _fillIndexBuffer;
  66635. private _fillIndexData;
  66636. /**
  66637. * Instantiates a new bounding box renderer in a scene.
  66638. * @param scene the scene the renderer renders in
  66639. */
  66640. constructor(scene: Scene);
  66641. /**
  66642. * Registers the component in a given scene
  66643. */
  66644. register(): void;
  66645. private _evaluateSubMesh;
  66646. private _activeMesh;
  66647. private _prepareRessources;
  66648. private _createIndexBuffer;
  66649. /**
  66650. * Rebuilds the elements related to this component in case of
  66651. * context lost for instance.
  66652. */
  66653. rebuild(): void;
  66654. /**
  66655. * @hidden
  66656. */
  66657. reset(): void;
  66658. /**
  66659. * Render the bounding boxes of a specific rendering group
  66660. * @param renderingGroupId defines the rendering group to render
  66661. */
  66662. render(renderingGroupId: number): void;
  66663. /**
  66664. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66665. * @param mesh Define the mesh to render the occlusion bounding box for
  66666. */
  66667. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66668. /**
  66669. * Dispose and release the resources attached to this renderer.
  66670. */
  66671. dispose(): void;
  66672. }
  66673. }
  66674. declare module BABYLON {
  66675. interface Scene {
  66676. /** @hidden (Backing field) */
  66677. _depthRenderer: {
  66678. [id: string]: DepthRenderer;
  66679. };
  66680. /**
  66681. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66682. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66683. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66684. * @returns the created depth renderer
  66685. */
  66686. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66687. /**
  66688. * Disables a depth renderer for a given camera
  66689. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66690. */
  66691. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66692. }
  66693. /**
  66694. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66695. * in several rendering techniques.
  66696. */
  66697. export class DepthRendererSceneComponent implements ISceneComponent {
  66698. /**
  66699. * The component name helpfull to identify the component in the list of scene components.
  66700. */
  66701. readonly name: string;
  66702. /**
  66703. * The scene the component belongs to.
  66704. */
  66705. scene: Scene;
  66706. /**
  66707. * Creates a new instance of the component for the given scene
  66708. * @param scene Defines the scene to register the component in
  66709. */
  66710. constructor(scene: Scene);
  66711. /**
  66712. * Registers the component in a given scene
  66713. */
  66714. register(): void;
  66715. /**
  66716. * Rebuilds the elements related to this component in case of
  66717. * context lost for instance.
  66718. */
  66719. rebuild(): void;
  66720. /**
  66721. * Disposes the component and the associated ressources
  66722. */
  66723. dispose(): void;
  66724. private _gatherRenderTargets;
  66725. private _gatherActiveCameraRenderTargets;
  66726. }
  66727. }
  66728. declare module BABYLON {
  66729. /** @hidden */
  66730. export var outlinePixelShader: {
  66731. name: string;
  66732. shader: string;
  66733. };
  66734. }
  66735. declare module BABYLON {
  66736. /** @hidden */
  66737. export var outlineVertexShader: {
  66738. name: string;
  66739. shader: string;
  66740. };
  66741. }
  66742. declare module BABYLON {
  66743. interface Scene {
  66744. /** @hidden */
  66745. _outlineRenderer: OutlineRenderer;
  66746. /**
  66747. * Gets the outline renderer associated with the scene
  66748. * @returns a OutlineRenderer
  66749. */
  66750. getOutlineRenderer(): OutlineRenderer;
  66751. }
  66752. interface AbstractMesh {
  66753. /** @hidden (Backing field) */
  66754. _renderOutline: boolean;
  66755. /**
  66756. * Gets or sets a boolean indicating if the outline must be rendered as well
  66757. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66758. */
  66759. renderOutline: boolean;
  66760. /** @hidden (Backing field) */
  66761. _renderOverlay: boolean;
  66762. /**
  66763. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66764. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66765. */
  66766. renderOverlay: boolean;
  66767. }
  66768. /**
  66769. * This class is responsible to draw bothe outline/overlay of meshes.
  66770. * It should not be used directly but through the available method on mesh.
  66771. */
  66772. export class OutlineRenderer implements ISceneComponent {
  66773. /**
  66774. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66775. */
  66776. private static _StencilReference;
  66777. /**
  66778. * The name of the component. Each component must have a unique name.
  66779. */
  66780. name: string;
  66781. /**
  66782. * The scene the component belongs to.
  66783. */
  66784. scene: Scene;
  66785. /**
  66786. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66787. */
  66788. zOffset: number;
  66789. private _engine;
  66790. private _effect;
  66791. private _cachedDefines;
  66792. private _savedDepthWrite;
  66793. /**
  66794. * Instantiates a new outline renderer. (There could be only one per scene).
  66795. * @param scene Defines the scene it belongs to
  66796. */
  66797. constructor(scene: Scene);
  66798. /**
  66799. * Register the component to one instance of a scene.
  66800. */
  66801. register(): void;
  66802. /**
  66803. * Rebuilds the elements related to this component in case of
  66804. * context lost for instance.
  66805. */
  66806. rebuild(): void;
  66807. /**
  66808. * Disposes the component and the associated ressources.
  66809. */
  66810. dispose(): void;
  66811. /**
  66812. * Renders the outline in the canvas.
  66813. * @param subMesh Defines the sumesh to render
  66814. * @param batch Defines the batch of meshes in case of instances
  66815. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66816. */
  66817. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66818. /**
  66819. * Returns whether or not the outline renderer is ready for a given submesh.
  66820. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66821. * @param subMesh Defines the submesh to check readyness for
  66822. * @param useInstances Defines wheter wee are trying to render instances or not
  66823. * @returns true if ready otherwise false
  66824. */
  66825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66826. private _beforeRenderingMesh;
  66827. private _afterRenderingMesh;
  66828. }
  66829. }
  66830. declare module BABYLON {
  66831. /**
  66832. * Defines the basic options interface of a Sprite Frame Source Size.
  66833. */
  66834. export interface ISpriteJSONSpriteSourceSize {
  66835. /**
  66836. * number of the original width of the Frame
  66837. */
  66838. w: number;
  66839. /**
  66840. * number of the original height of the Frame
  66841. */
  66842. h: number;
  66843. }
  66844. /**
  66845. * Defines the basic options interface of a Sprite Frame Data.
  66846. */
  66847. export interface ISpriteJSONSpriteFrameData {
  66848. /**
  66849. * number of the x offset of the Frame
  66850. */
  66851. x: number;
  66852. /**
  66853. * number of the y offset of the Frame
  66854. */
  66855. y: number;
  66856. /**
  66857. * number of the width of the Frame
  66858. */
  66859. w: number;
  66860. /**
  66861. * number of the height of the Frame
  66862. */
  66863. h: number;
  66864. }
  66865. /**
  66866. * Defines the basic options interface of a JSON Sprite.
  66867. */
  66868. export interface ISpriteJSONSprite {
  66869. /**
  66870. * string name of the Frame
  66871. */
  66872. filename: string;
  66873. /**
  66874. * ISpriteJSONSpriteFrame basic object of the frame data
  66875. */
  66876. frame: ISpriteJSONSpriteFrameData;
  66877. /**
  66878. * boolean to flag is the frame was rotated.
  66879. */
  66880. rotated: boolean;
  66881. /**
  66882. * boolean to flag is the frame was trimmed.
  66883. */
  66884. trimmed: boolean;
  66885. /**
  66886. * ISpriteJSONSpriteFrame basic object of the source data
  66887. */
  66888. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66889. /**
  66890. * ISpriteJSONSpriteFrame basic object of the source data
  66891. */
  66892. sourceSize: ISpriteJSONSpriteSourceSize;
  66893. }
  66894. /**
  66895. * Defines the basic options interface of a JSON atlas.
  66896. */
  66897. export interface ISpriteJSONAtlas {
  66898. /**
  66899. * Array of objects that contain the frame data.
  66900. */
  66901. frames: Array<ISpriteJSONSprite>;
  66902. /**
  66903. * object basic object containing the sprite meta data.
  66904. */
  66905. meta?: object;
  66906. }
  66907. }
  66908. declare module BABYLON {
  66909. /** @hidden */
  66910. export var spriteMapPixelShader: {
  66911. name: string;
  66912. shader: string;
  66913. };
  66914. }
  66915. declare module BABYLON {
  66916. /** @hidden */
  66917. export var spriteMapVertexShader: {
  66918. name: string;
  66919. shader: string;
  66920. };
  66921. }
  66922. declare module BABYLON {
  66923. /**
  66924. * Defines the basic options interface of a SpriteMap
  66925. */
  66926. export interface ISpriteMapOptions {
  66927. /**
  66928. * Vector2 of the number of cells in the grid.
  66929. */
  66930. stageSize?: Vector2;
  66931. /**
  66932. * Vector2 of the size of the output plane in World Units.
  66933. */
  66934. outputSize?: Vector2;
  66935. /**
  66936. * Vector3 of the position of the output plane in World Units.
  66937. */
  66938. outputPosition?: Vector3;
  66939. /**
  66940. * Vector3 of the rotation of the output plane.
  66941. */
  66942. outputRotation?: Vector3;
  66943. /**
  66944. * number of layers that the system will reserve in resources.
  66945. */
  66946. layerCount?: number;
  66947. /**
  66948. * number of max animation frames a single cell will reserve in resources.
  66949. */
  66950. maxAnimationFrames?: number;
  66951. /**
  66952. * number cell index of the base tile when the system compiles.
  66953. */
  66954. baseTile?: number;
  66955. /**
  66956. * boolean flip the sprite after its been repositioned by the framing data.
  66957. */
  66958. flipU?: boolean;
  66959. /**
  66960. * Vector3 scalar of the global RGB values of the SpriteMap.
  66961. */
  66962. colorMultiply?: Vector3;
  66963. }
  66964. /**
  66965. * Defines the IDisposable interface in order to be cleanable from resources.
  66966. */
  66967. export interface ISpriteMap extends IDisposable {
  66968. /**
  66969. * String name of the SpriteMap.
  66970. */
  66971. name: string;
  66972. /**
  66973. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66974. */
  66975. atlasJSON: ISpriteJSONAtlas;
  66976. /**
  66977. * Texture of the SpriteMap.
  66978. */
  66979. spriteSheet: Texture;
  66980. /**
  66981. * The parameters to initialize the SpriteMap with.
  66982. */
  66983. options: ISpriteMapOptions;
  66984. }
  66985. /**
  66986. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66987. */
  66988. export class SpriteMap implements ISpriteMap {
  66989. /** The Name of the spriteMap */
  66990. name: string;
  66991. /** The JSON file with the frame and meta data */
  66992. atlasJSON: ISpriteJSONAtlas;
  66993. /** The systems Sprite Sheet Texture */
  66994. spriteSheet: Texture;
  66995. /** Arguments passed with the Constructor */
  66996. options: ISpriteMapOptions;
  66997. /** Public Sprite Storage array, parsed from atlasJSON */
  66998. sprites: Array<ISpriteJSONSprite>;
  66999. /** Returns the Number of Sprites in the System */
  67000. get spriteCount(): number;
  67001. /** Returns the Position of Output Plane*/
  67002. get position(): Vector3;
  67003. /** Returns the Position of Output Plane*/
  67004. set position(v: Vector3);
  67005. /** Returns the Rotation of Output Plane*/
  67006. get rotation(): Vector3;
  67007. /** Returns the Rotation of Output Plane*/
  67008. set rotation(v: Vector3);
  67009. /** Sets the AnimationMap*/
  67010. get animationMap(): RawTexture;
  67011. /** Sets the AnimationMap*/
  67012. set animationMap(v: RawTexture);
  67013. /** Scene that the SpriteMap was created in */
  67014. private _scene;
  67015. /** Texture Buffer of Float32 that holds tile frame data*/
  67016. private _frameMap;
  67017. /** Texture Buffers of Float32 that holds tileMap data*/
  67018. private _tileMaps;
  67019. /** Texture Buffer of Float32 that holds Animation Data*/
  67020. private _animationMap;
  67021. /** Custom ShaderMaterial Central to the System*/
  67022. private _material;
  67023. /** Custom ShaderMaterial Central to the System*/
  67024. private _output;
  67025. /** Systems Time Ticker*/
  67026. private _time;
  67027. /**
  67028. * Creates a new SpriteMap
  67029. * @param name defines the SpriteMaps Name
  67030. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67031. * @param spriteSheet is the Texture that the Sprites are on.
  67032. * @param options a basic deployment configuration
  67033. * @param scene The Scene that the map is deployed on
  67034. */
  67035. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67036. /**
  67037. * Returns tileID location
  67038. * @returns Vector2 the cell position ID
  67039. */
  67040. getTileID(): Vector2;
  67041. /**
  67042. * Gets the UV location of the mouse over the SpriteMap.
  67043. * @returns Vector2 the UV position of the mouse interaction
  67044. */
  67045. getMousePosition(): Vector2;
  67046. /**
  67047. * Creates the "frame" texture Buffer
  67048. * -------------------------------------
  67049. * Structure of frames
  67050. * "filename": "Falling-Water-2.png",
  67051. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67052. * "rotated": true,
  67053. * "trimmed": true,
  67054. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67055. * "sourceSize": {"w":32,"h":32}
  67056. * @returns RawTexture of the frameMap
  67057. */
  67058. private _createFrameBuffer;
  67059. /**
  67060. * Creates the tileMap texture Buffer
  67061. * @param buffer normally and array of numbers, or a false to generate from scratch
  67062. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67063. * @returns RawTexture of the tileMap
  67064. */
  67065. private _createTileBuffer;
  67066. /**
  67067. * Modifies the data of the tileMaps
  67068. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67069. * @param pos is the iVector2 Coordinates of the Tile
  67070. * @param tile The SpriteIndex of the new Tile
  67071. */
  67072. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67073. /**
  67074. * Creates the animationMap texture Buffer
  67075. * @param buffer normally and array of numbers, or a false to generate from scratch
  67076. * @returns RawTexture of the animationMap
  67077. */
  67078. private _createTileAnimationBuffer;
  67079. /**
  67080. * Modifies the data of the animationMap
  67081. * @param cellID is the Index of the Sprite
  67082. * @param _frame is the target Animation frame
  67083. * @param toCell is the Target Index of the next frame of the animation
  67084. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67085. * @param speed is a global scalar of the time variable on the map.
  67086. */
  67087. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67088. /**
  67089. * Exports the .tilemaps file
  67090. */
  67091. saveTileMaps(): void;
  67092. /**
  67093. * Imports the .tilemaps file
  67094. * @param url of the .tilemaps file
  67095. */
  67096. loadTileMaps(url: string): void;
  67097. /**
  67098. * Release associated resources
  67099. */
  67100. dispose(): void;
  67101. }
  67102. }
  67103. declare module BABYLON {
  67104. /**
  67105. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67106. * @see http://doc.babylonjs.com/babylon101/sprites
  67107. */
  67108. export class SpritePackedManager extends SpriteManager {
  67109. /** defines the packed manager's name */
  67110. name: string;
  67111. /**
  67112. * Creates a new sprite manager from a packed sprite sheet
  67113. * @param name defines the manager's name
  67114. * @param imgUrl defines the sprite sheet url
  67115. * @param capacity defines the maximum allowed number of sprites
  67116. * @param scene defines the hosting scene
  67117. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67118. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67119. * @param samplingMode defines the smapling mode to use with spritesheet
  67120. * @param fromPacked set to true; do not alter
  67121. */
  67122. constructor(
  67123. /** defines the packed manager's name */
  67124. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67125. }
  67126. }
  67127. declare module BABYLON {
  67128. /**
  67129. * Defines the list of states available for a task inside a AssetsManager
  67130. */
  67131. export enum AssetTaskState {
  67132. /**
  67133. * Initialization
  67134. */
  67135. INIT = 0,
  67136. /**
  67137. * Running
  67138. */
  67139. RUNNING = 1,
  67140. /**
  67141. * Done
  67142. */
  67143. DONE = 2,
  67144. /**
  67145. * Error
  67146. */
  67147. ERROR = 3
  67148. }
  67149. /**
  67150. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67151. */
  67152. export abstract class AbstractAssetTask {
  67153. /**
  67154. * Task name
  67155. */ name: string;
  67156. /**
  67157. * Callback called when the task is successful
  67158. */
  67159. onSuccess: (task: any) => void;
  67160. /**
  67161. * Callback called when the task is not successful
  67162. */
  67163. onError: (task: any, message?: string, exception?: any) => void;
  67164. /**
  67165. * Creates a new AssetsManager
  67166. * @param name defines the name of the task
  67167. */
  67168. constructor(
  67169. /**
  67170. * Task name
  67171. */ name: string);
  67172. private _isCompleted;
  67173. private _taskState;
  67174. private _errorObject;
  67175. /**
  67176. * Get if the task is completed
  67177. */
  67178. get isCompleted(): boolean;
  67179. /**
  67180. * Gets the current state of the task
  67181. */
  67182. get taskState(): AssetTaskState;
  67183. /**
  67184. * Gets the current error object (if task is in error)
  67185. */
  67186. get errorObject(): {
  67187. message?: string;
  67188. exception?: any;
  67189. };
  67190. /**
  67191. * Internal only
  67192. * @hidden
  67193. */
  67194. _setErrorObject(message?: string, exception?: any): void;
  67195. /**
  67196. * Execute the current task
  67197. * @param scene defines the scene where you want your assets to be loaded
  67198. * @param onSuccess is a callback called when the task is successfully executed
  67199. * @param onError is a callback called if an error occurs
  67200. */
  67201. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67202. /**
  67203. * Execute the current task
  67204. * @param scene defines the scene where you want your assets to be loaded
  67205. * @param onSuccess is a callback called when the task is successfully executed
  67206. * @param onError is a callback called if an error occurs
  67207. */
  67208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67209. /**
  67210. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67211. * This can be used with failed tasks that have the reason for failure fixed.
  67212. */
  67213. reset(): void;
  67214. private onErrorCallback;
  67215. private onDoneCallback;
  67216. }
  67217. /**
  67218. * Define the interface used by progress events raised during assets loading
  67219. */
  67220. export interface IAssetsProgressEvent {
  67221. /**
  67222. * Defines the number of remaining tasks to process
  67223. */
  67224. remainingCount: number;
  67225. /**
  67226. * Defines the total number of tasks
  67227. */
  67228. totalCount: number;
  67229. /**
  67230. * Defines the task that was just processed
  67231. */
  67232. task: AbstractAssetTask;
  67233. }
  67234. /**
  67235. * Class used to share progress information about assets loading
  67236. */
  67237. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67238. /**
  67239. * Defines the number of remaining tasks to process
  67240. */
  67241. remainingCount: number;
  67242. /**
  67243. * Defines the total number of tasks
  67244. */
  67245. totalCount: number;
  67246. /**
  67247. * Defines the task that was just processed
  67248. */
  67249. task: AbstractAssetTask;
  67250. /**
  67251. * Creates a AssetsProgressEvent
  67252. * @param remainingCount defines the number of remaining tasks to process
  67253. * @param totalCount defines the total number of tasks
  67254. * @param task defines the task that was just processed
  67255. */
  67256. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67257. }
  67258. /**
  67259. * Define a task used by AssetsManager to load meshes
  67260. */
  67261. export class MeshAssetTask extends AbstractAssetTask {
  67262. /**
  67263. * Defines the name of the task
  67264. */
  67265. name: string;
  67266. /**
  67267. * Defines the list of mesh's names you want to load
  67268. */
  67269. meshesNames: any;
  67270. /**
  67271. * Defines the root url to use as a base to load your meshes and associated resources
  67272. */
  67273. rootUrl: string;
  67274. /**
  67275. * Defines the filename of the scene to load from
  67276. */
  67277. sceneFilename: string;
  67278. /**
  67279. * Gets the list of loaded meshes
  67280. */
  67281. loadedMeshes: Array<AbstractMesh>;
  67282. /**
  67283. * Gets the list of loaded particle systems
  67284. */
  67285. loadedParticleSystems: Array<IParticleSystem>;
  67286. /**
  67287. * Gets the list of loaded skeletons
  67288. */
  67289. loadedSkeletons: Array<Skeleton>;
  67290. /**
  67291. * Gets the list of loaded animation groups
  67292. */
  67293. loadedAnimationGroups: Array<AnimationGroup>;
  67294. /**
  67295. * Callback called when the task is successful
  67296. */
  67297. onSuccess: (task: MeshAssetTask) => void;
  67298. /**
  67299. * Callback called when the task is successful
  67300. */
  67301. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67302. /**
  67303. * Creates a new MeshAssetTask
  67304. * @param name defines the name of the task
  67305. * @param meshesNames defines the list of mesh's names you want to load
  67306. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67307. * @param sceneFilename defines the filename of the scene to load from
  67308. */
  67309. constructor(
  67310. /**
  67311. * Defines the name of the task
  67312. */
  67313. name: string,
  67314. /**
  67315. * Defines the list of mesh's names you want to load
  67316. */
  67317. meshesNames: any,
  67318. /**
  67319. * Defines the root url to use as a base to load your meshes and associated resources
  67320. */
  67321. rootUrl: string,
  67322. /**
  67323. * Defines the filename of the scene to load from
  67324. */
  67325. sceneFilename: string);
  67326. /**
  67327. * Execute the current task
  67328. * @param scene defines the scene where you want your assets to be loaded
  67329. * @param onSuccess is a callback called when the task is successfully executed
  67330. * @param onError is a callback called if an error occurs
  67331. */
  67332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67333. }
  67334. /**
  67335. * Define a task used by AssetsManager to load text content
  67336. */
  67337. export class TextFileAssetTask extends AbstractAssetTask {
  67338. /**
  67339. * Defines the name of the task
  67340. */
  67341. name: string;
  67342. /**
  67343. * Defines the location of the file to load
  67344. */
  67345. url: string;
  67346. /**
  67347. * Gets the loaded text string
  67348. */
  67349. text: string;
  67350. /**
  67351. * Callback called when the task is successful
  67352. */
  67353. onSuccess: (task: TextFileAssetTask) => void;
  67354. /**
  67355. * Callback called when the task is successful
  67356. */
  67357. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67358. /**
  67359. * Creates a new TextFileAssetTask object
  67360. * @param name defines the name of the task
  67361. * @param url defines the location of the file to load
  67362. */
  67363. constructor(
  67364. /**
  67365. * Defines the name of the task
  67366. */
  67367. name: string,
  67368. /**
  67369. * Defines the location of the file to load
  67370. */
  67371. url: string);
  67372. /**
  67373. * Execute the current task
  67374. * @param scene defines the scene where you want your assets to be loaded
  67375. * @param onSuccess is a callback called when the task is successfully executed
  67376. * @param onError is a callback called if an error occurs
  67377. */
  67378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67379. }
  67380. /**
  67381. * Define a task used by AssetsManager to load binary data
  67382. */
  67383. export class BinaryFileAssetTask extends AbstractAssetTask {
  67384. /**
  67385. * Defines the name of the task
  67386. */
  67387. name: string;
  67388. /**
  67389. * Defines the location of the file to load
  67390. */
  67391. url: string;
  67392. /**
  67393. * Gets the lodaded data (as an array buffer)
  67394. */
  67395. data: ArrayBuffer;
  67396. /**
  67397. * Callback called when the task is successful
  67398. */
  67399. onSuccess: (task: BinaryFileAssetTask) => void;
  67400. /**
  67401. * Callback called when the task is successful
  67402. */
  67403. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67404. /**
  67405. * Creates a new BinaryFileAssetTask object
  67406. * @param name defines the name of the new task
  67407. * @param url defines the location of the file to load
  67408. */
  67409. constructor(
  67410. /**
  67411. * Defines the name of the task
  67412. */
  67413. name: string,
  67414. /**
  67415. * Defines the location of the file to load
  67416. */
  67417. url: string);
  67418. /**
  67419. * Execute the current task
  67420. * @param scene defines the scene where you want your assets to be loaded
  67421. * @param onSuccess is a callback called when the task is successfully executed
  67422. * @param onError is a callback called if an error occurs
  67423. */
  67424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67425. }
  67426. /**
  67427. * Define a task used by AssetsManager to load images
  67428. */
  67429. export class ImageAssetTask extends AbstractAssetTask {
  67430. /**
  67431. * Defines the name of the task
  67432. */
  67433. name: string;
  67434. /**
  67435. * Defines the location of the image to load
  67436. */
  67437. url: string;
  67438. /**
  67439. * Gets the loaded images
  67440. */
  67441. image: HTMLImageElement;
  67442. /**
  67443. * Callback called when the task is successful
  67444. */
  67445. onSuccess: (task: ImageAssetTask) => void;
  67446. /**
  67447. * Callback called when the task is successful
  67448. */
  67449. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67450. /**
  67451. * Creates a new ImageAssetTask
  67452. * @param name defines the name of the task
  67453. * @param url defines the location of the image to load
  67454. */
  67455. constructor(
  67456. /**
  67457. * Defines the name of the task
  67458. */
  67459. name: string,
  67460. /**
  67461. * Defines the location of the image to load
  67462. */
  67463. url: string);
  67464. /**
  67465. * Execute the current task
  67466. * @param scene defines the scene where you want your assets to be loaded
  67467. * @param onSuccess is a callback called when the task is successfully executed
  67468. * @param onError is a callback called if an error occurs
  67469. */
  67470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67471. }
  67472. /**
  67473. * Defines the interface used by texture loading tasks
  67474. */
  67475. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67476. /**
  67477. * Gets the loaded texture
  67478. */
  67479. texture: TEX;
  67480. }
  67481. /**
  67482. * Define a task used by AssetsManager to load 2D textures
  67483. */
  67484. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67485. /**
  67486. * Defines the name of the task
  67487. */
  67488. name: string;
  67489. /**
  67490. * Defines the location of the file to load
  67491. */
  67492. url: string;
  67493. /**
  67494. * Defines if mipmap should not be generated (default is false)
  67495. */
  67496. noMipmap?: boolean | undefined;
  67497. /**
  67498. * Defines if texture must be inverted on Y axis (default is false)
  67499. */
  67500. invertY?: boolean | undefined;
  67501. /**
  67502. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67503. */
  67504. samplingMode: number;
  67505. /**
  67506. * Gets the loaded texture
  67507. */
  67508. texture: Texture;
  67509. /**
  67510. * Callback called when the task is successful
  67511. */
  67512. onSuccess: (task: TextureAssetTask) => void;
  67513. /**
  67514. * Callback called when the task is successful
  67515. */
  67516. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67517. /**
  67518. * Creates a new TextureAssetTask object
  67519. * @param name defines the name of the task
  67520. * @param url defines the location of the file to load
  67521. * @param noMipmap defines if mipmap should not be generated (default is false)
  67522. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67523. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67524. */
  67525. constructor(
  67526. /**
  67527. * Defines the name of the task
  67528. */
  67529. name: string,
  67530. /**
  67531. * Defines the location of the file to load
  67532. */
  67533. url: string,
  67534. /**
  67535. * Defines if mipmap should not be generated (default is false)
  67536. */
  67537. noMipmap?: boolean | undefined,
  67538. /**
  67539. * Defines if texture must be inverted on Y axis (default is false)
  67540. */
  67541. invertY?: boolean | undefined,
  67542. /**
  67543. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67544. */
  67545. samplingMode?: number);
  67546. /**
  67547. * Execute the current task
  67548. * @param scene defines the scene where you want your assets to be loaded
  67549. * @param onSuccess is a callback called when the task is successfully executed
  67550. * @param onError is a callback called if an error occurs
  67551. */
  67552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67553. }
  67554. /**
  67555. * Define a task used by AssetsManager to load cube textures
  67556. */
  67557. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67558. /**
  67559. * Defines the name of the task
  67560. */
  67561. name: string;
  67562. /**
  67563. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67564. */
  67565. url: string;
  67566. /**
  67567. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67568. */
  67569. extensions?: string[] | undefined;
  67570. /**
  67571. * Defines if mipmaps should not be generated (default is false)
  67572. */
  67573. noMipmap?: boolean | undefined;
  67574. /**
  67575. * Defines the explicit list of files (undefined by default)
  67576. */
  67577. files?: string[] | undefined;
  67578. /**
  67579. * Gets the loaded texture
  67580. */
  67581. texture: CubeTexture;
  67582. /**
  67583. * Callback called when the task is successful
  67584. */
  67585. onSuccess: (task: CubeTextureAssetTask) => void;
  67586. /**
  67587. * Callback called when the task is successful
  67588. */
  67589. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67590. /**
  67591. * Creates a new CubeTextureAssetTask
  67592. * @param name defines the name of the task
  67593. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67594. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67595. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67596. * @param files defines the explicit list of files (undefined by default)
  67597. */
  67598. constructor(
  67599. /**
  67600. * Defines the name of the task
  67601. */
  67602. name: string,
  67603. /**
  67604. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67605. */
  67606. url: string,
  67607. /**
  67608. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67609. */
  67610. extensions?: string[] | undefined,
  67611. /**
  67612. * Defines if mipmaps should not be generated (default is false)
  67613. */
  67614. noMipmap?: boolean | undefined,
  67615. /**
  67616. * Defines the explicit list of files (undefined by default)
  67617. */
  67618. files?: string[] | undefined);
  67619. /**
  67620. * Execute the current task
  67621. * @param scene defines the scene where you want your assets to be loaded
  67622. * @param onSuccess is a callback called when the task is successfully executed
  67623. * @param onError is a callback called if an error occurs
  67624. */
  67625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67626. }
  67627. /**
  67628. * Define a task used by AssetsManager to load HDR cube textures
  67629. */
  67630. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67631. /**
  67632. * Defines the name of the task
  67633. */
  67634. name: string;
  67635. /**
  67636. * Defines the location of the file to load
  67637. */
  67638. url: string;
  67639. /**
  67640. * Defines the desired size (the more it increases the longer the generation will be)
  67641. */
  67642. size: number;
  67643. /**
  67644. * Defines if mipmaps should not be generated (default is false)
  67645. */
  67646. noMipmap: boolean;
  67647. /**
  67648. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67649. */
  67650. generateHarmonics: boolean;
  67651. /**
  67652. * 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)
  67653. */
  67654. gammaSpace: boolean;
  67655. /**
  67656. * Internal Use Only
  67657. */
  67658. reserved: boolean;
  67659. /**
  67660. * Gets the loaded texture
  67661. */
  67662. texture: HDRCubeTexture;
  67663. /**
  67664. * Callback called when the task is successful
  67665. */
  67666. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67667. /**
  67668. * Callback called when the task is successful
  67669. */
  67670. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67671. /**
  67672. * Creates a new HDRCubeTextureAssetTask object
  67673. * @param name defines the name of the task
  67674. * @param url defines the location of the file to load
  67675. * @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.
  67676. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67677. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67678. * @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)
  67679. * @param reserved Internal use only
  67680. */
  67681. constructor(
  67682. /**
  67683. * Defines the name of the task
  67684. */
  67685. name: string,
  67686. /**
  67687. * Defines the location of the file to load
  67688. */
  67689. url: string,
  67690. /**
  67691. * Defines the desired size (the more it increases the longer the generation will be)
  67692. */
  67693. size: number,
  67694. /**
  67695. * Defines if mipmaps should not be generated (default is false)
  67696. */
  67697. noMipmap?: boolean,
  67698. /**
  67699. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67700. */
  67701. generateHarmonics?: boolean,
  67702. /**
  67703. * 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)
  67704. */
  67705. gammaSpace?: boolean,
  67706. /**
  67707. * Internal Use Only
  67708. */
  67709. reserved?: boolean);
  67710. /**
  67711. * Execute the current task
  67712. * @param scene defines the scene where you want your assets to be loaded
  67713. * @param onSuccess is a callback called when the task is successfully executed
  67714. * @param onError is a callback called if an error occurs
  67715. */
  67716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67717. }
  67718. /**
  67719. * Define a task used by AssetsManager to load Equirectangular cube textures
  67720. */
  67721. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67722. /**
  67723. * Defines the name of the task
  67724. */
  67725. name: string;
  67726. /**
  67727. * Defines the location of the file to load
  67728. */
  67729. url: string;
  67730. /**
  67731. * Defines the desired size (the more it increases the longer the generation will be)
  67732. */
  67733. size: number;
  67734. /**
  67735. * Defines if mipmaps should not be generated (default is false)
  67736. */
  67737. noMipmap: boolean;
  67738. /**
  67739. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67740. * but the standard material would require them in Gamma space) (default is true)
  67741. */
  67742. gammaSpace: boolean;
  67743. /**
  67744. * Gets the loaded texture
  67745. */
  67746. texture: EquiRectangularCubeTexture;
  67747. /**
  67748. * Callback called when the task is successful
  67749. */
  67750. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67751. /**
  67752. * Callback called when the task is successful
  67753. */
  67754. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67755. /**
  67756. * Creates a new EquiRectangularCubeTextureAssetTask object
  67757. * @param name defines the name of the task
  67758. * @param url defines the location of the file to load
  67759. * @param size defines the desired size (the more it increases the longer the generation will be)
  67760. * If the size is omitted this implies you are using a preprocessed cubemap.
  67761. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67762. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67763. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67764. * (default is true)
  67765. */
  67766. constructor(
  67767. /**
  67768. * Defines the name of the task
  67769. */
  67770. name: string,
  67771. /**
  67772. * Defines the location of the file to load
  67773. */
  67774. url: string,
  67775. /**
  67776. * Defines the desired size (the more it increases the longer the generation will be)
  67777. */
  67778. size: number,
  67779. /**
  67780. * Defines if mipmaps should not be generated (default is false)
  67781. */
  67782. noMipmap?: boolean,
  67783. /**
  67784. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67785. * but the standard material would require them in Gamma space) (default is true)
  67786. */
  67787. gammaSpace?: boolean);
  67788. /**
  67789. * Execute the current task
  67790. * @param scene defines the scene where you want your assets to be loaded
  67791. * @param onSuccess is a callback called when the task is successfully executed
  67792. * @param onError is a callback called if an error occurs
  67793. */
  67794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67795. }
  67796. /**
  67797. * This class can be used to easily import assets into a scene
  67798. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67799. */
  67800. export class AssetsManager {
  67801. private _scene;
  67802. private _isLoading;
  67803. protected _tasks: AbstractAssetTask[];
  67804. protected _waitingTasksCount: number;
  67805. protected _totalTasksCount: number;
  67806. /**
  67807. * Callback called when all tasks are processed
  67808. */
  67809. onFinish: (tasks: AbstractAssetTask[]) => void;
  67810. /**
  67811. * Callback called when a task is successful
  67812. */
  67813. onTaskSuccess: (task: AbstractAssetTask) => void;
  67814. /**
  67815. * Callback called when a task had an error
  67816. */
  67817. onTaskError: (task: AbstractAssetTask) => void;
  67818. /**
  67819. * Callback called when a task is done (whatever the result is)
  67820. */
  67821. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67822. /**
  67823. * Observable called when all tasks are processed
  67824. */
  67825. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67826. /**
  67827. * Observable called when a task had an error
  67828. */
  67829. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67830. /**
  67831. * Observable called when all tasks were executed
  67832. */
  67833. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67834. /**
  67835. * Observable called when a task is done (whatever the result is)
  67836. */
  67837. onProgressObservable: Observable<IAssetsProgressEvent>;
  67838. /**
  67839. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67841. */
  67842. useDefaultLoadingScreen: boolean;
  67843. /**
  67844. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67845. * when all assets have been downloaded.
  67846. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67847. */
  67848. autoHideLoadingUI: boolean;
  67849. /**
  67850. * Creates a new AssetsManager
  67851. * @param scene defines the scene to work on
  67852. */
  67853. constructor(scene: Scene);
  67854. /**
  67855. * Add a MeshAssetTask to the list of active tasks
  67856. * @param taskName defines the name of the new task
  67857. * @param meshesNames defines the name of meshes to load
  67858. * @param rootUrl defines the root url to use to locate files
  67859. * @param sceneFilename defines the filename of the scene file
  67860. * @returns a new MeshAssetTask object
  67861. */
  67862. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67863. /**
  67864. * Add a TextFileAssetTask to the list of active tasks
  67865. * @param taskName defines the name of the new task
  67866. * @param url defines the url of the file to load
  67867. * @returns a new TextFileAssetTask object
  67868. */
  67869. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67870. /**
  67871. * Add a BinaryFileAssetTask to the list of active tasks
  67872. * @param taskName defines the name of the new task
  67873. * @param url defines the url of the file to load
  67874. * @returns a new BinaryFileAssetTask object
  67875. */
  67876. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67877. /**
  67878. * Add a ImageAssetTask to the list of active tasks
  67879. * @param taskName defines the name of the new task
  67880. * @param url defines the url of the file to load
  67881. * @returns a new ImageAssetTask object
  67882. */
  67883. addImageTask(taskName: string, url: string): ImageAssetTask;
  67884. /**
  67885. * Add a TextureAssetTask to the list of active tasks
  67886. * @param taskName defines the name of the new task
  67887. * @param url defines the url of the file to load
  67888. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67889. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67890. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67891. * @returns a new TextureAssetTask object
  67892. */
  67893. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67894. /**
  67895. * Add a CubeTextureAssetTask to the list of active tasks
  67896. * @param taskName defines the name of the new task
  67897. * @param url defines the url of the file to load
  67898. * @param extensions defines the extension to use to load the cube map (can be null)
  67899. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67900. * @param files defines the list of files to load (can be null)
  67901. * @returns a new CubeTextureAssetTask object
  67902. */
  67903. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67904. /**
  67905. *
  67906. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67907. * @param taskName defines the name of the new task
  67908. * @param url defines the url of the file to load
  67909. * @param size defines the size you want for the cubemap (can be null)
  67910. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67911. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67912. * @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)
  67913. * @param reserved Internal use only
  67914. * @returns a new HDRCubeTextureAssetTask object
  67915. */
  67916. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67917. /**
  67918. *
  67919. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67920. * @param taskName defines the name of the new task
  67921. * @param url defines the url of the file to load
  67922. * @param size defines the size you want for the cubemap (can be null)
  67923. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67924. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67925. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67926. * @returns a new EquiRectangularCubeTextureAssetTask object
  67927. */
  67928. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67929. /**
  67930. * Remove a task from the assets manager.
  67931. * @param task the task to remove
  67932. */
  67933. removeTask(task: AbstractAssetTask): void;
  67934. private _decreaseWaitingTasksCount;
  67935. private _runTask;
  67936. /**
  67937. * Reset the AssetsManager and remove all tasks
  67938. * @return the current instance of the AssetsManager
  67939. */
  67940. reset(): AssetsManager;
  67941. /**
  67942. * Start the loading process
  67943. * @return the current instance of the AssetsManager
  67944. */
  67945. load(): AssetsManager;
  67946. /**
  67947. * Start the loading process as an async operation
  67948. * @return a promise returning the list of failed tasks
  67949. */
  67950. loadAsync(): Promise<void>;
  67951. }
  67952. }
  67953. declare module BABYLON {
  67954. /**
  67955. * Wrapper class for promise with external resolve and reject.
  67956. */
  67957. export class Deferred<T> {
  67958. /**
  67959. * The promise associated with this deferred object.
  67960. */
  67961. readonly promise: Promise<T>;
  67962. private _resolve;
  67963. private _reject;
  67964. /**
  67965. * The resolve method of the promise associated with this deferred object.
  67966. */
  67967. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67968. /**
  67969. * The reject method of the promise associated with this deferred object.
  67970. */
  67971. get reject(): (reason?: any) => void;
  67972. /**
  67973. * Constructor for this deferred object.
  67974. */
  67975. constructor();
  67976. }
  67977. }
  67978. declare module BABYLON {
  67979. /**
  67980. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67981. */
  67982. export class MeshExploder {
  67983. private _centerMesh;
  67984. private _meshes;
  67985. private _meshesOrigins;
  67986. private _toCenterVectors;
  67987. private _scaledDirection;
  67988. private _newPosition;
  67989. private _centerPosition;
  67990. /**
  67991. * Explodes meshes from a center mesh.
  67992. * @param meshes The meshes to explode.
  67993. * @param centerMesh The mesh to be center of explosion.
  67994. */
  67995. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67996. private _setCenterMesh;
  67997. /**
  67998. * Get class name
  67999. * @returns "MeshExploder"
  68000. */
  68001. getClassName(): string;
  68002. /**
  68003. * "Exploded meshes"
  68004. * @returns Array of meshes with the centerMesh at index 0.
  68005. */
  68006. getMeshes(): Array<Mesh>;
  68007. /**
  68008. * Explodes meshes giving a specific direction
  68009. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68010. */
  68011. explode(direction?: number): void;
  68012. }
  68013. }
  68014. declare module BABYLON {
  68015. /**
  68016. * Class used to help managing file picking and drag'n'drop
  68017. */
  68018. export class FilesInput {
  68019. /**
  68020. * List of files ready to be loaded
  68021. */
  68022. static get FilesToLoad(): {
  68023. [key: string]: File;
  68024. };
  68025. /**
  68026. * Callback called when a file is processed
  68027. */
  68028. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68029. private _engine;
  68030. private _currentScene;
  68031. private _sceneLoadedCallback;
  68032. private _progressCallback;
  68033. private _additionalRenderLoopLogicCallback;
  68034. private _textureLoadingCallback;
  68035. private _startingProcessingFilesCallback;
  68036. private _onReloadCallback;
  68037. private _errorCallback;
  68038. private _elementToMonitor;
  68039. private _sceneFileToLoad;
  68040. private _filesToLoad;
  68041. /**
  68042. * Creates a new FilesInput
  68043. * @param engine defines the rendering engine
  68044. * @param scene defines the hosting scene
  68045. * @param sceneLoadedCallback callback called when scene is loaded
  68046. * @param progressCallback callback called to track progress
  68047. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68048. * @param textureLoadingCallback callback called when a texture is loading
  68049. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68050. * @param onReloadCallback callback called when a reload is requested
  68051. * @param errorCallback callback call if an error occurs
  68052. */
  68053. 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);
  68054. private _dragEnterHandler;
  68055. private _dragOverHandler;
  68056. private _dropHandler;
  68057. /**
  68058. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68059. * @param elementToMonitor defines the DOM element to track
  68060. */
  68061. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68062. /**
  68063. * Release all associated resources
  68064. */
  68065. dispose(): void;
  68066. private renderFunction;
  68067. private drag;
  68068. private drop;
  68069. private _traverseFolder;
  68070. private _processFiles;
  68071. /**
  68072. * Load files from a drop event
  68073. * @param event defines the drop event to use as source
  68074. */
  68075. loadFiles(event: any): void;
  68076. private _processReload;
  68077. /**
  68078. * Reload the current scene from the loaded files
  68079. */
  68080. reload(): void;
  68081. }
  68082. }
  68083. declare module BABYLON {
  68084. /**
  68085. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68087. */
  68088. export class SceneOptimization {
  68089. /**
  68090. * Defines the priority of this optimization (0 by default which means first in the list)
  68091. */
  68092. priority: number;
  68093. /**
  68094. * Gets a string describing the action executed by the current optimization
  68095. * @returns description string
  68096. */
  68097. getDescription(): string;
  68098. /**
  68099. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68100. * @param scene defines the current scene where to apply this optimization
  68101. * @param optimizer defines the current optimizer
  68102. * @returns true if everything that can be done was applied
  68103. */
  68104. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68105. /**
  68106. * Creates the SceneOptimization object
  68107. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68108. * @param desc defines the description associated with the optimization
  68109. */
  68110. constructor(
  68111. /**
  68112. * Defines the priority of this optimization (0 by default which means first in the list)
  68113. */
  68114. priority?: number);
  68115. }
  68116. /**
  68117. * Defines an optimization used to reduce the size of render target textures
  68118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68119. */
  68120. export class TextureOptimization extends SceneOptimization {
  68121. /**
  68122. * Defines the priority of this optimization (0 by default which means first in the list)
  68123. */
  68124. priority: number;
  68125. /**
  68126. * 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
  68127. */
  68128. maximumSize: number;
  68129. /**
  68130. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68131. */
  68132. step: number;
  68133. /**
  68134. * Gets a string describing the action executed by the current optimization
  68135. * @returns description string
  68136. */
  68137. getDescription(): string;
  68138. /**
  68139. * Creates the TextureOptimization object
  68140. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68141. * @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
  68142. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68143. */
  68144. constructor(
  68145. /**
  68146. * Defines the priority of this optimization (0 by default which means first in the list)
  68147. */
  68148. priority?: number,
  68149. /**
  68150. * 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
  68151. */
  68152. maximumSize?: number,
  68153. /**
  68154. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68155. */
  68156. step?: number);
  68157. /**
  68158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68159. * @param scene defines the current scene where to apply this optimization
  68160. * @param optimizer defines the current optimizer
  68161. * @returns true if everything that can be done was applied
  68162. */
  68163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68164. }
  68165. /**
  68166. * Defines an optimization used to increase or decrease the rendering resolution
  68167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68168. */
  68169. export class HardwareScalingOptimization extends SceneOptimization {
  68170. /**
  68171. * Defines the priority of this optimization (0 by default which means first in the list)
  68172. */
  68173. priority: number;
  68174. /**
  68175. * Defines the maximum scale to use (2 by default)
  68176. */
  68177. maximumScale: number;
  68178. /**
  68179. * Defines the step to use between two passes (0.5 by default)
  68180. */
  68181. step: number;
  68182. private _currentScale;
  68183. private _directionOffset;
  68184. /**
  68185. * Gets a string describing the action executed by the current optimization
  68186. * @return description string
  68187. */
  68188. getDescription(): string;
  68189. /**
  68190. * Creates the HardwareScalingOptimization object
  68191. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68192. * @param maximumScale defines the maximum scale to use (2 by default)
  68193. * @param step defines the step to use between two passes (0.5 by default)
  68194. */
  68195. constructor(
  68196. /**
  68197. * Defines the priority of this optimization (0 by default which means first in the list)
  68198. */
  68199. priority?: number,
  68200. /**
  68201. * Defines the maximum scale to use (2 by default)
  68202. */
  68203. maximumScale?: number,
  68204. /**
  68205. * Defines the step to use between two passes (0.5 by default)
  68206. */
  68207. step?: number);
  68208. /**
  68209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68210. * @param scene defines the current scene where to apply this optimization
  68211. * @param optimizer defines the current optimizer
  68212. * @returns true if everything that can be done was applied
  68213. */
  68214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68215. }
  68216. /**
  68217. * Defines an optimization used to remove shadows
  68218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68219. */
  68220. export class ShadowsOptimization extends SceneOptimization {
  68221. /**
  68222. * Gets a string describing the action executed by the current optimization
  68223. * @return description string
  68224. */
  68225. getDescription(): string;
  68226. /**
  68227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68228. * @param scene defines the current scene where to apply this optimization
  68229. * @param optimizer defines the current optimizer
  68230. * @returns true if everything that can be done was applied
  68231. */
  68232. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68233. }
  68234. /**
  68235. * Defines an optimization used to turn post-processes off
  68236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68237. */
  68238. export class PostProcessesOptimization extends SceneOptimization {
  68239. /**
  68240. * Gets a string describing the action executed by the current optimization
  68241. * @return description string
  68242. */
  68243. getDescription(): string;
  68244. /**
  68245. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68246. * @param scene defines the current scene where to apply this optimization
  68247. * @param optimizer defines the current optimizer
  68248. * @returns true if everything that can be done was applied
  68249. */
  68250. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68251. }
  68252. /**
  68253. * Defines an optimization used to turn lens flares off
  68254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68255. */
  68256. export class LensFlaresOptimization extends SceneOptimization {
  68257. /**
  68258. * Gets a string describing the action executed by the current optimization
  68259. * @return description string
  68260. */
  68261. getDescription(): string;
  68262. /**
  68263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68264. * @param scene defines the current scene where to apply this optimization
  68265. * @param optimizer defines the current optimizer
  68266. * @returns true if everything that can be done was applied
  68267. */
  68268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68269. }
  68270. /**
  68271. * Defines an optimization based on user defined callback.
  68272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68273. */
  68274. export class CustomOptimization extends SceneOptimization {
  68275. /**
  68276. * Callback called to apply the custom optimization.
  68277. */
  68278. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68279. /**
  68280. * Callback called to get custom description
  68281. */
  68282. onGetDescription: () => string;
  68283. /**
  68284. * Gets a string describing the action executed by the current optimization
  68285. * @returns description string
  68286. */
  68287. getDescription(): string;
  68288. /**
  68289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68290. * @param scene defines the current scene where to apply this optimization
  68291. * @param optimizer defines the current optimizer
  68292. * @returns true if everything that can be done was applied
  68293. */
  68294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68295. }
  68296. /**
  68297. * Defines an optimization used to turn particles off
  68298. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68299. */
  68300. export class ParticlesOptimization extends SceneOptimization {
  68301. /**
  68302. * Gets a string describing the action executed by the current optimization
  68303. * @return description string
  68304. */
  68305. getDescription(): string;
  68306. /**
  68307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68308. * @param scene defines the current scene where to apply this optimization
  68309. * @param optimizer defines the current optimizer
  68310. * @returns true if everything that can be done was applied
  68311. */
  68312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68313. }
  68314. /**
  68315. * Defines an optimization used to turn render targets off
  68316. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68317. */
  68318. export class RenderTargetsOptimization extends SceneOptimization {
  68319. /**
  68320. * Gets a string describing the action executed by the current optimization
  68321. * @return description string
  68322. */
  68323. getDescription(): string;
  68324. /**
  68325. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68326. * @param scene defines the current scene where to apply this optimization
  68327. * @param optimizer defines the current optimizer
  68328. * @returns true if everything that can be done was applied
  68329. */
  68330. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68331. }
  68332. /**
  68333. * Defines an optimization used to merge meshes with compatible materials
  68334. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68335. */
  68336. export class MergeMeshesOptimization extends SceneOptimization {
  68337. private static _UpdateSelectionTree;
  68338. /**
  68339. * Gets or sets a boolean which defines if optimization octree has to be updated
  68340. */
  68341. static get UpdateSelectionTree(): boolean;
  68342. /**
  68343. * Gets or sets a boolean which defines if optimization octree has to be updated
  68344. */
  68345. static set UpdateSelectionTree(value: boolean);
  68346. /**
  68347. * Gets a string describing the action executed by the current optimization
  68348. * @return description string
  68349. */
  68350. getDescription(): string;
  68351. private _canBeMerged;
  68352. /**
  68353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68354. * @param scene defines the current scene where to apply this optimization
  68355. * @param optimizer defines the current optimizer
  68356. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68357. * @returns true if everything that can be done was applied
  68358. */
  68359. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68360. }
  68361. /**
  68362. * Defines a list of options used by SceneOptimizer
  68363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68364. */
  68365. export class SceneOptimizerOptions {
  68366. /**
  68367. * Defines the target frame rate to reach (60 by default)
  68368. */
  68369. targetFrameRate: number;
  68370. /**
  68371. * Defines the interval between two checkes (2000ms by default)
  68372. */
  68373. trackerDuration: number;
  68374. /**
  68375. * Gets the list of optimizations to apply
  68376. */
  68377. optimizations: SceneOptimization[];
  68378. /**
  68379. * Creates a new list of options used by SceneOptimizer
  68380. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68381. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68382. */
  68383. constructor(
  68384. /**
  68385. * Defines the target frame rate to reach (60 by default)
  68386. */
  68387. targetFrameRate?: number,
  68388. /**
  68389. * Defines the interval between two checkes (2000ms by default)
  68390. */
  68391. trackerDuration?: number);
  68392. /**
  68393. * Add a new optimization
  68394. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68395. * @returns the current SceneOptimizerOptions
  68396. */
  68397. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68398. /**
  68399. * Add a new custom optimization
  68400. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68401. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68403. * @returns the current SceneOptimizerOptions
  68404. */
  68405. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68406. /**
  68407. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68408. * @param targetFrameRate defines the target frame rate (60 by default)
  68409. * @returns a SceneOptimizerOptions object
  68410. */
  68411. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68412. /**
  68413. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68414. * @param targetFrameRate defines the target frame rate (60 by default)
  68415. * @returns a SceneOptimizerOptions object
  68416. */
  68417. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68418. /**
  68419. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68420. * @param targetFrameRate defines the target frame rate (60 by default)
  68421. * @returns a SceneOptimizerOptions object
  68422. */
  68423. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68424. }
  68425. /**
  68426. * Class used to run optimizations in order to reach a target frame rate
  68427. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68428. */
  68429. export class SceneOptimizer implements IDisposable {
  68430. private _isRunning;
  68431. private _options;
  68432. private _scene;
  68433. private _currentPriorityLevel;
  68434. private _targetFrameRate;
  68435. private _trackerDuration;
  68436. private _currentFrameRate;
  68437. private _sceneDisposeObserver;
  68438. private _improvementMode;
  68439. /**
  68440. * Defines an observable called when the optimizer reaches the target frame rate
  68441. */
  68442. onSuccessObservable: Observable<SceneOptimizer>;
  68443. /**
  68444. * Defines an observable called when the optimizer enables an optimization
  68445. */
  68446. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68447. /**
  68448. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68449. */
  68450. onFailureObservable: Observable<SceneOptimizer>;
  68451. /**
  68452. * Gets a boolean indicating if the optimizer is in improvement mode
  68453. */
  68454. get isInImprovementMode(): boolean;
  68455. /**
  68456. * Gets the current priority level (0 at start)
  68457. */
  68458. get currentPriorityLevel(): number;
  68459. /**
  68460. * Gets the current frame rate checked by the SceneOptimizer
  68461. */
  68462. get currentFrameRate(): number;
  68463. /**
  68464. * Gets or sets the current target frame rate (60 by default)
  68465. */
  68466. get targetFrameRate(): number;
  68467. /**
  68468. * Gets or sets the current target frame rate (60 by default)
  68469. */
  68470. set targetFrameRate(value: number);
  68471. /**
  68472. * Gets or sets the current interval between two checks (every 2000ms by default)
  68473. */
  68474. get trackerDuration(): number;
  68475. /**
  68476. * Gets or sets the current interval between two checks (every 2000ms by default)
  68477. */
  68478. set trackerDuration(value: number);
  68479. /**
  68480. * Gets the list of active optimizations
  68481. */
  68482. get optimizations(): SceneOptimization[];
  68483. /**
  68484. * Creates a new SceneOptimizer
  68485. * @param scene defines the scene to work on
  68486. * @param options defines the options to use with the SceneOptimizer
  68487. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68488. * @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)
  68489. */
  68490. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68491. /**
  68492. * Stops the current optimizer
  68493. */
  68494. stop(): void;
  68495. /**
  68496. * Reset the optimizer to initial step (current priority level = 0)
  68497. */
  68498. reset(): void;
  68499. /**
  68500. * Start the optimizer. By default it will try to reach a specific framerate
  68501. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68502. */
  68503. start(): void;
  68504. private _checkCurrentState;
  68505. /**
  68506. * Release all resources
  68507. */
  68508. dispose(): void;
  68509. /**
  68510. * Helper function to create a SceneOptimizer with one single line of code
  68511. * @param scene defines the scene to work on
  68512. * @param options defines the options to use with the SceneOptimizer
  68513. * @param onSuccess defines a callback to call on success
  68514. * @param onFailure defines a callback to call on failure
  68515. * @returns the new SceneOptimizer object
  68516. */
  68517. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68518. }
  68519. }
  68520. declare module BABYLON {
  68521. /**
  68522. * Class used to serialize a scene into a string
  68523. */
  68524. export class SceneSerializer {
  68525. /**
  68526. * Clear cache used by a previous serialization
  68527. */
  68528. static ClearCache(): void;
  68529. /**
  68530. * Serialize a scene into a JSON compatible object
  68531. * @param scene defines the scene to serialize
  68532. * @returns a JSON compatible object
  68533. */
  68534. static Serialize(scene: Scene): any;
  68535. /**
  68536. * Serialize a mesh into a JSON compatible object
  68537. * @param toSerialize defines the mesh to serialize
  68538. * @param withParents defines if parents must be serialized as well
  68539. * @param withChildren defines if children must be serialized as well
  68540. * @returns a JSON compatible object
  68541. */
  68542. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68543. }
  68544. }
  68545. declare module BABYLON {
  68546. /**
  68547. * Class used to host texture specific utilities
  68548. */
  68549. export class TextureTools {
  68550. /**
  68551. * Uses the GPU to create a copy texture rescaled at a given size
  68552. * @param texture Texture to copy from
  68553. * @param width defines the desired width
  68554. * @param height defines the desired height
  68555. * @param useBilinearMode defines if bilinear mode has to be used
  68556. * @return the generated texture
  68557. */
  68558. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * This represents the different options available for the video capture.
  68564. */
  68565. export interface VideoRecorderOptions {
  68566. /** Defines the mime type of the video. */
  68567. mimeType: string;
  68568. /** Defines the FPS the video should be recorded at. */
  68569. fps: number;
  68570. /** Defines the chunk size for the recording data. */
  68571. recordChunckSize: number;
  68572. /** The audio tracks to attach to the recording. */
  68573. audioTracks?: MediaStreamTrack[];
  68574. }
  68575. /**
  68576. * This can help with recording videos from BabylonJS.
  68577. * This is based on the available WebRTC functionalities of the browser.
  68578. *
  68579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68580. */
  68581. export class VideoRecorder {
  68582. private static readonly _defaultOptions;
  68583. /**
  68584. * Returns whether or not the VideoRecorder is available in your browser.
  68585. * @param engine Defines the Babylon Engine.
  68586. * @returns true if supported otherwise false.
  68587. */
  68588. static IsSupported(engine: Engine): boolean;
  68589. private readonly _options;
  68590. private _canvas;
  68591. private _mediaRecorder;
  68592. private _recordedChunks;
  68593. private _fileName;
  68594. private _resolve;
  68595. private _reject;
  68596. /**
  68597. * True when a recording is already in progress.
  68598. */
  68599. get isRecording(): boolean;
  68600. /**
  68601. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68602. * @param engine Defines the BabylonJS Engine you wish to record.
  68603. * @param options Defines options that can be used to customize the capture.
  68604. */
  68605. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68606. /**
  68607. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68608. */
  68609. stopRecording(): void;
  68610. /**
  68611. * Starts recording the canvas for a max duration specified in parameters.
  68612. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68613. * If null no automatic download will start and you can rely on the promise to get the data back.
  68614. * @param maxDuration Defines the maximum recording time in seconds.
  68615. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68616. * @return A promise callback at the end of the recording with the video data in Blob.
  68617. */
  68618. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68619. /**
  68620. * Releases internal resources used during the recording.
  68621. */
  68622. dispose(): void;
  68623. private _handleDataAvailable;
  68624. private _handleError;
  68625. private _handleStop;
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /**
  68630. * Class containing a set of static utilities functions for screenshots
  68631. */
  68632. export class ScreenshotTools {
  68633. /**
  68634. * Captures a screenshot of the current rendering
  68635. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68636. * @param engine defines the rendering engine
  68637. * @param camera defines the source camera
  68638. * @param size This parameter can be set to a single number or to an object with the
  68639. * following (optional) properties: precision, width, height. If a single number is passed,
  68640. * it will be used for both width and height. If an object is passed, the screenshot size
  68641. * will be derived from the parameters. The precision property is a multiplier allowing
  68642. * rendering at a higher or lower resolution
  68643. * @param successCallback defines the callback receives a single parameter which contains the
  68644. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68645. * src parameter of an <img> to display it
  68646. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68647. * Check your browser for supported MIME types
  68648. */
  68649. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68650. /**
  68651. * Captures a screenshot of the current rendering
  68652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68653. * @param engine defines the rendering engine
  68654. * @param camera defines the source camera
  68655. * @param size This parameter can be set to a single number or to an object with the
  68656. * following (optional) properties: precision, width, height. If a single number is passed,
  68657. * it will be used for both width and height. If an object is passed, the screenshot size
  68658. * will be derived from the parameters. The precision property is a multiplier allowing
  68659. * rendering at a higher or lower resolution
  68660. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68661. * Check your browser for supported MIME types
  68662. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68663. * to the src parameter of an <img> to display it
  68664. */
  68665. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68666. /**
  68667. * Generates an image screenshot from the specified camera.
  68668. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68669. * @param engine The engine to use for rendering
  68670. * @param camera The camera to use for rendering
  68671. * @param size This parameter can be set to a single number or to an object with the
  68672. * following (optional) properties: precision, width, height. If a single number is passed,
  68673. * it will be used for both width and height. If an object is passed, the screenshot size
  68674. * will be derived from the parameters. The precision property is a multiplier allowing
  68675. * rendering at a higher or lower resolution
  68676. * @param successCallback The callback receives a single parameter which contains the
  68677. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68678. * src parameter of an <img> to display it
  68679. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68680. * Check your browser for supported MIME types
  68681. * @param samples Texture samples (default: 1)
  68682. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68683. * @param fileName A name for for the downloaded file.
  68684. */
  68685. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68686. /**
  68687. * Generates an image screenshot from the specified camera.
  68688. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68689. * @param engine The engine to use for rendering
  68690. * @param camera The camera to use for rendering
  68691. * @param size This parameter can be set to a single number or to an object with the
  68692. * following (optional) properties: precision, width, height. If a single number is passed,
  68693. * it will be used for both width and height. If an object is passed, the screenshot size
  68694. * will be derived from the parameters. The precision property is a multiplier allowing
  68695. * rendering at a higher or lower resolution
  68696. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68697. * Check your browser for supported MIME types
  68698. * @param samples Texture samples (default: 1)
  68699. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68700. * @param fileName A name for for the downloaded file.
  68701. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68702. * to the src parameter of an <img> to display it
  68703. */
  68704. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68705. /**
  68706. * Gets height and width for screenshot size
  68707. * @private
  68708. */
  68709. private static _getScreenshotSize;
  68710. }
  68711. }
  68712. declare module BABYLON {
  68713. /**
  68714. * Interface for a data buffer
  68715. */
  68716. export interface IDataBuffer {
  68717. /**
  68718. * Reads bytes from the data buffer.
  68719. * @param byteOffset The byte offset to read
  68720. * @param byteLength The byte length to read
  68721. * @returns A promise that resolves when the bytes are read
  68722. */
  68723. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68724. /**
  68725. * The byte length of the buffer.
  68726. */
  68727. readonly byteLength: number;
  68728. }
  68729. /**
  68730. * Utility class for reading from a data buffer
  68731. */
  68732. export class DataReader {
  68733. /**
  68734. * The data buffer associated with this data reader.
  68735. */
  68736. readonly buffer: IDataBuffer;
  68737. /**
  68738. * The current byte offset from the beginning of the data buffer.
  68739. */
  68740. byteOffset: number;
  68741. private _dataView;
  68742. private _dataByteOffset;
  68743. /**
  68744. * Constructor
  68745. * @param buffer The buffer to read
  68746. */
  68747. constructor(buffer: IDataBuffer);
  68748. /**
  68749. * Loads the given byte length.
  68750. * @param byteLength The byte length to load
  68751. * @returns A promise that resolves when the load is complete
  68752. */
  68753. loadAsync(byteLength: number): Promise<void>;
  68754. /**
  68755. * Read a unsigned 32-bit integer from the currently loaded data range.
  68756. * @returns The 32-bit integer read
  68757. */
  68758. readUint32(): number;
  68759. /**
  68760. * Read a byte array from the currently loaded data range.
  68761. * @param byteLength The byte length to read
  68762. * @returns The byte array read
  68763. */
  68764. readUint8Array(byteLength: number): Uint8Array;
  68765. /**
  68766. * Read a string from the currently loaded data range.
  68767. * @param byteLength The byte length to read
  68768. * @returns The string read
  68769. */
  68770. readString(byteLength: number): string;
  68771. /**
  68772. * Skips the given byte length the currently loaded data range.
  68773. * @param byteLength The byte length to skip
  68774. */
  68775. skipBytes(byteLength: number): void;
  68776. }
  68777. }
  68778. declare module BABYLON {
  68779. /**
  68780. * A cursor which tracks a point on a path
  68781. */
  68782. export class PathCursor {
  68783. private path;
  68784. /**
  68785. * Stores path cursor callbacks for when an onchange event is triggered
  68786. */
  68787. private _onchange;
  68788. /**
  68789. * The value of the path cursor
  68790. */
  68791. value: number;
  68792. /**
  68793. * The animation array of the path cursor
  68794. */
  68795. animations: Animation[];
  68796. /**
  68797. * Initializes the path cursor
  68798. * @param path The path to track
  68799. */
  68800. constructor(path: Path2);
  68801. /**
  68802. * Gets the cursor point on the path
  68803. * @returns A point on the path cursor at the cursor location
  68804. */
  68805. getPoint(): Vector3;
  68806. /**
  68807. * Moves the cursor ahead by the step amount
  68808. * @param step The amount to move the cursor forward
  68809. * @returns This path cursor
  68810. */
  68811. moveAhead(step?: number): PathCursor;
  68812. /**
  68813. * Moves the cursor behind by the step amount
  68814. * @param step The amount to move the cursor back
  68815. * @returns This path cursor
  68816. */
  68817. moveBack(step?: number): PathCursor;
  68818. /**
  68819. * Moves the cursor by the step amount
  68820. * If the step amount is greater than one, an exception is thrown
  68821. * @param step The amount to move the cursor
  68822. * @returns This path cursor
  68823. */
  68824. move(step: number): PathCursor;
  68825. /**
  68826. * Ensures that the value is limited between zero and one
  68827. * @returns This path cursor
  68828. */
  68829. private ensureLimits;
  68830. /**
  68831. * Runs onchange callbacks on change (used by the animation engine)
  68832. * @returns This path cursor
  68833. */
  68834. private raiseOnChange;
  68835. /**
  68836. * Executes a function on change
  68837. * @param f A path cursor onchange callback
  68838. * @returns This path cursor
  68839. */
  68840. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68841. }
  68842. }
  68843. declare module BABYLON {
  68844. /** @hidden */
  68845. export var blurPixelShader: {
  68846. name: string;
  68847. shader: string;
  68848. };
  68849. }
  68850. declare module BABYLON {
  68851. /** @hidden */
  68852. export var pointCloudVertexDeclaration: {
  68853. name: string;
  68854. shader: string;
  68855. };
  68856. }
  68857. // Mixins
  68858. interface Window {
  68859. mozIndexedDB: IDBFactory;
  68860. webkitIndexedDB: IDBFactory;
  68861. msIndexedDB: IDBFactory;
  68862. webkitURL: typeof URL;
  68863. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  68864. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  68865. WebGLRenderingContext: WebGLRenderingContext;
  68866. MSGesture: MSGesture;
  68867. CANNON: any;
  68868. AudioContext: AudioContext;
  68869. webkitAudioContext: AudioContext;
  68870. PointerEvent: any;
  68871. Math: Math;
  68872. Uint8Array: Uint8ArrayConstructor;
  68873. Float32Array: Float32ArrayConstructor;
  68874. mozURL: typeof URL;
  68875. msURL: typeof URL;
  68876. VRFrameData: any; // WebVR, from specs 1.1
  68877. DracoDecoderModule: any;
  68878. setImmediate(handler: (...args: any[]) => void): number;
  68879. }
  68880. interface HTMLCanvasElement {
  68881. requestPointerLock(): void;
  68882. msRequestPointerLock?(): void;
  68883. mozRequestPointerLock?(): void;
  68884. webkitRequestPointerLock?(): void;
  68885. /** Track wether a record is in progress */
  68886. isRecording: boolean;
  68887. /** Capture Stream method defined by some browsers */
  68888. captureStream(fps?: number): MediaStream;
  68889. }
  68890. interface CanvasRenderingContext2D {
  68891. msImageSmoothingEnabled: boolean;
  68892. }
  68893. interface MouseEvent {
  68894. mozMovementX: number;
  68895. mozMovementY: number;
  68896. webkitMovementX: number;
  68897. webkitMovementY: number;
  68898. msMovementX: number;
  68899. msMovementY: number;
  68900. }
  68901. interface Navigator {
  68902. mozGetVRDevices: (any: any) => any;
  68903. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68904. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68905. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68906. webkitGetGamepads(): Gamepad[];
  68907. msGetGamepads(): Gamepad[];
  68908. webkitGamepads(): Gamepad[];
  68909. }
  68910. interface HTMLVideoElement {
  68911. mozSrcObject: any;
  68912. }
  68913. interface Math {
  68914. fround(x: number): number;
  68915. imul(a: number, b: number): number;
  68916. }
  68917. interface WebGLRenderingContext {
  68918. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  68919. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  68920. vertexAttribDivisor(index: number, divisor: number): void;
  68921. createVertexArray(): any;
  68922. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  68923. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  68924. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  68925. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  68926. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  68927. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  68928. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  68929. // Queries
  68930. createQuery(): WebGLQuery;
  68931. deleteQuery(query: WebGLQuery): void;
  68932. beginQuery(target: number, query: WebGLQuery): void;
  68933. endQuery(target: number): void;
  68934. getQueryParameter(query: WebGLQuery, pname: number): any;
  68935. getQuery(target: number, pname: number): any;
  68936. MAX_SAMPLES: number;
  68937. RGBA8: number;
  68938. READ_FRAMEBUFFER: number;
  68939. DRAW_FRAMEBUFFER: number;
  68940. UNIFORM_BUFFER: number;
  68941. HALF_FLOAT_OES: number;
  68942. RGBA16F: number;
  68943. RGBA32F: number;
  68944. R32F: number;
  68945. RG32F: number;
  68946. RGB32F: number;
  68947. R16F: number;
  68948. RG16F: number;
  68949. RGB16F: number;
  68950. RED: number;
  68951. RG: number;
  68952. R8: number;
  68953. RG8: number;
  68954. UNSIGNED_INT_24_8: number;
  68955. DEPTH24_STENCIL8: number;
  68956. MIN: number;
  68957. MAX: number;
  68958. /* Multiple Render Targets */
  68959. drawBuffers(buffers: number[]): void;
  68960. readBuffer(src: number): void;
  68961. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  68962. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  68963. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  68964. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  68965. // Occlusion Query
  68966. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  68967. ANY_SAMPLES_PASSED: number;
  68968. QUERY_RESULT_AVAILABLE: number;
  68969. QUERY_RESULT: number;
  68970. }
  68971. interface WebGLProgram {
  68972. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  68973. }
  68974. interface EXT_disjoint_timer_query {
  68975. QUERY_COUNTER_BITS_EXT: number;
  68976. TIME_ELAPSED_EXT: number;
  68977. TIMESTAMP_EXT: number;
  68978. GPU_DISJOINT_EXT: number;
  68979. QUERY_RESULT_EXT: number;
  68980. QUERY_RESULT_AVAILABLE_EXT: number;
  68981. queryCounterEXT(query: WebGLQuery, target: number): void;
  68982. createQueryEXT(): WebGLQuery;
  68983. beginQueryEXT(target: number, query: WebGLQuery): void;
  68984. endQueryEXT(target: number): void;
  68985. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  68986. deleteQueryEXT(query: WebGLQuery): void;
  68987. }
  68988. interface WebGLUniformLocation {
  68989. _currentState: any;
  68990. }
  68991. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  68992. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  68993. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  68994. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  68995. interface WebGLRenderingContext {
  68996. readonly RASTERIZER_DISCARD: number;
  68997. readonly DEPTH_COMPONENT24: number;
  68998. readonly TEXTURE_3D: number;
  68999. readonly TEXTURE_2D_ARRAY: number;
  69000. readonly TEXTURE_COMPARE_FUNC: number;
  69001. readonly TEXTURE_COMPARE_MODE: number;
  69002. readonly COMPARE_REF_TO_TEXTURE: number;
  69003. readonly TEXTURE_WRAP_R: number;
  69004. readonly HALF_FLOAT: number;
  69005. readonly RGB8: number;
  69006. readonly RED_INTEGER: number;
  69007. readonly RG_INTEGER: number;
  69008. readonly RGB_INTEGER: number;
  69009. readonly RGBA_INTEGER: number;
  69010. readonly R8_SNORM: number;
  69011. readonly RG8_SNORM: number;
  69012. readonly RGB8_SNORM: number;
  69013. readonly RGBA8_SNORM: number;
  69014. readonly R8I: number;
  69015. readonly RG8I: number;
  69016. readonly RGB8I: number;
  69017. readonly RGBA8I: number;
  69018. readonly R8UI: number;
  69019. readonly RG8UI: number;
  69020. readonly RGB8UI: number;
  69021. readonly RGBA8UI: number;
  69022. readonly R16I: number;
  69023. readonly RG16I: number;
  69024. readonly RGB16I: number;
  69025. readonly RGBA16I: number;
  69026. readonly R16UI: number;
  69027. readonly RG16UI: number;
  69028. readonly RGB16UI: number;
  69029. readonly RGBA16UI: number;
  69030. readonly R32I: number;
  69031. readonly RG32I: number;
  69032. readonly RGB32I: number;
  69033. readonly RGBA32I: number;
  69034. readonly R32UI: number;
  69035. readonly RG32UI: number;
  69036. readonly RGB32UI: number;
  69037. readonly RGBA32UI: number;
  69038. readonly RGB10_A2UI: number;
  69039. readonly R11F_G11F_B10F: number;
  69040. readonly RGB9_E5: number;
  69041. readonly RGB10_A2: number;
  69042. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69043. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69044. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69045. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69046. readonly DEPTH_COMPONENT32F: number;
  69047. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69048. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69049. 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;
  69050. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69051. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69052. readonly TRANSFORM_FEEDBACK: number;
  69053. readonly INTERLEAVED_ATTRIBS: number;
  69054. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69055. createTransformFeedback(): WebGLTransformFeedback;
  69056. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69057. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69058. beginTransformFeedback(primitiveMode: number): void;
  69059. endTransformFeedback(): void;
  69060. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69061. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69062. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69063. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69064. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69065. }
  69066. interface ImageBitmap {
  69067. readonly width: number;
  69068. readonly height: number;
  69069. close(): void;
  69070. }
  69071. interface WebGLQuery extends WebGLObject {
  69072. }
  69073. declare var WebGLQuery: {
  69074. prototype: WebGLQuery;
  69075. new(): WebGLQuery;
  69076. };
  69077. interface WebGLSampler extends WebGLObject {
  69078. }
  69079. declare var WebGLSampler: {
  69080. prototype: WebGLSampler;
  69081. new(): WebGLSampler;
  69082. };
  69083. interface WebGLSync extends WebGLObject {
  69084. }
  69085. declare var WebGLSync: {
  69086. prototype: WebGLSync;
  69087. new(): WebGLSync;
  69088. };
  69089. interface WebGLTransformFeedback extends WebGLObject {
  69090. }
  69091. declare var WebGLTransformFeedback: {
  69092. prototype: WebGLTransformFeedback;
  69093. new(): WebGLTransformFeedback;
  69094. };
  69095. interface WebGLVertexArrayObject extends WebGLObject {
  69096. }
  69097. declare var WebGLVertexArrayObject: {
  69098. prototype: WebGLVertexArrayObject;
  69099. new(): WebGLVertexArrayObject;
  69100. };
  69101. // Type definitions for WebVR API
  69102. // Project: https://w3c.github.io/webvr/
  69103. // Definitions by: six a <https://github.com/lostfictions>
  69104. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69105. interface VRDisplay extends EventTarget {
  69106. /**
  69107. * Dictionary of capabilities describing the VRDisplay.
  69108. */
  69109. readonly capabilities: VRDisplayCapabilities;
  69110. /**
  69111. * z-depth defining the far plane of the eye view frustum
  69112. * enables mapping of values in the render target depth
  69113. * attachment to scene coordinates. Initially set to 10000.0.
  69114. */
  69115. depthFar: number;
  69116. /**
  69117. * z-depth defining the near plane of the eye view frustum
  69118. * enables mapping of values in the render target depth
  69119. * attachment to scene coordinates. Initially set to 0.01.
  69120. */
  69121. depthNear: number;
  69122. /**
  69123. * An identifier for this distinct VRDisplay. Used as an
  69124. * association point in the Gamepad API.
  69125. */
  69126. readonly displayId: number;
  69127. /**
  69128. * A display name, a user-readable name identifying it.
  69129. */
  69130. readonly displayName: string;
  69131. readonly isConnected: boolean;
  69132. readonly isPresenting: boolean;
  69133. /**
  69134. * If this VRDisplay supports room-scale experiences, the optional
  69135. * stage attribute contains details on the room-scale parameters.
  69136. */
  69137. readonly stageParameters: VRStageParameters | null;
  69138. /**
  69139. * Passing the value returned by `requestAnimationFrame` to
  69140. * `cancelAnimationFrame` will unregister the callback.
  69141. * @param handle Define the hanle of the request to cancel
  69142. */
  69143. cancelAnimationFrame(handle: number): void;
  69144. /**
  69145. * Stops presenting to the VRDisplay.
  69146. * @returns a promise to know when it stopped
  69147. */
  69148. exitPresent(): Promise<void>;
  69149. /**
  69150. * Return the current VREyeParameters for the given eye.
  69151. * @param whichEye Define the eye we want the parameter for
  69152. * @returns the eye parameters
  69153. */
  69154. getEyeParameters(whichEye: string): VREyeParameters;
  69155. /**
  69156. * Populates the passed VRFrameData with the information required to render
  69157. * the current frame.
  69158. * @param frameData Define the data structure to populate
  69159. * @returns true if ok otherwise false
  69160. */
  69161. getFrameData(frameData: VRFrameData): boolean;
  69162. /**
  69163. * Get the layers currently being presented.
  69164. * @returns the list of VR layers
  69165. */
  69166. getLayers(): VRLayer[];
  69167. /**
  69168. * Return a VRPose containing the future predicted pose of the VRDisplay
  69169. * when the current frame will be presented. The value returned will not
  69170. * change until JavaScript has returned control to the browser.
  69171. *
  69172. * The VRPose will contain the position, orientation, velocity,
  69173. * and acceleration of each of these properties.
  69174. * @returns the pose object
  69175. */
  69176. getPose(): VRPose;
  69177. /**
  69178. * Return the current instantaneous pose of the VRDisplay, with no
  69179. * prediction applied.
  69180. * @returns the current instantaneous pose
  69181. */
  69182. getImmediatePose(): VRPose;
  69183. /**
  69184. * The callback passed to `requestAnimationFrame` will be called
  69185. * any time a new frame should be rendered. When the VRDisplay is
  69186. * presenting the callback will be called at the native refresh
  69187. * rate of the HMD. When not presenting this function acts
  69188. * identically to how window.requestAnimationFrame acts. Content should
  69189. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69190. * asynchronously from other displays and at differing refresh rates.
  69191. * @param callback Define the eaction to run next frame
  69192. * @returns the request handle it
  69193. */
  69194. requestAnimationFrame(callback: FrameRequestCallback): number;
  69195. /**
  69196. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69197. * Repeat calls while already presenting will update the VRLayers being displayed.
  69198. * @param layers Define the list of layer to present
  69199. * @returns a promise to know when the request has been fulfilled
  69200. */
  69201. requestPresent(layers: VRLayer[]): Promise<void>;
  69202. /**
  69203. * Reset the pose for this display, treating its current position and
  69204. * orientation as the "origin/zero" values. VRPose.position,
  69205. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69206. * updated when calling resetPose(). This should be called in only
  69207. * sitting-space experiences.
  69208. */
  69209. resetPose(): void;
  69210. /**
  69211. * The VRLayer provided to the VRDisplay will be captured and presented
  69212. * in the HMD. Calling this function has the same effect on the source
  69213. * canvas as any other operation that uses its source image, and canvases
  69214. * created without preserveDrawingBuffer set to true will be cleared.
  69215. * @param pose Define the pose to submit
  69216. */
  69217. submitFrame(pose?: VRPose): void;
  69218. }
  69219. declare var VRDisplay: {
  69220. prototype: VRDisplay;
  69221. new(): VRDisplay;
  69222. };
  69223. interface VRLayer {
  69224. leftBounds?: number[] | Float32Array | null;
  69225. rightBounds?: number[] | Float32Array | null;
  69226. source?: HTMLCanvasElement | null;
  69227. }
  69228. interface VRDisplayCapabilities {
  69229. readonly canPresent: boolean;
  69230. readonly hasExternalDisplay: boolean;
  69231. readonly hasOrientation: boolean;
  69232. readonly hasPosition: boolean;
  69233. readonly maxLayers: number;
  69234. }
  69235. interface VREyeParameters {
  69236. /** @deprecated */
  69237. readonly fieldOfView: VRFieldOfView;
  69238. readonly offset: Float32Array;
  69239. readonly renderHeight: number;
  69240. readonly renderWidth: number;
  69241. }
  69242. interface VRFieldOfView {
  69243. readonly downDegrees: number;
  69244. readonly leftDegrees: number;
  69245. readonly rightDegrees: number;
  69246. readonly upDegrees: number;
  69247. }
  69248. interface VRFrameData {
  69249. readonly leftProjectionMatrix: Float32Array;
  69250. readonly leftViewMatrix: Float32Array;
  69251. readonly pose: VRPose;
  69252. readonly rightProjectionMatrix: Float32Array;
  69253. readonly rightViewMatrix: Float32Array;
  69254. readonly timestamp: number;
  69255. }
  69256. interface VRPose {
  69257. readonly angularAcceleration: Float32Array | null;
  69258. readonly angularVelocity: Float32Array | null;
  69259. readonly linearAcceleration: Float32Array | null;
  69260. readonly linearVelocity: Float32Array | null;
  69261. readonly orientation: Float32Array | null;
  69262. readonly position: Float32Array | null;
  69263. readonly timestamp: number;
  69264. }
  69265. interface VRStageParameters {
  69266. sittingToStandingTransform?: Float32Array;
  69267. sizeX?: number;
  69268. sizeY?: number;
  69269. }
  69270. interface Navigator {
  69271. getVRDisplays(): Promise<VRDisplay[]>;
  69272. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69273. }
  69274. interface Window {
  69275. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69276. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69277. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69278. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69279. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69280. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69281. }
  69282. interface Gamepad {
  69283. readonly displayId: number;
  69284. }
  69285. type XRSessionMode =
  69286. | "inline"
  69287. | "immersive-vr"
  69288. | "immersive-ar";
  69289. type XRReferenceSpaceType =
  69290. | "viewer"
  69291. | "local"
  69292. | "local-floor"
  69293. | "bounded-floor"
  69294. | "unbounded";
  69295. type XREnvironmentBlendMode =
  69296. | "opaque"
  69297. | "additive"
  69298. | "alpha-blend";
  69299. type XRVisibilityState =
  69300. | "visible"
  69301. | "visible-blurred"
  69302. | "hidden";
  69303. type XRHandedness =
  69304. | "none"
  69305. | "left"
  69306. | "right";
  69307. type XRTargetRayMode =
  69308. | "gaze"
  69309. | "tracked-pointer"
  69310. | "screen";
  69311. type XREye =
  69312. | "none"
  69313. | "left"
  69314. | "right";
  69315. interface XRSpace extends EventTarget {
  69316. }
  69317. interface XRRenderState {
  69318. depthNear?: number;
  69319. depthFar?: number;
  69320. inlineVerticalFieldOfView?: number;
  69321. baseLayer?: XRWebGLLayer;
  69322. }
  69323. interface XRInputSource {
  69324. handedness: XRHandedness;
  69325. targetRayMode: XRTargetRayMode;
  69326. targetRaySpace: XRSpace;
  69327. gripSpace: XRSpace | undefined;
  69328. gamepad: Gamepad | undefined;
  69329. profiles: Array<string>;
  69330. }
  69331. interface XRSessionInit {
  69332. optionalFeatures?: XRReferenceSpaceType[];
  69333. requiredFeatures?: XRReferenceSpaceType[];
  69334. }
  69335. interface XRSession extends XRAnchorCreator {
  69336. addEventListener: Function;
  69337. removeEventListener: Function;
  69338. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69339. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69340. requestAnimationFrame: Function;
  69341. end(): Promise<void>;
  69342. renderState: XRRenderState;
  69343. inputSources: Array<XRInputSource>;
  69344. // AR hit test
  69345. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69346. updateWorldTrackingState(options: {
  69347. planeDetectionState?: { enabled: boolean; }
  69348. }): void;
  69349. }
  69350. interface XRReferenceSpace extends XRSpace {
  69351. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69352. onreset: any;
  69353. }
  69354. type XRPlaneSet = Set<XRPlane>;
  69355. type XRAnchorSet = Set<XRAnchor>;
  69356. interface XRFrame {
  69357. session: XRSession;
  69358. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69359. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69360. // Anchors
  69361. trackedAnchors?: XRAnchorSet;
  69362. // Planes
  69363. worldInformation: {
  69364. detectedPlanes?: XRPlaneSet;
  69365. };
  69366. }
  69367. interface XRViewerPose extends XRPose {
  69368. views: Array<XRView>;
  69369. }
  69370. interface XRPose {
  69371. transform: XRRigidTransform;
  69372. emulatedPosition: boolean;
  69373. }
  69374. interface XRWebGLLayerOptions {
  69375. antialias?: boolean;
  69376. depth?: boolean;
  69377. stencil?: boolean;
  69378. alpha?: boolean;
  69379. multiview?: boolean;
  69380. framebufferScaleFactor?: number;
  69381. }
  69382. declare var XRWebGLLayer: {
  69383. prototype: XRWebGLLayer;
  69384. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69385. };
  69386. interface XRWebGLLayer {
  69387. framebuffer: WebGLFramebuffer;
  69388. framebufferWidth: number;
  69389. framebufferHeight: number;
  69390. getViewport: Function;
  69391. }
  69392. declare class XRRigidTransform {
  69393. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69394. position: DOMPointReadOnly;
  69395. orientation: DOMPointReadOnly;
  69396. matrix: Float32Array;
  69397. inverse: XRRigidTransform;
  69398. }
  69399. interface XRView {
  69400. eye: XREye;
  69401. projectionMatrix: Float32Array;
  69402. transform: XRRigidTransform;
  69403. }
  69404. interface XRInputSourceChangeEvent {
  69405. session: XRSession;
  69406. removed: Array<XRInputSource>;
  69407. added: Array<XRInputSource>;
  69408. }
  69409. interface XRInputSourceEvent extends Event {
  69410. readonly frame: XRFrame;
  69411. readonly inputSource: XRInputSource;
  69412. }
  69413. // Experimental(er) features
  69414. declare class XRRay {
  69415. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69416. origin: DOMPointReadOnly;
  69417. direction: DOMPointReadOnly;
  69418. matrix: Float32Array;
  69419. }
  69420. interface XRHitResult {
  69421. hitMatrix: Float32Array;
  69422. }
  69423. interface XRAnchor {
  69424. // remove?
  69425. id?: string;
  69426. anchorSpace: XRSpace;
  69427. lastChangedTime: number;
  69428. detach(): void;
  69429. }
  69430. interface XRPlane extends XRAnchorCreator {
  69431. orientation: "Horizontal" | "Vertical";
  69432. planeSpace: XRSpace;
  69433. polygon: Array<DOMPointReadOnly>;
  69434. lastChangedTime: number;
  69435. }
  69436. interface XRAnchorCreator {
  69437. // AR Anchors
  69438. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69439. }
  69440. /**
  69441. * @ignore
  69442. */
  69443. declare module BABYLON.GLTF2.Exporter {
  69444. }
  69445. /**
  69446. * @ignore
  69447. */
  69448. declare module BABYLON.GLTF1 {
  69449. }
  69450. declare module BABYLON.GUI {
  69451. /**
  69452. * Class used to specific a value and its associated unit
  69453. */
  69454. export class ValueAndUnit {
  69455. /** defines the unit to store */
  69456. unit: number;
  69457. /** defines a boolean indicating if the value can be negative */
  69458. negativeValueAllowed: boolean;
  69459. private _value;
  69460. private _originalUnit;
  69461. /**
  69462. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69463. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69464. */
  69465. ignoreAdaptiveScaling: boolean;
  69466. /**
  69467. * Creates a new ValueAndUnit
  69468. * @param value defines the value to store
  69469. * @param unit defines the unit to store
  69470. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69471. */
  69472. constructor(value: number,
  69473. /** defines the unit to store */
  69474. unit?: number,
  69475. /** defines a boolean indicating if the value can be negative */
  69476. negativeValueAllowed?: boolean);
  69477. /** Gets a boolean indicating if the value is a percentage */
  69478. get isPercentage(): boolean;
  69479. /** Gets a boolean indicating if the value is store as pixel */
  69480. get isPixel(): boolean;
  69481. /** Gets direct internal value */
  69482. get internalValue(): number;
  69483. /**
  69484. * Gets value as pixel
  69485. * @param host defines the root host
  69486. * @param refValue defines the reference value for percentages
  69487. * @returns the value as pixel
  69488. */
  69489. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  69490. /**
  69491. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  69492. * @param value defines the value to store
  69493. * @param unit defines the unit to store
  69494. * @returns the current ValueAndUnit
  69495. */
  69496. updateInPlace(value: number, unit?: number): ValueAndUnit;
  69497. /**
  69498. * Gets the value accordingly to its unit
  69499. * @param host defines the root host
  69500. * @returns the value
  69501. */
  69502. getValue(host: AdvancedDynamicTexture): number;
  69503. /**
  69504. * Gets a string representation of the value
  69505. * @param host defines the root host
  69506. * @param decimals defines an optional number of decimals to display
  69507. * @returns a string
  69508. */
  69509. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  69510. /**
  69511. * Store a value parsed from a string
  69512. * @param source defines the source string
  69513. * @returns true if the value was successfully parsed
  69514. */
  69515. fromString(source: string | number): boolean;
  69516. private static _Regex;
  69517. private static _UNITMODE_PERCENTAGE;
  69518. private static _UNITMODE_PIXEL;
  69519. /** UNITMODE_PERCENTAGE */
  69520. static get UNITMODE_PERCENTAGE(): number;
  69521. /** UNITMODE_PIXEL */
  69522. static get UNITMODE_PIXEL(): number;
  69523. }
  69524. }
  69525. declare module BABYLON.GUI {
  69526. /**
  69527. * Define a style used by control to automatically setup properties based on a template.
  69528. * Only support font related properties so far
  69529. */
  69530. export class Style implements BABYLON.IDisposable {
  69531. private _fontFamily;
  69532. private _fontStyle;
  69533. private _fontWeight;
  69534. /** @hidden */
  69535. _host: AdvancedDynamicTexture;
  69536. /** @hidden */
  69537. _fontSize: ValueAndUnit;
  69538. /**
  69539. * BABYLON.Observable raised when the style values are changed
  69540. */
  69541. onChangedObservable: BABYLON.Observable<Style>;
  69542. /**
  69543. * Creates a new style object
  69544. * @param host defines the AdvancedDynamicTexture which hosts this style
  69545. */
  69546. constructor(host: AdvancedDynamicTexture);
  69547. /**
  69548. * Gets or sets the font size
  69549. */
  69550. get fontSize(): string | number;
  69551. set fontSize(value: string | number);
  69552. /**
  69553. * Gets or sets the font family
  69554. */
  69555. get fontFamily(): string;
  69556. set fontFamily(value: string);
  69557. /**
  69558. * Gets or sets the font style
  69559. */
  69560. get fontStyle(): string;
  69561. set fontStyle(value: string);
  69562. /** Gets or sets font weight */
  69563. get fontWeight(): string;
  69564. set fontWeight(value: string);
  69565. /** Dispose all associated resources */
  69566. dispose(): void;
  69567. }
  69568. }
  69569. declare module BABYLON.GUI {
  69570. /**
  69571. * Class used to transport BABYLON.Vector2 information for pointer events
  69572. */
  69573. export class Vector2WithInfo extends BABYLON.Vector2 {
  69574. /** defines the current mouse button index */
  69575. buttonIndex: number;
  69576. /**
  69577. * Creates a new Vector2WithInfo
  69578. * @param source defines the vector2 data to transport
  69579. * @param buttonIndex defines the current mouse button index
  69580. */
  69581. constructor(source: BABYLON.Vector2,
  69582. /** defines the current mouse button index */
  69583. buttonIndex?: number);
  69584. }
  69585. /** Class used to provide 2D matrix features */
  69586. export class Matrix2D {
  69587. /** Gets the internal array of 6 floats used to store matrix data */
  69588. m: Float32Array;
  69589. /**
  69590. * Creates a new matrix
  69591. * @param m00 defines value for (0, 0)
  69592. * @param m01 defines value for (0, 1)
  69593. * @param m10 defines value for (1, 0)
  69594. * @param m11 defines value for (1, 1)
  69595. * @param m20 defines value for (2, 0)
  69596. * @param m21 defines value for (2, 1)
  69597. */
  69598. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  69599. /**
  69600. * Fills the matrix from direct values
  69601. * @param m00 defines value for (0, 0)
  69602. * @param m01 defines value for (0, 1)
  69603. * @param m10 defines value for (1, 0)
  69604. * @param m11 defines value for (1, 1)
  69605. * @param m20 defines value for (2, 0)
  69606. * @param m21 defines value for (2, 1)
  69607. * @returns the current modified matrix
  69608. */
  69609. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  69610. /**
  69611. * Gets matrix determinant
  69612. * @returns the determinant
  69613. */
  69614. determinant(): number;
  69615. /**
  69616. * Inverses the matrix and stores it in a target matrix
  69617. * @param result defines the target matrix
  69618. * @returns the current matrix
  69619. */
  69620. invertToRef(result: Matrix2D): Matrix2D;
  69621. /**
  69622. * Multiplies the current matrix with another one
  69623. * @param other defines the second operand
  69624. * @param result defines the target matrix
  69625. * @returns the current matrix
  69626. */
  69627. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  69628. /**
  69629. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  69630. * @param x defines the x coordinate to transform
  69631. * @param y defines the x coordinate to transform
  69632. * @param result defines the target vector2
  69633. * @returns the current matrix
  69634. */
  69635. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  69636. /**
  69637. * Creates an identity matrix
  69638. * @returns a new matrix
  69639. */
  69640. static Identity(): Matrix2D;
  69641. /**
  69642. * Creates a translation matrix and stores it in a target matrix
  69643. * @param x defines the x coordinate of the translation
  69644. * @param y defines the y coordinate of the translation
  69645. * @param result defines the target matrix
  69646. */
  69647. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  69648. /**
  69649. * Creates a scaling matrix and stores it in a target matrix
  69650. * @param x defines the x coordinate of the scaling
  69651. * @param y defines the y coordinate of the scaling
  69652. * @param result defines the target matrix
  69653. */
  69654. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  69655. /**
  69656. * Creates a rotation matrix and stores it in a target matrix
  69657. * @param angle defines the rotation angle
  69658. * @param result defines the target matrix
  69659. */
  69660. static RotationToRef(angle: number, result: Matrix2D): void;
  69661. private static _TempPreTranslationMatrix;
  69662. private static _TempPostTranslationMatrix;
  69663. private static _TempRotationMatrix;
  69664. private static _TempScalingMatrix;
  69665. private static _TempCompose0;
  69666. private static _TempCompose1;
  69667. private static _TempCompose2;
  69668. /**
  69669. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  69670. * @param tx defines the x coordinate of the translation
  69671. * @param ty defines the y coordinate of the translation
  69672. * @param angle defines the rotation angle
  69673. * @param scaleX defines the x coordinate of the scaling
  69674. * @param scaleY defines the y coordinate of the scaling
  69675. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  69676. * @param result defines the target matrix
  69677. */
  69678. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  69679. }
  69680. }
  69681. declare module BABYLON.GUI {
  69682. /**
  69683. * Class used to store 2D control sizes
  69684. */
  69685. export class Measure {
  69686. /** defines left coordinate */
  69687. left: number;
  69688. /** defines top coordinate */
  69689. top: number;
  69690. /** defines width dimension */
  69691. width: number;
  69692. /** defines height dimension */
  69693. height: number;
  69694. /**
  69695. * Creates a new measure
  69696. * @param left defines left coordinate
  69697. * @param top defines top coordinate
  69698. * @param width defines width dimension
  69699. * @param height defines height dimension
  69700. */
  69701. constructor(
  69702. /** defines left coordinate */
  69703. left: number,
  69704. /** defines top coordinate */
  69705. top: number,
  69706. /** defines width dimension */
  69707. width: number,
  69708. /** defines height dimension */
  69709. height: number);
  69710. /**
  69711. * Copy from another measure
  69712. * @param other defines the other measure to copy from
  69713. */
  69714. copyFrom(other: Measure): void;
  69715. /**
  69716. * Copy from a group of 4 floats
  69717. * @param left defines left coordinate
  69718. * @param top defines top coordinate
  69719. * @param width defines width dimension
  69720. * @param height defines height dimension
  69721. */
  69722. copyFromFloats(left: number, top: number, width: number, height: number): void;
  69723. /**
  69724. * Computes the axis aligned bounding box measure for two given measures
  69725. * @param a Input measure
  69726. * @param b Input measure
  69727. * @param result the resulting bounding measure
  69728. */
  69729. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  69730. /**
  69731. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  69732. * @param transform the matrix to transform the measure before computing the AABB
  69733. * @param result the resulting AABB
  69734. */
  69735. transformToRef(transform: Matrix2D, result: Measure): void;
  69736. /**
  69737. * Check equality between this measure and another one
  69738. * @param other defines the other measures
  69739. * @returns true if both measures are equals
  69740. */
  69741. isEqualsTo(other: Measure): boolean;
  69742. /**
  69743. * Creates an empty measure
  69744. * @returns a new measure
  69745. */
  69746. static Empty(): Measure;
  69747. }
  69748. }
  69749. declare module BABYLON.GUI {
  69750. /**
  69751. * Interface used to define a control that can receive focus
  69752. */
  69753. export interface IFocusableControl {
  69754. /**
  69755. * Function called when the control receives the focus
  69756. */
  69757. onFocus(): void;
  69758. /**
  69759. * Function called when the control loses the focus
  69760. */
  69761. onBlur(): void;
  69762. /**
  69763. * Function called to let the control handle keyboard events
  69764. * @param evt defines the current keyboard event
  69765. */
  69766. processKeyboard(evt: KeyboardEvent): void;
  69767. /**
  69768. * Function called to get the list of controls that should not steal the focus from this control
  69769. * @returns an array of controls
  69770. */
  69771. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69772. }
  69773. /**
  69774. * Class used to create texture to support 2D GUI elements
  69775. * @see http://doc.babylonjs.com/how_to/gui
  69776. */
  69777. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  69778. private _isDirty;
  69779. private _renderObserver;
  69780. private _resizeObserver;
  69781. private _preKeyboardObserver;
  69782. private _pointerMoveObserver;
  69783. private _pointerObserver;
  69784. private _canvasPointerOutObserver;
  69785. private _background;
  69786. /** @hidden */
  69787. _rootContainer: Container;
  69788. /** @hidden */
  69789. _lastPickedControl: Control;
  69790. /** @hidden */
  69791. _lastControlOver: {
  69792. [pointerId: number]: Control;
  69793. };
  69794. /** @hidden */
  69795. _lastControlDown: {
  69796. [pointerId: number]: Control;
  69797. };
  69798. /** @hidden */
  69799. _capturingControl: {
  69800. [pointerId: number]: Control;
  69801. };
  69802. /** @hidden */
  69803. _shouldBlockPointer: boolean;
  69804. /** @hidden */
  69805. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  69806. /** @hidden */
  69807. _linkedControls: Control[];
  69808. private _isFullscreen;
  69809. private _fullscreenViewport;
  69810. private _idealWidth;
  69811. private _idealHeight;
  69812. private _useSmallestIdeal;
  69813. private _renderAtIdealSize;
  69814. private _focusedControl;
  69815. private _blockNextFocusCheck;
  69816. private _renderScale;
  69817. private _rootElement;
  69818. private _cursorChanged;
  69819. /**
  69820. * Define type to string to ensure compatibility across browsers
  69821. * Safari doesn't support DataTransfer constructor
  69822. */
  69823. private _clipboardData;
  69824. /**
  69825. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  69826. */
  69827. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  69828. /**
  69829. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  69830. */
  69831. onControlPickedObservable: BABYLON.Observable<Control>;
  69832. /**
  69833. * BABYLON.Observable event triggered before layout is evaluated
  69834. */
  69835. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69836. /**
  69837. * BABYLON.Observable event triggered after the layout was evaluated
  69838. */
  69839. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69840. /**
  69841. * BABYLON.Observable event triggered before the texture is rendered
  69842. */
  69843. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69844. /**
  69845. * BABYLON.Observable event triggered after the texture was rendered
  69846. */
  69847. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69848. /**
  69849. * Gets or sets a boolean defining if alpha is stored as premultiplied
  69850. */
  69851. premulAlpha: boolean;
  69852. /**
  69853. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  69854. * Useful when you want more antialiasing
  69855. */
  69856. get renderScale(): number;
  69857. set renderScale(value: number);
  69858. /** Gets or sets the background color */
  69859. get background(): string;
  69860. set background(value: string);
  69861. /**
  69862. * Gets or sets the ideal width used to design controls.
  69863. * The GUI will then rescale everything accordingly
  69864. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69865. */
  69866. get idealWidth(): number;
  69867. set idealWidth(value: number);
  69868. /**
  69869. * Gets or sets the ideal height used to design controls.
  69870. * The GUI will then rescale everything accordingly
  69871. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69872. */
  69873. get idealHeight(): number;
  69874. set idealHeight(value: number);
  69875. /**
  69876. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  69877. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69878. */
  69879. get useSmallestIdeal(): boolean;
  69880. set useSmallestIdeal(value: boolean);
  69881. /**
  69882. * Gets or sets a boolean indicating if adaptive scaling must be used
  69883. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69884. */
  69885. get renderAtIdealSize(): boolean;
  69886. set renderAtIdealSize(value: boolean);
  69887. /**
  69888. * Gets the underlying layer used to render the texture when in fullscreen mode
  69889. */
  69890. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  69891. /**
  69892. * Gets the root container control
  69893. */
  69894. get rootContainer(): Container;
  69895. /**
  69896. * Returns an array containing the root container.
  69897. * This is mostly used to let the Inspector introspects the ADT
  69898. * @returns an array containing the rootContainer
  69899. */
  69900. getChildren(): Array<Container>;
  69901. /**
  69902. * Will return all controls that are inside this texture
  69903. * @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
  69904. * @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
  69905. * @return all child controls
  69906. */
  69907. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  69908. /**
  69909. * Gets or sets the current focused control
  69910. */
  69911. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  69912. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  69913. /**
  69914. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  69915. */
  69916. get isForeground(): boolean;
  69917. set isForeground(value: boolean);
  69918. /**
  69919. * Gets or set information about clipboardData
  69920. */
  69921. get clipboardData(): string;
  69922. set clipboardData(value: string);
  69923. /**
  69924. * Creates a new AdvancedDynamicTexture
  69925. * @param name defines the name of the texture
  69926. * @param width defines the width of the texture
  69927. * @param height defines the height of the texture
  69928. * @param scene defines the hosting scene
  69929. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  69930. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  69931. */
  69932. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  69933. /**
  69934. * Get the current class name of the texture useful for serialization or dynamic coding.
  69935. * @returns "AdvancedDynamicTexture"
  69936. */
  69937. getClassName(): string;
  69938. /**
  69939. * Function used to execute a function on all controls
  69940. * @param func defines the function to execute
  69941. * @param container defines the container where controls belong. If null the root container will be used
  69942. */
  69943. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  69944. private _useInvalidateRectOptimization;
  69945. /**
  69946. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  69947. */
  69948. get useInvalidateRectOptimization(): boolean;
  69949. set useInvalidateRectOptimization(value: boolean);
  69950. private _invalidatedRectangle;
  69951. /**
  69952. * Invalidates a rectangle area on the gui texture
  69953. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  69954. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  69955. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  69956. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  69957. */
  69958. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  69959. /**
  69960. * Marks the texture as dirty forcing a complete update
  69961. */
  69962. markAsDirty(): void;
  69963. /**
  69964. * Helper function used to create a new style
  69965. * @returns a new style
  69966. * @see http://doc.babylonjs.com/how_to/gui#styles
  69967. */
  69968. createStyle(): Style;
  69969. /**
  69970. * Adds a new control to the root container
  69971. * @param control defines the control to add
  69972. * @returns the current texture
  69973. */
  69974. addControl(control: Control): AdvancedDynamicTexture;
  69975. /**
  69976. * Removes a control from the root container
  69977. * @param control defines the control to remove
  69978. * @returns the current texture
  69979. */
  69980. removeControl(control: Control): AdvancedDynamicTexture;
  69981. /**
  69982. * Release all resources
  69983. */
  69984. dispose(): void;
  69985. private _onResize;
  69986. /** @hidden */
  69987. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  69988. /**
  69989. * Get screen coordinates for a vector3
  69990. * @param position defines the position to project
  69991. * @param worldMatrix defines the world matrix to use
  69992. * @returns the projected position
  69993. */
  69994. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  69995. private _checkUpdate;
  69996. private _clearMeasure;
  69997. private _render;
  69998. /** @hidden */
  69999. _changeCursor(cursor: string): void;
  70000. /** @hidden */
  70001. _registerLastControlDown(control: Control, pointerId: number): void;
  70002. private _doPicking;
  70003. /** @hidden */
  70004. _cleanControlAfterRemovalFromList(list: {
  70005. [pointerId: number]: Control;
  70006. }, control: Control): void;
  70007. /** @hidden */
  70008. _cleanControlAfterRemoval(control: Control): void;
  70009. /** Attach to all scene events required to support pointer events */
  70010. attach(): void;
  70011. /** @hidden */
  70012. private onClipboardCopy;
  70013. /** @hidden */
  70014. private onClipboardCut;
  70015. /** @hidden */
  70016. private onClipboardPaste;
  70017. /**
  70018. * Register the clipboard Events onto the canvas
  70019. */
  70020. registerClipboardEvents(): void;
  70021. /**
  70022. * Unregister the clipboard Events from the canvas
  70023. */
  70024. unRegisterClipboardEvents(): void;
  70025. /**
  70026. * Connect the texture to a hosting mesh to enable interactions
  70027. * @param mesh defines the mesh to attach to
  70028. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70029. */
  70030. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70031. /**
  70032. * Move the focus to a specific control
  70033. * @param control defines the control which will receive the focus
  70034. */
  70035. moveFocusToControl(control: IFocusableControl): void;
  70036. private _manageFocus;
  70037. private _attachToOnPointerOut;
  70038. /**
  70039. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70040. * @param mesh defines the mesh which will receive the texture
  70041. * @param width defines the texture width (1024 by default)
  70042. * @param height defines the texture height (1024 by default)
  70043. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70044. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70045. * @returns a new AdvancedDynamicTexture
  70046. */
  70047. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70048. /**
  70049. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70050. * In this mode the texture will rely on a layer for its rendering.
  70051. * This allows it to be treated like any other layer.
  70052. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70053. * LayerMask is set through advancedTexture.layer.layerMask
  70054. * @param name defines name for the texture
  70055. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70056. * @param scene defines the hsoting scene
  70057. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70058. * @returns a new AdvancedDynamicTexture
  70059. */
  70060. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70061. }
  70062. }
  70063. declare module BABYLON.GUI {
  70064. /**
  70065. * Root class used for all 2D controls
  70066. * @see http://doc.babylonjs.com/how_to/gui#controls
  70067. */
  70068. export class Control {
  70069. /** defines the name of the control */
  70070. name?: string | undefined;
  70071. /**
  70072. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70073. */
  70074. static AllowAlphaInheritance: boolean;
  70075. private _alpha;
  70076. private _alphaSet;
  70077. private _zIndex;
  70078. /** @hidden */
  70079. _host: AdvancedDynamicTexture;
  70080. /** Gets or sets the control parent */
  70081. parent: BABYLON.Nullable<Container>;
  70082. /** @hidden */
  70083. _currentMeasure: Measure;
  70084. private _fontFamily;
  70085. private _fontStyle;
  70086. private _fontWeight;
  70087. private _fontSize;
  70088. private _font;
  70089. /** @hidden */
  70090. _width: ValueAndUnit;
  70091. /** @hidden */
  70092. _height: ValueAndUnit;
  70093. /** @hidden */
  70094. protected _fontOffset: {
  70095. ascent: number;
  70096. height: number;
  70097. descent: number;
  70098. };
  70099. private _color;
  70100. private _style;
  70101. private _styleObserver;
  70102. /** @hidden */
  70103. protected _horizontalAlignment: number;
  70104. /** @hidden */
  70105. protected _verticalAlignment: number;
  70106. /** @hidden */
  70107. protected _isDirty: boolean;
  70108. /** @hidden */
  70109. protected _wasDirty: boolean;
  70110. /** @hidden */
  70111. _tempParentMeasure: Measure;
  70112. /** @hidden */
  70113. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70114. /** @hidden */
  70115. protected _cachedParentMeasure: Measure;
  70116. private _paddingLeft;
  70117. private _paddingRight;
  70118. private _paddingTop;
  70119. private _paddingBottom;
  70120. /** @hidden */
  70121. _left: ValueAndUnit;
  70122. /** @hidden */
  70123. _top: ValueAndUnit;
  70124. private _scaleX;
  70125. private _scaleY;
  70126. private _rotation;
  70127. private _transformCenterX;
  70128. private _transformCenterY;
  70129. /** @hidden */
  70130. _transformMatrix: Matrix2D;
  70131. /** @hidden */
  70132. protected _invertTransformMatrix: Matrix2D;
  70133. /** @hidden */
  70134. protected _transformedPosition: BABYLON.Vector2;
  70135. private _isMatrixDirty;
  70136. private _cachedOffsetX;
  70137. private _cachedOffsetY;
  70138. private _isVisible;
  70139. private _isHighlighted;
  70140. /** @hidden */
  70141. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70142. private _fontSet;
  70143. private _dummyVector2;
  70144. private _downCount;
  70145. private _enterCount;
  70146. private _doNotRender;
  70147. private _downPointerIds;
  70148. protected _isEnabled: boolean;
  70149. protected _disabledColor: string;
  70150. /** @hidden */
  70151. protected _rebuildLayout: boolean;
  70152. /** @hidden */
  70153. _isClipped: boolean;
  70154. /** @hidden */
  70155. _automaticSize: boolean;
  70156. /** @hidden */
  70157. _tag: any;
  70158. /**
  70159. * 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
  70160. */
  70161. uniqueId: number;
  70162. /**
  70163. * Gets or sets an object used to store user defined information for the node
  70164. */
  70165. metadata: any;
  70166. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70167. isHitTestVisible: boolean;
  70168. /** Gets or sets a boolean indicating if the control can block pointer events */
  70169. isPointerBlocker: boolean;
  70170. /** Gets or sets a boolean indicating if the control can be focusable */
  70171. isFocusInvisible: boolean;
  70172. /**
  70173. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70174. * 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
  70175. */
  70176. clipChildren: boolean;
  70177. /**
  70178. * Gets or sets a boolean indicating that control content must be clipped
  70179. * 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
  70180. */
  70181. clipContent: boolean;
  70182. /**
  70183. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70184. */
  70185. useBitmapCache: boolean;
  70186. private _cacheData;
  70187. private _shadowOffsetX;
  70188. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70189. get shadowOffsetX(): number;
  70190. set shadowOffsetX(value: number);
  70191. private _shadowOffsetY;
  70192. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70193. get shadowOffsetY(): number;
  70194. set shadowOffsetY(value: number);
  70195. private _shadowBlur;
  70196. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70197. get shadowBlur(): number;
  70198. set shadowBlur(value: number);
  70199. private _shadowColor;
  70200. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70201. get shadowColor(): string;
  70202. set shadowColor(value: string);
  70203. /** Gets or sets the cursor to use when the control is hovered */
  70204. hoverCursor: string;
  70205. /** @hidden */
  70206. protected _linkOffsetX: ValueAndUnit;
  70207. /** @hidden */
  70208. protected _linkOffsetY: ValueAndUnit;
  70209. /** Gets the control type name */
  70210. get typeName(): string;
  70211. /**
  70212. * Get the current class name of the control.
  70213. * @returns current class name
  70214. */
  70215. getClassName(): string;
  70216. /**
  70217. * An event triggered when the pointer move over the control.
  70218. */
  70219. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70220. /**
  70221. * An event triggered when the pointer move out of the control.
  70222. */
  70223. onPointerOutObservable: BABYLON.Observable<Control>;
  70224. /**
  70225. * An event triggered when the pointer taps the control
  70226. */
  70227. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70228. /**
  70229. * An event triggered when pointer up
  70230. */
  70231. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70232. /**
  70233. * An event triggered when a control is clicked on
  70234. */
  70235. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70236. /**
  70237. * An event triggered when pointer enters the control
  70238. */
  70239. onPointerEnterObservable: BABYLON.Observable<Control>;
  70240. /**
  70241. * An event triggered when the control is marked as dirty
  70242. */
  70243. onDirtyObservable: BABYLON.Observable<Control>;
  70244. /**
  70245. * An event triggered before drawing the control
  70246. */
  70247. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70248. /**
  70249. * An event triggered after the control was drawn
  70250. */
  70251. onAfterDrawObservable: BABYLON.Observable<Control>;
  70252. /**
  70253. * Get the hosting AdvancedDynamicTexture
  70254. */
  70255. get host(): AdvancedDynamicTexture;
  70256. /** Gets or set information about font offsets (used to render and align text) */
  70257. get fontOffset(): {
  70258. ascent: number;
  70259. height: number;
  70260. descent: number;
  70261. };
  70262. set fontOffset(offset: {
  70263. ascent: number;
  70264. height: number;
  70265. descent: number;
  70266. });
  70267. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70268. get alpha(): number;
  70269. set alpha(value: number);
  70270. /**
  70271. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70272. */
  70273. get isHighlighted(): boolean;
  70274. set isHighlighted(value: boolean);
  70275. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70276. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70277. */
  70278. get scaleX(): number;
  70279. set scaleX(value: number);
  70280. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70281. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70282. */
  70283. get scaleY(): number;
  70284. set scaleY(value: number);
  70285. /** Gets or sets the rotation angle (0 by default)
  70286. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70287. */
  70288. get rotation(): number;
  70289. set rotation(value: number);
  70290. /** Gets or sets the transformation center on Y axis (0 by default)
  70291. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70292. */
  70293. get transformCenterY(): number;
  70294. set transformCenterY(value: number);
  70295. /** Gets or sets the transformation center on X axis (0 by default)
  70296. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70297. */
  70298. get transformCenterX(): number;
  70299. set transformCenterX(value: number);
  70300. /**
  70301. * Gets or sets the horizontal alignment
  70302. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70303. */
  70304. get horizontalAlignment(): number;
  70305. set horizontalAlignment(value: number);
  70306. /**
  70307. * Gets or sets the vertical alignment
  70308. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70309. */
  70310. get verticalAlignment(): number;
  70311. set verticalAlignment(value: number);
  70312. /**
  70313. * Gets or sets control width
  70314. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70315. */
  70316. get width(): string | number;
  70317. set width(value: string | number);
  70318. /**
  70319. * Gets or sets the control width in pixel
  70320. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70321. */
  70322. get widthInPixels(): number;
  70323. set widthInPixels(value: number);
  70324. /**
  70325. * Gets or sets control height
  70326. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70327. */
  70328. get height(): string | number;
  70329. set height(value: string | number);
  70330. /**
  70331. * Gets or sets control height in pixel
  70332. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70333. */
  70334. get heightInPixels(): number;
  70335. set heightInPixels(value: number);
  70336. /** Gets or set font family */
  70337. get fontFamily(): string;
  70338. set fontFamily(value: string);
  70339. /** Gets or sets font style */
  70340. get fontStyle(): string;
  70341. set fontStyle(value: string);
  70342. /** Gets or sets font weight */
  70343. get fontWeight(): string;
  70344. set fontWeight(value: string);
  70345. /**
  70346. * Gets or sets style
  70347. * @see http://doc.babylonjs.com/how_to/gui#styles
  70348. */
  70349. get style(): BABYLON.Nullable<Style>;
  70350. set style(value: BABYLON.Nullable<Style>);
  70351. /** @hidden */
  70352. get _isFontSizeInPercentage(): boolean;
  70353. /** Gets or sets font size in pixels */
  70354. get fontSizeInPixels(): number;
  70355. set fontSizeInPixels(value: number);
  70356. /** Gets or sets font size */
  70357. get fontSize(): string | number;
  70358. set fontSize(value: string | number);
  70359. /** Gets or sets foreground color */
  70360. get color(): string;
  70361. set color(value: string);
  70362. /** Gets or sets z index which is used to reorder controls on the z axis */
  70363. get zIndex(): number;
  70364. set zIndex(value: number);
  70365. /** Gets or sets a boolean indicating if the control can be rendered */
  70366. get notRenderable(): boolean;
  70367. set notRenderable(value: boolean);
  70368. /** Gets or sets a boolean indicating if the control is visible */
  70369. get isVisible(): boolean;
  70370. set isVisible(value: boolean);
  70371. /** Gets a boolean indicating that the control needs to update its rendering */
  70372. get isDirty(): boolean;
  70373. /**
  70374. * Gets the current linked mesh (or null if none)
  70375. */
  70376. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70377. /**
  70378. * Gets or sets a value indicating the padding to use on the left of the control
  70379. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70380. */
  70381. get paddingLeft(): string | number;
  70382. set paddingLeft(value: string | number);
  70383. /**
  70384. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70385. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70386. */
  70387. get paddingLeftInPixels(): number;
  70388. set paddingLeftInPixels(value: number);
  70389. /**
  70390. * Gets or sets a value indicating the padding to use on the right of the control
  70391. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70392. */
  70393. get paddingRight(): string | number;
  70394. set paddingRight(value: string | number);
  70395. /**
  70396. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70397. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70398. */
  70399. get paddingRightInPixels(): number;
  70400. set paddingRightInPixels(value: number);
  70401. /**
  70402. * Gets or sets a value indicating the padding to use on the top of the control
  70403. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70404. */
  70405. get paddingTop(): string | number;
  70406. set paddingTop(value: string | number);
  70407. /**
  70408. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70409. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70410. */
  70411. get paddingTopInPixels(): number;
  70412. set paddingTopInPixels(value: number);
  70413. /**
  70414. * Gets or sets a value indicating the padding to use on the bottom of the control
  70415. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70416. */
  70417. get paddingBottom(): string | number;
  70418. set paddingBottom(value: string | number);
  70419. /**
  70420. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70421. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70422. */
  70423. get paddingBottomInPixels(): number;
  70424. set paddingBottomInPixels(value: number);
  70425. /**
  70426. * Gets or sets a value indicating the left coordinate of the control
  70427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70428. */
  70429. get left(): string | number;
  70430. set left(value: string | number);
  70431. /**
  70432. * Gets or sets a value indicating the left coordinate in pixels of the control
  70433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70434. */
  70435. get leftInPixels(): number;
  70436. set leftInPixels(value: number);
  70437. /**
  70438. * Gets or sets a value indicating the top coordinate of the control
  70439. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70440. */
  70441. get top(): string | number;
  70442. set top(value: string | number);
  70443. /**
  70444. * Gets or sets a value indicating the top coordinate in pixels of the control
  70445. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70446. */
  70447. get topInPixels(): number;
  70448. set topInPixels(value: number);
  70449. /**
  70450. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70451. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70452. */
  70453. get linkOffsetX(): string | number;
  70454. set linkOffsetX(value: string | number);
  70455. /**
  70456. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70457. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70458. */
  70459. get linkOffsetXInPixels(): number;
  70460. set linkOffsetXInPixels(value: number);
  70461. /**
  70462. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70463. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70464. */
  70465. get linkOffsetY(): string | number;
  70466. set linkOffsetY(value: string | number);
  70467. /**
  70468. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70469. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70470. */
  70471. get linkOffsetYInPixels(): number;
  70472. set linkOffsetYInPixels(value: number);
  70473. /** Gets the center coordinate on X axis */
  70474. get centerX(): number;
  70475. /** Gets the center coordinate on Y axis */
  70476. get centerY(): number;
  70477. /** Gets or sets if control is Enabled*/
  70478. get isEnabled(): boolean;
  70479. set isEnabled(value: boolean);
  70480. /** Gets or sets background color of control if it's disabled*/
  70481. get disabledColor(): string;
  70482. set disabledColor(value: string);
  70483. /**
  70484. * Creates a new control
  70485. * @param name defines the name of the control
  70486. */
  70487. constructor(
  70488. /** defines the name of the control */
  70489. name?: string | undefined);
  70490. /** @hidden */
  70491. protected _getTypeName(): string;
  70492. /**
  70493. * Gets the first ascendant in the hierarchy of the given type
  70494. * @param className defines the required type
  70495. * @returns the ascendant or null if not found
  70496. */
  70497. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  70498. /** @hidden */
  70499. _resetFontCache(): void;
  70500. /**
  70501. * Determines if a container is an ascendant of the current control
  70502. * @param container defines the container to look for
  70503. * @returns true if the container is one of the ascendant of the control
  70504. */
  70505. isAscendant(container: Control): boolean;
  70506. /**
  70507. * Gets coordinates in local control space
  70508. * @param globalCoordinates defines the coordinates to transform
  70509. * @returns the new coordinates in local space
  70510. */
  70511. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70512. /**
  70513. * Gets coordinates in local control space
  70514. * @param globalCoordinates defines the coordinates to transform
  70515. * @param result defines the target vector2 where to store the result
  70516. * @returns the current control
  70517. */
  70518. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  70519. /**
  70520. * Gets coordinates in parent local control space
  70521. * @param globalCoordinates defines the coordinates to transform
  70522. * @returns the new coordinates in parent local space
  70523. */
  70524. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70525. /**
  70526. * Move the current control to a vector3 position projected onto the screen.
  70527. * @param position defines the target position
  70528. * @param scene defines the hosting scene
  70529. */
  70530. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  70531. /**
  70532. * Will store all controls that have this control as ascendant in a given array
  70533. * @param results defines the array where to store the descendants
  70534. * @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
  70535. * @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
  70536. */
  70537. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70538. /**
  70539. * Will return all controls that have this control as ascendant
  70540. * @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
  70541. * @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
  70542. * @return all child controls
  70543. */
  70544. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70545. /**
  70546. * Link current control with a target mesh
  70547. * @param mesh defines the mesh to link with
  70548. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70549. */
  70550. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  70551. /** @hidden */
  70552. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  70553. /** @hidden */
  70554. _offsetLeft(offset: number): void;
  70555. /** @hidden */
  70556. _offsetTop(offset: number): void;
  70557. /** @hidden */
  70558. _markMatrixAsDirty(): void;
  70559. /** @hidden */
  70560. _flagDescendantsAsMatrixDirty(): void;
  70561. /** @hidden */
  70562. _intersectsRect(rect: Measure): boolean;
  70563. /** @hidden */
  70564. protected invalidateRect(): void;
  70565. /** @hidden */
  70566. _markAsDirty(force?: boolean): void;
  70567. /** @hidden */
  70568. _markAllAsDirty(): void;
  70569. /** @hidden */
  70570. _link(host: AdvancedDynamicTexture): void;
  70571. /** @hidden */
  70572. protected _transform(context?: CanvasRenderingContext2D): void;
  70573. /** @hidden */
  70574. _renderHighlight(context: CanvasRenderingContext2D): void;
  70575. /** @hidden */
  70576. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70577. /** @hidden */
  70578. protected _applyStates(context: CanvasRenderingContext2D): void;
  70579. /** @hidden */
  70580. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70581. /** @hidden */
  70582. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70583. protected _evaluateClippingState(parentMeasure: Measure): void;
  70584. /** @hidden */
  70585. _measure(): void;
  70586. /** @hidden */
  70587. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70588. /** @hidden */
  70589. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70590. /** @hidden */
  70591. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70592. /** @hidden */
  70593. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70594. private static _ClipMeasure;
  70595. private _tmpMeasureA;
  70596. private _clip;
  70597. /** @hidden */
  70598. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  70599. /** @hidden */
  70600. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70601. /**
  70602. * Tests if a given coordinates belong to the current control
  70603. * @param x defines x coordinate to test
  70604. * @param y defines y coordinate to test
  70605. * @returns true if the coordinates are inside the control
  70606. */
  70607. contains(x: number, y: number): boolean;
  70608. /** @hidden */
  70609. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70610. /** @hidden */
  70611. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70612. /** @hidden */
  70613. _onPointerEnter(target: Control): boolean;
  70614. /** @hidden */
  70615. _onPointerOut(target: Control, force?: boolean): void;
  70616. /** @hidden */
  70617. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70618. /** @hidden */
  70619. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70620. /** @hidden */
  70621. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70622. /** @hidden */
  70623. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  70624. private _prepareFont;
  70625. /** Releases associated resources */
  70626. dispose(): void;
  70627. private static _HORIZONTAL_ALIGNMENT_LEFT;
  70628. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  70629. private static _HORIZONTAL_ALIGNMENT_CENTER;
  70630. private static _VERTICAL_ALIGNMENT_TOP;
  70631. private static _VERTICAL_ALIGNMENT_BOTTOM;
  70632. private static _VERTICAL_ALIGNMENT_CENTER;
  70633. /** HORIZONTAL_ALIGNMENT_LEFT */
  70634. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  70635. /** HORIZONTAL_ALIGNMENT_RIGHT */
  70636. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  70637. /** HORIZONTAL_ALIGNMENT_CENTER */
  70638. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  70639. /** VERTICAL_ALIGNMENT_TOP */
  70640. static get VERTICAL_ALIGNMENT_TOP(): number;
  70641. /** VERTICAL_ALIGNMENT_BOTTOM */
  70642. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  70643. /** VERTICAL_ALIGNMENT_CENTER */
  70644. static get VERTICAL_ALIGNMENT_CENTER(): number;
  70645. private static _FontHeightSizes;
  70646. /** @hidden */
  70647. static _GetFontOffset(font: string): {
  70648. ascent: number;
  70649. height: number;
  70650. descent: number;
  70651. };
  70652. /**
  70653. * Creates a stack panel that can be used to render headers
  70654. * @param control defines the control to associate with the header
  70655. * @param text defines the text of the header
  70656. * @param size defines the size of the header
  70657. * @param options defines options used to configure the header
  70658. * @returns a new StackPanel
  70659. * @ignore
  70660. * @hidden
  70661. */
  70662. static AddHeader: (control: Control, text: string, size: string | number, options: {
  70663. isHorizontal: boolean;
  70664. controlFirst: boolean;
  70665. }) => any;
  70666. /** @hidden */
  70667. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  70668. }
  70669. }
  70670. declare module BABYLON.GUI {
  70671. /**
  70672. * Root class for 2D containers
  70673. * @see http://doc.babylonjs.com/how_to/gui#containers
  70674. */
  70675. export class Container extends Control {
  70676. name?: string | undefined;
  70677. /** @hidden */
  70678. protected _children: Control[];
  70679. /** @hidden */
  70680. protected _measureForChildren: Measure;
  70681. /** @hidden */
  70682. protected _background: string;
  70683. /** @hidden */
  70684. protected _adaptWidthToChildren: boolean;
  70685. /** @hidden */
  70686. protected _adaptHeightToChildren: boolean;
  70687. /**
  70688. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  70689. */
  70690. logLayoutCycleErrors: boolean;
  70691. /**
  70692. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  70693. */
  70694. maxLayoutCycle: number;
  70695. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  70696. get adaptHeightToChildren(): boolean;
  70697. set adaptHeightToChildren(value: boolean);
  70698. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  70699. get adaptWidthToChildren(): boolean;
  70700. set adaptWidthToChildren(value: boolean);
  70701. /** Gets or sets background color */
  70702. get background(): string;
  70703. set background(value: string);
  70704. /** Gets the list of children */
  70705. get children(): Control[];
  70706. /**
  70707. * Creates a new Container
  70708. * @param name defines the name of the container
  70709. */
  70710. constructor(name?: string | undefined);
  70711. protected _getTypeName(): string;
  70712. _flagDescendantsAsMatrixDirty(): void;
  70713. /**
  70714. * Gets a child using its name
  70715. * @param name defines the child name to look for
  70716. * @returns the child control if found
  70717. */
  70718. getChildByName(name: string): BABYLON.Nullable<Control>;
  70719. /**
  70720. * Gets a child using its type and its name
  70721. * @param name defines the child name to look for
  70722. * @param type defines the child type to look for
  70723. * @returns the child control if found
  70724. */
  70725. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  70726. /**
  70727. * Search for a specific control in children
  70728. * @param control defines the control to look for
  70729. * @returns true if the control is in child list
  70730. */
  70731. containsControl(control: Control): boolean;
  70732. /**
  70733. * Adds a new control to the current container
  70734. * @param control defines the control to add
  70735. * @returns the current container
  70736. */
  70737. addControl(control: BABYLON.Nullable<Control>): Container;
  70738. /**
  70739. * Removes all controls from the current container
  70740. * @returns the current container
  70741. */
  70742. clearControls(): Container;
  70743. /**
  70744. * Removes a control from the current container
  70745. * @param control defines the control to remove
  70746. * @returns the current container
  70747. */
  70748. removeControl(control: Control): Container;
  70749. /** @hidden */
  70750. _reOrderControl(control: Control): void;
  70751. /** @hidden */
  70752. _offsetLeft(offset: number): void;
  70753. /** @hidden */
  70754. _offsetTop(offset: number): void;
  70755. /** @hidden */
  70756. _markAllAsDirty(): void;
  70757. /** @hidden */
  70758. protected _localDraw(context: CanvasRenderingContext2D): void;
  70759. /** @hidden */
  70760. _link(host: AdvancedDynamicTexture): void;
  70761. /** @hidden */
  70762. protected _beforeLayout(): void;
  70763. /** @hidden */
  70764. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70765. /** @hidden */
  70766. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70767. protected _postMeasure(): void;
  70768. /** @hidden */
  70769. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  70770. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70771. /** @hidden */
  70772. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70773. /** @hidden */
  70774. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70775. /** Releases associated resources */
  70776. dispose(): void;
  70777. }
  70778. }
  70779. declare module BABYLON.GUI {
  70780. /** Class used to create rectangle container */
  70781. export class Rectangle extends Container {
  70782. name?: string | undefined;
  70783. private _thickness;
  70784. private _cornerRadius;
  70785. /** Gets or sets border thickness */
  70786. get thickness(): number;
  70787. set thickness(value: number);
  70788. /** Gets or sets the corner radius angle */
  70789. get cornerRadius(): number;
  70790. set cornerRadius(value: number);
  70791. /**
  70792. * Creates a new Rectangle
  70793. * @param name defines the control name
  70794. */
  70795. constructor(name?: string | undefined);
  70796. protected _getTypeName(): string;
  70797. protected _localDraw(context: CanvasRenderingContext2D): void;
  70798. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70799. private _drawRoundedRect;
  70800. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70801. }
  70802. }
  70803. declare module BABYLON.GUI {
  70804. /**
  70805. * Enum that determines the text-wrapping mode to use.
  70806. */
  70807. export enum TextWrapping {
  70808. /**
  70809. * Clip the text when it's larger than Control.width; this is the default mode.
  70810. */
  70811. Clip = 0,
  70812. /**
  70813. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  70814. */
  70815. WordWrap = 1,
  70816. /**
  70817. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  70818. */
  70819. Ellipsis = 2
  70820. }
  70821. /**
  70822. * Class used to create text block control
  70823. */
  70824. export class TextBlock extends Control {
  70825. /**
  70826. * Defines the name of the control
  70827. */
  70828. name?: string | undefined;
  70829. private _text;
  70830. private _textWrapping;
  70831. private _textHorizontalAlignment;
  70832. private _textVerticalAlignment;
  70833. private _lines;
  70834. private _resizeToFit;
  70835. private _lineSpacing;
  70836. private _outlineWidth;
  70837. private _outlineColor;
  70838. /**
  70839. * An event triggered after the text is changed
  70840. */
  70841. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  70842. /**
  70843. * An event triggered after the text was broken up into lines
  70844. */
  70845. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  70846. /**
  70847. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  70848. */
  70849. get lines(): any[];
  70850. /**
  70851. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70852. */
  70853. get resizeToFit(): boolean;
  70854. /**
  70855. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70856. */
  70857. set resizeToFit(value: boolean);
  70858. /**
  70859. * Gets or sets a boolean indicating if text must be wrapped
  70860. */
  70861. get textWrapping(): TextWrapping | boolean;
  70862. /**
  70863. * Gets or sets a boolean indicating if text must be wrapped
  70864. */
  70865. set textWrapping(value: TextWrapping | boolean);
  70866. /**
  70867. * Gets or sets text to display
  70868. */
  70869. get text(): string;
  70870. /**
  70871. * Gets or sets text to display
  70872. */
  70873. set text(value: string);
  70874. /**
  70875. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70876. */
  70877. get textHorizontalAlignment(): number;
  70878. /**
  70879. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70880. */
  70881. set textHorizontalAlignment(value: number);
  70882. /**
  70883. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70884. */
  70885. get textVerticalAlignment(): number;
  70886. /**
  70887. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70888. */
  70889. set textVerticalAlignment(value: number);
  70890. /**
  70891. * Gets or sets line spacing value
  70892. */
  70893. set lineSpacing(value: string | number);
  70894. /**
  70895. * Gets or sets line spacing value
  70896. */
  70897. get lineSpacing(): string | number;
  70898. /**
  70899. * Gets or sets outlineWidth of the text to display
  70900. */
  70901. get outlineWidth(): number;
  70902. /**
  70903. * Gets or sets outlineWidth of the text to display
  70904. */
  70905. set outlineWidth(value: number);
  70906. /**
  70907. * Gets or sets outlineColor of the text to display
  70908. */
  70909. get outlineColor(): string;
  70910. /**
  70911. * Gets or sets outlineColor of the text to display
  70912. */
  70913. set outlineColor(value: string);
  70914. /**
  70915. * Creates a new TextBlock object
  70916. * @param name defines the name of the control
  70917. * @param text defines the text to display (emptry string by default)
  70918. */
  70919. constructor(
  70920. /**
  70921. * Defines the name of the control
  70922. */
  70923. name?: string | undefined, text?: string);
  70924. protected _getTypeName(): string;
  70925. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70926. private _drawText;
  70927. /** @hidden */
  70928. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70929. protected _applyStates(context: CanvasRenderingContext2D): void;
  70930. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  70931. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  70932. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  70933. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  70934. protected _renderLines(context: CanvasRenderingContext2D): void;
  70935. /**
  70936. * Given a width constraint applied on the text block, find the expected height
  70937. * @returns expected height
  70938. */
  70939. computeExpectedHeight(): number;
  70940. dispose(): void;
  70941. }
  70942. }
  70943. declare module BABYLON.GUI {
  70944. /**
  70945. * Class used to create 2D images
  70946. */
  70947. export class Image extends Control {
  70948. name?: string | undefined;
  70949. private _workingCanvas;
  70950. private _domImage;
  70951. private _imageWidth;
  70952. private _imageHeight;
  70953. private _loaded;
  70954. private _stretch;
  70955. private _source;
  70956. private _autoScale;
  70957. private _sourceLeft;
  70958. private _sourceTop;
  70959. private _sourceWidth;
  70960. private _sourceHeight;
  70961. private _cellWidth;
  70962. private _cellHeight;
  70963. private _cellId;
  70964. private _populateNinePatchSlicesFromImage;
  70965. private _sliceLeft;
  70966. private _sliceRight;
  70967. private _sliceTop;
  70968. private _sliceBottom;
  70969. private _detectPointerOnOpaqueOnly;
  70970. /**
  70971. * BABYLON.Observable notified when the content is loaded
  70972. */
  70973. onImageLoadedObservable: BABYLON.Observable<Image>;
  70974. /**
  70975. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  70976. */
  70977. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  70978. /**
  70979. * Gets a boolean indicating that the content is loaded
  70980. */
  70981. get isLoaded(): boolean;
  70982. /**
  70983. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  70984. */
  70985. get populateNinePatchSlicesFromImage(): boolean;
  70986. set populateNinePatchSlicesFromImage(value: boolean);
  70987. /**
  70988. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  70989. * Beware using this as this will comsume more memory as the image has to be stored twice
  70990. */
  70991. get detectPointerOnOpaqueOnly(): boolean;
  70992. set detectPointerOnOpaqueOnly(value: boolean);
  70993. /**
  70994. * Gets or sets the left value for slicing (9-patch)
  70995. */
  70996. get sliceLeft(): number;
  70997. set sliceLeft(value: number);
  70998. /**
  70999. * Gets or sets the right value for slicing (9-patch)
  71000. */
  71001. get sliceRight(): number;
  71002. set sliceRight(value: number);
  71003. /**
  71004. * Gets or sets the top value for slicing (9-patch)
  71005. */
  71006. get sliceTop(): number;
  71007. set sliceTop(value: number);
  71008. /**
  71009. * Gets or sets the bottom value for slicing (9-patch)
  71010. */
  71011. get sliceBottom(): number;
  71012. set sliceBottom(value: number);
  71013. /**
  71014. * Gets or sets the left coordinate in the source image
  71015. */
  71016. get sourceLeft(): number;
  71017. set sourceLeft(value: number);
  71018. /**
  71019. * Gets or sets the top coordinate in the source image
  71020. */
  71021. get sourceTop(): number;
  71022. set sourceTop(value: number);
  71023. /**
  71024. * Gets or sets the width to capture in the source image
  71025. */
  71026. get sourceWidth(): number;
  71027. set sourceWidth(value: number);
  71028. /**
  71029. * Gets or sets the height to capture in the source image
  71030. */
  71031. get sourceHeight(): number;
  71032. set sourceHeight(value: number);
  71033. /**
  71034. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71035. * @see http://doc.babylonjs.com/how_to/gui#image
  71036. */
  71037. get autoScale(): boolean;
  71038. set autoScale(value: boolean);
  71039. /** Gets or sets the streching mode used by the image */
  71040. get stretch(): number;
  71041. set stretch(value: number);
  71042. /** @hidden */
  71043. _rotate90(n: number): Image;
  71044. /**
  71045. * Gets or sets the internal DOM image used to render the control
  71046. */
  71047. set domImage(value: HTMLImageElement);
  71048. get domImage(): HTMLImageElement;
  71049. private _onImageLoaded;
  71050. private _extractNinePatchSliceDataFromImage;
  71051. /**
  71052. * Gets or sets image source url
  71053. */
  71054. set source(value: BABYLON.Nullable<string>);
  71055. /**
  71056. * Checks for svg document with icon id present
  71057. */
  71058. private _svgCheck;
  71059. /**
  71060. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71061. * given external svg file and icon id
  71062. */
  71063. private _getSVGAttribs;
  71064. /**
  71065. * Gets or sets the cell width to use when animation sheet is enabled
  71066. * @see http://doc.babylonjs.com/how_to/gui#image
  71067. */
  71068. get cellWidth(): number;
  71069. set cellWidth(value: number);
  71070. /**
  71071. * Gets or sets the cell height to use when animation sheet is enabled
  71072. * @see http://doc.babylonjs.com/how_to/gui#image
  71073. */
  71074. get cellHeight(): number;
  71075. set cellHeight(value: number);
  71076. /**
  71077. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71078. * @see http://doc.babylonjs.com/how_to/gui#image
  71079. */
  71080. get cellId(): number;
  71081. set cellId(value: number);
  71082. /**
  71083. * Creates a new Image
  71084. * @param name defines the control name
  71085. * @param url defines the image url
  71086. */
  71087. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71088. /**
  71089. * Tests if a given coordinates belong to the current control
  71090. * @param x defines x coordinate to test
  71091. * @param y defines y coordinate to test
  71092. * @returns true if the coordinates are inside the control
  71093. */
  71094. contains(x: number, y: number): boolean;
  71095. protected _getTypeName(): string;
  71096. /** Force the control to synchronize with its content */
  71097. synchronizeSizeWithContent(): void;
  71098. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71099. private _prepareWorkingCanvasForOpaqueDetection;
  71100. private _drawImage;
  71101. _draw(context: CanvasRenderingContext2D): void;
  71102. private _renderCornerPatch;
  71103. private _renderNinePatch;
  71104. dispose(): void;
  71105. /** STRETCH_NONE */
  71106. static readonly STRETCH_NONE: number;
  71107. /** STRETCH_FILL */
  71108. static readonly STRETCH_FILL: number;
  71109. /** STRETCH_UNIFORM */
  71110. static readonly STRETCH_UNIFORM: number;
  71111. /** STRETCH_EXTEND */
  71112. static readonly STRETCH_EXTEND: number;
  71113. /** NINE_PATCH */
  71114. static readonly STRETCH_NINE_PATCH: number;
  71115. }
  71116. }
  71117. declare module BABYLON.GUI {
  71118. /**
  71119. * Class used to create 2D buttons
  71120. */
  71121. export class Button extends Rectangle {
  71122. name?: string | undefined;
  71123. /**
  71124. * Function called to generate a pointer enter animation
  71125. */
  71126. pointerEnterAnimation: () => void;
  71127. /**
  71128. * Function called to generate a pointer out animation
  71129. */
  71130. pointerOutAnimation: () => void;
  71131. /**
  71132. * Function called to generate a pointer down animation
  71133. */
  71134. pointerDownAnimation: () => void;
  71135. /**
  71136. * Function called to generate a pointer up animation
  71137. */
  71138. pointerUpAnimation: () => void;
  71139. /**
  71140. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71141. */
  71142. delegatePickingToChildren: boolean;
  71143. private _image;
  71144. /**
  71145. * Returns the image part of the button (if any)
  71146. */
  71147. get image(): BABYLON.Nullable<Image>;
  71148. private _textBlock;
  71149. /**
  71150. * Returns the image part of the button (if any)
  71151. */
  71152. get textBlock(): BABYLON.Nullable<TextBlock>;
  71153. /**
  71154. * Creates a new Button
  71155. * @param name defines the name of the button
  71156. */
  71157. constructor(name?: string | undefined);
  71158. protected _getTypeName(): string;
  71159. /** @hidden */
  71160. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71161. /** @hidden */
  71162. _onPointerEnter(target: Control): boolean;
  71163. /** @hidden */
  71164. _onPointerOut(target: Control, force?: boolean): void;
  71165. /** @hidden */
  71166. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71167. /** @hidden */
  71168. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71169. /**
  71170. * Creates a new button made with an image and a text
  71171. * @param name defines the name of the button
  71172. * @param text defines the text of the button
  71173. * @param imageUrl defines the url of the image
  71174. * @returns a new Button
  71175. */
  71176. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71177. /**
  71178. * Creates a new button made with an image
  71179. * @param name defines the name of the button
  71180. * @param imageUrl defines the url of the image
  71181. * @returns a new Button
  71182. */
  71183. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71184. /**
  71185. * Creates a new button made with a text
  71186. * @param name defines the name of the button
  71187. * @param text defines the text of the button
  71188. * @returns a new Button
  71189. */
  71190. static CreateSimpleButton(name: string, text: string): Button;
  71191. /**
  71192. * Creates a new button made with an image and a centered text
  71193. * @param name defines the name of the button
  71194. * @param text defines the text of the button
  71195. * @param imageUrl defines the url of the image
  71196. * @returns a new Button
  71197. */
  71198. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71199. }
  71200. }
  71201. declare module BABYLON.GUI {
  71202. /**
  71203. * Class used to create a 2D stack panel container
  71204. */
  71205. export class StackPanel extends Container {
  71206. name?: string | undefined;
  71207. private _isVertical;
  71208. private _manualWidth;
  71209. private _manualHeight;
  71210. private _doNotTrackManualChanges;
  71211. /**
  71212. * Gets or sets a boolean indicating that layou warnings should be ignored
  71213. */
  71214. ignoreLayoutWarnings: boolean;
  71215. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71216. get isVertical(): boolean;
  71217. set isVertical(value: boolean);
  71218. /**
  71219. * Gets or sets panel width.
  71220. * This value should not be set when in horizontal mode as it will be computed automatically
  71221. */
  71222. set width(value: string | number);
  71223. get width(): string | number;
  71224. /**
  71225. * Gets or sets panel height.
  71226. * This value should not be set when in vertical mode as it will be computed automatically
  71227. */
  71228. set height(value: string | number);
  71229. get height(): string | number;
  71230. /**
  71231. * Creates a new StackPanel
  71232. * @param name defines control name
  71233. */
  71234. constructor(name?: string | undefined);
  71235. protected _getTypeName(): string;
  71236. /** @hidden */
  71237. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71238. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71239. protected _postMeasure(): void;
  71240. }
  71241. }
  71242. declare module BABYLON.GUI {
  71243. /**
  71244. * Class used to represent a 2D checkbox
  71245. */
  71246. export class Checkbox extends Control {
  71247. name?: string | undefined;
  71248. private _isChecked;
  71249. private _background;
  71250. private _checkSizeRatio;
  71251. private _thickness;
  71252. /** Gets or sets border thickness */
  71253. get thickness(): number;
  71254. set thickness(value: number);
  71255. /**
  71256. * BABYLON.Observable raised when isChecked property changes
  71257. */
  71258. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71259. /** Gets or sets a value indicating the ratio between overall size and check size */
  71260. get checkSizeRatio(): number;
  71261. set checkSizeRatio(value: number);
  71262. /** Gets or sets background color */
  71263. get background(): string;
  71264. set background(value: string);
  71265. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71266. get isChecked(): boolean;
  71267. set isChecked(value: boolean);
  71268. /**
  71269. * Creates a new CheckBox
  71270. * @param name defines the control name
  71271. */
  71272. constructor(name?: string | undefined);
  71273. protected _getTypeName(): string;
  71274. /** @hidden */
  71275. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71276. /** @hidden */
  71277. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71278. /**
  71279. * Utility function to easily create a checkbox with a header
  71280. * @param title defines the label to use for the header
  71281. * @param onValueChanged defines the callback to call when value changes
  71282. * @returns a StackPanel containing the checkbox and a textBlock
  71283. */
  71284. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71285. }
  71286. }
  71287. declare module BABYLON.GUI {
  71288. /**
  71289. * Class used to store key control properties
  71290. */
  71291. export class KeyPropertySet {
  71292. /** Width */
  71293. width?: string;
  71294. /** Height */
  71295. height?: string;
  71296. /** Left padding */
  71297. paddingLeft?: string;
  71298. /** Right padding */
  71299. paddingRight?: string;
  71300. /** Top padding */
  71301. paddingTop?: string;
  71302. /** Bottom padding */
  71303. paddingBottom?: string;
  71304. /** Foreground color */
  71305. color?: string;
  71306. /** Background color */
  71307. background?: string;
  71308. }
  71309. /**
  71310. * Class used to create virtual keyboard
  71311. */
  71312. export class VirtualKeyboard extends StackPanel {
  71313. /** BABYLON.Observable raised when a key is pressed */
  71314. onKeyPressObservable: BABYLON.Observable<string>;
  71315. /** Gets or sets default key button width */
  71316. defaultButtonWidth: string;
  71317. /** Gets or sets default key button height */
  71318. defaultButtonHeight: string;
  71319. /** Gets or sets default key button left padding */
  71320. defaultButtonPaddingLeft: string;
  71321. /** Gets or sets default key button right padding */
  71322. defaultButtonPaddingRight: string;
  71323. /** Gets or sets default key button top padding */
  71324. defaultButtonPaddingTop: string;
  71325. /** Gets or sets default key button bottom padding */
  71326. defaultButtonPaddingBottom: string;
  71327. /** Gets or sets default key button foreground color */
  71328. defaultButtonColor: string;
  71329. /** Gets or sets default key button background color */
  71330. defaultButtonBackground: string;
  71331. /** Gets or sets shift button foreground color */
  71332. shiftButtonColor: string;
  71333. /** Gets or sets shift button thickness*/
  71334. selectedShiftThickness: number;
  71335. /** Gets shift key state */
  71336. shiftState: number;
  71337. protected _getTypeName(): string;
  71338. private _createKey;
  71339. /**
  71340. * Adds a new row of keys
  71341. * @param keys defines the list of keys to add
  71342. * @param propertySets defines the associated property sets
  71343. */
  71344. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71345. /**
  71346. * Set the shift key to a specific state
  71347. * @param shiftState defines the new shift state
  71348. */
  71349. applyShiftState(shiftState: number): void;
  71350. private _currentlyConnectedInputText;
  71351. private _connectedInputTexts;
  71352. private _onKeyPressObserver;
  71353. /** Gets the input text control currently attached to the keyboard */
  71354. get connectedInputText(): BABYLON.Nullable<InputText>;
  71355. /**
  71356. * Connects the keyboard with an input text control
  71357. *
  71358. * @param input defines the target control
  71359. */
  71360. connect(input: InputText): void;
  71361. /**
  71362. * Disconnects the keyboard from connected InputText controls
  71363. *
  71364. * @param input optionally defines a target control, otherwise all are disconnected
  71365. */
  71366. disconnect(input?: InputText): void;
  71367. private _removeConnectedInputObservables;
  71368. /**
  71369. * Release all resources
  71370. */
  71371. dispose(): void;
  71372. /**
  71373. * Creates a new keyboard using a default layout
  71374. *
  71375. * @param name defines control name
  71376. * @returns a new VirtualKeyboard
  71377. */
  71378. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71379. }
  71380. }
  71381. declare module BABYLON.GUI {
  71382. /**
  71383. * Class used to create input text control
  71384. */
  71385. export class InputText extends Control implements IFocusableControl {
  71386. name?: string | undefined;
  71387. private _text;
  71388. private _placeholderText;
  71389. private _background;
  71390. private _focusedBackground;
  71391. private _focusedColor;
  71392. private _placeholderColor;
  71393. private _thickness;
  71394. private _margin;
  71395. private _autoStretchWidth;
  71396. private _maxWidth;
  71397. private _isFocused;
  71398. private _blinkTimeout;
  71399. private _blinkIsEven;
  71400. private _cursorOffset;
  71401. private _scrollLeft;
  71402. private _textWidth;
  71403. private _clickedCoordinate;
  71404. private _deadKey;
  71405. private _addKey;
  71406. private _currentKey;
  71407. private _isTextHighlightOn;
  71408. private _textHighlightColor;
  71409. private _highligherOpacity;
  71410. private _highlightedText;
  71411. private _startHighlightIndex;
  71412. private _endHighlightIndex;
  71413. private _cursorIndex;
  71414. private _onFocusSelectAll;
  71415. private _isPointerDown;
  71416. private _onClipboardObserver;
  71417. private _onPointerDblTapObserver;
  71418. /** @hidden */
  71419. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71420. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71421. promptMessage: string;
  71422. /** Force disable prompt on mobile device */
  71423. disableMobilePrompt: boolean;
  71424. /** BABYLON.Observable raised when the text changes */
  71425. onTextChangedObservable: BABYLON.Observable<InputText>;
  71426. /** BABYLON.Observable raised just before an entered character is to be added */
  71427. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71428. /** BABYLON.Observable raised when the control gets the focus */
  71429. onFocusObservable: BABYLON.Observable<InputText>;
  71430. /** BABYLON.Observable raised when the control loses the focus */
  71431. onBlurObservable: BABYLON.Observable<InputText>;
  71432. /**Observable raised when the text is highlighted */
  71433. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71434. /**Observable raised when copy event is triggered */
  71435. onTextCopyObservable: BABYLON.Observable<InputText>;
  71436. /** BABYLON.Observable raised when cut event is triggered */
  71437. onTextCutObservable: BABYLON.Observable<InputText>;
  71438. /** BABYLON.Observable raised when paste event is triggered */
  71439. onTextPasteObservable: BABYLON.Observable<InputText>;
  71440. /** BABYLON.Observable raised when a key event was processed */
  71441. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71442. /** Gets or sets the maximum width allowed by the control */
  71443. get maxWidth(): string | number;
  71444. /** Gets the maximum width allowed by the control in pixels */
  71445. get maxWidthInPixels(): number;
  71446. set maxWidth(value: string | number);
  71447. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71448. get highligherOpacity(): number;
  71449. set highligherOpacity(value: number);
  71450. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71451. get onFocusSelectAll(): boolean;
  71452. set onFocusSelectAll(value: boolean);
  71453. /** Gets or sets the text hightlight color */
  71454. get textHighlightColor(): string;
  71455. set textHighlightColor(value: string);
  71456. /** Gets or sets control margin */
  71457. get margin(): string;
  71458. /** Gets control margin in pixels */
  71459. get marginInPixels(): number;
  71460. set margin(value: string);
  71461. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71462. get autoStretchWidth(): boolean;
  71463. set autoStretchWidth(value: boolean);
  71464. /** Gets or sets border thickness */
  71465. get thickness(): number;
  71466. set thickness(value: number);
  71467. /** Gets or sets the background color when focused */
  71468. get focusedBackground(): string;
  71469. set focusedBackground(value: string);
  71470. /** Gets or sets the background color when focused */
  71471. get focusedColor(): string;
  71472. set focusedColor(value: string);
  71473. /** Gets or sets the background color */
  71474. get background(): string;
  71475. set background(value: string);
  71476. /** Gets or sets the placeholder color */
  71477. get placeholderColor(): string;
  71478. set placeholderColor(value: string);
  71479. /** Gets or sets the text displayed when the control is empty */
  71480. get placeholderText(): string;
  71481. set placeholderText(value: string);
  71482. /** Gets or sets the dead key flag */
  71483. get deadKey(): boolean;
  71484. set deadKey(flag: boolean);
  71485. /** Gets or sets the highlight text */
  71486. get highlightedText(): string;
  71487. set highlightedText(text: string);
  71488. /** Gets or sets if the current key should be added */
  71489. get addKey(): boolean;
  71490. set addKey(flag: boolean);
  71491. /** Gets or sets the value of the current key being entered */
  71492. get currentKey(): string;
  71493. set currentKey(key: string);
  71494. /** Gets or sets the text displayed in the control */
  71495. get text(): string;
  71496. set text(value: string);
  71497. /** Gets or sets control width */
  71498. get width(): string | number;
  71499. set width(value: string | number);
  71500. /**
  71501. * Creates a new InputText
  71502. * @param name defines the control name
  71503. * @param text defines the text of the control
  71504. */
  71505. constructor(name?: string | undefined, text?: string);
  71506. /** @hidden */
  71507. onBlur(): void;
  71508. /** @hidden */
  71509. onFocus(): void;
  71510. protected _getTypeName(): string;
  71511. /**
  71512. * Function called to get the list of controls that should not steal the focus from this control
  71513. * @returns an array of controls
  71514. */
  71515. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71516. /** @hidden */
  71517. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  71518. /** @hidden */
  71519. private _updateValueFromCursorIndex;
  71520. /** @hidden */
  71521. private _processDblClick;
  71522. /** @hidden */
  71523. private _selectAllText;
  71524. /**
  71525. * Handles the keyboard event
  71526. * @param evt Defines the KeyboardEvent
  71527. */
  71528. processKeyboard(evt: KeyboardEvent): void;
  71529. /** @hidden */
  71530. private _onCopyText;
  71531. /** @hidden */
  71532. private _onCutText;
  71533. /** @hidden */
  71534. private _onPasteText;
  71535. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71536. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71537. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71538. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71539. protected _beforeRenderText(text: string): string;
  71540. dispose(): void;
  71541. }
  71542. }
  71543. declare module BABYLON.GUI {
  71544. /**
  71545. * Class used to create a 2D grid container
  71546. */
  71547. export class Grid extends Container {
  71548. name?: string | undefined;
  71549. private _rowDefinitions;
  71550. private _columnDefinitions;
  71551. private _cells;
  71552. private _childControls;
  71553. /**
  71554. * Gets the number of columns
  71555. */
  71556. get columnCount(): number;
  71557. /**
  71558. * Gets the number of rows
  71559. */
  71560. get rowCount(): number;
  71561. /** Gets the list of children */
  71562. get children(): Control[];
  71563. /** Gets the list of cells (e.g. the containers) */
  71564. get cells(): {
  71565. [key: string]: Container;
  71566. };
  71567. /**
  71568. * Gets the definition of a specific row
  71569. * @param index defines the index of the row
  71570. * @returns the row definition
  71571. */
  71572. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71573. /**
  71574. * Gets the definition of a specific column
  71575. * @param index defines the index of the column
  71576. * @returns the column definition
  71577. */
  71578. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71579. /**
  71580. * Adds a new row to the grid
  71581. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71582. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  71583. * @returns the current grid
  71584. */
  71585. addRowDefinition(height: number, isPixel?: boolean): Grid;
  71586. /**
  71587. * Adds a new column to the grid
  71588. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71589. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71590. * @returns the current grid
  71591. */
  71592. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  71593. /**
  71594. * Update a row definition
  71595. * @param index defines the index of the row to update
  71596. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71597. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  71598. * @returns the current grid
  71599. */
  71600. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  71601. /**
  71602. * Update a column definition
  71603. * @param index defines the index of the column to update
  71604. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71605. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71606. * @returns the current grid
  71607. */
  71608. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  71609. /**
  71610. * Gets the list of children stored in a specific cell
  71611. * @param row defines the row to check
  71612. * @param column defines the column to check
  71613. * @returns the list of controls
  71614. */
  71615. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  71616. /**
  71617. * Gets a string representing the child cell info (row x column)
  71618. * @param child defines the control to get info from
  71619. * @returns a string containing the child cell info (row x column)
  71620. */
  71621. getChildCellInfo(child: Control): string;
  71622. private _removeCell;
  71623. private _offsetCell;
  71624. /**
  71625. * Remove a column definition at specified index
  71626. * @param index defines the index of the column to remove
  71627. * @returns the current grid
  71628. */
  71629. removeColumnDefinition(index: number): Grid;
  71630. /**
  71631. * Remove a row definition at specified index
  71632. * @param index defines the index of the row to remove
  71633. * @returns the current grid
  71634. */
  71635. removeRowDefinition(index: number): Grid;
  71636. /**
  71637. * Adds a new control to the current grid
  71638. * @param control defines the control to add
  71639. * @param row defines the row where to add the control (0 by default)
  71640. * @param column defines the column where to add the control (0 by default)
  71641. * @returns the current grid
  71642. */
  71643. addControl(control: Control, row?: number, column?: number): Grid;
  71644. /**
  71645. * Removes a control from the current container
  71646. * @param control defines the control to remove
  71647. * @returns the current container
  71648. */
  71649. removeControl(control: Control): Container;
  71650. /**
  71651. * Creates a new Grid
  71652. * @param name defines control name
  71653. */
  71654. constructor(name?: string | undefined);
  71655. protected _getTypeName(): string;
  71656. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  71657. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71658. _flagDescendantsAsMatrixDirty(): void;
  71659. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71660. /** Releases associated resources */
  71661. dispose(): void;
  71662. }
  71663. }
  71664. declare module BABYLON.GUI {
  71665. /** Class used to create color pickers */
  71666. export class ColorPicker extends Control {
  71667. name?: string | undefined;
  71668. private static _Epsilon;
  71669. private _colorWheelCanvas;
  71670. private _value;
  71671. private _tmpColor;
  71672. private _pointerStartedOnSquare;
  71673. private _pointerStartedOnWheel;
  71674. private _squareLeft;
  71675. private _squareTop;
  71676. private _squareSize;
  71677. private _h;
  71678. private _s;
  71679. private _v;
  71680. private _lastPointerDownID;
  71681. /**
  71682. * BABYLON.Observable raised when the value changes
  71683. */
  71684. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  71685. /** Gets or sets the color of the color picker */
  71686. get value(): BABYLON.Color3;
  71687. set value(value: BABYLON.Color3);
  71688. /**
  71689. * Gets or sets control width
  71690. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71691. */
  71692. get width(): string | number;
  71693. set width(value: string | number);
  71694. /**
  71695. * Gets or sets control height
  71696. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71697. */
  71698. get height(): string | number;
  71699. /** Gets or sets control height */
  71700. set height(value: string | number);
  71701. /** Gets or sets control size */
  71702. get size(): string | number;
  71703. set size(value: string | number);
  71704. /**
  71705. * Creates a new ColorPicker
  71706. * @param name defines the control name
  71707. */
  71708. constructor(name?: string | undefined);
  71709. protected _getTypeName(): string;
  71710. /** @hidden */
  71711. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71712. private _updateSquareProps;
  71713. private _drawGradientSquare;
  71714. private _drawCircle;
  71715. private _createColorWheelCanvas;
  71716. /** @hidden */
  71717. _draw(context: CanvasRenderingContext2D): void;
  71718. private _pointerIsDown;
  71719. private _updateValueFromPointer;
  71720. private _isPointOnSquare;
  71721. private _isPointOnWheel;
  71722. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71723. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71724. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71725. /**
  71726. * This function expands the color picker by creating a color picker dialog with manual
  71727. * color value input and the ability to save colors into an array to be used later in
  71728. * subsequent launches of the dialogue.
  71729. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  71730. * @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.
  71731. * @returns picked color as a hex string and the saved colors array as hex strings.
  71732. */
  71733. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  71734. pickerWidth?: string;
  71735. pickerHeight?: string;
  71736. headerHeight?: string;
  71737. lastColor?: string;
  71738. swatchLimit?: number;
  71739. numSwatchesPerLine?: number;
  71740. savedColors?: Array<string>;
  71741. }): Promise<{
  71742. savedColors?: string[];
  71743. pickedColor: string;
  71744. }>;
  71745. }
  71746. }
  71747. declare module BABYLON.GUI {
  71748. /** Class used to create 2D ellipse containers */
  71749. export class Ellipse extends Container {
  71750. name?: string | undefined;
  71751. private _thickness;
  71752. /** Gets or sets border thickness */
  71753. get thickness(): number;
  71754. set thickness(value: number);
  71755. /**
  71756. * Creates a new Ellipse
  71757. * @param name defines the control name
  71758. */
  71759. constructor(name?: string | undefined);
  71760. protected _getTypeName(): string;
  71761. protected _localDraw(context: CanvasRenderingContext2D): void;
  71762. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71763. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71764. }
  71765. }
  71766. declare module BABYLON.GUI {
  71767. /**
  71768. * Class used to create a password control
  71769. */
  71770. export class InputPassword extends InputText {
  71771. protected _beforeRenderText(text: string): string;
  71772. }
  71773. }
  71774. declare module BABYLON.GUI {
  71775. /** Class used to render 2D lines */
  71776. export class Line extends Control {
  71777. name?: string | undefined;
  71778. private _lineWidth;
  71779. private _x1;
  71780. private _y1;
  71781. private _x2;
  71782. private _y2;
  71783. private _dash;
  71784. private _connectedControl;
  71785. private _connectedControlDirtyObserver;
  71786. /** Gets or sets the dash pattern */
  71787. get dash(): Array<number>;
  71788. set dash(value: Array<number>);
  71789. /** Gets or sets the control connected with the line end */
  71790. get connectedControl(): Control;
  71791. set connectedControl(value: Control);
  71792. /** Gets or sets start coordinates on X axis */
  71793. get x1(): string | number;
  71794. set x1(value: string | number);
  71795. /** Gets or sets start coordinates on Y axis */
  71796. get y1(): string | number;
  71797. set y1(value: string | number);
  71798. /** Gets or sets end coordinates on X axis */
  71799. get x2(): string | number;
  71800. set x2(value: string | number);
  71801. /** Gets or sets end coordinates on Y axis */
  71802. get y2(): string | number;
  71803. set y2(value: string | number);
  71804. /** Gets or sets line width */
  71805. get lineWidth(): number;
  71806. set lineWidth(value: number);
  71807. /** Gets or sets horizontal alignment */
  71808. set horizontalAlignment(value: number);
  71809. /** Gets or sets vertical alignment */
  71810. set verticalAlignment(value: number);
  71811. private get _effectiveX2();
  71812. private get _effectiveY2();
  71813. /**
  71814. * Creates a new Line
  71815. * @param name defines the control name
  71816. */
  71817. constructor(name?: string | undefined);
  71818. protected _getTypeName(): string;
  71819. _draw(context: CanvasRenderingContext2D): void;
  71820. _measure(): void;
  71821. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71822. /**
  71823. * Move one end of the line given 3D cartesian coordinates.
  71824. * @param position Targeted world position
  71825. * @param scene BABYLON.Scene
  71826. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71827. */
  71828. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  71829. /**
  71830. * Move one end of the line to a position in screen absolute space.
  71831. * @param projectedPosition Position in screen absolute space (X, Y)
  71832. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71833. */
  71834. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  71835. }
  71836. }
  71837. declare module BABYLON.GUI {
  71838. /**
  71839. * Class used to store a point for a MultiLine object.
  71840. * The point can be pure 2D coordinates, a mesh or a control
  71841. */
  71842. export class MultiLinePoint {
  71843. private _multiLine;
  71844. private _x;
  71845. private _y;
  71846. private _control;
  71847. private _mesh;
  71848. private _controlObserver;
  71849. private _meshObserver;
  71850. /** @hidden */
  71851. _point: BABYLON.Vector2;
  71852. /**
  71853. * Creates a new MultiLinePoint
  71854. * @param multiLine defines the source MultiLine object
  71855. */
  71856. constructor(multiLine: MultiLine);
  71857. /** Gets or sets x coordinate */
  71858. get x(): string | number;
  71859. set x(value: string | number);
  71860. /** Gets or sets y coordinate */
  71861. get y(): string | number;
  71862. set y(value: string | number);
  71863. /** Gets or sets the control associated with this point */
  71864. get control(): BABYLON.Nullable<Control>;
  71865. set control(value: BABYLON.Nullable<Control>);
  71866. /** Gets or sets the mesh associated with this point */
  71867. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71868. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  71869. /** Resets links */
  71870. resetLinks(): void;
  71871. /**
  71872. * Gets a translation vector
  71873. * @returns the translation vector
  71874. */
  71875. translate(): BABYLON.Vector2;
  71876. private _translatePoint;
  71877. /** Release associated resources */
  71878. dispose(): void;
  71879. }
  71880. }
  71881. declare module BABYLON.GUI {
  71882. /**
  71883. * Class used to create multi line control
  71884. */
  71885. export class MultiLine extends Control {
  71886. name?: string | undefined;
  71887. private _lineWidth;
  71888. private _dash;
  71889. private _points;
  71890. private _minX;
  71891. private _minY;
  71892. private _maxX;
  71893. private _maxY;
  71894. /**
  71895. * Creates a new MultiLine
  71896. * @param name defines the control name
  71897. */
  71898. constructor(name?: string | undefined);
  71899. /** Gets or sets dash pattern */
  71900. get dash(): Array<number>;
  71901. set dash(value: Array<number>);
  71902. /**
  71903. * Gets point stored at specified index
  71904. * @param index defines the index to look for
  71905. * @returns the requested point if found
  71906. */
  71907. getAt(index: number): MultiLinePoint;
  71908. /** Function called when a point is updated */
  71909. onPointUpdate: () => void;
  71910. /**
  71911. * Adds new points to the point collection
  71912. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  71913. * @returns the list of created MultiLinePoint
  71914. */
  71915. add(...items: (AbstractMesh | Control | {
  71916. x: string | number;
  71917. y: string | number;
  71918. })[]): MultiLinePoint[];
  71919. /**
  71920. * Adds a new point to the point collection
  71921. * @param item defines the item (mesh, control or 2d coordiantes) to add
  71922. * @returns the created MultiLinePoint
  71923. */
  71924. push(item?: (AbstractMesh | Control | {
  71925. x: string | number;
  71926. y: string | number;
  71927. })): MultiLinePoint;
  71928. /**
  71929. * Remove a specific value or point from the active point collection
  71930. * @param value defines the value or point to remove
  71931. */
  71932. remove(value: number | MultiLinePoint): void;
  71933. /**
  71934. * Resets this object to initial state (no point)
  71935. */
  71936. reset(): void;
  71937. /**
  71938. * Resets all links
  71939. */
  71940. resetLinks(): void;
  71941. /** Gets or sets line width */
  71942. get lineWidth(): number;
  71943. set lineWidth(value: number);
  71944. set horizontalAlignment(value: number);
  71945. set verticalAlignment(value: number);
  71946. protected _getTypeName(): string;
  71947. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71948. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71949. _measure(): void;
  71950. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71951. dispose(): void;
  71952. }
  71953. }
  71954. declare module BABYLON.GUI {
  71955. /**
  71956. * Class used to create radio button controls
  71957. */
  71958. export class RadioButton extends Control {
  71959. name?: string | undefined;
  71960. private _isChecked;
  71961. private _background;
  71962. private _checkSizeRatio;
  71963. private _thickness;
  71964. /** Gets or sets border thickness */
  71965. get thickness(): number;
  71966. set thickness(value: number);
  71967. /** Gets or sets group name */
  71968. group: string;
  71969. /** BABYLON.Observable raised when isChecked is changed */
  71970. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71971. /** Gets or sets a value indicating the ratio between overall size and check size */
  71972. get checkSizeRatio(): number;
  71973. set checkSizeRatio(value: number);
  71974. /** Gets or sets background color */
  71975. get background(): string;
  71976. set background(value: string);
  71977. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71978. get isChecked(): boolean;
  71979. set isChecked(value: boolean);
  71980. /**
  71981. * Creates a new RadioButton
  71982. * @param name defines the control name
  71983. */
  71984. constructor(name?: string | undefined);
  71985. protected _getTypeName(): string;
  71986. _draw(context: CanvasRenderingContext2D): void;
  71987. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71988. /**
  71989. * Utility function to easily create a radio button with a header
  71990. * @param title defines the label to use for the header
  71991. * @param group defines the group to use for the radio button
  71992. * @param isChecked defines the initial state of the radio button
  71993. * @param onValueChanged defines the callback to call when value changes
  71994. * @returns a StackPanel containing the radio button and a textBlock
  71995. */
  71996. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  71997. }
  71998. }
  71999. declare module BABYLON.GUI {
  72000. /**
  72001. * Class used to create slider controls
  72002. */
  72003. export class BaseSlider extends Control {
  72004. name?: string | undefined;
  72005. protected _thumbWidth: ValueAndUnit;
  72006. private _minimum;
  72007. private _maximum;
  72008. private _value;
  72009. private _isVertical;
  72010. protected _barOffset: ValueAndUnit;
  72011. private _isThumbClamped;
  72012. protected _displayThumb: boolean;
  72013. private _step;
  72014. private _lastPointerDownID;
  72015. protected _effectiveBarOffset: number;
  72016. protected _renderLeft: number;
  72017. protected _renderTop: number;
  72018. protected _renderWidth: number;
  72019. protected _renderHeight: number;
  72020. protected _backgroundBoxLength: number;
  72021. protected _backgroundBoxThickness: number;
  72022. protected _effectiveThumbThickness: number;
  72023. /** BABYLON.Observable raised when the sldier value changes */
  72024. onValueChangedObservable: BABYLON.Observable<number>;
  72025. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72026. get displayThumb(): boolean;
  72027. set displayThumb(value: boolean);
  72028. /** Gets or sets a step to apply to values (0 by default) */
  72029. get step(): number;
  72030. set step(value: number);
  72031. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72032. get barOffset(): string | number;
  72033. /** Gets main bar offset in pixels*/
  72034. get barOffsetInPixels(): number;
  72035. set barOffset(value: string | number);
  72036. /** Gets or sets thumb width */
  72037. get thumbWidth(): string | number;
  72038. /** Gets thumb width in pixels */
  72039. get thumbWidthInPixels(): number;
  72040. set thumbWidth(value: string | number);
  72041. /** Gets or sets minimum value */
  72042. get minimum(): number;
  72043. set minimum(value: number);
  72044. /** Gets or sets maximum value */
  72045. get maximum(): number;
  72046. set maximum(value: number);
  72047. /** Gets or sets current value */
  72048. get value(): number;
  72049. set value(value: number);
  72050. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72051. get isVertical(): boolean;
  72052. set isVertical(value: boolean);
  72053. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72054. get isThumbClamped(): boolean;
  72055. set isThumbClamped(value: boolean);
  72056. /**
  72057. * Creates a new BaseSlider
  72058. * @param name defines the control name
  72059. */
  72060. constructor(name?: string | undefined);
  72061. protected _getTypeName(): string;
  72062. protected _getThumbPosition(): number;
  72063. protected _getThumbThickness(type: string): number;
  72064. protected _prepareRenderingData(type: string): void;
  72065. private _pointerIsDown;
  72066. /** @hidden */
  72067. protected _updateValueFromPointer(x: number, y: number): void;
  72068. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72069. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72070. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72071. }
  72072. }
  72073. declare module BABYLON.GUI {
  72074. /**
  72075. * Class used to create slider controls
  72076. */
  72077. export class Slider extends BaseSlider {
  72078. name?: string | undefined;
  72079. private _background;
  72080. private _borderColor;
  72081. private _isThumbCircle;
  72082. protected _displayValueBar: boolean;
  72083. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72084. get displayValueBar(): boolean;
  72085. set displayValueBar(value: boolean);
  72086. /** Gets or sets border color */
  72087. get borderColor(): string;
  72088. set borderColor(value: string);
  72089. /** Gets or sets background color */
  72090. get background(): string;
  72091. set background(value: string);
  72092. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72093. get isThumbCircle(): boolean;
  72094. set isThumbCircle(value: boolean);
  72095. /**
  72096. * Creates a new Slider
  72097. * @param name defines the control name
  72098. */
  72099. constructor(name?: string | undefined);
  72100. protected _getTypeName(): string;
  72101. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72102. }
  72103. }
  72104. declare module BABYLON.GUI {
  72105. /** Class used to create a RadioGroup
  72106. * which contains groups of radio buttons
  72107. */
  72108. export class SelectorGroup {
  72109. /** name of SelectorGroup */
  72110. name: string;
  72111. private _groupPanel;
  72112. private _selectors;
  72113. private _groupHeader;
  72114. /**
  72115. * Creates a new SelectorGroup
  72116. * @param name of group, used as a group heading
  72117. */
  72118. constructor(
  72119. /** name of SelectorGroup */
  72120. name: string);
  72121. /** Gets the groupPanel of the SelectorGroup */
  72122. get groupPanel(): StackPanel;
  72123. /** Gets the selectors array */
  72124. get selectors(): StackPanel[];
  72125. /** Gets and sets the group header */
  72126. get header(): string;
  72127. set header(label: string);
  72128. /** @hidden */
  72129. private _addGroupHeader;
  72130. /** @hidden*/
  72131. _getSelector(selectorNb: number): StackPanel | undefined;
  72132. /** Removes the selector at the given position
  72133. * @param selectorNb the position of the selector within the group
  72134. */
  72135. removeSelector(selectorNb: number): void;
  72136. }
  72137. /** Class used to create a CheckboxGroup
  72138. * which contains groups of checkbox buttons
  72139. */
  72140. export class CheckboxGroup extends SelectorGroup {
  72141. /** Adds a checkbox as a control
  72142. * @param text is the label for the selector
  72143. * @param func is the function called when the Selector is checked
  72144. * @param checked is true when Selector is checked
  72145. */
  72146. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72147. /** @hidden */
  72148. _setSelectorLabel(selectorNb: number, label: string): void;
  72149. /** @hidden */
  72150. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72151. /** @hidden */
  72152. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72153. /** @hidden */
  72154. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72155. }
  72156. /** Class used to create a RadioGroup
  72157. * which contains groups of radio buttons
  72158. */
  72159. export class RadioGroup extends SelectorGroup {
  72160. private _selectNb;
  72161. /** Adds a radio button as a control
  72162. * @param label is the label for the selector
  72163. * @param func is the function called when the Selector is checked
  72164. * @param checked is true when Selector is checked
  72165. */
  72166. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72167. /** @hidden */
  72168. _setSelectorLabel(selectorNb: number, label: string): void;
  72169. /** @hidden */
  72170. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72171. /** @hidden */
  72172. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72173. /** @hidden */
  72174. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72175. }
  72176. /** Class used to create a SliderGroup
  72177. * which contains groups of slider buttons
  72178. */
  72179. export class SliderGroup extends SelectorGroup {
  72180. /**
  72181. * Adds a slider to the SelectorGroup
  72182. * @param label is the label for the SliderBar
  72183. * @param func is the function called when the Slider moves
  72184. * @param unit is a string describing the units used, eg degrees or metres
  72185. * @param min is the minimum value for the Slider
  72186. * @param max is the maximum value for the Slider
  72187. * @param value is the start value for the Slider between min and max
  72188. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72189. */
  72190. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72191. /** @hidden */
  72192. _setSelectorLabel(selectorNb: number, label: string): void;
  72193. /** @hidden */
  72194. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72195. /** @hidden */
  72196. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72197. /** @hidden */
  72198. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72199. }
  72200. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72201. * @see http://doc.babylonjs.com/how_to/selector
  72202. */
  72203. export class SelectionPanel extends Rectangle {
  72204. /** name of SelectionPanel */
  72205. name: string;
  72206. /** an array of SelectionGroups */
  72207. groups: SelectorGroup[];
  72208. private _panel;
  72209. private _buttonColor;
  72210. private _buttonBackground;
  72211. private _headerColor;
  72212. private _barColor;
  72213. private _barHeight;
  72214. private _spacerHeight;
  72215. private _labelColor;
  72216. private _groups;
  72217. private _bars;
  72218. /**
  72219. * Creates a new SelectionPanel
  72220. * @param name of SelectionPanel
  72221. * @param groups is an array of SelectionGroups
  72222. */
  72223. constructor(
  72224. /** name of SelectionPanel */
  72225. name: string,
  72226. /** an array of SelectionGroups */
  72227. groups?: SelectorGroup[]);
  72228. protected _getTypeName(): string;
  72229. /** Gets or sets the headerColor */
  72230. get headerColor(): string;
  72231. set headerColor(color: string);
  72232. private _setHeaderColor;
  72233. /** Gets or sets the button color */
  72234. get buttonColor(): string;
  72235. set buttonColor(color: string);
  72236. private _setbuttonColor;
  72237. /** Gets or sets the label color */
  72238. get labelColor(): string;
  72239. set labelColor(color: string);
  72240. private _setLabelColor;
  72241. /** Gets or sets the button background */
  72242. get buttonBackground(): string;
  72243. set buttonBackground(color: string);
  72244. private _setButtonBackground;
  72245. /** Gets or sets the color of separator bar */
  72246. get barColor(): string;
  72247. set barColor(color: string);
  72248. private _setBarColor;
  72249. /** Gets or sets the height of separator bar */
  72250. get barHeight(): string;
  72251. set barHeight(value: string);
  72252. private _setBarHeight;
  72253. /** Gets or sets the height of spacers*/
  72254. get spacerHeight(): string;
  72255. set spacerHeight(value: string);
  72256. private _setSpacerHeight;
  72257. /** Adds a bar between groups */
  72258. private _addSpacer;
  72259. /** Add a group to the selection panel
  72260. * @param group is the selector group to add
  72261. */
  72262. addGroup(group: SelectorGroup): void;
  72263. /** Remove the group from the given position
  72264. * @param groupNb is the position of the group in the list
  72265. */
  72266. removeGroup(groupNb: number): void;
  72267. /** Change a group header label
  72268. * @param label is the new group header label
  72269. * @param groupNb is the number of the group to relabel
  72270. * */
  72271. setHeaderName(label: string, groupNb: number): void;
  72272. /** Change selector label to the one given
  72273. * @param label is the new selector label
  72274. * @param groupNb is the number of the groupcontaining the selector
  72275. * @param selectorNb is the number of the selector within a group to relabel
  72276. * */
  72277. relabel(label: string, groupNb: number, selectorNb: number): void;
  72278. /** For a given group position remove the selector at the given position
  72279. * @param groupNb is the number of the group to remove the selector from
  72280. * @param selectorNb is the number of the selector within the group
  72281. */
  72282. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72283. /** For a given group position of correct type add a checkbox button
  72284. * @param groupNb is the number of the group to remove the selector from
  72285. * @param label is the label for the selector
  72286. * @param func is the function called when the Selector is checked
  72287. * @param checked is true when Selector is checked
  72288. */
  72289. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72290. /** For a given group position of correct type add a radio button
  72291. * @param groupNb is the number of the group to remove the selector from
  72292. * @param label is the label for the selector
  72293. * @param func is the function called when the Selector is checked
  72294. * @param checked is true when Selector is checked
  72295. */
  72296. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72297. /**
  72298. * For a given slider group add a slider
  72299. * @param groupNb is the number of the group to add the slider to
  72300. * @param label is the label for the Slider
  72301. * @param func is the function called when the Slider moves
  72302. * @param unit is a string describing the units used, eg degrees or metres
  72303. * @param min is the minimum value for the Slider
  72304. * @param max is the maximum value for the Slider
  72305. * @param value is the start value for the Slider between min and max
  72306. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72307. */
  72308. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72309. }
  72310. }
  72311. declare module BABYLON.GUI {
  72312. /**
  72313. * Class used to hold a the container for ScrollViewer
  72314. * @hidden
  72315. */
  72316. export class _ScrollViewerWindow extends Container {
  72317. parentClientWidth: number;
  72318. parentClientHeight: number;
  72319. /**
  72320. * Creates a new ScrollViewerWindow
  72321. * @param name of ScrollViewerWindow
  72322. */
  72323. constructor(name?: string);
  72324. protected _getTypeName(): string;
  72325. /** @hidden */
  72326. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72327. protected _postMeasure(): void;
  72328. }
  72329. }
  72330. declare module BABYLON.GUI {
  72331. /**
  72332. * Class used to create slider controls
  72333. */
  72334. export class ScrollBar extends BaseSlider {
  72335. name?: string | undefined;
  72336. private _background;
  72337. private _borderColor;
  72338. private _tempMeasure;
  72339. /** Gets or sets border color */
  72340. get borderColor(): string;
  72341. set borderColor(value: string);
  72342. /** Gets or sets background color */
  72343. get background(): string;
  72344. set background(value: string);
  72345. /**
  72346. * Creates a new Slider
  72347. * @param name defines the control name
  72348. */
  72349. constructor(name?: string | undefined);
  72350. protected _getTypeName(): string;
  72351. protected _getThumbThickness(): number;
  72352. _draw(context: CanvasRenderingContext2D): void;
  72353. private _first;
  72354. private _originX;
  72355. private _originY;
  72356. /** @hidden */
  72357. protected _updateValueFromPointer(x: number, y: number): void;
  72358. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72359. }
  72360. }
  72361. declare module BABYLON.GUI {
  72362. /**
  72363. * Class used to create slider controls
  72364. */
  72365. export class ImageScrollBar extends BaseSlider {
  72366. name?: string | undefined;
  72367. private _backgroundBaseImage;
  72368. private _backgroundImage;
  72369. private _thumbImage;
  72370. private _thumbBaseImage;
  72371. private _thumbLength;
  72372. private _thumbHeight;
  72373. private _barImageHeight;
  72374. private _tempMeasure;
  72375. /**
  72376. * Gets or sets the image used to render the background for horizontal bar
  72377. */
  72378. get backgroundImage(): Image;
  72379. set backgroundImage(value: Image);
  72380. /**
  72381. * Gets or sets the image used to render the thumb
  72382. */
  72383. get thumbImage(): Image;
  72384. set thumbImage(value: Image);
  72385. /**
  72386. * Gets or sets the length of the thumb
  72387. */
  72388. get thumbLength(): number;
  72389. set thumbLength(value: number);
  72390. /**
  72391. * Gets or sets the height of the thumb
  72392. */
  72393. get thumbHeight(): number;
  72394. set thumbHeight(value: number);
  72395. /**
  72396. * Gets or sets the height of the bar image
  72397. */
  72398. get barImageHeight(): number;
  72399. set barImageHeight(value: number);
  72400. /**
  72401. * Creates a new ImageScrollBar
  72402. * @param name defines the control name
  72403. */
  72404. constructor(name?: string | undefined);
  72405. protected _getTypeName(): string;
  72406. protected _getThumbThickness(): number;
  72407. _draw(context: CanvasRenderingContext2D): void;
  72408. private _first;
  72409. private _originX;
  72410. private _originY;
  72411. /** @hidden */
  72412. protected _updateValueFromPointer(x: number, y: number): void;
  72413. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72414. }
  72415. }
  72416. declare module BABYLON.GUI {
  72417. /**
  72418. * Class used to hold a viewer window and sliders in a grid
  72419. */
  72420. export class ScrollViewer extends Rectangle {
  72421. private _grid;
  72422. private _horizontalBarSpace;
  72423. private _verticalBarSpace;
  72424. private _dragSpace;
  72425. private _horizontalBar;
  72426. private _verticalBar;
  72427. private _barColor;
  72428. private _barBackground;
  72429. private _barImage;
  72430. private _barBackgroundImage;
  72431. private _barSize;
  72432. private _endLeft;
  72433. private _endTop;
  72434. private _window;
  72435. private _pointerIsOver;
  72436. private _wheelPrecision;
  72437. private _onPointerObserver;
  72438. private _clientWidth;
  72439. private _clientHeight;
  72440. private _useImageBar;
  72441. private _thumbLength;
  72442. private _thumbHeight;
  72443. private _barImageHeight;
  72444. /**
  72445. * Gets the horizontal scrollbar
  72446. */
  72447. get horizontalBar(): ScrollBar | ImageScrollBar;
  72448. /**
  72449. * Gets the vertical scrollbar
  72450. */
  72451. get verticalBar(): ScrollBar | ImageScrollBar;
  72452. /**
  72453. * Adds a new control to the current container
  72454. * @param control defines the control to add
  72455. * @returns the current container
  72456. */
  72457. addControl(control: BABYLON.Nullable<Control>): Container;
  72458. /**
  72459. * Removes a control from the current container
  72460. * @param control defines the control to remove
  72461. * @returns the current container
  72462. */
  72463. removeControl(control: Control): Container;
  72464. /** Gets the list of children */
  72465. get children(): Control[];
  72466. _flagDescendantsAsMatrixDirty(): void;
  72467. /**
  72468. * Creates a new ScrollViewer
  72469. * @param name of ScrollViewer
  72470. */
  72471. constructor(name?: string, isImageBased?: boolean);
  72472. /** Reset the scroll viewer window to initial size */
  72473. resetWindow(): void;
  72474. protected _getTypeName(): string;
  72475. private _buildClientSizes;
  72476. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72477. protected _postMeasure(): void;
  72478. /**
  72479. * Gets or sets the mouse wheel precision
  72480. * from 0 to 1 with a default value of 0.05
  72481. * */
  72482. get wheelPrecision(): number;
  72483. set wheelPrecision(value: number);
  72484. /** Gets or sets the scroll bar container background color */
  72485. get scrollBackground(): string;
  72486. set scrollBackground(color: string);
  72487. /** Gets or sets the bar color */
  72488. get barColor(): string;
  72489. set barColor(color: string);
  72490. /** Gets or sets the bar image */
  72491. get thumbImage(): Image;
  72492. set thumbImage(value: Image);
  72493. /** Gets or sets the size of the bar */
  72494. get barSize(): number;
  72495. set barSize(value: number);
  72496. /** Gets or sets the length of the thumb */
  72497. get thumbLength(): number;
  72498. set thumbLength(value: number);
  72499. /** Gets or sets the height of the thumb */
  72500. get thumbHeight(): number;
  72501. set thumbHeight(value: number);
  72502. /** Gets or sets the height of the bar image */
  72503. get barImageHeight(): number;
  72504. set barImageHeight(value: number);
  72505. /** Gets or sets the bar background */
  72506. get barBackground(): string;
  72507. set barBackground(color: string);
  72508. /** Gets or sets the bar background image */
  72509. get barImage(): Image;
  72510. set barImage(value: Image);
  72511. /** @hidden */
  72512. private _updateScroller;
  72513. _link(host: AdvancedDynamicTexture): void;
  72514. /** @hidden */
  72515. private _addBar;
  72516. /** @hidden */
  72517. private _attachWheel;
  72518. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72519. /** Releases associated resources */
  72520. dispose(): void;
  72521. }
  72522. }
  72523. declare module BABYLON.GUI {
  72524. /** Class used to render a grid */
  72525. export class DisplayGrid extends Control {
  72526. name?: string | undefined;
  72527. private _cellWidth;
  72528. private _cellHeight;
  72529. private _minorLineTickness;
  72530. private _minorLineColor;
  72531. private _majorLineTickness;
  72532. private _majorLineColor;
  72533. private _majorLineFrequency;
  72534. private _background;
  72535. private _displayMajorLines;
  72536. private _displayMinorLines;
  72537. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  72538. get displayMinorLines(): boolean;
  72539. set displayMinorLines(value: boolean);
  72540. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  72541. get displayMajorLines(): boolean;
  72542. set displayMajorLines(value: boolean);
  72543. /** Gets or sets background color (Black by default) */
  72544. get background(): string;
  72545. set background(value: string);
  72546. /** Gets or sets the width of each cell (20 by default) */
  72547. get cellWidth(): number;
  72548. set cellWidth(value: number);
  72549. /** Gets or sets the height of each cell (20 by default) */
  72550. get cellHeight(): number;
  72551. set cellHeight(value: number);
  72552. /** Gets or sets the tickness of minor lines (1 by default) */
  72553. get minorLineTickness(): number;
  72554. set minorLineTickness(value: number);
  72555. /** Gets or sets the color of minor lines (DarkGray by default) */
  72556. get minorLineColor(): string;
  72557. set minorLineColor(value: string);
  72558. /** Gets or sets the tickness of major lines (2 by default) */
  72559. get majorLineTickness(): number;
  72560. set majorLineTickness(value: number);
  72561. /** Gets or sets the color of major lines (White by default) */
  72562. get majorLineColor(): string;
  72563. set majorLineColor(value: string);
  72564. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  72565. get majorLineFrequency(): number;
  72566. set majorLineFrequency(value: number);
  72567. /**
  72568. * Creates a new GridDisplayRectangle
  72569. * @param name defines the control name
  72570. */
  72571. constructor(name?: string | undefined);
  72572. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72573. protected _getTypeName(): string;
  72574. }
  72575. }
  72576. declare module BABYLON.GUI {
  72577. /**
  72578. * Class used to create slider controls based on images
  72579. */
  72580. export class ImageBasedSlider extends BaseSlider {
  72581. name?: string | undefined;
  72582. private _backgroundImage;
  72583. private _thumbImage;
  72584. private _valueBarImage;
  72585. private _tempMeasure;
  72586. get displayThumb(): boolean;
  72587. set displayThumb(value: boolean);
  72588. /**
  72589. * Gets or sets the image used to render the background
  72590. */
  72591. get backgroundImage(): Image;
  72592. set backgroundImage(value: Image);
  72593. /**
  72594. * Gets or sets the image used to render the value bar
  72595. */
  72596. get valueBarImage(): Image;
  72597. set valueBarImage(value: Image);
  72598. /**
  72599. * Gets or sets the image used to render the thumb
  72600. */
  72601. get thumbImage(): Image;
  72602. set thumbImage(value: Image);
  72603. /**
  72604. * Creates a new ImageBasedSlider
  72605. * @param name defines the control name
  72606. */
  72607. constructor(name?: string | undefined);
  72608. protected _getTypeName(): string;
  72609. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72610. }
  72611. }
  72612. declare module BABYLON.GUI {
  72613. /**
  72614. * Forcing an export so that this code will execute
  72615. * @hidden
  72616. */
  72617. const name = "Statics";
  72618. }
  72619. declare module BABYLON.GUI {
  72620. /**
  72621. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  72622. */
  72623. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  72624. /**
  72625. * Define the instrumented AdvancedDynamicTexture.
  72626. */
  72627. texture: AdvancedDynamicTexture;
  72628. private _captureRenderTime;
  72629. private _renderTime;
  72630. private _captureLayoutTime;
  72631. private _layoutTime;
  72632. private _onBeginRenderObserver;
  72633. private _onEndRenderObserver;
  72634. private _onBeginLayoutObserver;
  72635. private _onEndLayoutObserver;
  72636. /**
  72637. * Gets the perf counter used to capture render time
  72638. */
  72639. get renderTimeCounter(): BABYLON.PerfCounter;
  72640. /**
  72641. * Gets the perf counter used to capture layout time
  72642. */
  72643. get layoutTimeCounter(): BABYLON.PerfCounter;
  72644. /**
  72645. * Enable or disable the render time capture
  72646. */
  72647. get captureRenderTime(): boolean;
  72648. set captureRenderTime(value: boolean);
  72649. /**
  72650. * Enable or disable the layout time capture
  72651. */
  72652. get captureLayoutTime(): boolean;
  72653. set captureLayoutTime(value: boolean);
  72654. /**
  72655. * Instantiates a new advanced dynamic texture instrumentation.
  72656. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  72657. * @param texture Defines the AdvancedDynamicTexture to instrument
  72658. */
  72659. constructor(
  72660. /**
  72661. * Define the instrumented AdvancedDynamicTexture.
  72662. */
  72663. texture: AdvancedDynamicTexture);
  72664. /**
  72665. * Dispose and release associated resources.
  72666. */
  72667. dispose(): void;
  72668. }
  72669. }
  72670. declare module BABYLON.GUI {
  72671. /**
  72672. * Class used to load GUI via XML.
  72673. */
  72674. export class XmlLoader {
  72675. private _nodes;
  72676. private _nodeTypes;
  72677. private _isLoaded;
  72678. private _objectAttributes;
  72679. private _parentClass;
  72680. /**
  72681. * Create a new xml loader
  72682. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  72683. */
  72684. constructor(parentClass?: null);
  72685. private _getChainElement;
  72686. private _getClassAttribute;
  72687. private _createGuiElement;
  72688. private _parseGrid;
  72689. private _parseElement;
  72690. private _prepareSourceElement;
  72691. private _parseElementsFromSource;
  72692. private _parseXml;
  72693. /**
  72694. * Gets if the loading has finished.
  72695. * @returns whether the loading has finished or not
  72696. */
  72697. isLoaded(): boolean;
  72698. /**
  72699. * Gets a loaded node / control by id.
  72700. * @param id the Controls id set in the xml
  72701. * @returns element of type Control
  72702. */
  72703. getNodeById(id: string): any;
  72704. /**
  72705. * Gets all loaded nodes / controls
  72706. * @returns Array of controls
  72707. */
  72708. getNodes(): any;
  72709. /**
  72710. * Initiates the xml layout loading
  72711. * @param xmlFile defines the xml layout to load
  72712. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  72713. * @param callback defines the callback called on layout load.
  72714. */
  72715. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  72716. }
  72717. }
  72718. declare module BABYLON.GUI {
  72719. /**
  72720. * Class used to create containers for controls
  72721. */
  72722. export class Container3D extends Control3D {
  72723. private _blockLayout;
  72724. /**
  72725. * Gets the list of child controls
  72726. */
  72727. protected _children: Control3D[];
  72728. /**
  72729. * Gets the list of child controls
  72730. */
  72731. get children(): Array<Control3D>;
  72732. /**
  72733. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  72734. * This is helpful to optimize layout operation when adding multiple children in a row
  72735. */
  72736. get blockLayout(): boolean;
  72737. set blockLayout(value: boolean);
  72738. /**
  72739. * Creates a new container
  72740. * @param name defines the container name
  72741. */
  72742. constructor(name?: string);
  72743. /**
  72744. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  72745. * @returns the current container
  72746. */
  72747. updateLayout(): Container3D;
  72748. /**
  72749. * Gets a boolean indicating if the given control is in the children of this control
  72750. * @param control defines the control to check
  72751. * @returns true if the control is in the child list
  72752. */
  72753. containsControl(control: Control3D): boolean;
  72754. /**
  72755. * Adds a control to the children of this control
  72756. * @param control defines the control to add
  72757. * @returns the current container
  72758. */
  72759. addControl(control: Control3D): Container3D;
  72760. /**
  72761. * This function will be called everytime a new control is added
  72762. */
  72763. protected _arrangeChildren(): void;
  72764. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72765. /**
  72766. * Removes a control from the children of this control
  72767. * @param control defines the control to remove
  72768. * @returns the current container
  72769. */
  72770. removeControl(control: Control3D): Container3D;
  72771. protected _getTypeName(): string;
  72772. /**
  72773. * Releases all associated resources
  72774. */
  72775. dispose(): void;
  72776. /** Control rotation will remain unchanged */
  72777. static readonly UNSET_ORIENTATION: number;
  72778. /** Control will rotate to make it look at sphere central axis */
  72779. static readonly FACEORIGIN_ORIENTATION: number;
  72780. /** Control will rotate to make it look back at sphere central axis */
  72781. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  72782. /** Control will rotate to look at z axis (0, 0, 1) */
  72783. static readonly FACEFORWARD_ORIENTATION: number;
  72784. /** Control will rotate to look at negative z axis (0, 0, -1) */
  72785. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  72786. }
  72787. }
  72788. declare module BABYLON.GUI {
  72789. /**
  72790. * Class used to manage 3D user interface
  72791. * @see http://doc.babylonjs.com/how_to/gui3d
  72792. */
  72793. export class GUI3DManager implements BABYLON.IDisposable {
  72794. private _scene;
  72795. private _sceneDisposeObserver;
  72796. private _utilityLayer;
  72797. private _rootContainer;
  72798. private _pointerObserver;
  72799. private _pointerOutObserver;
  72800. /** @hidden */
  72801. _lastPickedControl: Control3D;
  72802. /** @hidden */
  72803. _lastControlOver: {
  72804. [pointerId: number]: Control3D;
  72805. };
  72806. /** @hidden */
  72807. _lastControlDown: {
  72808. [pointerId: number]: Control3D;
  72809. };
  72810. /**
  72811. * BABYLON.Observable raised when the point picked by the pointer events changed
  72812. */
  72813. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  72814. /** @hidden */
  72815. _sharedMaterials: {
  72816. [key: string]: BABYLON.Material;
  72817. };
  72818. /** Gets the hosting scene */
  72819. get scene(): BABYLON.Scene;
  72820. /** Gets associated utility layer */
  72821. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  72822. /**
  72823. * Creates a new GUI3DManager
  72824. * @param scene
  72825. */
  72826. constructor(scene?: BABYLON.Scene);
  72827. private _handlePointerOut;
  72828. private _doPicking;
  72829. /**
  72830. * Gets the root container
  72831. */
  72832. get rootContainer(): Container3D;
  72833. /**
  72834. * Gets a boolean indicating if the given control is in the root child list
  72835. * @param control defines the control to check
  72836. * @returns true if the control is in the root child list
  72837. */
  72838. containsControl(control: Control3D): boolean;
  72839. /**
  72840. * Adds a control to the root child list
  72841. * @param control defines the control to add
  72842. * @returns the current manager
  72843. */
  72844. addControl(control: Control3D): GUI3DManager;
  72845. /**
  72846. * Removes a control from the root child list
  72847. * @param control defines the control to remove
  72848. * @returns the current container
  72849. */
  72850. removeControl(control: Control3D): GUI3DManager;
  72851. /**
  72852. * Releases all associated resources
  72853. */
  72854. dispose(): void;
  72855. }
  72856. }
  72857. declare module BABYLON.GUI {
  72858. /**
  72859. * Class used to transport BABYLON.Vector3 information for pointer events
  72860. */
  72861. export class Vector3WithInfo extends BABYLON.Vector3 {
  72862. /** defines the current mouse button index */
  72863. buttonIndex: number;
  72864. /**
  72865. * Creates a new Vector3WithInfo
  72866. * @param source defines the vector3 data to transport
  72867. * @param buttonIndex defines the current mouse button index
  72868. */
  72869. constructor(source: BABYLON.Vector3,
  72870. /** defines the current mouse button index */
  72871. buttonIndex?: number);
  72872. }
  72873. }
  72874. declare module BABYLON.GUI {
  72875. /**
  72876. * Class used as base class for controls
  72877. */
  72878. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  72879. /** Defines the control name */
  72880. name?: string | undefined;
  72881. /** @hidden */
  72882. _host: GUI3DManager;
  72883. private _node;
  72884. private _downCount;
  72885. private _enterCount;
  72886. private _downPointerIds;
  72887. private _isVisible;
  72888. /** Gets or sets the control position in world space */
  72889. get position(): BABYLON.Vector3;
  72890. set position(value: BABYLON.Vector3);
  72891. /** Gets or sets the control scaling in world space */
  72892. get scaling(): BABYLON.Vector3;
  72893. set scaling(value: BABYLON.Vector3);
  72894. /** Callback used to start pointer enter animation */
  72895. pointerEnterAnimation: () => void;
  72896. /** Callback used to start pointer out animation */
  72897. pointerOutAnimation: () => void;
  72898. /** Callback used to start pointer down animation */
  72899. pointerDownAnimation: () => void;
  72900. /** Callback used to start pointer up animation */
  72901. pointerUpAnimation: () => void;
  72902. /**
  72903. * An event triggered when the pointer move over the control
  72904. */
  72905. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  72906. /**
  72907. * An event triggered when the pointer move out of the control
  72908. */
  72909. onPointerOutObservable: BABYLON.Observable<Control3D>;
  72910. /**
  72911. * An event triggered when the pointer taps the control
  72912. */
  72913. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  72914. /**
  72915. * An event triggered when pointer is up
  72916. */
  72917. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  72918. /**
  72919. * An event triggered when a control is clicked on (with a mouse)
  72920. */
  72921. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  72922. /**
  72923. * An event triggered when pointer enters the control
  72924. */
  72925. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  72926. /**
  72927. * Gets or sets the parent container
  72928. */
  72929. parent: BABYLON.Nullable<Container3D>;
  72930. private _behaviors;
  72931. /**
  72932. * Gets the list of attached behaviors
  72933. * @see http://doc.babylonjs.com/features/behaviour
  72934. */
  72935. get behaviors(): BABYLON.Behavior<Control3D>[];
  72936. /**
  72937. * Attach a behavior to the control
  72938. * @see http://doc.babylonjs.com/features/behaviour
  72939. * @param behavior defines the behavior to attach
  72940. * @returns the current control
  72941. */
  72942. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72943. /**
  72944. * Remove an attached behavior
  72945. * @see http://doc.babylonjs.com/features/behaviour
  72946. * @param behavior defines the behavior to attach
  72947. * @returns the current control
  72948. */
  72949. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72950. /**
  72951. * Gets an attached behavior by name
  72952. * @param name defines the name of the behavior to look for
  72953. * @see http://doc.babylonjs.com/features/behaviour
  72954. * @returns null if behavior was not found else the requested behavior
  72955. */
  72956. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  72957. /** Gets or sets a boolean indicating if the control is visible */
  72958. get isVisible(): boolean;
  72959. set isVisible(value: boolean);
  72960. /**
  72961. * Creates a new control
  72962. * @param name defines the control name
  72963. */
  72964. constructor(
  72965. /** Defines the control name */
  72966. name?: string | undefined);
  72967. /**
  72968. * Gets a string representing the class name
  72969. */
  72970. get typeName(): string;
  72971. /**
  72972. * Get the current class name of the control.
  72973. * @returns current class name
  72974. */
  72975. getClassName(): string;
  72976. protected _getTypeName(): string;
  72977. /**
  72978. * Gets the transform node used by this control
  72979. */
  72980. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  72981. /**
  72982. * Gets the mesh used to render this control
  72983. */
  72984. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72985. /**
  72986. * Link the control as child of the given node
  72987. * @param node defines the node to link to. Use null to unlink the control
  72988. * @returns the current control
  72989. */
  72990. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  72991. /** @hidden **/
  72992. _prepareNode(scene: BABYLON.Scene): void;
  72993. /**
  72994. * Node creation.
  72995. * Can be overriden by children
  72996. * @param scene defines the scene where the node must be attached
  72997. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  72998. */
  72999. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73000. /**
  73001. * Affect a material to the given mesh
  73002. * @param mesh defines the mesh which will represent the control
  73003. */
  73004. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73005. /** @hidden */
  73006. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73007. /** @hidden */
  73008. _onPointerEnter(target: Control3D): boolean;
  73009. /** @hidden */
  73010. _onPointerOut(target: Control3D): void;
  73011. /** @hidden */
  73012. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73013. /** @hidden */
  73014. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73015. /** @hidden */
  73016. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73017. /** @hidden */
  73018. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73019. /** @hidden */
  73020. _disposeNode(): void;
  73021. /**
  73022. * Releases all associated resources
  73023. */
  73024. dispose(): void;
  73025. }
  73026. }
  73027. declare module BABYLON.GUI {
  73028. /**
  73029. * Class used as a root to all buttons
  73030. */
  73031. export class AbstractButton3D extends Control3D {
  73032. /**
  73033. * Creates a new button
  73034. * @param name defines the control name
  73035. */
  73036. constructor(name?: string);
  73037. protected _getTypeName(): string;
  73038. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73039. }
  73040. }
  73041. declare module BABYLON.GUI {
  73042. /**
  73043. * Class used to create a button in 3D
  73044. */
  73045. export class Button3D extends AbstractButton3D {
  73046. /** @hidden */
  73047. protected _currentMaterial: BABYLON.Material;
  73048. private _facadeTexture;
  73049. private _content;
  73050. private _contentResolution;
  73051. private _contentScaleRatio;
  73052. /**
  73053. * Gets or sets the texture resolution used to render content (512 by default)
  73054. */
  73055. get contentResolution(): BABYLON.int;
  73056. set contentResolution(value: BABYLON.int);
  73057. /**
  73058. * Gets or sets the texture scale ratio used to render content (2 by default)
  73059. */
  73060. get contentScaleRatio(): number;
  73061. set contentScaleRatio(value: number);
  73062. protected _disposeFacadeTexture(): void;
  73063. protected _resetContent(): void;
  73064. /**
  73065. * Creates a new button
  73066. * @param name defines the control name
  73067. */
  73068. constructor(name?: string);
  73069. /**
  73070. * Gets or sets the GUI 2D content used to display the button's facade
  73071. */
  73072. get content(): Control;
  73073. set content(value: Control);
  73074. /**
  73075. * Apply the facade texture (created from the content property).
  73076. * This function can be overloaded by child classes
  73077. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73078. */
  73079. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73080. protected _getTypeName(): string;
  73081. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73082. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73083. /**
  73084. * Releases all associated resources
  73085. */
  73086. dispose(): void;
  73087. }
  73088. }
  73089. declare module BABYLON.GUI {
  73090. /**
  73091. * Abstract class used to create a container panel deployed on the surface of a volume
  73092. */
  73093. export abstract class VolumeBasedPanel extends Container3D {
  73094. private _columns;
  73095. private _rows;
  73096. private _rowThenColum;
  73097. private _orientation;
  73098. protected _cellWidth: number;
  73099. protected _cellHeight: number;
  73100. /**
  73101. * Gets or sets the distance between elements
  73102. */
  73103. margin: number;
  73104. /**
  73105. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73106. * | Value | Type | Description |
  73107. * | ----- | ----------------------------------- | ----------- |
  73108. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73109. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73110. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73111. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73112. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73113. */
  73114. get orientation(): number;
  73115. set orientation(value: number);
  73116. /**
  73117. * Gets or sets the number of columns requested (10 by default).
  73118. * The panel will automatically compute the number of rows based on number of child controls.
  73119. */
  73120. get columns(): BABYLON.int;
  73121. set columns(value: BABYLON.int);
  73122. /**
  73123. * Gets or sets a the number of rows requested.
  73124. * The panel will automatically compute the number of columns based on number of child controls.
  73125. */
  73126. get rows(): BABYLON.int;
  73127. set rows(value: BABYLON.int);
  73128. /**
  73129. * Creates new VolumeBasedPanel
  73130. */
  73131. constructor();
  73132. protected _arrangeChildren(): void;
  73133. /** Child classes must implement this function to provide correct control positioning */
  73134. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73135. /** Child classes can implement this function to provide additional processing */
  73136. protected _finalProcessing(): void;
  73137. }
  73138. }
  73139. declare module BABYLON.GUI {
  73140. /**
  73141. * Class used to create a container panel deployed on the surface of a cylinder
  73142. */
  73143. export class CylinderPanel extends VolumeBasedPanel {
  73144. private _radius;
  73145. /**
  73146. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73147. */
  73148. get radius(): BABYLON.float;
  73149. set radius(value: BABYLON.float);
  73150. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73151. private _cylindricalMapping;
  73152. }
  73153. }
  73154. declare module BABYLON.GUI {
  73155. /** @hidden */
  73156. export var fluentVertexShader: {
  73157. name: string;
  73158. shader: string;
  73159. };
  73160. }
  73161. declare module BABYLON.GUI {
  73162. /** @hidden */
  73163. export var fluentPixelShader: {
  73164. name: string;
  73165. shader: string;
  73166. };
  73167. }
  73168. declare module BABYLON.GUI {
  73169. /** @hidden */
  73170. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73171. INNERGLOW: boolean;
  73172. BORDER: boolean;
  73173. HOVERLIGHT: boolean;
  73174. TEXTURE: boolean;
  73175. constructor();
  73176. }
  73177. /**
  73178. * Class used to render controls with fluent desgin
  73179. */
  73180. export class FluentMaterial extends BABYLON.PushMaterial {
  73181. /**
  73182. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73183. */
  73184. innerGlowColorIntensity: number;
  73185. /**
  73186. * Gets or sets the inner glow color (white by default)
  73187. */
  73188. innerGlowColor: BABYLON.Color3;
  73189. /**
  73190. * Gets or sets alpha value (default is 1.0)
  73191. */
  73192. alpha: number;
  73193. /**
  73194. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73195. */
  73196. albedoColor: BABYLON.Color3;
  73197. /**
  73198. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73199. */
  73200. renderBorders: boolean;
  73201. /**
  73202. * Gets or sets border width (default is 0.5)
  73203. */
  73204. borderWidth: number;
  73205. /**
  73206. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73207. */
  73208. edgeSmoothingValue: number;
  73209. /**
  73210. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73211. */
  73212. borderMinValue: number;
  73213. /**
  73214. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73215. */
  73216. renderHoverLight: boolean;
  73217. /**
  73218. * Gets or sets the radius used to render the hover light (default is 1.0)
  73219. */
  73220. hoverRadius: number;
  73221. /**
  73222. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73223. */
  73224. hoverColor: BABYLON.Color4;
  73225. /**
  73226. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73227. */
  73228. hoverPosition: BABYLON.Vector3;
  73229. private _albedoTexture;
  73230. /** Gets or sets the texture to use for albedo color */
  73231. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73232. /**
  73233. * Creates a new Fluent material
  73234. * @param name defines the name of the material
  73235. * @param scene defines the hosting scene
  73236. */
  73237. constructor(name: string, scene: BABYLON.Scene);
  73238. needAlphaBlending(): boolean;
  73239. needAlphaTesting(): boolean;
  73240. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73241. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73242. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73243. getActiveTextures(): BABYLON.BaseTexture[];
  73244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73245. dispose(forceDisposeEffect?: boolean): void;
  73246. clone(name: string): FluentMaterial;
  73247. serialize(): any;
  73248. getClassName(): string;
  73249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73250. }
  73251. }
  73252. declare module BABYLON.GUI {
  73253. /**
  73254. * Class used to create a holographic button in 3D
  73255. */
  73256. export class HolographicButton extends Button3D {
  73257. private _backPlate;
  73258. private _textPlate;
  73259. private _frontPlate;
  73260. private _text;
  73261. private _imageUrl;
  73262. private _shareMaterials;
  73263. private _frontMaterial;
  73264. private _backMaterial;
  73265. private _plateMaterial;
  73266. private _pickedPointObserver;
  73267. private _tooltipFade;
  73268. private _tooltipTextBlock;
  73269. private _tooltipTexture;
  73270. private _tooltipMesh;
  73271. private _tooltipHoverObserver;
  73272. private _tooltipOutObserver;
  73273. private _disposeTooltip;
  73274. /**
  73275. * Rendering ground id of all the mesh in the button
  73276. */
  73277. set renderingGroupId(id: number);
  73278. get renderingGroupId(): number;
  73279. /**
  73280. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73281. */
  73282. set tooltipText(text: BABYLON.Nullable<string>);
  73283. get tooltipText(): BABYLON.Nullable<string>;
  73284. /**
  73285. * Gets or sets text for the button
  73286. */
  73287. get text(): string;
  73288. set text(value: string);
  73289. /**
  73290. * Gets or sets the image url for the button
  73291. */
  73292. get imageUrl(): string;
  73293. set imageUrl(value: string);
  73294. /**
  73295. * Gets the back material used by this button
  73296. */
  73297. get backMaterial(): FluentMaterial;
  73298. /**
  73299. * Gets the front material used by this button
  73300. */
  73301. get frontMaterial(): FluentMaterial;
  73302. /**
  73303. * Gets the plate material used by this button
  73304. */
  73305. get plateMaterial(): BABYLON.StandardMaterial;
  73306. /**
  73307. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73308. */
  73309. get shareMaterials(): boolean;
  73310. /**
  73311. * Creates a new button
  73312. * @param name defines the control name
  73313. */
  73314. constructor(name?: string, shareMaterials?: boolean);
  73315. protected _getTypeName(): string;
  73316. private _rebuildContent;
  73317. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73318. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73319. private _createBackMaterial;
  73320. private _createFrontMaterial;
  73321. private _createPlateMaterial;
  73322. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73323. /**
  73324. * Releases all associated resources
  73325. */
  73326. dispose(): void;
  73327. }
  73328. }
  73329. declare module BABYLON.GUI {
  73330. /**
  73331. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73332. */
  73333. export class MeshButton3D extends Button3D {
  73334. /** @hidden */
  73335. protected _currentMesh: BABYLON.Mesh;
  73336. /**
  73337. * Creates a new 3D button based on a mesh
  73338. * @param mesh mesh to become a 3D button
  73339. * @param name defines the control name
  73340. */
  73341. constructor(mesh: BABYLON.Mesh, name?: string);
  73342. protected _getTypeName(): string;
  73343. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73344. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73345. }
  73346. }
  73347. declare module BABYLON.GUI {
  73348. /**
  73349. * Class used to create a container panel deployed on the surface of a plane
  73350. */
  73351. export class PlanePanel extends VolumeBasedPanel {
  73352. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73353. }
  73354. }
  73355. declare module BABYLON.GUI {
  73356. /**
  73357. * Class used to create a container panel where items get randomized planar mapping
  73358. */
  73359. export class ScatterPanel extends VolumeBasedPanel {
  73360. private _iteration;
  73361. /**
  73362. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73363. */
  73364. get iteration(): BABYLON.float;
  73365. set iteration(value: BABYLON.float);
  73366. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73367. private _scatterMapping;
  73368. protected _finalProcessing(): void;
  73369. }
  73370. }
  73371. declare module BABYLON.GUI {
  73372. /**
  73373. * Class used to create a container panel deployed on the surface of a sphere
  73374. */
  73375. export class SpherePanel extends VolumeBasedPanel {
  73376. private _radius;
  73377. /**
  73378. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73379. */
  73380. get radius(): BABYLON.float;
  73381. set radius(value: BABYLON.float);
  73382. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73383. private _sphericalMapping;
  73384. }
  73385. }
  73386. declare module BABYLON.GUI {
  73387. /**
  73388. * Class used to create a stack panel in 3D on XY plane
  73389. */
  73390. export class StackPanel3D extends Container3D {
  73391. private _isVertical;
  73392. /**
  73393. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  73394. */
  73395. get isVertical(): boolean;
  73396. set isVertical(value: boolean);
  73397. /**
  73398. * Gets or sets the distance between elements
  73399. */
  73400. margin: number;
  73401. /**
  73402. * Creates new StackPanel
  73403. * @param isVertical
  73404. */
  73405. constructor(isVertical?: boolean);
  73406. protected _arrangeChildren(): void;
  73407. }
  73408. }
  73409. declare module BABYLON {
  73410. /**
  73411. * Configuration for glTF validation
  73412. */
  73413. export interface IGLTFValidationConfiguration {
  73414. /**
  73415. * The url of the glTF validator.
  73416. */
  73417. url: string;
  73418. }
  73419. /**
  73420. * glTF validation
  73421. */
  73422. export class GLTFValidation {
  73423. /**
  73424. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  73425. */
  73426. static Configuration: IGLTFValidationConfiguration;
  73427. private static _LoadScriptPromise;
  73428. /**
  73429. * Validate a glTF asset using the glTF-Validator.
  73430. * @param data The JSON of a glTF or the array buffer of a binary glTF
  73431. * @param rootUrl The root url for the glTF
  73432. * @param fileName The file name for the glTF
  73433. * @param getExternalResource The callback to get external resources for the glTF validator
  73434. * @returns A promise that resolves with the glTF validation results once complete
  73435. */
  73436. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  73437. }
  73438. }
  73439. declare module BABYLON {
  73440. /**
  73441. * Mode that determines the coordinate system to use.
  73442. */
  73443. export enum GLTFLoaderCoordinateSystemMode {
  73444. /**
  73445. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  73446. */
  73447. AUTO = 0,
  73448. /**
  73449. * Sets the useRightHandedSystem flag on the scene.
  73450. */
  73451. FORCE_RIGHT_HANDED = 1
  73452. }
  73453. /**
  73454. * Mode that determines what animations will start.
  73455. */
  73456. export enum GLTFLoaderAnimationStartMode {
  73457. /**
  73458. * No animation will start.
  73459. */
  73460. NONE = 0,
  73461. /**
  73462. * The first animation will start.
  73463. */
  73464. FIRST = 1,
  73465. /**
  73466. * All animations will start.
  73467. */
  73468. ALL = 2
  73469. }
  73470. /**
  73471. * Interface that contains the data for the glTF asset.
  73472. */
  73473. export interface IGLTFLoaderData {
  73474. /**
  73475. * The object that represents the glTF JSON.
  73476. */
  73477. json: Object;
  73478. /**
  73479. * The BIN chunk of a binary glTF.
  73480. */
  73481. bin: Nullable<IDataBuffer>;
  73482. }
  73483. /**
  73484. * Interface for extending the loader.
  73485. */
  73486. export interface IGLTFLoaderExtension {
  73487. /**
  73488. * The name of this extension.
  73489. */
  73490. readonly name: string;
  73491. /**
  73492. * Defines whether this extension is enabled.
  73493. */
  73494. enabled: boolean;
  73495. /**
  73496. * Defines the order of this extension.
  73497. * The loader sorts the extensions using these values when loading.
  73498. */
  73499. order?: number;
  73500. }
  73501. /**
  73502. * Loader state.
  73503. */
  73504. export enum GLTFLoaderState {
  73505. /**
  73506. * The asset is loading.
  73507. */
  73508. LOADING = 0,
  73509. /**
  73510. * The asset is ready for rendering.
  73511. */
  73512. READY = 1,
  73513. /**
  73514. * The asset is completely loaded.
  73515. */
  73516. COMPLETE = 2
  73517. }
  73518. /** @hidden */
  73519. export interface IGLTFLoader extends IDisposable {
  73520. readonly state: Nullable<GLTFLoaderState>;
  73521. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  73522. meshes: AbstractMesh[];
  73523. particleSystems: IParticleSystem[];
  73524. skeletons: Skeleton[];
  73525. animationGroups: AnimationGroup[];
  73526. }>;
  73527. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  73528. }
  73529. /**
  73530. * File loader for loading glTF files into a scene.
  73531. */
  73532. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73533. /** @hidden */
  73534. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73535. /** @hidden */
  73536. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73537. /**
  73538. * Raised when the asset has been parsed
  73539. */
  73540. onParsedObservable: Observable<IGLTFLoaderData>;
  73541. private _onParsedObserver;
  73542. /**
  73543. * Raised when the asset has been parsed
  73544. */
  73545. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  73546. /**
  73547. * 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.
  73548. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  73549. * Defaults to true.
  73550. * @hidden
  73551. */
  73552. static IncrementalLoading: boolean;
  73553. /**
  73554. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  73555. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  73556. * @hidden
  73557. */
  73558. static HomogeneousCoordinates: boolean;
  73559. /**
  73560. * The coordinate system mode. Defaults to AUTO.
  73561. */
  73562. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  73563. /**
  73564. * The animation start mode. Defaults to FIRST.
  73565. */
  73566. animationStartMode: GLTFLoaderAnimationStartMode;
  73567. /**
  73568. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  73569. */
  73570. compileMaterials: boolean;
  73571. /**
  73572. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  73573. */
  73574. useClipPlane: boolean;
  73575. /**
  73576. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  73577. */
  73578. compileShadowGenerators: boolean;
  73579. /**
  73580. * Defines if the Alpha blended materials are only applied as coverage.
  73581. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  73582. * If true, no extra effects are applied to transparent pixels.
  73583. */
  73584. transparencyAsCoverage: boolean;
  73585. /**
  73586. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  73587. * Enabling will disable offline support and glTF validator.
  73588. * Defaults to false.
  73589. */
  73590. useRangeRequests: boolean;
  73591. /**
  73592. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  73593. */
  73594. createInstances: boolean;
  73595. /**
  73596. * Function called before loading a url referenced by the asset.
  73597. */
  73598. preprocessUrlAsync: (url: string) => Promise<string>;
  73599. /**
  73600. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73601. */
  73602. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  73603. private _onMeshLoadedObserver;
  73604. /**
  73605. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73606. */
  73607. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  73608. /**
  73609. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  73610. */
  73611. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  73612. private _onTextureLoadedObserver;
  73613. /**
  73614. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  73615. */
  73616. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  73617. /**
  73618. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  73619. */
  73620. readonly onMaterialLoadedObservable: Observable<Material>;
  73621. private _onMaterialLoadedObserver;
  73622. /**
  73623. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  73624. */
  73625. set onMaterialLoaded(callback: (material: Material) => void);
  73626. /**
  73627. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  73628. */
  73629. readonly onCameraLoadedObservable: Observable<Camera>;
  73630. private _onCameraLoadedObserver;
  73631. /**
  73632. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  73633. */
  73634. set onCameraLoaded(callback: (camera: Camera) => void);
  73635. /**
  73636. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  73637. * For assets with LODs, raised when all of the LODs are complete.
  73638. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73639. */
  73640. readonly onCompleteObservable: Observable<void>;
  73641. private _onCompleteObserver;
  73642. /**
  73643. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  73644. * For assets with LODs, raised when all of the LODs are complete.
  73645. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73646. */
  73647. set onComplete(callback: () => void);
  73648. /**
  73649. * Observable raised when an error occurs.
  73650. */
  73651. readonly onErrorObservable: Observable<any>;
  73652. private _onErrorObserver;
  73653. /**
  73654. * Callback raised when an error occurs.
  73655. */
  73656. set onError(callback: (reason: any) => void);
  73657. /**
  73658. * Observable raised after the loader is disposed.
  73659. */
  73660. readonly onDisposeObservable: Observable<void>;
  73661. private _onDisposeObserver;
  73662. /**
  73663. * Callback raised after the loader is disposed.
  73664. */
  73665. set onDispose(callback: () => void);
  73666. /**
  73667. * Observable raised after a loader extension is created.
  73668. * Set additional options for a loader extension in this event.
  73669. */
  73670. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  73671. private _onExtensionLoadedObserver;
  73672. /**
  73673. * Callback raised after a loader extension is created.
  73674. */
  73675. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  73676. /**
  73677. * Defines if the loader logging is enabled.
  73678. */
  73679. get loggingEnabled(): boolean;
  73680. set loggingEnabled(value: boolean);
  73681. /**
  73682. * Defines if the loader should capture performance counters.
  73683. */
  73684. get capturePerformanceCounters(): boolean;
  73685. set capturePerformanceCounters(value: boolean);
  73686. /**
  73687. * Defines if the loader should validate the asset.
  73688. */
  73689. validate: boolean;
  73690. /**
  73691. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  73692. */
  73693. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  73694. private _onValidatedObserver;
  73695. /**
  73696. * Callback raised after a loader extension is created.
  73697. */
  73698. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  73699. private _loader;
  73700. /**
  73701. * Name of the loader ("gltf")
  73702. */
  73703. name: string;
  73704. /** @hidden */
  73705. extensions: ISceneLoaderPluginExtensions;
  73706. /**
  73707. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  73708. */
  73709. dispose(): void;
  73710. /** @hidden */
  73711. _clear(): void;
  73712. /** @hidden */
  73713. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73714. /** @hidden */
  73715. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73716. /** @hidden */
  73717. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73718. meshes: AbstractMesh[];
  73719. particleSystems: IParticleSystem[];
  73720. skeletons: Skeleton[];
  73721. animationGroups: AnimationGroup[];
  73722. }>;
  73723. /** @hidden */
  73724. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73725. /** @hidden */
  73726. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73727. /** @hidden */
  73728. canDirectLoad(data: string): boolean;
  73729. /** @hidden */
  73730. directLoad(scene: Scene, data: string): any;
  73731. /**
  73732. * The callback that allows custom handling of the root url based on the response url.
  73733. * @param rootUrl the original root url
  73734. * @param responseURL the response url if available
  73735. * @returns the new root url
  73736. */
  73737. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  73738. /** @hidden */
  73739. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  73740. /**
  73741. * The loader state or null if the loader is not active.
  73742. */
  73743. get loaderState(): Nullable<GLTFLoaderState>;
  73744. /**
  73745. * Returns a promise that resolves when the asset is completely loaded.
  73746. * @returns a promise that resolves when the asset is completely loaded.
  73747. */
  73748. whenCompleteAsync(): Promise<void>;
  73749. private _validate;
  73750. private _getLoader;
  73751. private _parseJson;
  73752. private _unpackBinaryAsync;
  73753. private _unpackBinaryV1Async;
  73754. private _unpackBinaryV2Async;
  73755. private static _parseVersion;
  73756. private static _compareVersion;
  73757. private static readonly _logSpaces;
  73758. private _logIndentLevel;
  73759. private _loggingEnabled;
  73760. /** @hidden */
  73761. _log: (message: string) => void;
  73762. /** @hidden */
  73763. _logOpen(message: string): void;
  73764. /** @hidden */
  73765. _logClose(): void;
  73766. private _logEnabled;
  73767. private _logDisabled;
  73768. private _capturePerformanceCounters;
  73769. /** @hidden */
  73770. _startPerformanceCounter: (counterName: string) => void;
  73771. /** @hidden */
  73772. _endPerformanceCounter: (counterName: string) => void;
  73773. private _startPerformanceCounterEnabled;
  73774. private _startPerformanceCounterDisabled;
  73775. private _endPerformanceCounterEnabled;
  73776. private _endPerformanceCounterDisabled;
  73777. }
  73778. }
  73779. declare module BABYLON.GLTF1 {
  73780. /**
  73781. * Enums
  73782. * @hidden
  73783. */
  73784. export enum EComponentType {
  73785. BYTE = 5120,
  73786. UNSIGNED_BYTE = 5121,
  73787. SHORT = 5122,
  73788. UNSIGNED_SHORT = 5123,
  73789. FLOAT = 5126
  73790. }
  73791. /** @hidden */
  73792. export enum EShaderType {
  73793. FRAGMENT = 35632,
  73794. VERTEX = 35633
  73795. }
  73796. /** @hidden */
  73797. export enum EParameterType {
  73798. BYTE = 5120,
  73799. UNSIGNED_BYTE = 5121,
  73800. SHORT = 5122,
  73801. UNSIGNED_SHORT = 5123,
  73802. INT = 5124,
  73803. UNSIGNED_INT = 5125,
  73804. FLOAT = 5126,
  73805. FLOAT_VEC2 = 35664,
  73806. FLOAT_VEC3 = 35665,
  73807. FLOAT_VEC4 = 35666,
  73808. INT_VEC2 = 35667,
  73809. INT_VEC3 = 35668,
  73810. INT_VEC4 = 35669,
  73811. BOOL = 35670,
  73812. BOOL_VEC2 = 35671,
  73813. BOOL_VEC3 = 35672,
  73814. BOOL_VEC4 = 35673,
  73815. FLOAT_MAT2 = 35674,
  73816. FLOAT_MAT3 = 35675,
  73817. FLOAT_MAT4 = 35676,
  73818. SAMPLER_2D = 35678
  73819. }
  73820. /** @hidden */
  73821. export enum ETextureWrapMode {
  73822. CLAMP_TO_EDGE = 33071,
  73823. MIRRORED_REPEAT = 33648,
  73824. REPEAT = 10497
  73825. }
  73826. /** @hidden */
  73827. export enum ETextureFilterType {
  73828. NEAREST = 9728,
  73829. LINEAR = 9728,
  73830. NEAREST_MIPMAP_NEAREST = 9984,
  73831. LINEAR_MIPMAP_NEAREST = 9985,
  73832. NEAREST_MIPMAP_LINEAR = 9986,
  73833. LINEAR_MIPMAP_LINEAR = 9987
  73834. }
  73835. /** @hidden */
  73836. export enum ETextureFormat {
  73837. ALPHA = 6406,
  73838. RGB = 6407,
  73839. RGBA = 6408,
  73840. LUMINANCE = 6409,
  73841. LUMINANCE_ALPHA = 6410
  73842. }
  73843. /** @hidden */
  73844. export enum ECullingType {
  73845. FRONT = 1028,
  73846. BACK = 1029,
  73847. FRONT_AND_BACK = 1032
  73848. }
  73849. /** @hidden */
  73850. export enum EBlendingFunction {
  73851. ZERO = 0,
  73852. ONE = 1,
  73853. SRC_COLOR = 768,
  73854. ONE_MINUS_SRC_COLOR = 769,
  73855. DST_COLOR = 774,
  73856. ONE_MINUS_DST_COLOR = 775,
  73857. SRC_ALPHA = 770,
  73858. ONE_MINUS_SRC_ALPHA = 771,
  73859. DST_ALPHA = 772,
  73860. ONE_MINUS_DST_ALPHA = 773,
  73861. CONSTANT_COLOR = 32769,
  73862. ONE_MINUS_CONSTANT_COLOR = 32770,
  73863. CONSTANT_ALPHA = 32771,
  73864. ONE_MINUS_CONSTANT_ALPHA = 32772,
  73865. SRC_ALPHA_SATURATE = 776
  73866. }
  73867. /** @hidden */
  73868. export interface IGLTFProperty {
  73869. extensions?: {
  73870. [key: string]: any;
  73871. };
  73872. extras?: Object;
  73873. }
  73874. /** @hidden */
  73875. export interface IGLTFChildRootProperty extends IGLTFProperty {
  73876. name?: string;
  73877. }
  73878. /** @hidden */
  73879. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  73880. bufferView: string;
  73881. byteOffset: number;
  73882. byteStride: number;
  73883. count: number;
  73884. type: string;
  73885. componentType: EComponentType;
  73886. max?: number[];
  73887. min?: number[];
  73888. name?: string;
  73889. }
  73890. /** @hidden */
  73891. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  73892. buffer: string;
  73893. byteOffset: number;
  73894. byteLength: number;
  73895. byteStride: number;
  73896. target?: number;
  73897. }
  73898. /** @hidden */
  73899. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  73900. uri: string;
  73901. byteLength?: number;
  73902. type?: string;
  73903. }
  73904. /** @hidden */
  73905. export interface IGLTFShader extends IGLTFChildRootProperty {
  73906. uri: string;
  73907. type: EShaderType;
  73908. }
  73909. /** @hidden */
  73910. export interface IGLTFProgram extends IGLTFChildRootProperty {
  73911. attributes: string[];
  73912. fragmentShader: string;
  73913. vertexShader: string;
  73914. }
  73915. /** @hidden */
  73916. export interface IGLTFTechniqueParameter {
  73917. type: number;
  73918. count?: number;
  73919. semantic?: string;
  73920. node?: string;
  73921. value?: number | boolean | string | Array<any>;
  73922. source?: string;
  73923. babylonValue?: any;
  73924. }
  73925. /** @hidden */
  73926. export interface IGLTFTechniqueCommonProfile {
  73927. lightingModel: string;
  73928. texcoordBindings: Object;
  73929. parameters?: Array<any>;
  73930. }
  73931. /** @hidden */
  73932. export interface IGLTFTechniqueStatesFunctions {
  73933. blendColor?: number[];
  73934. blendEquationSeparate?: number[];
  73935. blendFuncSeparate?: number[];
  73936. colorMask: boolean[];
  73937. cullFace: number[];
  73938. }
  73939. /** @hidden */
  73940. export interface IGLTFTechniqueStates {
  73941. enable: number[];
  73942. functions: IGLTFTechniqueStatesFunctions;
  73943. }
  73944. /** @hidden */
  73945. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  73946. parameters: {
  73947. [key: string]: IGLTFTechniqueParameter;
  73948. };
  73949. program: string;
  73950. attributes: {
  73951. [key: string]: string;
  73952. };
  73953. uniforms: {
  73954. [key: string]: string;
  73955. };
  73956. states: IGLTFTechniqueStates;
  73957. }
  73958. /** @hidden */
  73959. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  73960. technique?: string;
  73961. values: string[];
  73962. }
  73963. /** @hidden */
  73964. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  73965. attributes: {
  73966. [key: string]: string;
  73967. };
  73968. indices: string;
  73969. material: string;
  73970. mode?: number;
  73971. }
  73972. /** @hidden */
  73973. export interface IGLTFMesh extends IGLTFChildRootProperty {
  73974. primitives: IGLTFMeshPrimitive[];
  73975. }
  73976. /** @hidden */
  73977. export interface IGLTFImage extends IGLTFChildRootProperty {
  73978. uri: string;
  73979. }
  73980. /** @hidden */
  73981. export interface IGLTFSampler extends IGLTFChildRootProperty {
  73982. magFilter?: number;
  73983. minFilter?: number;
  73984. wrapS?: number;
  73985. wrapT?: number;
  73986. }
  73987. /** @hidden */
  73988. export interface IGLTFTexture extends IGLTFChildRootProperty {
  73989. sampler: string;
  73990. source: string;
  73991. format?: ETextureFormat;
  73992. internalFormat?: ETextureFormat;
  73993. target?: number;
  73994. type?: number;
  73995. babylonTexture?: Texture;
  73996. }
  73997. /** @hidden */
  73998. export interface IGLTFAmbienLight {
  73999. color?: number[];
  74000. }
  74001. /** @hidden */
  74002. export interface IGLTFDirectionalLight {
  74003. color?: number[];
  74004. }
  74005. /** @hidden */
  74006. export interface IGLTFPointLight {
  74007. color?: number[];
  74008. constantAttenuation?: number;
  74009. linearAttenuation?: number;
  74010. quadraticAttenuation?: number;
  74011. }
  74012. /** @hidden */
  74013. export interface IGLTFSpotLight {
  74014. color?: number[];
  74015. constantAttenuation?: number;
  74016. fallOfAngle?: number;
  74017. fallOffExponent?: number;
  74018. linearAttenuation?: number;
  74019. quadraticAttenuation?: number;
  74020. }
  74021. /** @hidden */
  74022. export interface IGLTFLight extends IGLTFChildRootProperty {
  74023. type: string;
  74024. }
  74025. /** @hidden */
  74026. export interface IGLTFCameraOrthographic {
  74027. xmag: number;
  74028. ymag: number;
  74029. zfar: number;
  74030. znear: number;
  74031. }
  74032. /** @hidden */
  74033. export interface IGLTFCameraPerspective {
  74034. aspectRatio: number;
  74035. yfov: number;
  74036. zfar: number;
  74037. znear: number;
  74038. }
  74039. /** @hidden */
  74040. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74041. type: string;
  74042. }
  74043. /** @hidden */
  74044. export interface IGLTFAnimationChannelTarget {
  74045. id: string;
  74046. path: string;
  74047. }
  74048. /** @hidden */
  74049. export interface IGLTFAnimationChannel {
  74050. sampler: string;
  74051. target: IGLTFAnimationChannelTarget;
  74052. }
  74053. /** @hidden */
  74054. export interface IGLTFAnimationSampler {
  74055. input: string;
  74056. output: string;
  74057. interpolation?: string;
  74058. }
  74059. /** @hidden */
  74060. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74061. channels?: IGLTFAnimationChannel[];
  74062. parameters?: {
  74063. [key: string]: string;
  74064. };
  74065. samplers?: {
  74066. [key: string]: IGLTFAnimationSampler;
  74067. };
  74068. }
  74069. /** @hidden */
  74070. export interface IGLTFNodeInstanceSkin {
  74071. skeletons: string[];
  74072. skin: string;
  74073. meshes: string[];
  74074. }
  74075. /** @hidden */
  74076. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74077. bindShapeMatrix: number[];
  74078. inverseBindMatrices: string;
  74079. jointNames: string[];
  74080. babylonSkeleton?: Skeleton;
  74081. }
  74082. /** @hidden */
  74083. export interface IGLTFNode extends IGLTFChildRootProperty {
  74084. camera?: string;
  74085. children: string[];
  74086. skin?: string;
  74087. jointName?: string;
  74088. light?: string;
  74089. matrix: number[];
  74090. mesh?: string;
  74091. meshes?: string[];
  74092. rotation?: number[];
  74093. scale?: number[];
  74094. translation?: number[];
  74095. babylonNode?: Node;
  74096. }
  74097. /** @hidden */
  74098. export interface IGLTFScene extends IGLTFChildRootProperty {
  74099. nodes: string[];
  74100. }
  74101. /** @hidden */
  74102. export interface IGLTFRuntime {
  74103. extensions: {
  74104. [key: string]: any;
  74105. };
  74106. accessors: {
  74107. [key: string]: IGLTFAccessor;
  74108. };
  74109. buffers: {
  74110. [key: string]: IGLTFBuffer;
  74111. };
  74112. bufferViews: {
  74113. [key: string]: IGLTFBufferView;
  74114. };
  74115. meshes: {
  74116. [key: string]: IGLTFMesh;
  74117. };
  74118. lights: {
  74119. [key: string]: IGLTFLight;
  74120. };
  74121. cameras: {
  74122. [key: string]: IGLTFCamera;
  74123. };
  74124. nodes: {
  74125. [key: string]: IGLTFNode;
  74126. };
  74127. images: {
  74128. [key: string]: IGLTFImage;
  74129. };
  74130. textures: {
  74131. [key: string]: IGLTFTexture;
  74132. };
  74133. shaders: {
  74134. [key: string]: IGLTFShader;
  74135. };
  74136. programs: {
  74137. [key: string]: IGLTFProgram;
  74138. };
  74139. samplers: {
  74140. [key: string]: IGLTFSampler;
  74141. };
  74142. techniques: {
  74143. [key: string]: IGLTFTechnique;
  74144. };
  74145. materials: {
  74146. [key: string]: IGLTFMaterial;
  74147. };
  74148. animations: {
  74149. [key: string]: IGLTFAnimation;
  74150. };
  74151. skins: {
  74152. [key: string]: IGLTFSkins;
  74153. };
  74154. currentScene?: Object;
  74155. scenes: {
  74156. [key: string]: IGLTFScene;
  74157. };
  74158. extensionsUsed: string[];
  74159. extensionsRequired?: string[];
  74160. buffersCount: number;
  74161. shaderscount: number;
  74162. scene: Scene;
  74163. rootUrl: string;
  74164. loadedBufferCount: number;
  74165. loadedBufferViews: {
  74166. [name: string]: ArrayBufferView;
  74167. };
  74168. loadedShaderCount: number;
  74169. importOnlyMeshes: boolean;
  74170. importMeshesNames?: string[];
  74171. dummyNodes: Node[];
  74172. }
  74173. /** @hidden */
  74174. export interface INodeToRoot {
  74175. bone: Bone;
  74176. node: IGLTFNode;
  74177. id: string;
  74178. }
  74179. /** @hidden */
  74180. export interface IJointNode {
  74181. node: IGLTFNode;
  74182. id: string;
  74183. }
  74184. }
  74185. declare module BABYLON.GLTF1 {
  74186. /**
  74187. * Utils functions for GLTF
  74188. * @hidden
  74189. */
  74190. export class GLTFUtils {
  74191. /**
  74192. * Sets the given "parameter" matrix
  74193. * @param scene: the Scene object
  74194. * @param source: the source node where to pick the matrix
  74195. * @param parameter: the GLTF technique parameter
  74196. * @param uniformName: the name of the shader's uniform
  74197. * @param shaderMaterial: the shader material
  74198. */
  74199. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74200. /**
  74201. * Sets the given "parameter" matrix
  74202. * @param shaderMaterial: the shader material
  74203. * @param uniform: the name of the shader's uniform
  74204. * @param value: the value of the uniform
  74205. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74206. */
  74207. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74208. /**
  74209. * Returns the wrap mode of the texture
  74210. * @param mode: the mode value
  74211. */
  74212. static GetWrapMode(mode: number): number;
  74213. /**
  74214. * Returns the byte stride giving an accessor
  74215. * @param accessor: the GLTF accessor objet
  74216. */
  74217. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74218. /**
  74219. * Returns the texture filter mode giving a mode value
  74220. * @param mode: the filter mode value
  74221. */
  74222. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74223. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74224. /**
  74225. * Returns a buffer from its accessor
  74226. * @param gltfRuntime: the GLTF runtime
  74227. * @param accessor: the GLTF accessor
  74228. */
  74229. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74230. /**
  74231. * Decodes a buffer view into a string
  74232. * @param view: the buffer view
  74233. */
  74234. static DecodeBufferToText(view: ArrayBufferView): string;
  74235. /**
  74236. * Returns the default material of gltf. Related to
  74237. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74238. * @param scene: the Babylon.js scene
  74239. */
  74240. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74241. private static _DefaultMaterial;
  74242. }
  74243. }
  74244. declare module BABYLON.GLTF1 {
  74245. /**
  74246. * Implementation of the base glTF spec
  74247. * @hidden
  74248. */
  74249. export class GLTFLoaderBase {
  74250. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74251. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74252. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74253. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74254. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74255. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74256. }
  74257. /**
  74258. * glTF V1 Loader
  74259. * @hidden
  74260. */
  74261. export class GLTFLoader implements IGLTFLoader {
  74262. static Extensions: {
  74263. [name: string]: GLTFLoaderExtension;
  74264. };
  74265. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74266. state: Nullable<GLTFLoaderState>;
  74267. dispose(): void;
  74268. private _importMeshAsync;
  74269. /**
  74270. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74271. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74272. * @param scene the scene the meshes should be added to
  74273. * @param data gltf data containing information of the meshes in a loaded file
  74274. * @param rootUrl root url to load from
  74275. * @param onProgress event that fires when loading progress has occured
  74276. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74277. */
  74278. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74279. meshes: AbstractMesh[];
  74280. particleSystems: IParticleSystem[];
  74281. skeletons: Skeleton[];
  74282. animationGroups: AnimationGroup[];
  74283. }>;
  74284. private _loadAsync;
  74285. /**
  74286. * Imports all objects from a loaded gltf file and adds them to the scene
  74287. * @param scene the scene the objects should be added to
  74288. * @param data gltf data containing information of the meshes in a loaded file
  74289. * @param rootUrl root url to load from
  74290. * @param onProgress event that fires when loading progress has occured
  74291. * @returns a promise which completes when objects have been loaded to the scene
  74292. */
  74293. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74294. private _loadShadersAsync;
  74295. private _loadBuffersAsync;
  74296. private _createNodes;
  74297. }
  74298. /** @hidden */
  74299. export abstract class GLTFLoaderExtension {
  74300. private _name;
  74301. constructor(name: string);
  74302. get name(): string;
  74303. /**
  74304. * Defines an override for loading the runtime
  74305. * Return true to stop further extensions from loading the runtime
  74306. */
  74307. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74308. /**
  74309. * Defines an onverride for creating gltf runtime
  74310. * Return true to stop further extensions from creating the runtime
  74311. */
  74312. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74313. /**
  74314. * Defines an override for loading buffers
  74315. * Return true to stop further extensions from loading this buffer
  74316. */
  74317. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74318. /**
  74319. * Defines an override for loading texture buffers
  74320. * Return true to stop further extensions from loading this texture data
  74321. */
  74322. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74323. /**
  74324. * Defines an override for creating textures
  74325. * Return true to stop further extensions from loading this texture
  74326. */
  74327. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74328. /**
  74329. * Defines an override for loading shader strings
  74330. * Return true to stop further extensions from loading this shader data
  74331. */
  74332. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74333. /**
  74334. * Defines an override for loading materials
  74335. * Return true to stop further extensions from loading this material
  74336. */
  74337. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74338. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74339. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74340. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74341. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74342. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74343. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74344. private static LoadTextureBufferAsync;
  74345. private static CreateTextureAsync;
  74346. private static ApplyExtensions;
  74347. }
  74348. }
  74349. declare module BABYLON.GLTF1 {
  74350. /** @hidden */
  74351. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74352. private _bin;
  74353. constructor();
  74354. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74355. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74356. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74357. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74358. }
  74359. }
  74360. declare module BABYLON.GLTF1 {
  74361. /** @hidden */
  74362. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74363. constructor();
  74364. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74365. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74366. private _loadTexture;
  74367. }
  74368. }
  74369. declare module BABYLON.GLTF2.Loader {
  74370. /**
  74371. * Loader interface with an index field.
  74372. */
  74373. export interface IArrayItem {
  74374. /**
  74375. * The index of this item in the array.
  74376. */
  74377. index: number;
  74378. }
  74379. /**
  74380. * Loader interface with additional members.
  74381. */
  74382. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  74383. /** @hidden */
  74384. _data?: Promise<ArrayBufferView>;
  74385. /** @hidden */
  74386. _babylonVertexBuffer?: Promise<VertexBuffer>;
  74387. }
  74388. /**
  74389. * Loader interface with additional members.
  74390. */
  74391. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  74392. }
  74393. /** @hidden */
  74394. export interface _IAnimationSamplerData {
  74395. input: Float32Array;
  74396. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  74397. output: Float32Array;
  74398. }
  74399. /**
  74400. * Loader interface with additional members.
  74401. */
  74402. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  74403. /** @hidden */
  74404. _data?: Promise<_IAnimationSamplerData>;
  74405. }
  74406. /**
  74407. * Loader interface with additional members.
  74408. */
  74409. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  74410. channels: IAnimationChannel[];
  74411. samplers: IAnimationSampler[];
  74412. /** @hidden */
  74413. _babylonAnimationGroup?: AnimationGroup;
  74414. }
  74415. /**
  74416. * Loader interface with additional members.
  74417. */
  74418. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  74419. /** @hidden */
  74420. _data?: Promise<ArrayBufferView>;
  74421. }
  74422. /**
  74423. * Loader interface with additional members.
  74424. */
  74425. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  74426. /** @hidden */
  74427. _data?: Promise<ArrayBufferView>;
  74428. /** @hidden */
  74429. _babylonBuffer?: Promise<Buffer>;
  74430. }
  74431. /**
  74432. * Loader interface with additional members.
  74433. */
  74434. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  74435. }
  74436. /**
  74437. * Loader interface with additional members.
  74438. */
  74439. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  74440. /** @hidden */
  74441. _data?: Promise<ArrayBufferView>;
  74442. }
  74443. /**
  74444. * Loader interface with additional members.
  74445. */
  74446. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  74447. }
  74448. /**
  74449. * Loader interface with additional members.
  74450. */
  74451. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  74452. }
  74453. /**
  74454. * Loader interface with additional members.
  74455. */
  74456. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  74457. baseColorTexture?: ITextureInfo;
  74458. metallicRoughnessTexture?: ITextureInfo;
  74459. }
  74460. /**
  74461. * Loader interface with additional members.
  74462. */
  74463. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  74464. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74465. normalTexture?: IMaterialNormalTextureInfo;
  74466. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74467. emissiveTexture?: ITextureInfo;
  74468. /** @hidden */
  74469. _data?: {
  74470. [babylonDrawMode: number]: {
  74471. babylonMaterial: Material;
  74472. babylonMeshes: AbstractMesh[];
  74473. promise: Promise<void>;
  74474. };
  74475. };
  74476. }
  74477. /**
  74478. * Loader interface with additional members.
  74479. */
  74480. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  74481. primitives: IMeshPrimitive[];
  74482. }
  74483. /**
  74484. * Loader interface with additional members.
  74485. */
  74486. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  74487. /** @hidden */
  74488. _instanceData?: {
  74489. babylonSourceMesh: Mesh;
  74490. promise: Promise<any>;
  74491. };
  74492. }
  74493. /**
  74494. * Loader interface with additional members.
  74495. */
  74496. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  74497. /**
  74498. * The parent glTF node.
  74499. */
  74500. parent?: INode;
  74501. /** @hidden */
  74502. _babylonTransformNode?: TransformNode;
  74503. /** @hidden */
  74504. _primitiveBabylonMeshes?: AbstractMesh[];
  74505. /** @hidden */
  74506. _babylonBones?: Bone[];
  74507. /** @hidden */
  74508. _numMorphTargets?: number;
  74509. }
  74510. /** @hidden */
  74511. export interface _ISamplerData {
  74512. noMipMaps: boolean;
  74513. samplingMode: number;
  74514. wrapU: number;
  74515. wrapV: number;
  74516. }
  74517. /**
  74518. * Loader interface with additional members.
  74519. */
  74520. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  74521. /** @hidden */
  74522. _data?: _ISamplerData;
  74523. }
  74524. /**
  74525. * Loader interface with additional members.
  74526. */
  74527. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  74528. }
  74529. /**
  74530. * Loader interface with additional members.
  74531. */
  74532. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  74533. /** @hidden */
  74534. _data?: {
  74535. babylonSkeleton: Skeleton;
  74536. promise: Promise<void>;
  74537. };
  74538. }
  74539. /**
  74540. * Loader interface with additional members.
  74541. */
  74542. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  74543. }
  74544. /**
  74545. * Loader interface with additional members.
  74546. */
  74547. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  74548. }
  74549. /**
  74550. * Loader interface with additional members.
  74551. */
  74552. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  74553. accessors?: IAccessor[];
  74554. animations?: IAnimation[];
  74555. buffers?: IBuffer[];
  74556. bufferViews?: IBufferView[];
  74557. cameras?: ICamera[];
  74558. images?: IImage[];
  74559. materials?: IMaterial[];
  74560. meshes?: IMesh[];
  74561. nodes?: INode[];
  74562. samplers?: ISampler[];
  74563. scenes?: IScene[];
  74564. skins?: ISkin[];
  74565. textures?: ITexture[];
  74566. }
  74567. }
  74568. declare module BABYLON.GLTF2 {
  74569. /**
  74570. * Interface for a glTF loader extension.
  74571. */
  74572. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  74573. /**
  74574. * Called after the loader state changes to LOADING.
  74575. */
  74576. onLoading?(): void;
  74577. /**
  74578. * Called after the loader state changes to READY.
  74579. */
  74580. onReady?(): void;
  74581. /**
  74582. * Define this method to modify the default behavior when loading scenes.
  74583. * @param context The context when loading the asset
  74584. * @param scene The glTF scene property
  74585. * @returns A promise that resolves when the load is complete or null if not handled
  74586. */
  74587. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  74588. /**
  74589. * Define this method to modify the default behavior when loading nodes.
  74590. * @param context The context when loading the asset
  74591. * @param node The glTF node property
  74592. * @param assign A function called synchronously after parsing the glTF properties
  74593. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  74594. */
  74595. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74596. /**
  74597. * Define this method to modify the default behavior when loading cameras.
  74598. * @param context The context when loading the asset
  74599. * @param camera The glTF camera property
  74600. * @param assign A function called synchronously after parsing the glTF properties
  74601. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  74602. */
  74603. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74604. /**
  74605. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  74606. * @param context The context when loading the asset
  74607. * @param primitive The glTF mesh primitive property
  74608. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  74609. */
  74610. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74611. /**
  74612. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74613. * @param context The context when loading the asset
  74614. * @param name The mesh name when loading the asset
  74615. * @param node The glTF node when loading the asset
  74616. * @param mesh The glTF mesh when loading the asset
  74617. * @param primitive The glTF mesh primitive property
  74618. * @param assign A function called synchronously after parsing the glTF properties
  74619. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74620. */
  74621. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74622. /**
  74623. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  74624. * @param context The context when loading the asset
  74625. * @param material The glTF material property
  74626. * @param assign A function called synchronously after parsing the glTF properties
  74627. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  74628. */
  74629. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74630. /**
  74631. * Define this method to modify the default behavior when creating materials.
  74632. * @param context The context when loading the asset
  74633. * @param material The glTF material property
  74634. * @param babylonDrawMode The draw mode for the Babylon material
  74635. * @returns The Babylon material or null if not handled
  74636. */
  74637. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74638. /**
  74639. * Define this method to modify the default behavior when loading material properties.
  74640. * @param context The context when loading the asset
  74641. * @param material The glTF material property
  74642. * @param babylonMaterial The Babylon material
  74643. * @returns A promise that resolves when the load is complete or null if not handled
  74644. */
  74645. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74646. /**
  74647. * Define this method to modify the default behavior when loading texture infos.
  74648. * @param context The context when loading the asset
  74649. * @param textureInfo The glTF texture info property
  74650. * @param assign A function called synchronously after parsing the glTF properties
  74651. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  74652. */
  74653. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  74654. /**
  74655. * Define this method to modify the default behavior when loading animations.
  74656. * @param context The context when loading the asset
  74657. * @param animation The glTF animation property
  74658. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  74659. */
  74660. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  74661. /**
  74662. * @hidden Define this method to modify the default behavior when loading skins.
  74663. * @param context The context when loading the asset
  74664. * @param node The glTF node property
  74665. * @param skin The glTF skin property
  74666. * @returns A promise that resolves when the load is complete or null if not handled
  74667. */
  74668. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  74669. /**
  74670. * @hidden Define this method to modify the default behavior when loading uris.
  74671. * @param context The context when loading the asset
  74672. * @param property The glTF property associated with the uri
  74673. * @param uri The uri to load
  74674. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74675. */
  74676. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  74677. /**
  74678. * Define this method to modify the default behavior when loading buffer views.
  74679. * @param context The context when loading the asset
  74680. * @param bufferView The glTF buffer view property
  74681. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74682. */
  74683. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  74684. /**
  74685. * Define this method to modify the default behavior when loading buffers.
  74686. * @param context The context when loading the asset
  74687. * @param buffer The glTF buffer property
  74688. * @param byteOffset The byte offset to load
  74689. * @param byteLength The byte length to load
  74690. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74691. */
  74692. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  74693. }
  74694. }
  74695. declare module BABYLON.GLTF2 {
  74696. /**
  74697. * Helper class for working with arrays when loading the glTF asset
  74698. */
  74699. export class ArrayItem {
  74700. /**
  74701. * Gets an item from the given array.
  74702. * @param context The context when loading the asset
  74703. * @param array The array to get the item from
  74704. * @param index The index to the array
  74705. * @returns The array item
  74706. */
  74707. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  74708. /**
  74709. * Assign an `index` field to each item of the given array.
  74710. * @param array The array of items
  74711. */
  74712. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  74713. }
  74714. /**
  74715. * The glTF 2.0 loader
  74716. */
  74717. export class GLTFLoader implements IGLTFLoader {
  74718. /** @hidden */
  74719. _completePromises: Promise<any>[];
  74720. private _disposed;
  74721. private _parent;
  74722. private _state;
  74723. private _extensions;
  74724. private _rootUrl;
  74725. private _fileName;
  74726. private _uniqueRootUrl;
  74727. private _gltf;
  74728. private _bin;
  74729. private _babylonScene;
  74730. private _rootBabylonMesh;
  74731. private _defaultBabylonMaterialData;
  74732. private _progressCallback?;
  74733. private _requests;
  74734. private static readonly _DefaultSampler;
  74735. private static _RegisteredExtensions;
  74736. /**
  74737. * Registers a loader extension.
  74738. * @param name The name of the loader extension.
  74739. * @param factory The factory function that creates the loader extension.
  74740. */
  74741. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  74742. /**
  74743. * Unregisters a loader extension.
  74744. * @param name The name of the loader extension.
  74745. * @returns A boolean indicating whether the extension has been unregistered
  74746. */
  74747. static UnregisterExtension(name: string): boolean;
  74748. /**
  74749. * Gets the loader state.
  74750. */
  74751. get state(): Nullable<GLTFLoaderState>;
  74752. /**
  74753. * The object that represents the glTF JSON.
  74754. */
  74755. get gltf(): IGLTF;
  74756. /**
  74757. * The BIN chunk of a binary glTF.
  74758. */
  74759. get bin(): Nullable<IDataBuffer>;
  74760. /**
  74761. * The parent file loader.
  74762. */
  74763. get parent(): GLTFFileLoader;
  74764. /**
  74765. * The Babylon scene when loading the asset.
  74766. */
  74767. get babylonScene(): Scene;
  74768. /**
  74769. * The root Babylon mesh when loading the asset.
  74770. */
  74771. get rootBabylonMesh(): Mesh;
  74772. /** @hidden */
  74773. constructor(parent: GLTFFileLoader);
  74774. /** @hidden */
  74775. dispose(): void;
  74776. /** @hidden */
  74777. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74778. meshes: AbstractMesh[];
  74779. particleSystems: IParticleSystem[];
  74780. skeletons: Skeleton[];
  74781. animationGroups: AnimationGroup[];
  74782. }>;
  74783. /** @hidden */
  74784. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74785. private _loadAsync;
  74786. private _loadData;
  74787. private _setupData;
  74788. private _loadExtensions;
  74789. private _checkExtensions;
  74790. private _setState;
  74791. private _createRootNode;
  74792. /**
  74793. * Loads a glTF scene.
  74794. * @param context The context when loading the asset
  74795. * @param scene The glTF scene property
  74796. * @returns A promise that resolves when the load is complete
  74797. */
  74798. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  74799. private _forEachPrimitive;
  74800. private _getMeshes;
  74801. private _getSkeletons;
  74802. private _getAnimationGroups;
  74803. private _startAnimations;
  74804. /**
  74805. * Loads a glTF node.
  74806. * @param context The context when loading the asset
  74807. * @param node The glTF node property
  74808. * @param assign A function called synchronously after parsing the glTF properties
  74809. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  74810. */
  74811. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  74812. private _loadMeshAsync;
  74813. /**
  74814. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74815. * @param context The context when loading the asset
  74816. * @param name The mesh name when loading the asset
  74817. * @param node The glTF node when loading the asset
  74818. * @param mesh The glTF mesh when loading the asset
  74819. * @param primitive The glTF mesh primitive property
  74820. * @param assign A function called synchronously after parsing the glTF properties
  74821. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74822. */
  74823. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74824. private _loadVertexDataAsync;
  74825. private _createMorphTargets;
  74826. private _loadMorphTargetsAsync;
  74827. private _loadMorphTargetVertexDataAsync;
  74828. private static _LoadTransform;
  74829. private _loadSkinAsync;
  74830. private _loadBones;
  74831. private _loadBone;
  74832. private _loadSkinInverseBindMatricesDataAsync;
  74833. private _updateBoneMatrices;
  74834. private _getNodeMatrix;
  74835. /**
  74836. * Loads a glTF camera.
  74837. * @param context The context when loading the asset
  74838. * @param camera The glTF camera property
  74839. * @param assign A function called synchronously after parsing the glTF properties
  74840. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  74841. */
  74842. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  74843. private _loadAnimationsAsync;
  74844. /**
  74845. * Loads a glTF animation.
  74846. * @param context The context when loading the asset
  74847. * @param animation The glTF animation property
  74848. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  74849. */
  74850. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  74851. /**
  74852. * @hidden Loads a glTF animation channel.
  74853. * @param context The context when loading the asset
  74854. * @param animationContext The context of the animation when loading the asset
  74855. * @param animation The glTF animation property
  74856. * @param channel The glTF animation channel property
  74857. * @param babylonAnimationGroup The babylon animation group property
  74858. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  74859. * @returns A void promise when the channel load is complete
  74860. */
  74861. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  74862. private _loadAnimationSamplerAsync;
  74863. private _loadBufferAsync;
  74864. /**
  74865. * Loads a glTF buffer view.
  74866. * @param context The context when loading the asset
  74867. * @param bufferView The glTF buffer view property
  74868. * @returns A promise that resolves with the loaded data when the load is complete
  74869. */
  74870. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  74871. private _loadAccessorAsync;
  74872. private _loadFloatAccessorAsync;
  74873. private _loadIndicesAccessorAsync;
  74874. private _loadVertexBufferViewAsync;
  74875. private _loadVertexAccessorAsync;
  74876. private _loadMaterialMetallicRoughnessPropertiesAsync;
  74877. /** @hidden */
  74878. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  74879. private _createDefaultMaterial;
  74880. /**
  74881. * Creates a Babylon material from a glTF material.
  74882. * @param context The context when loading the asset
  74883. * @param material The glTF material property
  74884. * @param babylonDrawMode The draw mode for the Babylon material
  74885. * @returns The Babylon material
  74886. */
  74887. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  74888. /**
  74889. * Loads properties from a glTF material into a Babylon material.
  74890. * @param context The context when loading the asset
  74891. * @param material The glTF material property
  74892. * @param babylonMaterial The Babylon material
  74893. * @returns A promise that resolves when the load is complete
  74894. */
  74895. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74896. /**
  74897. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  74898. * @param context The context when loading the asset
  74899. * @param material The glTF material property
  74900. * @param babylonMaterial The Babylon material
  74901. * @returns A promise that resolves when the load is complete
  74902. */
  74903. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74904. /**
  74905. * Loads the alpha properties from a glTF material into a Babylon material.
  74906. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  74907. * @param context The context when loading the asset
  74908. * @param material The glTF material property
  74909. * @param babylonMaterial The Babylon material
  74910. */
  74911. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  74912. /**
  74913. * Loads a glTF texture info.
  74914. * @param context The context when loading the asset
  74915. * @param textureInfo The glTF texture info property
  74916. * @param assign A function called synchronously after parsing the glTF properties
  74917. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  74918. */
  74919. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  74920. private _loadTextureAsync;
  74921. private _loadSampler;
  74922. /**
  74923. * Loads a glTF image.
  74924. * @param context The context when loading the asset
  74925. * @param image The glTF image property
  74926. * @returns A promise that resolves with the loaded data when the load is complete
  74927. */
  74928. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  74929. /**
  74930. * Loads a glTF uri.
  74931. * @param context The context when loading the asset
  74932. * @param property The glTF property associated with the uri
  74933. * @param uri The base64 or relative uri
  74934. * @returns A promise that resolves with the loaded data when the load is complete
  74935. */
  74936. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  74937. private _onProgress;
  74938. /**
  74939. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  74940. * @param babylonObject the Babylon object with metadata
  74941. * @param pointer the JSON pointer
  74942. */
  74943. static AddPointerMetadata(babylonObject: {
  74944. metadata: any;
  74945. }, pointer: string): void;
  74946. private static _GetTextureWrapMode;
  74947. private static _GetTextureSamplingMode;
  74948. private static _GetTypedArrayConstructor;
  74949. private static _GetTypedArray;
  74950. private static _GetNumComponents;
  74951. private static _ValidateUri;
  74952. private static _GetDrawMode;
  74953. private _compileMaterialsAsync;
  74954. private _compileShadowGeneratorsAsync;
  74955. private _forEachExtensions;
  74956. private _applyExtensions;
  74957. private _extensionsOnLoading;
  74958. private _extensionsOnReady;
  74959. private _extensionsLoadSceneAsync;
  74960. private _extensionsLoadNodeAsync;
  74961. private _extensionsLoadCameraAsync;
  74962. private _extensionsLoadVertexDataAsync;
  74963. private _extensionsLoadMeshPrimitiveAsync;
  74964. private _extensionsLoadMaterialAsync;
  74965. private _extensionsCreateMaterial;
  74966. private _extensionsLoadMaterialPropertiesAsync;
  74967. private _extensionsLoadTextureInfoAsync;
  74968. private _extensionsLoadAnimationAsync;
  74969. private _extensionsLoadSkinAsync;
  74970. private _extensionsLoadUriAsync;
  74971. private _extensionsLoadBufferViewAsync;
  74972. private _extensionsLoadBufferAsync;
  74973. /**
  74974. * Helper method called by a loader extension to load an glTF extension.
  74975. * @param context The context when loading the asset
  74976. * @param property The glTF property to load the extension from
  74977. * @param extensionName The name of the extension to load
  74978. * @param actionAsync The action to run
  74979. * @returns The promise returned by actionAsync or null if the extension does not exist
  74980. */
  74981. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74982. /**
  74983. * Helper method called by a loader extension to load a glTF extra.
  74984. * @param context The context when loading the asset
  74985. * @param property The glTF property to load the extra from
  74986. * @param extensionName The name of the extension to load
  74987. * @param actionAsync The action to run
  74988. * @returns The promise returned by actionAsync or null if the extra does not exist
  74989. */
  74990. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74991. /**
  74992. * Checks for presence of an extension.
  74993. * @param name The name of the extension to check
  74994. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  74995. */
  74996. isExtensionUsed(name: string): boolean;
  74997. /**
  74998. * Increments the indentation level and logs a message.
  74999. * @param message The message to log
  75000. */
  75001. logOpen(message: string): void;
  75002. /**
  75003. * Decrements the indentation level.
  75004. */
  75005. logClose(): void;
  75006. /**
  75007. * Logs a message
  75008. * @param message The message to log
  75009. */
  75010. log(message: string): void;
  75011. /**
  75012. * Starts a performance counter.
  75013. * @param counterName The name of the performance counter
  75014. */
  75015. startPerformanceCounter(counterName: string): void;
  75016. /**
  75017. * Ends a performance counter.
  75018. * @param counterName The name of the performance counter
  75019. */
  75020. endPerformanceCounter(counterName: string): void;
  75021. }
  75022. }
  75023. declare module BABYLON.GLTF2.Loader.Extensions {
  75024. /**
  75025. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75026. */
  75027. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75028. /**
  75029. * The name of this extension.
  75030. */
  75031. readonly name: string;
  75032. /**
  75033. * Defines whether this extension is enabled.
  75034. */
  75035. enabled: boolean;
  75036. private _loader;
  75037. private _lights?;
  75038. /** @hidden */
  75039. constructor(loader: GLTFLoader);
  75040. /** @hidden */
  75041. dispose(): void;
  75042. /** @hidden */
  75043. onLoading(): void;
  75044. /** @hidden */
  75045. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75046. private _loadLightAsync;
  75047. }
  75048. }
  75049. declare module BABYLON.GLTF2.Loader.Extensions {
  75050. /**
  75051. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75052. */
  75053. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75054. /**
  75055. * The name of this extension.
  75056. */
  75057. readonly name: string;
  75058. /**
  75059. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75060. */
  75061. dracoCompression?: DracoCompression;
  75062. /**
  75063. * Defines whether this extension is enabled.
  75064. */
  75065. enabled: boolean;
  75066. private _loader;
  75067. /** @hidden */
  75068. constructor(loader: GLTFLoader);
  75069. /** @hidden */
  75070. dispose(): void;
  75071. /** @hidden */
  75072. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75073. }
  75074. }
  75075. declare module BABYLON.GLTF2.Loader.Extensions {
  75076. /**
  75077. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75078. */
  75079. export class KHR_lights implements IGLTFLoaderExtension {
  75080. /**
  75081. * The name of this extension.
  75082. */
  75083. readonly name: string;
  75084. /**
  75085. * Defines whether this extension is enabled.
  75086. */
  75087. enabled: boolean;
  75088. private _loader;
  75089. private _lights?;
  75090. /** @hidden */
  75091. constructor(loader: GLTFLoader);
  75092. /** @hidden */
  75093. dispose(): void;
  75094. /** @hidden */
  75095. onLoading(): void;
  75096. /** @hidden */
  75097. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75098. }
  75099. }
  75100. declare module BABYLON.GLTF2.Loader.Extensions {
  75101. /**
  75102. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75103. */
  75104. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75105. /**
  75106. * The name of this extension.
  75107. */
  75108. readonly name: string;
  75109. /**
  75110. * Defines whether this extension is enabled.
  75111. */
  75112. enabled: boolean;
  75113. /**
  75114. * Defines a number that determines the order the extensions are applied.
  75115. */
  75116. order: number;
  75117. private _loader;
  75118. /** @hidden */
  75119. constructor(loader: GLTFLoader);
  75120. /** @hidden */
  75121. dispose(): void;
  75122. /** @hidden */
  75123. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75124. private _loadSpecularGlossinessPropertiesAsync;
  75125. }
  75126. }
  75127. declare module BABYLON.GLTF2.Loader.Extensions {
  75128. /**
  75129. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75130. */
  75131. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75132. /**
  75133. * The name of this extension.
  75134. */
  75135. readonly name: string;
  75136. /**
  75137. * Defines whether this extension is enabled.
  75138. */
  75139. enabled: boolean;
  75140. /**
  75141. * Defines a number that determines the order the extensions are applied.
  75142. */
  75143. order: number;
  75144. private _loader;
  75145. /** @hidden */
  75146. constructor(loader: GLTFLoader);
  75147. /** @hidden */
  75148. dispose(): void;
  75149. /** @hidden */
  75150. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75151. private _loadUnlitPropertiesAsync;
  75152. }
  75153. }
  75154. declare module BABYLON.GLTF2.Loader.Extensions {
  75155. /**
  75156. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75157. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75158. * !!! Experimental Extension Subject to Changes !!!
  75159. */
  75160. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75161. /**
  75162. * The name of this extension.
  75163. */
  75164. readonly name: string;
  75165. /**
  75166. * Defines whether this extension is enabled.
  75167. */
  75168. enabled: boolean;
  75169. /**
  75170. * Defines a number that determines the order the extensions are applied.
  75171. */
  75172. order: number;
  75173. private _loader;
  75174. /** @hidden */
  75175. constructor(loader: GLTFLoader);
  75176. /** @hidden */
  75177. dispose(): void;
  75178. /** @hidden */
  75179. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75180. private _loadClearCoatPropertiesAsync;
  75181. }
  75182. }
  75183. declare module BABYLON.GLTF2.Loader.Extensions {
  75184. /**
  75185. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75186. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75187. * !!! Experimental Extension Subject to Changes !!!
  75188. */
  75189. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75190. /**
  75191. * The name of this extension.
  75192. */
  75193. readonly name: string;
  75194. /**
  75195. * Defines whether this extension is enabled.
  75196. */
  75197. enabled: boolean;
  75198. /**
  75199. * Defines a number that determines the order the extensions are applied.
  75200. */
  75201. order: number;
  75202. private _loader;
  75203. /** @hidden */
  75204. constructor(loader: GLTFLoader);
  75205. /** @hidden */
  75206. dispose(): void;
  75207. /** @hidden */
  75208. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75209. private _loadSheenPropertiesAsync;
  75210. }
  75211. }
  75212. declare module BABYLON.GLTF2.Loader.Extensions {
  75213. /**
  75214. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75215. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75216. * !!! Experimental Extension Subject to Changes !!!
  75217. */
  75218. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75219. /**
  75220. * The name of this extension.
  75221. */
  75222. readonly name: string;
  75223. /**
  75224. * Defines whether this extension is enabled.
  75225. */
  75226. enabled: boolean;
  75227. /**
  75228. * Defines a number that determines the order the extensions are applied.
  75229. */
  75230. order: number;
  75231. private _loader;
  75232. /** @hidden */
  75233. constructor(loader: GLTFLoader);
  75234. /** @hidden */
  75235. dispose(): void;
  75236. /** @hidden */
  75237. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75238. private _loadSpecularPropertiesAsync;
  75239. }
  75240. }
  75241. declare module BABYLON.GLTF2.Loader.Extensions {
  75242. /**
  75243. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75244. */
  75245. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75246. /**
  75247. * The name of this extension.
  75248. */
  75249. readonly name: string;
  75250. /**
  75251. * Defines whether this extension is enabled.
  75252. */
  75253. enabled: boolean;
  75254. /** @hidden */
  75255. constructor(loader: GLTFLoader);
  75256. /** @hidden */
  75257. dispose(): void;
  75258. }
  75259. }
  75260. declare module BABYLON.GLTF2.Loader.Extensions {
  75261. /**
  75262. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75263. */
  75264. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75265. /**
  75266. * The name of this extension.
  75267. */
  75268. readonly name: string;
  75269. /**
  75270. * Defines whether this extension is enabled.
  75271. */
  75272. enabled: boolean;
  75273. private _loader;
  75274. /** @hidden */
  75275. constructor(loader: GLTFLoader);
  75276. /** @hidden */
  75277. dispose(): void;
  75278. /** @hidden */
  75279. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75280. }
  75281. }
  75282. declare module BABYLON.GLTF2.Loader.Extensions {
  75283. /**
  75284. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75285. */
  75286. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75287. /**
  75288. * The name of this extension.
  75289. */
  75290. readonly name: string;
  75291. /**
  75292. * Defines whether this extension is enabled.
  75293. */
  75294. enabled: boolean;
  75295. private _loader;
  75296. private _clips;
  75297. private _emitters;
  75298. /** @hidden */
  75299. constructor(loader: GLTFLoader);
  75300. /** @hidden */
  75301. dispose(): void;
  75302. /** @hidden */
  75303. onLoading(): void;
  75304. /** @hidden */
  75305. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75306. /** @hidden */
  75307. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75308. /** @hidden */
  75309. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75310. private _loadClipAsync;
  75311. private _loadEmitterAsync;
  75312. private _getEventAction;
  75313. private _loadAnimationEventAsync;
  75314. }
  75315. }
  75316. declare module BABYLON.GLTF2.Loader.Extensions {
  75317. /**
  75318. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75319. */
  75320. export class MSFT_lod implements IGLTFLoaderExtension {
  75321. /**
  75322. * The name of this extension.
  75323. */
  75324. readonly name: string;
  75325. /**
  75326. * Defines whether this extension is enabled.
  75327. */
  75328. enabled: boolean;
  75329. /**
  75330. * Defines a number that determines the order the extensions are applied.
  75331. */
  75332. order: number;
  75333. /**
  75334. * Maximum number of LODs to load, starting from the lowest LOD.
  75335. */
  75336. maxLODsToLoad: number;
  75337. /**
  75338. * Observable raised when all node LODs of one level are loaded.
  75339. * The event data is the index of the loaded LOD starting from zero.
  75340. * Dispose the loader to cancel the loading of the next level of LODs.
  75341. */
  75342. onNodeLODsLoadedObservable: Observable<number>;
  75343. /**
  75344. * Observable raised when all material LODs of one level are loaded.
  75345. * The event data is the index of the loaded LOD starting from zero.
  75346. * Dispose the loader to cancel the loading of the next level of LODs.
  75347. */
  75348. onMaterialLODsLoadedObservable: Observable<number>;
  75349. private _loader;
  75350. private _nodeIndexLOD;
  75351. private _nodeSignalLODs;
  75352. private _nodePromiseLODs;
  75353. private _materialIndexLOD;
  75354. private _materialSignalLODs;
  75355. private _materialPromiseLODs;
  75356. private _indexLOD;
  75357. private _bufferLODs;
  75358. /** @hidden */
  75359. constructor(loader: GLTFLoader);
  75360. /** @hidden */
  75361. dispose(): void;
  75362. /** @hidden */
  75363. onReady(): void;
  75364. /** @hidden */
  75365. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75366. /** @hidden */
  75367. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75368. /** @hidden */
  75369. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75370. /** @hidden */
  75371. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75372. private _loadBufferLOD;
  75373. /**
  75374. * Gets an array of LOD properties from lowest to highest.
  75375. */
  75376. private _getLODs;
  75377. private _disposeUnusedMaterials;
  75378. }
  75379. }
  75380. declare module BABYLON.GLTF2.Loader.Extensions {
  75381. /** @hidden */
  75382. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  75383. readonly name: string;
  75384. enabled: boolean;
  75385. private _loader;
  75386. constructor(loader: GLTFLoader);
  75387. dispose(): void;
  75388. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75389. }
  75390. }
  75391. declare module BABYLON.GLTF2.Loader.Extensions {
  75392. /** @hidden */
  75393. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  75394. readonly name: string;
  75395. enabled: boolean;
  75396. private _loader;
  75397. constructor(loader: GLTFLoader);
  75398. dispose(): void;
  75399. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75400. }
  75401. }
  75402. declare module BABYLON.GLTF2.Loader.Extensions {
  75403. /**
  75404. * Store glTF extras (if present) in BJS objects' metadata
  75405. */
  75406. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  75407. /**
  75408. * The name of this extension.
  75409. */
  75410. readonly name: string;
  75411. /**
  75412. * Defines whether this extension is enabled.
  75413. */
  75414. enabled: boolean;
  75415. private _loader;
  75416. private _assignExtras;
  75417. /** @hidden */
  75418. constructor(loader: GLTFLoader);
  75419. /** @hidden */
  75420. dispose(): void;
  75421. /** @hidden */
  75422. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75423. /** @hidden */
  75424. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75425. /** @hidden */
  75426. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75427. }
  75428. }
  75429. declare module BABYLON {
  75430. /**
  75431. * Class reading and parsing the MTL file bundled with the obj file.
  75432. */
  75433. export class MTLFileLoader {
  75434. /**
  75435. * Invert Y-Axis of referenced textures on load
  75436. */
  75437. static INVERT_TEXTURE_Y: boolean;
  75438. /**
  75439. * All material loaded from the mtl will be set here
  75440. */
  75441. materials: StandardMaterial[];
  75442. /**
  75443. * This function will read the mtl file and create each material described inside
  75444. * This function could be improve by adding :
  75445. * -some component missing (Ni, Tf...)
  75446. * -including the specific options available
  75447. *
  75448. * @param scene defines the scene the material will be created in
  75449. * @param data defines the mtl data to parse
  75450. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  75451. */
  75452. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  75453. /**
  75454. * Gets the texture for the material.
  75455. *
  75456. * If the material is imported from input file,
  75457. * We sanitize the url to ensure it takes the textre from aside the material.
  75458. *
  75459. * @param rootUrl The root url to load from
  75460. * @param value The value stored in the mtl
  75461. * @return The Texture
  75462. */
  75463. private static _getTexture;
  75464. }
  75465. }
  75466. declare module BABYLON {
  75467. /**
  75468. * Options for loading OBJ/MTL files
  75469. */
  75470. type MeshLoadOptions = {
  75471. /**
  75472. * Defines if UVs are optimized by default during load.
  75473. */
  75474. OptimizeWithUV: boolean;
  75475. /**
  75476. * Defines custom scaling of UV coordinates of loaded meshes.
  75477. */
  75478. UVScaling: Vector2;
  75479. /**
  75480. * Invert model on y-axis (does a model scaling inversion)
  75481. */
  75482. InvertY: boolean;
  75483. /**
  75484. * Invert Y-Axis of referenced textures on load
  75485. */
  75486. InvertTextureY: boolean;
  75487. /**
  75488. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75489. */
  75490. ImportVertexColors: boolean;
  75491. /**
  75492. * Compute the normals for the model, even if normals are present in the file.
  75493. */
  75494. ComputeNormals: boolean;
  75495. /**
  75496. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75497. */
  75498. SkipMaterials: boolean;
  75499. /**
  75500. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75501. */
  75502. MaterialLoadingFailsSilently: boolean;
  75503. };
  75504. /**
  75505. * OBJ file type loader.
  75506. * This is a babylon scene loader plugin.
  75507. */
  75508. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75509. /**
  75510. * Defines if UVs are optimized by default during load.
  75511. */
  75512. static OPTIMIZE_WITH_UV: boolean;
  75513. /**
  75514. * Invert model on y-axis (does a model scaling inversion)
  75515. */
  75516. static INVERT_Y: boolean;
  75517. /**
  75518. * Invert Y-Axis of referenced textures on load
  75519. */
  75520. static get INVERT_TEXTURE_Y(): boolean;
  75521. static set INVERT_TEXTURE_Y(value: boolean);
  75522. /**
  75523. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75524. */
  75525. static IMPORT_VERTEX_COLORS: boolean;
  75526. /**
  75527. * Compute the normals for the model, even if normals are present in the file.
  75528. */
  75529. static COMPUTE_NORMALS: boolean;
  75530. /**
  75531. * Defines custom scaling of UV coordinates of loaded meshes.
  75532. */
  75533. static UV_SCALING: Vector2;
  75534. /**
  75535. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75536. */
  75537. static SKIP_MATERIALS: boolean;
  75538. /**
  75539. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75540. *
  75541. * Defaults to true for backwards compatibility.
  75542. */
  75543. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  75544. /**
  75545. * Defines the name of the plugin.
  75546. */
  75547. name: string;
  75548. /**
  75549. * Defines the extension the plugin is able to load.
  75550. */
  75551. extensions: string;
  75552. /** @hidden */
  75553. obj: RegExp;
  75554. /** @hidden */
  75555. group: RegExp;
  75556. /** @hidden */
  75557. mtllib: RegExp;
  75558. /** @hidden */
  75559. usemtl: RegExp;
  75560. /** @hidden */
  75561. smooth: RegExp;
  75562. /** @hidden */
  75563. vertexPattern: RegExp;
  75564. /** @hidden */
  75565. normalPattern: RegExp;
  75566. /** @hidden */
  75567. uvPattern: RegExp;
  75568. /** @hidden */
  75569. facePattern1: RegExp;
  75570. /** @hidden */
  75571. facePattern2: RegExp;
  75572. /** @hidden */
  75573. facePattern3: RegExp;
  75574. /** @hidden */
  75575. facePattern4: RegExp;
  75576. /** @hidden */
  75577. facePattern5: RegExp;
  75578. private _meshLoadOptions;
  75579. /**
  75580. * Creates loader for .OBJ files
  75581. *
  75582. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  75583. */
  75584. constructor(meshLoadOptions?: MeshLoadOptions);
  75585. private static get currentMeshLoadOptions();
  75586. /**
  75587. * Calls synchronously the MTL file attached to this obj.
  75588. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  75589. * Without this function materials are not displayed in the first frame (but displayed after).
  75590. * In consequence it is impossible to get material information in your HTML file
  75591. *
  75592. * @param url The URL of the MTL file
  75593. * @param rootUrl
  75594. * @param onSuccess Callback function to be called when the MTL file is loaded
  75595. * @private
  75596. */
  75597. private _loadMTL;
  75598. /**
  75599. * Instantiates a OBJ file loader plugin.
  75600. * @returns the created plugin
  75601. */
  75602. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  75603. /**
  75604. * If the data string can be loaded directly.
  75605. *
  75606. * @param data string containing the file data
  75607. * @returns if the data can be loaded directly
  75608. */
  75609. canDirectLoad(data: string): boolean;
  75610. /**
  75611. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  75612. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75613. * @param scene the scene the meshes should be added to
  75614. * @param data the OBJ data to load
  75615. * @param rootUrl root url to load from
  75616. * @param onProgress event that fires when loading progress has occured
  75617. * @param fileName Defines the name of the file to load
  75618. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75619. */
  75620. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75621. meshes: AbstractMesh[];
  75622. particleSystems: IParticleSystem[];
  75623. skeletons: Skeleton[];
  75624. animationGroups: AnimationGroup[];
  75625. }>;
  75626. /**
  75627. * Imports all objects from the loaded OBJ data and adds them to the scene
  75628. * @param scene the scene the objects should be added to
  75629. * @param data the OBJ data to load
  75630. * @param rootUrl root url to load from
  75631. * @param onProgress event that fires when loading progress has occured
  75632. * @param fileName Defines the name of the file to load
  75633. * @returns a promise which completes when objects have been loaded to the scene
  75634. */
  75635. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75636. /**
  75637. * Load into an asset container.
  75638. * @param scene The scene to load into
  75639. * @param data The data to import
  75640. * @param rootUrl The root url for scene and resources
  75641. * @param onProgress The callback when the load progresses
  75642. * @param fileName Defines the name of the file to load
  75643. * @returns The loaded asset container
  75644. */
  75645. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75646. /**
  75647. * Read the OBJ file and create an Array of meshes.
  75648. * Each mesh contains all information given by the OBJ and the MTL file.
  75649. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  75650. *
  75651. * @param meshesNames
  75652. * @param scene Scene The scene where are displayed the data
  75653. * @param data String The content of the obj file
  75654. * @param rootUrl String The path to the folder
  75655. * @returns Array<AbstractMesh>
  75656. * @private
  75657. */
  75658. private _parseSolid;
  75659. }
  75660. }
  75661. declare module BABYLON {
  75662. /**
  75663. * STL file type loader.
  75664. * This is a babylon scene loader plugin.
  75665. */
  75666. export class STLFileLoader implements ISceneLoaderPlugin {
  75667. /** @hidden */
  75668. solidPattern: RegExp;
  75669. /** @hidden */
  75670. facetsPattern: RegExp;
  75671. /** @hidden */
  75672. normalPattern: RegExp;
  75673. /** @hidden */
  75674. vertexPattern: RegExp;
  75675. /**
  75676. * Defines the name of the plugin.
  75677. */
  75678. name: string;
  75679. /**
  75680. * Defines the extensions the stl loader is able to load.
  75681. * force data to come in as an ArrayBuffer
  75682. * we'll convert to string if it looks like it's an ASCII .stl
  75683. */
  75684. extensions: ISceneLoaderPluginExtensions;
  75685. /**
  75686. * Import meshes into a scene.
  75687. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  75688. * @param scene The scene to import into
  75689. * @param data The data to import
  75690. * @param rootUrl The root url for scene and resources
  75691. * @param meshes The meshes array to import into
  75692. * @param particleSystems The particle systems array to import into
  75693. * @param skeletons The skeletons array to import into
  75694. * @param onError The callback when import fails
  75695. * @returns True if successful or false otherwise
  75696. */
  75697. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  75698. /**
  75699. * Load into a scene.
  75700. * @param scene The scene to load into
  75701. * @param data The data to import
  75702. * @param rootUrl The root url for scene and resources
  75703. * @param onError The callback when import fails
  75704. * @returns true if successful or false otherwise
  75705. */
  75706. load(scene: Scene, data: any, rootUrl: string): boolean;
  75707. /**
  75708. * Load into an asset container.
  75709. * @param scene The scene to load into
  75710. * @param data The data to import
  75711. * @param rootUrl The root url for scene and resources
  75712. * @param onError The callback when import fails
  75713. * @returns The loaded asset container
  75714. */
  75715. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  75716. private _isBinary;
  75717. private _parseBinary;
  75718. private _parseASCII;
  75719. }
  75720. }
  75721. declare module BABYLON {
  75722. /**
  75723. * Class for generating OBJ data from a Babylon scene.
  75724. */
  75725. export class OBJExport {
  75726. /**
  75727. * Exports the geometry of a Mesh array in .OBJ file format (text)
  75728. * @param mesh defines the list of meshes to serialize
  75729. * @param materials defines if materials should be exported
  75730. * @param matlibname defines the name of the associated mtl file
  75731. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  75732. * @returns the OBJ content
  75733. */
  75734. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  75735. /**
  75736. * Exports the material(s) of a mesh in .MTL file format (text)
  75737. * @param mesh defines the mesh to extract the material from
  75738. * @returns the mtl content
  75739. */
  75740. static MTL(mesh: Mesh): string;
  75741. }
  75742. }
  75743. declare module BABYLON {
  75744. /** @hidden */
  75745. export var __IGLTFExporterExtension: number;
  75746. /**
  75747. * Interface for extending the exporter
  75748. * @hidden
  75749. */
  75750. export interface IGLTFExporterExtension {
  75751. /**
  75752. * The name of this extension
  75753. */
  75754. readonly name: string;
  75755. /**
  75756. * Defines whether this extension is enabled
  75757. */
  75758. enabled: boolean;
  75759. /**
  75760. * Defines whether this extension is required
  75761. */
  75762. required: boolean;
  75763. }
  75764. }
  75765. declare module BABYLON.GLTF2.Exporter {
  75766. /** @hidden */
  75767. export var __IGLTFExporterExtensionV2: number;
  75768. /**
  75769. * Interface for a glTF exporter extension
  75770. * @hidden
  75771. */
  75772. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  75773. /**
  75774. * Define this method to modify the default behavior before exporting a texture
  75775. * @param context The context when loading the asset
  75776. * @param babylonTexture The Babylon.js texture
  75777. * @param mimeType The mime-type of the generated image
  75778. * @returns A promise that resolves with the exported texture
  75779. */
  75780. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  75781. /**
  75782. * Define this method to get notified when a texture info is created
  75783. * @param context The context when loading the asset
  75784. * @param textureInfo The glTF texture info
  75785. * @param babylonTexture The Babylon.js texture
  75786. */
  75787. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  75788. /**
  75789. * Define this method to modify the default behavior when exporting texture info
  75790. * @param context The context when loading the asset
  75791. * @param meshPrimitive glTF mesh primitive
  75792. * @param babylonSubMesh Babylon submesh
  75793. * @param binaryWriter glTF serializer binary writer instance
  75794. * @returns nullable IMeshPrimitive promise
  75795. */
  75796. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  75797. /**
  75798. * Define this method to modify the default behavior when exporting a node
  75799. * @param context The context when exporting the node
  75800. * @param node glTF node
  75801. * @param babylonNode BabylonJS node
  75802. * @returns nullable INode promise
  75803. */
  75804. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  75805. /**
  75806. * Define this method to modify the default behavior when exporting a material
  75807. * @param material glTF material
  75808. * @param babylonMaterial BabylonJS material
  75809. * @returns nullable IMaterial promise
  75810. */
  75811. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  75812. /**
  75813. * Define this method to return additional textures to export from a material
  75814. * @param material glTF material
  75815. * @param babylonMaterial BabylonJS material
  75816. * @returns List of textures
  75817. */
  75818. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  75819. /** Gets a boolean indicating that this extension was used */
  75820. wasUsed: boolean;
  75821. /** Gets a boolean indicating that this extension is required for the file to work */
  75822. required: boolean;
  75823. /**
  75824. * Called after the exporter state changes to EXPORTING
  75825. */
  75826. onExporting?(): void;
  75827. }
  75828. }
  75829. declare module BABYLON.GLTF2.Exporter {
  75830. /**
  75831. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  75832. * @hidden
  75833. */
  75834. export class _GLTFMaterialExporter {
  75835. /**
  75836. * Represents the dielectric specular values for R, G and B
  75837. */
  75838. private static readonly _DielectricSpecular;
  75839. /**
  75840. * Allows the maximum specular power to be defined for material calculations
  75841. */
  75842. private static readonly _MaxSpecularPower;
  75843. /**
  75844. * Mapping to store textures
  75845. */
  75846. private _textureMap;
  75847. /**
  75848. * Numeric tolerance value
  75849. */
  75850. private static readonly _Epsilon;
  75851. /**
  75852. * Reference to the glTF Exporter
  75853. */
  75854. private _exporter;
  75855. constructor(exporter: _Exporter);
  75856. /**
  75857. * Specifies if two colors are approximately equal in value
  75858. * @param color1 first color to compare to
  75859. * @param color2 second color to compare to
  75860. * @param epsilon threshold value
  75861. */
  75862. private static FuzzyEquals;
  75863. /**
  75864. * Gets the materials from a Babylon scene and converts them to glTF materials
  75865. * @param scene babylonjs scene
  75866. * @param mimeType texture mime type
  75867. * @param images array of images
  75868. * @param textures array of textures
  75869. * @param materials array of materials
  75870. * @param imageData mapping of texture names to base64 textures
  75871. * @param hasTextureCoords specifies if texture coordinates are present on the material
  75872. */
  75873. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  75874. /**
  75875. * Makes a copy of the glTF material without the texture parameters
  75876. * @param originalMaterial original glTF material
  75877. * @returns glTF material without texture parameters
  75878. */
  75879. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  75880. /**
  75881. * Specifies if the material has any texture parameters present
  75882. * @param material glTF Material
  75883. * @returns boolean specifying if texture parameters are present
  75884. */
  75885. _hasTexturesPresent(material: IMaterial): boolean;
  75886. /**
  75887. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  75888. * @param babylonStandardMaterial
  75889. * @returns glTF Metallic Roughness Material representation
  75890. */
  75891. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  75892. /**
  75893. * Computes the metallic factor
  75894. * @param diffuse diffused value
  75895. * @param specular specular value
  75896. * @param oneMinusSpecularStrength one minus the specular strength
  75897. * @returns metallic value
  75898. */
  75899. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  75900. /**
  75901. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  75902. * @param glTFMaterial glTF material
  75903. * @param babylonMaterial Babylon material
  75904. */
  75905. private static _SetAlphaMode;
  75906. /**
  75907. * Converts a Babylon Standard Material to a glTF Material
  75908. * @param babylonStandardMaterial BJS Standard Material
  75909. * @param mimeType mime type to use for the textures
  75910. * @param images array of glTF image interfaces
  75911. * @param textures array of glTF texture interfaces
  75912. * @param materials array of glTF material interfaces
  75913. * @param imageData map of image file name to data
  75914. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75915. */
  75916. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75917. private _finishMaterial;
  75918. /**
  75919. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75920. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  75921. * @param mimeType mime type to use for the textures
  75922. * @param images array of glTF image interfaces
  75923. * @param textures array of glTF texture interfaces
  75924. * @param materials array of glTF material interfaces
  75925. * @param imageData map of image file name to data
  75926. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75927. */
  75928. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75929. /**
  75930. * Converts an image typed array buffer to a base64 image
  75931. * @param buffer typed array buffer
  75932. * @param width width of the image
  75933. * @param height height of the image
  75934. * @param mimeType mimetype of the image
  75935. * @returns base64 image string
  75936. */
  75937. private _createBase64FromCanvasAsync;
  75938. /**
  75939. * Generates a white texture based on the specified width and height
  75940. * @param width width of the texture in pixels
  75941. * @param height height of the texture in pixels
  75942. * @param scene babylonjs scene
  75943. * @returns white texture
  75944. */
  75945. private _createWhiteTexture;
  75946. /**
  75947. * 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
  75948. * @param texture1 first texture to resize
  75949. * @param texture2 second texture to resize
  75950. * @param scene babylonjs scene
  75951. * @returns resized textures or null
  75952. */
  75953. private _resizeTexturesToSameDimensions;
  75954. /**
  75955. * Converts an array of pixels to a Float32Array
  75956. * Throws an error if the pixel format is not supported
  75957. * @param pixels - array buffer containing pixel values
  75958. * @returns Float32 of pixels
  75959. */
  75960. private _convertPixelArrayToFloat32;
  75961. /**
  75962. * Convert Specular Glossiness Textures to Metallic Roughness
  75963. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  75964. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  75965. * @param diffuseTexture texture used to store diffuse information
  75966. * @param specularGlossinessTexture texture used to store specular and glossiness information
  75967. * @param factors specular glossiness material factors
  75968. * @param mimeType the mime type to use for the texture
  75969. * @returns pbr metallic roughness interface or null
  75970. */
  75971. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  75972. /**
  75973. * Converts specular glossiness material properties to metallic roughness
  75974. * @param specularGlossiness interface with specular glossiness material properties
  75975. * @returns interface with metallic roughness material properties
  75976. */
  75977. private _convertSpecularGlossinessToMetallicRoughness;
  75978. /**
  75979. * Calculates the surface reflectance, independent of lighting conditions
  75980. * @param color Color source to calculate brightness from
  75981. * @returns number representing the perceived brightness, or zero if color is undefined
  75982. */
  75983. private _getPerceivedBrightness;
  75984. /**
  75985. * Returns the maximum color component value
  75986. * @param color
  75987. * @returns maximum color component value, or zero if color is null or undefined
  75988. */
  75989. private _getMaxComponent;
  75990. /**
  75991. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  75992. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75993. * @param mimeType mime type to use for the textures
  75994. * @param images array of glTF image interfaces
  75995. * @param textures array of glTF texture interfaces
  75996. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  75997. * @param imageData map of image file name to data
  75998. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75999. * @returns glTF PBR Metallic Roughness factors
  76000. */
  76001. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76002. private _getGLTFTextureSampler;
  76003. private _getGLTFTextureWrapMode;
  76004. private _getGLTFTextureWrapModesSampler;
  76005. /**
  76006. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76007. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76008. * @param mimeType mime type to use for the textures
  76009. * @param images array of glTF image interfaces
  76010. * @param textures array of glTF texture interfaces
  76011. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76012. * @param imageData map of image file name to data
  76013. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76014. * @returns glTF PBR Metallic Roughness factors
  76015. */
  76016. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76017. /**
  76018. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76019. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76020. * @param mimeType mime type to use for the textures
  76021. * @param images array of glTF image interfaces
  76022. * @param textures array of glTF texture interfaces
  76023. * @param materials array of glTF material interfaces
  76024. * @param imageData map of image file name to data
  76025. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76026. */
  76027. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76028. private setMetallicRoughnessPbrMaterial;
  76029. private getPixelsFromTexture;
  76030. /**
  76031. * Extracts a texture from a Babylon texture into file data and glTF data
  76032. * @param babylonTexture Babylon texture to extract
  76033. * @param mimeType Mime Type of the babylonTexture
  76034. * @return glTF texture info, or null if the texture format is not supported
  76035. */
  76036. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76037. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76038. /**
  76039. * Builds a texture from base64 string
  76040. * @param base64Texture base64 texture string
  76041. * @param baseTextureName Name to use for the texture
  76042. * @param mimeType image mime type for the texture
  76043. * @param images array of images
  76044. * @param textures array of textures
  76045. * @param imageData map of image data
  76046. * @returns glTF texture info, or null if the texture format is not supported
  76047. */
  76048. private _getTextureInfoFromBase64;
  76049. }
  76050. }
  76051. declare module BABYLON {
  76052. /**
  76053. * Class for holding and downloading glTF file data
  76054. */
  76055. export class GLTFData {
  76056. /**
  76057. * Object which contains the file name as the key and its data as the value
  76058. */
  76059. glTFFiles: {
  76060. [fileName: string]: string | Blob;
  76061. };
  76062. /**
  76063. * Initializes the glTF file object
  76064. */
  76065. constructor();
  76066. /**
  76067. * Downloads the glTF data as files based on their names and data
  76068. */
  76069. downloadFiles(): void;
  76070. }
  76071. }
  76072. declare module BABYLON {
  76073. /**
  76074. * Holds a collection of exporter options and parameters
  76075. */
  76076. export interface IExportOptions {
  76077. /**
  76078. * Function which indicates whether a babylon node should be exported or not
  76079. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76080. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76081. */
  76082. shouldExportNode?(node: Node): boolean;
  76083. /**
  76084. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76085. * @param metadata source metadata to read from
  76086. * @returns the data to store to glTF node extras
  76087. */
  76088. metadataSelector?(metadata: any): any;
  76089. /**
  76090. * The sample rate to bake animation curves
  76091. */
  76092. animationSampleRate?: number;
  76093. /**
  76094. * Begin serialization without waiting for the scene to be ready
  76095. */
  76096. exportWithoutWaitingForScene?: boolean;
  76097. }
  76098. /**
  76099. * Class for generating glTF data from a Babylon scene.
  76100. */
  76101. export class GLTF2Export {
  76102. /**
  76103. * Exports the geometry of the scene to .gltf file format asynchronously
  76104. * @param scene Babylon scene with scene hierarchy information
  76105. * @param filePrefix File prefix to use when generating the glTF file
  76106. * @param options Exporter options
  76107. * @returns Returns an object with a .gltf file and associates texture names
  76108. * as keys and their data and paths as values
  76109. */
  76110. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76111. private static _PreExportAsync;
  76112. private static _PostExportAsync;
  76113. /**
  76114. * Exports the geometry of the scene to .glb file format asychronously
  76115. * @param scene Babylon scene with scene hierarchy information
  76116. * @param filePrefix File prefix to use when generating glb file
  76117. * @param options Exporter options
  76118. * @returns Returns an object with a .glb filename as key and data as value
  76119. */
  76120. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76121. }
  76122. }
  76123. declare module BABYLON.GLTF2.Exporter {
  76124. /**
  76125. * @hidden
  76126. */
  76127. export class _GLTFUtilities {
  76128. /**
  76129. * Creates a buffer view based on the supplied arguments
  76130. * @param bufferIndex index value of the specified buffer
  76131. * @param byteOffset byte offset value
  76132. * @param byteLength byte length of the bufferView
  76133. * @param byteStride byte distance between conequential elements
  76134. * @param name name of the buffer view
  76135. * @returns bufferView for glTF
  76136. */
  76137. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76138. /**
  76139. * Creates an accessor based on the supplied arguments
  76140. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76141. * @param name The name of the accessor
  76142. * @param type The type of the accessor
  76143. * @param componentType The datatype of components in the attribute
  76144. * @param count The number of attributes referenced by this accessor
  76145. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76146. * @param min Minimum value of each component in this attribute
  76147. * @param max Maximum value of each component in this attribute
  76148. * @returns accessor for glTF
  76149. */
  76150. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76151. /**
  76152. * Calculates the minimum and maximum values of an array of position floats
  76153. * @param positions Positions array of a mesh
  76154. * @param vertexStart Starting vertex offset to calculate min and max values
  76155. * @param vertexCount Number of vertices to check for min and max values
  76156. * @returns min number array and max number array
  76157. */
  76158. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76159. min: number[];
  76160. max: number[];
  76161. };
  76162. /**
  76163. * Converts a new right-handed Vector3
  76164. * @param vector vector3 array
  76165. * @returns right-handed Vector3
  76166. */
  76167. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76168. /**
  76169. * Converts a Vector3 to right-handed
  76170. * @param vector Vector3 to convert to right-handed
  76171. */
  76172. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76173. /**
  76174. * Converts a three element number array to right-handed
  76175. * @param vector number array to convert to right-handed
  76176. */
  76177. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76178. /**
  76179. * Converts a new right-handed Vector3
  76180. * @param vector vector3 array
  76181. * @returns right-handed Vector3
  76182. */
  76183. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76184. /**
  76185. * Converts a Vector3 to right-handed
  76186. * @param vector Vector3 to convert to right-handed
  76187. */
  76188. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76189. /**
  76190. * Converts a three element number array to right-handed
  76191. * @param vector number array to convert to right-handed
  76192. */
  76193. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76194. /**
  76195. * Converts a Vector4 to right-handed
  76196. * @param vector Vector4 to convert to right-handed
  76197. */
  76198. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76199. /**
  76200. * Converts a Vector4 to right-handed
  76201. * @param vector Vector4 to convert to right-handed
  76202. */
  76203. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76204. /**
  76205. * Converts a Quaternion to right-handed
  76206. * @param quaternion Source quaternion to convert to right-handed
  76207. */
  76208. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76209. /**
  76210. * Converts a Quaternion to right-handed
  76211. * @param quaternion Source quaternion to convert to right-handed
  76212. */
  76213. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76214. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76215. }
  76216. }
  76217. declare module BABYLON.GLTF2.Exporter {
  76218. /**
  76219. * Converts Babylon Scene into glTF 2.0.
  76220. * @hidden
  76221. */
  76222. export class _Exporter {
  76223. /**
  76224. * Stores the glTF to export
  76225. */
  76226. _glTF: IGLTF;
  76227. /**
  76228. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76229. */
  76230. _bufferViews: IBufferView[];
  76231. /**
  76232. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76233. */
  76234. _accessors: IAccessor[];
  76235. /**
  76236. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76237. */
  76238. private _nodes;
  76239. /**
  76240. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76241. */
  76242. private _scenes;
  76243. /**
  76244. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76245. */
  76246. private _meshes;
  76247. /**
  76248. * Stores all the generated material information, which represents the appearance of each primitive
  76249. */
  76250. _materials: IMaterial[];
  76251. _materialMap: {
  76252. [materialID: number]: number;
  76253. };
  76254. /**
  76255. * Stores all the generated texture information, which is referenced by glTF materials
  76256. */
  76257. _textures: ITexture[];
  76258. /**
  76259. * Stores all the generated image information, which is referenced by glTF textures
  76260. */
  76261. _images: IImage[];
  76262. /**
  76263. * Stores all the texture samplers
  76264. */
  76265. _samplers: ISampler[];
  76266. /**
  76267. * Stores all the generated animation samplers, which is referenced by glTF animations
  76268. */
  76269. /**
  76270. * Stores the animations for glTF models
  76271. */
  76272. private _animations;
  76273. /**
  76274. * Stores the total amount of bytes stored in the glTF buffer
  76275. */
  76276. private _totalByteLength;
  76277. /**
  76278. * Stores a reference to the Babylon scene containing the source geometry and material information
  76279. */
  76280. _babylonScene: Scene;
  76281. /**
  76282. * Stores a map of the image data, where the key is the file name and the value
  76283. * is the image data
  76284. */
  76285. _imageData: {
  76286. [fileName: string]: {
  76287. data: Uint8Array;
  76288. mimeType: ImageMimeType;
  76289. };
  76290. };
  76291. /**
  76292. * Stores a map of the unique id of a node to its index in the node array
  76293. */
  76294. private _nodeMap;
  76295. /**
  76296. * Specifies if the Babylon scene should be converted to right-handed on export
  76297. */
  76298. _convertToRightHandedSystem: boolean;
  76299. /**
  76300. * Baked animation sample rate
  76301. */
  76302. private _animationSampleRate;
  76303. private _options;
  76304. private _localEngine;
  76305. _glTFMaterialExporter: _GLTFMaterialExporter;
  76306. private _extensions;
  76307. private static _ExtensionNames;
  76308. private static _ExtensionFactories;
  76309. private _applyExtension;
  76310. private _applyExtensions;
  76311. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76312. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76313. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76314. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76315. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76316. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76317. private _forEachExtensions;
  76318. private _extensionsOnExporting;
  76319. /**
  76320. * Load glTF serializer extensions
  76321. */
  76322. private _loadExtensions;
  76323. /**
  76324. * Creates a glTF Exporter instance, which can accept optional exporter options
  76325. * @param babylonScene Babylon scene object
  76326. * @param options Options to modify the behavior of the exporter
  76327. */
  76328. constructor(babylonScene: Scene, options?: IExportOptions);
  76329. dispose(): void;
  76330. /**
  76331. * Registers a glTF exporter extension
  76332. * @param name Name of the extension to export
  76333. * @param factory The factory function that creates the exporter extension
  76334. */
  76335. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76336. /**
  76337. * Un-registers an exporter extension
  76338. * @param name The name fo the exporter extension
  76339. * @returns A boolean indicating whether the extension has been un-registered
  76340. */
  76341. static UnregisterExtension(name: string): boolean;
  76342. /**
  76343. * Lazy load a local engine
  76344. */
  76345. _getLocalEngine(): Engine;
  76346. private reorderIndicesBasedOnPrimitiveMode;
  76347. /**
  76348. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76349. * clock-wise during export to glTF
  76350. * @param submesh BabylonJS submesh
  76351. * @param primitiveMode Primitive mode of the mesh
  76352. * @param sideOrientation the winding order of the submesh
  76353. * @param vertexBufferKind The type of vertex attribute
  76354. * @param meshAttributeArray The vertex attribute data
  76355. * @param byteOffset The offset to the binary data
  76356. * @param binaryWriter The binary data for the glTF file
  76357. */
  76358. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76359. /**
  76360. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76361. * clock-wise during export to glTF
  76362. * @param submesh BabylonJS submesh
  76363. * @param primitiveMode Primitive mode of the mesh
  76364. * @param sideOrientation the winding order of the submesh
  76365. * @param vertexBufferKind The type of vertex attribute
  76366. * @param meshAttributeArray The vertex attribute data
  76367. * @param byteOffset The offset to the binary data
  76368. * @param binaryWriter The binary data for the glTF file
  76369. */
  76370. private reorderTriangleFillMode;
  76371. /**
  76372. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76373. * clock-wise during export to glTF
  76374. * @param submesh BabylonJS submesh
  76375. * @param primitiveMode Primitive mode of the mesh
  76376. * @param sideOrientation the winding order of the submesh
  76377. * @param vertexBufferKind The type of vertex attribute
  76378. * @param meshAttributeArray The vertex attribute data
  76379. * @param byteOffset The offset to the binary data
  76380. * @param binaryWriter The binary data for the glTF file
  76381. */
  76382. private reorderTriangleStripDrawMode;
  76383. /**
  76384. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  76385. * clock-wise during export to glTF
  76386. * @param submesh BabylonJS submesh
  76387. * @param primitiveMode Primitive mode of the mesh
  76388. * @param sideOrientation the winding order of the submesh
  76389. * @param vertexBufferKind The type of vertex attribute
  76390. * @param meshAttributeArray The vertex attribute data
  76391. * @param byteOffset The offset to the binary data
  76392. * @param binaryWriter The binary data for the glTF file
  76393. */
  76394. private reorderTriangleFanMode;
  76395. /**
  76396. * Writes the vertex attribute data to binary
  76397. * @param vertices The vertices to write to the binary writer
  76398. * @param byteOffset The offset into the binary writer to overwrite binary data
  76399. * @param vertexAttributeKind The vertex attribute type
  76400. * @param meshAttributeArray The vertex attribute data
  76401. * @param binaryWriter The writer containing the binary data
  76402. */
  76403. private writeVertexAttributeData;
  76404. /**
  76405. * Writes mesh attribute data to a data buffer
  76406. * Returns the bytelength of the data
  76407. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  76408. * @param meshAttributeArray Array containing the attribute data
  76409. * @param binaryWriter The buffer to write the binary data to
  76410. * @param indices Used to specify the order of the vertex data
  76411. */
  76412. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  76413. /**
  76414. * Generates glTF json data
  76415. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  76416. * @param glTFPrefix Text to use when prefixing a glTF file
  76417. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  76418. * @returns json data as string
  76419. */
  76420. private generateJSON;
  76421. /**
  76422. * Generates data for .gltf and .bin files based on the glTF prefix string
  76423. * @param glTFPrefix Text to use when prefixing a glTF file
  76424. * @param dispose Dispose the exporter
  76425. * @returns GLTFData with glTF file data
  76426. */
  76427. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76428. /**
  76429. * Creates a binary buffer for glTF
  76430. * @returns array buffer for binary data
  76431. */
  76432. private _generateBinaryAsync;
  76433. /**
  76434. * Pads the number to a multiple of 4
  76435. * @param num number to pad
  76436. * @returns padded number
  76437. */
  76438. private _getPadding;
  76439. /**
  76440. * @hidden
  76441. */
  76442. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76443. /**
  76444. * Sets the TRS for each node
  76445. * @param node glTF Node for storing the transformation data
  76446. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  76447. */
  76448. private setNodeTransformation;
  76449. private getVertexBufferFromMesh;
  76450. /**
  76451. * Creates a bufferview based on the vertices type for the Babylon mesh
  76452. * @param kind Indicates the type of vertices data
  76453. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  76454. * @param binaryWriter The buffer to write the bufferview data to
  76455. */
  76456. private createBufferViewKind;
  76457. /**
  76458. * The primitive mode of the Babylon mesh
  76459. * @param babylonMesh The BabylonJS mesh
  76460. */
  76461. private getMeshPrimitiveMode;
  76462. /**
  76463. * Sets the primitive mode of the glTF mesh primitive
  76464. * @param meshPrimitive glTF mesh primitive
  76465. * @param primitiveMode The primitive mode
  76466. */
  76467. private setPrimitiveMode;
  76468. /**
  76469. * Sets the vertex attribute accessor based of the glTF mesh primitive
  76470. * @param meshPrimitive glTF mesh primitive
  76471. * @param attributeKind vertex attribute
  76472. * @returns boolean specifying if uv coordinates are present
  76473. */
  76474. private setAttributeKind;
  76475. /**
  76476. * Sets data for the primitive attributes of each submesh
  76477. * @param mesh glTF Mesh object to store the primitive attribute information
  76478. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  76479. * @param binaryWriter Buffer to write the attribute data to
  76480. */
  76481. private setPrimitiveAttributesAsync;
  76482. /**
  76483. * Creates a glTF scene based on the array of meshes
  76484. * Returns the the total byte offset
  76485. * @param babylonScene Babylon scene to get the mesh data from
  76486. * @param binaryWriter Buffer to write binary data to
  76487. */
  76488. private createSceneAsync;
  76489. /**
  76490. * Creates a mapping of Node unique id to node index and handles animations
  76491. * @param babylonScene Babylon Scene
  76492. * @param nodes Babylon transform nodes
  76493. * @param binaryWriter Buffer to write binary data to
  76494. * @returns Node mapping of unique id to index
  76495. */
  76496. private createNodeMapAndAnimationsAsync;
  76497. /**
  76498. * Creates a glTF node from a Babylon mesh
  76499. * @param babylonMesh Source Babylon mesh
  76500. * @param binaryWriter Buffer for storing geometry data
  76501. * @returns glTF node
  76502. */
  76503. private createNodeAsync;
  76504. }
  76505. /**
  76506. * @hidden
  76507. *
  76508. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  76509. */
  76510. export class _BinaryWriter {
  76511. /**
  76512. * Array buffer which stores all binary data
  76513. */
  76514. private _arrayBuffer;
  76515. /**
  76516. * View of the array buffer
  76517. */
  76518. private _dataView;
  76519. /**
  76520. * byte offset of data in array buffer
  76521. */
  76522. private _byteOffset;
  76523. /**
  76524. * Initialize binary writer with an initial byte length
  76525. * @param byteLength Initial byte length of the array buffer
  76526. */
  76527. constructor(byteLength: number);
  76528. /**
  76529. * Resize the array buffer to the specified byte length
  76530. * @param byteLength
  76531. */
  76532. private resizeBuffer;
  76533. /**
  76534. * Get an array buffer with the length of the byte offset
  76535. * @returns ArrayBuffer resized to the byte offset
  76536. */
  76537. getArrayBuffer(): ArrayBuffer;
  76538. /**
  76539. * Get the byte offset of the array buffer
  76540. * @returns byte offset
  76541. */
  76542. getByteOffset(): number;
  76543. /**
  76544. * Stores an UInt8 in the array buffer
  76545. * @param entry
  76546. * @param byteOffset If defined, specifies where to set the value as an offset.
  76547. */
  76548. setUInt8(entry: number, byteOffset?: number): void;
  76549. /**
  76550. * Gets an UInt32 in the array buffer
  76551. * @param entry
  76552. * @param byteOffset If defined, specifies where to set the value as an offset.
  76553. */
  76554. getUInt32(byteOffset: number): number;
  76555. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76556. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76557. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76558. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76559. /**
  76560. * Stores a Float32 in the array buffer
  76561. * @param entry
  76562. */
  76563. setFloat32(entry: number, byteOffset?: number): void;
  76564. /**
  76565. * Stores an UInt32 in the array buffer
  76566. * @param entry
  76567. * @param byteOffset If defined, specifies where to set the value as an offset.
  76568. */
  76569. setUInt32(entry: number, byteOffset?: number): void;
  76570. }
  76571. }
  76572. declare module BABYLON.GLTF2.Exporter {
  76573. /**
  76574. * @hidden
  76575. * Interface to store animation data.
  76576. */
  76577. export interface _IAnimationData {
  76578. /**
  76579. * Keyframe data.
  76580. */
  76581. inputs: number[];
  76582. /**
  76583. * Value data.
  76584. */
  76585. outputs: number[][];
  76586. /**
  76587. * Animation interpolation data.
  76588. */
  76589. samplerInterpolation: AnimationSamplerInterpolation;
  76590. /**
  76591. * Minimum keyframe value.
  76592. */
  76593. inputsMin: number;
  76594. /**
  76595. * Maximum keyframe value.
  76596. */
  76597. inputsMax: number;
  76598. }
  76599. /**
  76600. * @hidden
  76601. */
  76602. export interface _IAnimationInfo {
  76603. /**
  76604. * The target channel for the animation
  76605. */
  76606. animationChannelTargetPath: AnimationChannelTargetPath;
  76607. /**
  76608. * The glTF accessor type for the data.
  76609. */
  76610. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  76611. /**
  76612. * Specifies if quaternions should be used.
  76613. */
  76614. useQuaternion: boolean;
  76615. }
  76616. /**
  76617. * @hidden
  76618. * Utility class for generating glTF animation data from BabylonJS.
  76619. */
  76620. export class _GLTFAnimation {
  76621. /**
  76622. * @ignore
  76623. *
  76624. * Creates glTF channel animation from BabylonJS animation.
  76625. * @param babylonTransformNode - BabylonJS mesh.
  76626. * @param animation - animation.
  76627. * @param animationChannelTargetPath - The target animation channel.
  76628. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  76629. * @param useQuaternion - Specifies if quaternions are used.
  76630. * @returns nullable IAnimationData
  76631. */
  76632. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  76633. private static _DeduceAnimationInfo;
  76634. /**
  76635. * @ignore
  76636. * Create node animations from the transform node animations
  76637. * @param babylonNode
  76638. * @param runtimeGLTFAnimation
  76639. * @param idleGLTFAnimations
  76640. * @param nodeMap
  76641. * @param nodes
  76642. * @param binaryWriter
  76643. * @param bufferViews
  76644. * @param accessors
  76645. * @param convertToRightHandedSystem
  76646. */
  76647. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  76648. [key: number]: number;
  76649. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76650. /**
  76651. * @ignore
  76652. * Create node animations from the animation groups
  76653. * @param babylonScene
  76654. * @param glTFAnimations
  76655. * @param nodeMap
  76656. * @param nodes
  76657. * @param binaryWriter
  76658. * @param bufferViews
  76659. * @param accessors
  76660. * @param convertToRightHandedSystem
  76661. */
  76662. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  76663. [key: number]: number;
  76664. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76665. private static AddAnimation;
  76666. /**
  76667. * Create a baked animation
  76668. * @param babylonTransformNode BabylonJS mesh
  76669. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  76670. * @param animationChannelTargetPath animation target channel
  76671. * @param minFrame minimum animation frame
  76672. * @param maxFrame maximum animation frame
  76673. * @param fps frames per second of the animation
  76674. * @param inputs input key frames of the animation
  76675. * @param outputs output key frame data of the animation
  76676. * @param convertToRightHandedSystem converts the values to right-handed
  76677. * @param useQuaternion specifies if quaternions should be used
  76678. */
  76679. private static _CreateBakedAnimation;
  76680. private static _ConvertFactorToVector3OrQuaternion;
  76681. private static _SetInterpolatedValue;
  76682. /**
  76683. * Creates linear animation from the animation key frames
  76684. * @param babylonTransformNode BabylonJS mesh
  76685. * @param animation BabylonJS animation
  76686. * @param animationChannelTargetPath The target animation channel
  76687. * @param frameDelta The difference between the last and first frame of the animation
  76688. * @param inputs Array to store the key frame times
  76689. * @param outputs Array to store the key frame data
  76690. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76691. * @param useQuaternion Specifies if quaternions are used in the animation
  76692. */
  76693. private static _CreateLinearOrStepAnimation;
  76694. /**
  76695. * Creates cubic spline animation from the animation key frames
  76696. * @param babylonTransformNode BabylonJS mesh
  76697. * @param animation BabylonJS animation
  76698. * @param animationChannelTargetPath The target animation channel
  76699. * @param frameDelta The difference between the last and first frame of the animation
  76700. * @param inputs Array to store the key frame times
  76701. * @param outputs Array to store the key frame data
  76702. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76703. * @param useQuaternion Specifies if quaternions are used in the animation
  76704. */
  76705. private static _CreateCubicSplineAnimation;
  76706. private static _GetBasePositionRotationOrScale;
  76707. /**
  76708. * Adds a key frame value
  76709. * @param keyFrame
  76710. * @param animation
  76711. * @param outputs
  76712. * @param animationChannelTargetPath
  76713. * @param basePositionRotationOrScale
  76714. * @param convertToRightHandedSystem
  76715. * @param useQuaternion
  76716. */
  76717. private static _AddKeyframeValue;
  76718. /**
  76719. * Determine the interpolation based on the key frames
  76720. * @param keyFrames
  76721. * @param animationChannelTargetPath
  76722. * @param useQuaternion
  76723. */
  76724. private static _DeduceInterpolation;
  76725. /**
  76726. * Adds an input tangent or output tangent to the output data
  76727. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  76728. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  76729. * @param outputs The animation data by keyframe
  76730. * @param animationChannelTargetPath The target animation channel
  76731. * @param interpolation The interpolation type
  76732. * @param keyFrame The key frame with the animation data
  76733. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  76734. * @param useQuaternion Specifies if quaternions are used
  76735. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  76736. */
  76737. private static AddSplineTangent;
  76738. /**
  76739. * Get the minimum and maximum key frames' frame values
  76740. * @param keyFrames animation key frames
  76741. * @returns the minimum and maximum key frame value
  76742. */
  76743. private static calculateMinMaxKeyFrames;
  76744. }
  76745. }
  76746. declare module BABYLON.GLTF2.Exporter {
  76747. /** @hidden */
  76748. export var textureTransformPixelShader: {
  76749. name: string;
  76750. shader: string;
  76751. };
  76752. }
  76753. declare module BABYLON.GLTF2.Exporter.Extensions {
  76754. /**
  76755. * @hidden
  76756. */
  76757. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  76758. private _recordedTextures;
  76759. /** Name of this extension */
  76760. readonly name: string;
  76761. /** Defines whether this extension is enabled */
  76762. enabled: boolean;
  76763. /** Defines whether this extension is required */
  76764. required: boolean;
  76765. /** Reference to the glTF exporter */
  76766. private _wasUsed;
  76767. constructor(exporter: _Exporter);
  76768. dispose(): void;
  76769. /** @hidden */
  76770. get wasUsed(): boolean;
  76771. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76772. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76773. /**
  76774. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  76775. * @param babylonTexture
  76776. * @param offset
  76777. * @param rotation
  76778. * @param scale
  76779. * @param scene
  76780. */
  76781. private _textureTransformTextureAsync;
  76782. }
  76783. }
  76784. declare module BABYLON.GLTF2.Exporter.Extensions {
  76785. /**
  76786. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  76787. */
  76788. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  76789. /** The name of this extension. */
  76790. readonly name: string;
  76791. /** Defines whether this extension is enabled. */
  76792. enabled: boolean;
  76793. /** Defines whether this extension is required */
  76794. required: boolean;
  76795. /** Reference to the glTF exporter */
  76796. private _exporter;
  76797. private _lights;
  76798. /** @hidden */
  76799. constructor(exporter: _Exporter);
  76800. /** @hidden */
  76801. dispose(): void;
  76802. /** @hidden */
  76803. get wasUsed(): boolean;
  76804. /** @hidden */
  76805. onExporting(): void;
  76806. /**
  76807. * Define this method to modify the default behavior when exporting a node
  76808. * @param context The context when exporting the node
  76809. * @param node glTF node
  76810. * @param babylonNode BabylonJS node
  76811. * @returns nullable INode promise
  76812. */
  76813. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76814. }
  76815. }
  76816. declare module BABYLON.GLTF2.Exporter.Extensions {
  76817. /**
  76818. * @hidden
  76819. */
  76820. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  76821. /** Name of this extension */
  76822. readonly name: string;
  76823. /** Defines whether this extension is enabled */
  76824. enabled: boolean;
  76825. /** Defines whether this extension is required */
  76826. required: boolean;
  76827. /** Reference to the glTF exporter */
  76828. private _textureInfos;
  76829. private _exportedTextures;
  76830. private _wasUsed;
  76831. constructor(exporter: _Exporter);
  76832. dispose(): void;
  76833. /** @hidden */
  76834. get wasUsed(): boolean;
  76835. private _getTextureIndex;
  76836. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76837. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76838. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76839. }
  76840. }
  76841. declare module BABYLON {
  76842. /**
  76843. * Class for generating STL data from a Babylon scene.
  76844. */
  76845. export class STLExport {
  76846. /**
  76847. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  76848. * @param meshes list defines the mesh to serialize
  76849. * @param download triggers the automatic download of the file.
  76850. * @param fileName changes the downloads fileName.
  76851. * @param binary changes the STL to a binary type.
  76852. * @param isLittleEndian toggle for binary type exporter.
  76853. * @returns the STL as UTF8 string
  76854. */
  76855. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  76856. }
  76857. }
  76858. declare module "babylonjs-gltf2interface" {
  76859. export = BABYLON.GLTF2;
  76860. }
  76861. /**
  76862. * Module for glTF 2.0 Interface
  76863. */
  76864. declare module BABYLON.GLTF2 {
  76865. /**
  76866. * The datatype of the components in the attribute
  76867. */
  76868. const enum AccessorComponentType {
  76869. /**
  76870. * Byte
  76871. */
  76872. BYTE = 5120,
  76873. /**
  76874. * Unsigned Byte
  76875. */
  76876. UNSIGNED_BYTE = 5121,
  76877. /**
  76878. * Short
  76879. */
  76880. SHORT = 5122,
  76881. /**
  76882. * Unsigned Short
  76883. */
  76884. UNSIGNED_SHORT = 5123,
  76885. /**
  76886. * Unsigned Int
  76887. */
  76888. UNSIGNED_INT = 5125,
  76889. /**
  76890. * Float
  76891. */
  76892. FLOAT = 5126,
  76893. }
  76894. /**
  76895. * Specifies if the attirbute is a scalar, vector, or matrix
  76896. */
  76897. const enum AccessorType {
  76898. /**
  76899. * Scalar
  76900. */
  76901. SCALAR = "SCALAR",
  76902. /**
  76903. * Vector2
  76904. */
  76905. VEC2 = "VEC2",
  76906. /**
  76907. * Vector3
  76908. */
  76909. VEC3 = "VEC3",
  76910. /**
  76911. * Vector4
  76912. */
  76913. VEC4 = "VEC4",
  76914. /**
  76915. * Matrix2x2
  76916. */
  76917. MAT2 = "MAT2",
  76918. /**
  76919. * Matrix3x3
  76920. */
  76921. MAT3 = "MAT3",
  76922. /**
  76923. * Matrix4x4
  76924. */
  76925. MAT4 = "MAT4",
  76926. }
  76927. /**
  76928. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  76929. */
  76930. const enum AnimationChannelTargetPath {
  76931. /**
  76932. * Translation
  76933. */
  76934. TRANSLATION = "translation",
  76935. /**
  76936. * Rotation
  76937. */
  76938. ROTATION = "rotation",
  76939. /**
  76940. * Scale
  76941. */
  76942. SCALE = "scale",
  76943. /**
  76944. * Weights
  76945. */
  76946. WEIGHTS = "weights",
  76947. }
  76948. /**
  76949. * Interpolation algorithm
  76950. */
  76951. const enum AnimationSamplerInterpolation {
  76952. /**
  76953. * The animated values are linearly interpolated between keyframes
  76954. */
  76955. LINEAR = "LINEAR",
  76956. /**
  76957. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  76958. */
  76959. STEP = "STEP",
  76960. /**
  76961. * The animation's interpolation is computed using a cubic spline with specified tangents
  76962. */
  76963. CUBICSPLINE = "CUBICSPLINE",
  76964. }
  76965. /**
  76966. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  76967. */
  76968. const enum CameraType {
  76969. /**
  76970. * A perspective camera containing properties to create a perspective projection matrix
  76971. */
  76972. PERSPECTIVE = "perspective",
  76973. /**
  76974. * An orthographic camera containing properties to create an orthographic projection matrix
  76975. */
  76976. ORTHOGRAPHIC = "orthographic",
  76977. }
  76978. /**
  76979. * The mime-type of the image
  76980. */
  76981. const enum ImageMimeType {
  76982. /**
  76983. * JPEG Mime-type
  76984. */
  76985. JPEG = "image/jpeg",
  76986. /**
  76987. * PNG Mime-type
  76988. */
  76989. PNG = "image/png",
  76990. }
  76991. /**
  76992. * The alpha rendering mode of the material
  76993. */
  76994. const enum MaterialAlphaMode {
  76995. /**
  76996. * The alpha value is ignored and the rendered output is fully opaque
  76997. */
  76998. OPAQUE = "OPAQUE",
  76999. /**
  77000. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77001. */
  77002. MASK = "MASK",
  77003. /**
  77004. * 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)
  77005. */
  77006. BLEND = "BLEND",
  77007. }
  77008. /**
  77009. * The type of the primitives to render
  77010. */
  77011. const enum MeshPrimitiveMode {
  77012. /**
  77013. * Points
  77014. */
  77015. POINTS = 0,
  77016. /**
  77017. * Lines
  77018. */
  77019. LINES = 1,
  77020. /**
  77021. * Line Loop
  77022. */
  77023. LINE_LOOP = 2,
  77024. /**
  77025. * Line Strip
  77026. */
  77027. LINE_STRIP = 3,
  77028. /**
  77029. * Triangles
  77030. */
  77031. TRIANGLES = 4,
  77032. /**
  77033. * Triangle Strip
  77034. */
  77035. TRIANGLE_STRIP = 5,
  77036. /**
  77037. * Triangle Fan
  77038. */
  77039. TRIANGLE_FAN = 6,
  77040. }
  77041. /**
  77042. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77043. */
  77044. const enum TextureMagFilter {
  77045. /**
  77046. * Nearest
  77047. */
  77048. NEAREST = 9728,
  77049. /**
  77050. * Linear
  77051. */
  77052. LINEAR = 9729,
  77053. }
  77054. /**
  77055. * Minification filter. All valid values correspond to WebGL enums
  77056. */
  77057. const enum TextureMinFilter {
  77058. /**
  77059. * Nearest
  77060. */
  77061. NEAREST = 9728,
  77062. /**
  77063. * Linear
  77064. */
  77065. LINEAR = 9729,
  77066. /**
  77067. * Nearest Mip-Map Nearest
  77068. */
  77069. NEAREST_MIPMAP_NEAREST = 9984,
  77070. /**
  77071. * Linear Mipmap Nearest
  77072. */
  77073. LINEAR_MIPMAP_NEAREST = 9985,
  77074. /**
  77075. * Nearest Mipmap Linear
  77076. */
  77077. NEAREST_MIPMAP_LINEAR = 9986,
  77078. /**
  77079. * Linear Mipmap Linear
  77080. */
  77081. LINEAR_MIPMAP_LINEAR = 9987,
  77082. }
  77083. /**
  77084. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77085. */
  77086. const enum TextureWrapMode {
  77087. /**
  77088. * Clamp to Edge
  77089. */
  77090. CLAMP_TO_EDGE = 33071,
  77091. /**
  77092. * Mirrored Repeat
  77093. */
  77094. MIRRORED_REPEAT = 33648,
  77095. /**
  77096. * Repeat
  77097. */
  77098. REPEAT = 10497,
  77099. }
  77100. /**
  77101. * glTF Property
  77102. */
  77103. interface IProperty {
  77104. /**
  77105. * Dictionary object with extension-specific objects
  77106. */
  77107. extensions?: {
  77108. [key: string]: any;
  77109. };
  77110. /**
  77111. * Application-Specific data
  77112. */
  77113. extras?: any;
  77114. }
  77115. /**
  77116. * glTF Child of Root Property
  77117. */
  77118. interface IChildRootProperty extends IProperty {
  77119. /**
  77120. * The user-defined name of this object
  77121. */
  77122. name?: string;
  77123. }
  77124. /**
  77125. * Indices of those attributes that deviate from their initialization value
  77126. */
  77127. interface IAccessorSparseIndices extends IProperty {
  77128. /**
  77129. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77130. */
  77131. bufferView: number;
  77132. /**
  77133. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77134. */
  77135. byteOffset?: number;
  77136. /**
  77137. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77138. */
  77139. componentType: AccessorComponentType;
  77140. }
  77141. /**
  77142. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77143. */
  77144. interface IAccessorSparseValues extends IProperty {
  77145. /**
  77146. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77147. */
  77148. bufferView: number;
  77149. /**
  77150. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77151. */
  77152. byteOffset?: number;
  77153. }
  77154. /**
  77155. * Sparse storage of attributes that deviate from their initialization value
  77156. */
  77157. interface IAccessorSparse extends IProperty {
  77158. /**
  77159. * The number of attributes encoded in this sparse accessor
  77160. */
  77161. count: number;
  77162. /**
  77163. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77164. */
  77165. indices: IAccessorSparseIndices;
  77166. /**
  77167. * 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
  77168. */
  77169. values: IAccessorSparseValues;
  77170. }
  77171. /**
  77172. * 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
  77173. */
  77174. interface IAccessor extends IChildRootProperty {
  77175. /**
  77176. * The index of the bufferview
  77177. */
  77178. bufferView?: number;
  77179. /**
  77180. * The offset relative to the start of the bufferView in bytes
  77181. */
  77182. byteOffset?: number;
  77183. /**
  77184. * The datatype of components in the attribute
  77185. */
  77186. componentType: AccessorComponentType;
  77187. /**
  77188. * Specifies whether integer data values should be normalized
  77189. */
  77190. normalized?: boolean;
  77191. /**
  77192. * The number of attributes referenced by this accessor
  77193. */
  77194. count: number;
  77195. /**
  77196. * Specifies if the attribute is a scalar, vector, or matrix
  77197. */
  77198. type: AccessorType;
  77199. /**
  77200. * Maximum value of each component in this attribute
  77201. */
  77202. max?: number[];
  77203. /**
  77204. * Minimum value of each component in this attribute
  77205. */
  77206. min?: number[];
  77207. /**
  77208. * Sparse storage of attributes that deviate from their initialization value
  77209. */
  77210. sparse?: IAccessorSparse;
  77211. }
  77212. /**
  77213. * Targets an animation's sampler at a node's property
  77214. */
  77215. interface IAnimationChannel extends IProperty {
  77216. /**
  77217. * The index of a sampler in this animation used to compute the value for the target
  77218. */
  77219. sampler: number;
  77220. /**
  77221. * The index of the node and TRS property to target
  77222. */
  77223. target: IAnimationChannelTarget;
  77224. }
  77225. /**
  77226. * The index of the node and TRS property that an animation channel targets
  77227. */
  77228. interface IAnimationChannelTarget extends IProperty {
  77229. /**
  77230. * The index of the node to target
  77231. */
  77232. node: number;
  77233. /**
  77234. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77235. */
  77236. path: AnimationChannelTargetPath;
  77237. }
  77238. /**
  77239. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77240. */
  77241. interface IAnimationSampler extends IProperty {
  77242. /**
  77243. * The index of an accessor containing keyframe input values, e.g., time
  77244. */
  77245. input: number;
  77246. /**
  77247. * Interpolation algorithm
  77248. */
  77249. interpolation?: AnimationSamplerInterpolation;
  77250. /**
  77251. * The index of an accessor, containing keyframe output values
  77252. */
  77253. output: number;
  77254. }
  77255. /**
  77256. * A keyframe animation
  77257. */
  77258. interface IAnimation extends IChildRootProperty {
  77259. /**
  77260. * An array of channels, each of which targets an animation's sampler at a node's property
  77261. */
  77262. channels: IAnimationChannel[];
  77263. /**
  77264. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77265. */
  77266. samplers: IAnimationSampler[];
  77267. }
  77268. /**
  77269. * Metadata about the glTF asset
  77270. */
  77271. interface IAsset extends IChildRootProperty {
  77272. /**
  77273. * A copyright message suitable for display to credit the content creator
  77274. */
  77275. copyright?: string;
  77276. /**
  77277. * Tool that generated this glTF model. Useful for debugging
  77278. */
  77279. generator?: string;
  77280. /**
  77281. * The glTF version that this asset targets
  77282. */
  77283. version: string;
  77284. /**
  77285. * The minimum glTF version that this asset targets
  77286. */
  77287. minVersion?: string;
  77288. }
  77289. /**
  77290. * A buffer points to binary geometry, animation, or skins
  77291. */
  77292. interface IBuffer extends IChildRootProperty {
  77293. /**
  77294. * 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
  77295. */
  77296. uri?: string;
  77297. /**
  77298. * The length of the buffer in bytes
  77299. */
  77300. byteLength: number;
  77301. }
  77302. /**
  77303. * A view into a buffer generally representing a subset of the buffer
  77304. */
  77305. interface IBufferView extends IChildRootProperty {
  77306. /**
  77307. * The index of the buffer
  77308. */
  77309. buffer: number;
  77310. /**
  77311. * The offset into the buffer in bytes
  77312. */
  77313. byteOffset?: number;
  77314. /**
  77315. * The lenth of the bufferView in bytes
  77316. */
  77317. byteLength: number;
  77318. /**
  77319. * The stride, in bytes
  77320. */
  77321. byteStride?: number;
  77322. }
  77323. /**
  77324. * An orthographic camera containing properties to create an orthographic projection matrix
  77325. */
  77326. interface ICameraOrthographic extends IProperty {
  77327. /**
  77328. * The floating-point horizontal magnification of the view. Must not be zero
  77329. */
  77330. xmag: number;
  77331. /**
  77332. * The floating-point vertical magnification of the view. Must not be zero
  77333. */
  77334. ymag: number;
  77335. /**
  77336. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77337. */
  77338. zfar: number;
  77339. /**
  77340. * The floating-point distance to the near clipping plane
  77341. */
  77342. znear: number;
  77343. }
  77344. /**
  77345. * A perspective camera containing properties to create a perspective projection matrix
  77346. */
  77347. interface ICameraPerspective extends IProperty {
  77348. /**
  77349. * The floating-point aspect ratio of the field of view
  77350. */
  77351. aspectRatio?: number;
  77352. /**
  77353. * The floating-point vertical field of view in radians
  77354. */
  77355. yfov: number;
  77356. /**
  77357. * The floating-point distance to the far clipping plane
  77358. */
  77359. zfar?: number;
  77360. /**
  77361. * The floating-point distance to the near clipping plane
  77362. */
  77363. znear: number;
  77364. }
  77365. /**
  77366. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77367. */
  77368. interface ICamera extends IChildRootProperty {
  77369. /**
  77370. * An orthographic camera containing properties to create an orthographic projection matrix
  77371. */
  77372. orthographic?: ICameraOrthographic;
  77373. /**
  77374. * A perspective camera containing properties to create a perspective projection matrix
  77375. */
  77376. perspective?: ICameraPerspective;
  77377. /**
  77378. * Specifies if the camera uses a perspective or orthographic projection
  77379. */
  77380. type: CameraType;
  77381. }
  77382. /**
  77383. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  77384. */
  77385. interface IImage extends IChildRootProperty {
  77386. /**
  77387. * 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
  77388. */
  77389. uri?: string;
  77390. /**
  77391. * The image's MIME type
  77392. */
  77393. mimeType?: ImageMimeType;
  77394. /**
  77395. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  77396. */
  77397. bufferView?: number;
  77398. }
  77399. /**
  77400. * Material Normal Texture Info
  77401. */
  77402. interface IMaterialNormalTextureInfo extends ITextureInfo {
  77403. /**
  77404. * The scalar multiplier applied to each normal vector of the normal texture
  77405. */
  77406. scale?: number;
  77407. }
  77408. /**
  77409. * Material Occlusion Texture Info
  77410. */
  77411. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  77412. /**
  77413. * A scalar multiplier controlling the amount of occlusion applied
  77414. */
  77415. strength?: number;
  77416. }
  77417. /**
  77418. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  77419. */
  77420. interface IMaterialPbrMetallicRoughness {
  77421. /**
  77422. * The material's base color factor
  77423. */
  77424. baseColorFactor?: number[];
  77425. /**
  77426. * The base color texture
  77427. */
  77428. baseColorTexture?: ITextureInfo;
  77429. /**
  77430. * The metalness of the material
  77431. */
  77432. metallicFactor?: number;
  77433. /**
  77434. * The roughness of the material
  77435. */
  77436. roughnessFactor?: number;
  77437. /**
  77438. * The metallic-roughness texture
  77439. */
  77440. metallicRoughnessTexture?: ITextureInfo;
  77441. }
  77442. /**
  77443. * The material appearance of a primitive
  77444. */
  77445. interface IMaterial extends IChildRootProperty {
  77446. /**
  77447. * 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
  77448. */
  77449. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77450. /**
  77451. * The normal map texture
  77452. */
  77453. normalTexture?: IMaterialNormalTextureInfo;
  77454. /**
  77455. * The occlusion map texture
  77456. */
  77457. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77458. /**
  77459. * The emissive map texture
  77460. */
  77461. emissiveTexture?: ITextureInfo;
  77462. /**
  77463. * 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
  77464. */
  77465. emissiveFactor?: number[];
  77466. /**
  77467. * The alpha rendering mode of the material
  77468. */
  77469. alphaMode?: MaterialAlphaMode;
  77470. /**
  77471. * The alpha cutoff value of the material
  77472. */
  77473. alphaCutoff?: number;
  77474. /**
  77475. * Specifies whether the material is double sided
  77476. */
  77477. doubleSided?: boolean;
  77478. }
  77479. /**
  77480. * Geometry to be rendered with the given material
  77481. */
  77482. interface IMeshPrimitive extends IProperty {
  77483. /**
  77484. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  77485. */
  77486. attributes: {
  77487. [name: string]: number;
  77488. };
  77489. /**
  77490. * The index of the accessor that contains the indices
  77491. */
  77492. indices?: number;
  77493. /**
  77494. * The index of the material to apply to this primitive when rendering
  77495. */
  77496. material?: number;
  77497. /**
  77498. * The type of primitives to render. All valid values correspond to WebGL enums
  77499. */
  77500. mode?: MeshPrimitiveMode;
  77501. /**
  77502. * 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
  77503. */
  77504. targets?: {
  77505. [name: string]: number;
  77506. }[];
  77507. }
  77508. /**
  77509. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  77510. */
  77511. interface IMesh extends IChildRootProperty {
  77512. /**
  77513. * An array of primitives, each defining geometry to be rendered with a material
  77514. */
  77515. primitives: IMeshPrimitive[];
  77516. /**
  77517. * Array of weights to be applied to the Morph Targets
  77518. */
  77519. weights?: number[];
  77520. }
  77521. /**
  77522. * A node in the node hierarchy
  77523. */
  77524. interface INode extends IChildRootProperty {
  77525. /**
  77526. * The index of the camera referenced by this node
  77527. */
  77528. camera?: number;
  77529. /**
  77530. * The indices of this node's children
  77531. */
  77532. children?: number[];
  77533. /**
  77534. * The index of the skin referenced by this node
  77535. */
  77536. skin?: number;
  77537. /**
  77538. * A floating-point 4x4 transformation matrix stored in column-major order
  77539. */
  77540. matrix?: number[];
  77541. /**
  77542. * The index of the mesh in this node
  77543. */
  77544. mesh?: number;
  77545. /**
  77546. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  77547. */
  77548. rotation?: number[];
  77549. /**
  77550. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  77551. */
  77552. scale?: number[];
  77553. /**
  77554. * The node's translation along the x, y, and z axes
  77555. */
  77556. translation?: number[];
  77557. /**
  77558. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  77559. */
  77560. weights?: number[];
  77561. }
  77562. /**
  77563. * Texture sampler properties for filtering and wrapping modes
  77564. */
  77565. interface ISampler extends IChildRootProperty {
  77566. /**
  77567. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77568. */
  77569. magFilter?: TextureMagFilter;
  77570. /**
  77571. * Minification filter. All valid values correspond to WebGL enums
  77572. */
  77573. minFilter?: TextureMinFilter;
  77574. /**
  77575. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77576. */
  77577. wrapS?: TextureWrapMode;
  77578. /**
  77579. * T (V) wrapping mode. All valid values correspond to WebGL enums
  77580. */
  77581. wrapT?: TextureWrapMode;
  77582. }
  77583. /**
  77584. * The root nodes of a scene
  77585. */
  77586. interface IScene extends IChildRootProperty {
  77587. /**
  77588. * The indices of each root node
  77589. */
  77590. nodes: number[];
  77591. }
  77592. /**
  77593. * Joints and matrices defining a skin
  77594. */
  77595. interface ISkin extends IChildRootProperty {
  77596. /**
  77597. * 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
  77598. */
  77599. inverseBindMatrices?: number;
  77600. /**
  77601. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  77602. */
  77603. skeleton?: number;
  77604. /**
  77605. * 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)
  77606. */
  77607. joints: number[];
  77608. }
  77609. /**
  77610. * A texture and its sampler
  77611. */
  77612. interface ITexture extends IChildRootProperty {
  77613. /**
  77614. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  77615. */
  77616. sampler?: number;
  77617. /**
  77618. * The index of the image used by this texture
  77619. */
  77620. source: number;
  77621. }
  77622. /**
  77623. * Reference to a texture
  77624. */
  77625. interface ITextureInfo extends IProperty {
  77626. /**
  77627. * The index of the texture
  77628. */
  77629. index: number;
  77630. /**
  77631. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  77632. */
  77633. texCoord?: number;
  77634. }
  77635. /**
  77636. * The root object for a glTF asset
  77637. */
  77638. interface IGLTF extends IProperty {
  77639. /**
  77640. * An array of accessors. An accessor is a typed view into a bufferView
  77641. */
  77642. accessors?: IAccessor[];
  77643. /**
  77644. * An array of keyframe animations
  77645. */
  77646. animations?: IAnimation[];
  77647. /**
  77648. * Metadata about the glTF asset
  77649. */
  77650. asset: IAsset;
  77651. /**
  77652. * An array of buffers. A buffer points to binary geometry, animation, or skins
  77653. */
  77654. buffers?: IBuffer[];
  77655. /**
  77656. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  77657. */
  77658. bufferViews?: IBufferView[];
  77659. /**
  77660. * An array of cameras
  77661. */
  77662. cameras?: ICamera[];
  77663. /**
  77664. * Names of glTF extensions used somewhere in this asset
  77665. */
  77666. extensionsUsed?: string[];
  77667. /**
  77668. * Names of glTF extensions required to properly load this asset
  77669. */
  77670. extensionsRequired?: string[];
  77671. /**
  77672. * An array of images. An image defines data used to create a texture
  77673. */
  77674. images?: IImage[];
  77675. /**
  77676. * An array of materials. A material defines the appearance of a primitive
  77677. */
  77678. materials?: IMaterial[];
  77679. /**
  77680. * An array of meshes. A mesh is a set of primitives to be rendered
  77681. */
  77682. meshes?: IMesh[];
  77683. /**
  77684. * An array of nodes
  77685. */
  77686. nodes?: INode[];
  77687. /**
  77688. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  77689. */
  77690. samplers?: ISampler[];
  77691. /**
  77692. * The index of the default scene
  77693. */
  77694. scene?: number;
  77695. /**
  77696. * An array of scenes
  77697. */
  77698. scenes?: IScene[];
  77699. /**
  77700. * An array of skins. A skin is defined by joints and matrices
  77701. */
  77702. skins?: ISkin[];
  77703. /**
  77704. * An array of textures
  77705. */
  77706. textures?: ITexture[];
  77707. }
  77708. /**
  77709. * The glTF validation results
  77710. * @ignore
  77711. */
  77712. interface IGLTFValidationResults {
  77713. info: {
  77714. generator: string;
  77715. hasAnimations: boolean;
  77716. hasDefaultScene: boolean;
  77717. hasMaterials: boolean;
  77718. hasMorphTargets: boolean;
  77719. hasSkins: boolean;
  77720. hasTextures: boolean;
  77721. maxAttributesUsed: number;
  77722. primitivesCount: number
  77723. };
  77724. issues: {
  77725. messages: Array<string>;
  77726. numErrors: number;
  77727. numHints: number;
  77728. numInfos: number;
  77729. numWarnings: number;
  77730. truncated: boolean
  77731. };
  77732. mimeType: string;
  77733. uri: string;
  77734. validatedAt: string;
  77735. validatorVersion: string;
  77736. }
  77737. /**
  77738. * The glTF validation options
  77739. */
  77740. interface IGLTFValidationOptions {
  77741. /** Uri to use */
  77742. uri?: string;
  77743. /** Function used to load external resources */
  77744. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  77745. /** Boolean indicating that we need to validate accessor data */
  77746. validateAccessorData?: boolean;
  77747. /** max number of issues allowed */
  77748. maxIssues?: number;
  77749. /** Ignored issues */
  77750. ignoredIssues?: Array<string>;
  77751. /** Value to override severy settings */
  77752. severityOverrides?: Object;
  77753. }
  77754. /**
  77755. * The glTF validator object
  77756. * @ignore
  77757. */
  77758. interface IGLTFValidator {
  77759. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77760. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77761. }
  77762. }
  77763. declare module BABYLON {
  77764. /** @hidden */
  77765. export var cellPixelShader: {
  77766. name: string;
  77767. shader: string;
  77768. };
  77769. }
  77770. declare module BABYLON {
  77771. /** @hidden */
  77772. export var cellVertexShader: {
  77773. name: string;
  77774. shader: string;
  77775. };
  77776. }
  77777. declare module BABYLON {
  77778. export class CellMaterial extends BABYLON.PushMaterial {
  77779. private _diffuseTexture;
  77780. diffuseTexture: BABYLON.BaseTexture;
  77781. diffuseColor: BABYLON.Color3;
  77782. _computeHighLevel: boolean;
  77783. computeHighLevel: boolean;
  77784. private _disableLighting;
  77785. disableLighting: boolean;
  77786. private _maxSimultaneousLights;
  77787. maxSimultaneousLights: number;
  77788. private _renderId;
  77789. constructor(name: string, scene: BABYLON.Scene);
  77790. needAlphaBlending(): boolean;
  77791. needAlphaTesting(): boolean;
  77792. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77793. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77794. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77795. getAnimatables(): BABYLON.IAnimatable[];
  77796. getActiveTextures(): BABYLON.BaseTexture[];
  77797. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77798. dispose(forceDisposeEffect?: boolean): void;
  77799. getClassName(): string;
  77800. clone(name: string): CellMaterial;
  77801. serialize(): any;
  77802. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  77803. }
  77804. }
  77805. declare module BABYLON {
  77806. export class CustomShaderStructure {
  77807. FragmentStore: string;
  77808. VertexStore: string;
  77809. constructor();
  77810. }
  77811. export class ShaderSpecialParts {
  77812. constructor();
  77813. Fragment_Begin: string;
  77814. Fragment_Definitions: string;
  77815. Fragment_MainBegin: string;
  77816. Fragment_Custom_Diffuse: string;
  77817. Fragment_Before_Lights: string;
  77818. Fragment_Before_Fog: string;
  77819. Fragment_Custom_Alpha: string;
  77820. Fragment_Before_FragColor: string;
  77821. Vertex_Begin: string;
  77822. Vertex_Definitions: string;
  77823. Vertex_MainBegin: string;
  77824. Vertex_Before_PositionUpdated: string;
  77825. Vertex_Before_NormalUpdated: string;
  77826. Vertex_MainEnd: string;
  77827. }
  77828. export class CustomMaterial extends BABYLON.StandardMaterial {
  77829. static ShaderIndexer: number;
  77830. CustomParts: ShaderSpecialParts;
  77831. _isCreatedShader: boolean;
  77832. _createdShaderName: string;
  77833. _customUniform: string[];
  77834. _newUniforms: string[];
  77835. _newUniformInstances: any[];
  77836. _newSamplerInstances: BABYLON.Texture[];
  77837. FragmentShader: string;
  77838. VertexShader: string;
  77839. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77840. ReviewUniform(name: string, arr: string[]): string[];
  77841. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  77842. constructor(name: string, scene: BABYLON.Scene);
  77843. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  77844. Fragment_Begin(shaderPart: string): CustomMaterial;
  77845. Fragment_Definitions(shaderPart: string): CustomMaterial;
  77846. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  77847. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  77848. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  77849. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  77850. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  77851. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  77852. Vertex_Begin(shaderPart: string): CustomMaterial;
  77853. Vertex_Definitions(shaderPart: string): CustomMaterial;
  77854. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  77855. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  77856. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  77857. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  77858. }
  77859. }
  77860. declare module BABYLON {
  77861. export class ShaderAlebdoParts {
  77862. constructor();
  77863. Fragment_Begin: string;
  77864. Fragment_Definitions: string;
  77865. Fragment_MainBegin: string;
  77866. Fragment_Custom_Albedo: string;
  77867. Fragment_Before_Lights: string;
  77868. Fragment_Custom_MetallicRoughness: string;
  77869. Fragment_Custom_MicroSurface: string;
  77870. Fragment_Before_Fog: string;
  77871. Fragment_Custom_Alpha: string;
  77872. Fragment_Before_FragColor: string;
  77873. Vertex_Begin: string;
  77874. Vertex_Definitions: string;
  77875. Vertex_MainBegin: string;
  77876. Vertex_Before_PositionUpdated: string;
  77877. Vertex_Before_NormalUpdated: string;
  77878. Vertex_MainEnd: string;
  77879. }
  77880. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  77881. static ShaderIndexer: number;
  77882. CustomParts: ShaderAlebdoParts;
  77883. _isCreatedShader: boolean;
  77884. _createdShaderName: string;
  77885. _customUniform: string[];
  77886. _newUniforms: string[];
  77887. _newUniformInstances: any[];
  77888. _newSamplerInstances: BABYLON.Texture[];
  77889. FragmentShader: string;
  77890. VertexShader: string;
  77891. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77892. ReviewUniform(name: string, arr: string[]): string[];
  77893. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  77894. constructor(name: string, scene: BABYLON.Scene);
  77895. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  77896. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  77897. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  77898. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  77899. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  77900. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  77901. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  77902. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  77903. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  77904. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  77905. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  77906. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  77907. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  77908. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  77909. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  77910. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  77911. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  77912. }
  77913. }
  77914. declare module BABYLON {
  77915. /** @hidden */
  77916. export var firePixelShader: {
  77917. name: string;
  77918. shader: string;
  77919. };
  77920. }
  77921. declare module BABYLON {
  77922. /** @hidden */
  77923. export var fireVertexShader: {
  77924. name: string;
  77925. shader: string;
  77926. };
  77927. }
  77928. declare module BABYLON {
  77929. export class FireMaterial extends BABYLON.PushMaterial {
  77930. private _diffuseTexture;
  77931. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77932. private _distortionTexture;
  77933. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77934. private _opacityTexture;
  77935. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77936. diffuseColor: BABYLON.Color3;
  77937. speed: number;
  77938. private _scaledDiffuse;
  77939. private _renderId;
  77940. private _lastTime;
  77941. constructor(name: string, scene: BABYLON.Scene);
  77942. needAlphaBlending(): boolean;
  77943. needAlphaTesting(): boolean;
  77944. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77945. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77946. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77947. getAnimatables(): BABYLON.IAnimatable[];
  77948. getActiveTextures(): BABYLON.BaseTexture[];
  77949. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77950. getClassName(): string;
  77951. dispose(forceDisposeEffect?: boolean): void;
  77952. clone(name: string): FireMaterial;
  77953. serialize(): any;
  77954. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  77955. }
  77956. }
  77957. declare module BABYLON {
  77958. /** @hidden */
  77959. export var furPixelShader: {
  77960. name: string;
  77961. shader: string;
  77962. };
  77963. }
  77964. declare module BABYLON {
  77965. /** @hidden */
  77966. export var furVertexShader: {
  77967. name: string;
  77968. shader: string;
  77969. };
  77970. }
  77971. declare module BABYLON {
  77972. export class FurMaterial extends BABYLON.PushMaterial {
  77973. private _diffuseTexture;
  77974. diffuseTexture: BABYLON.BaseTexture;
  77975. private _heightTexture;
  77976. heightTexture: BABYLON.BaseTexture;
  77977. diffuseColor: BABYLON.Color3;
  77978. furLength: number;
  77979. furAngle: number;
  77980. furColor: BABYLON.Color3;
  77981. furOffset: number;
  77982. furSpacing: number;
  77983. furGravity: BABYLON.Vector3;
  77984. furSpeed: number;
  77985. furDensity: number;
  77986. furOcclusion: number;
  77987. furTexture: BABYLON.DynamicTexture;
  77988. private _disableLighting;
  77989. disableLighting: boolean;
  77990. private _maxSimultaneousLights;
  77991. maxSimultaneousLights: number;
  77992. highLevelFur: boolean;
  77993. _meshes: BABYLON.AbstractMesh[];
  77994. private _renderId;
  77995. private _furTime;
  77996. constructor(name: string, scene: BABYLON.Scene);
  77997. get furTime(): number;
  77998. set furTime(furTime: number);
  77999. needAlphaBlending(): boolean;
  78000. needAlphaTesting(): boolean;
  78001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78002. updateFur(): void;
  78003. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78004. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78005. getAnimatables(): BABYLON.IAnimatable[];
  78006. getActiveTextures(): BABYLON.BaseTexture[];
  78007. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78008. dispose(forceDisposeEffect?: boolean): void;
  78009. clone(name: string): FurMaterial;
  78010. serialize(): any;
  78011. getClassName(): string;
  78012. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78013. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78014. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78015. }
  78016. }
  78017. declare module BABYLON {
  78018. /** @hidden */
  78019. export var gradientPixelShader: {
  78020. name: string;
  78021. shader: string;
  78022. };
  78023. }
  78024. declare module BABYLON {
  78025. /** @hidden */
  78026. export var gradientVertexShader: {
  78027. name: string;
  78028. shader: string;
  78029. };
  78030. }
  78031. declare module BABYLON {
  78032. export class GradientMaterial extends BABYLON.PushMaterial {
  78033. private _maxSimultaneousLights;
  78034. maxSimultaneousLights: number;
  78035. topColor: BABYLON.Color3;
  78036. topColorAlpha: number;
  78037. bottomColor: BABYLON.Color3;
  78038. bottomColorAlpha: number;
  78039. offset: number;
  78040. scale: number;
  78041. smoothness: number;
  78042. private _disableLighting;
  78043. disableLighting: boolean;
  78044. private _renderId;
  78045. constructor(name: string, scene: BABYLON.Scene);
  78046. needAlphaBlending(): boolean;
  78047. needAlphaTesting(): boolean;
  78048. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78049. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78050. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78051. getAnimatables(): BABYLON.IAnimatable[];
  78052. dispose(forceDisposeEffect?: boolean): void;
  78053. clone(name: string): GradientMaterial;
  78054. serialize(): any;
  78055. getClassName(): string;
  78056. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78057. }
  78058. }
  78059. declare module BABYLON {
  78060. /** @hidden */
  78061. export var gridPixelShader: {
  78062. name: string;
  78063. shader: string;
  78064. };
  78065. }
  78066. declare module BABYLON {
  78067. /** @hidden */
  78068. export var gridVertexShader: {
  78069. name: string;
  78070. shader: string;
  78071. };
  78072. }
  78073. declare module BABYLON {
  78074. /**
  78075. * The grid materials allows you to wrap any shape with a grid.
  78076. * Colors are customizable.
  78077. */
  78078. export class GridMaterial extends BABYLON.PushMaterial {
  78079. /**
  78080. * Main color of the grid (e.g. between lines)
  78081. */
  78082. mainColor: BABYLON.Color3;
  78083. /**
  78084. * Color of the grid lines.
  78085. */
  78086. lineColor: BABYLON.Color3;
  78087. /**
  78088. * The scale of the grid compared to unit.
  78089. */
  78090. gridRatio: number;
  78091. /**
  78092. * Allows setting an offset for the grid lines.
  78093. */
  78094. gridOffset: BABYLON.Vector3;
  78095. /**
  78096. * The frequency of thicker lines.
  78097. */
  78098. majorUnitFrequency: number;
  78099. /**
  78100. * The visibility of minor units in the grid.
  78101. */
  78102. minorUnitVisibility: number;
  78103. /**
  78104. * The grid opacity outside of the lines.
  78105. */
  78106. opacity: number;
  78107. /**
  78108. * Determine RBG output is premultiplied by alpha value.
  78109. */
  78110. preMultiplyAlpha: boolean;
  78111. private _opacityTexture;
  78112. opacityTexture: BABYLON.BaseTexture;
  78113. private _gridControl;
  78114. private _renderId;
  78115. /**
  78116. * constructor
  78117. * @param name The name given to the material in order to identify it afterwards.
  78118. * @param scene The scene the material is used in.
  78119. */
  78120. constructor(name: string, scene: BABYLON.Scene);
  78121. /**
  78122. * Returns wehter or not the grid requires alpha blending.
  78123. */
  78124. needAlphaBlending(): boolean;
  78125. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78126. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78127. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78128. /**
  78129. * Dispose the material and its associated resources.
  78130. * @param forceDisposeEffect will also dispose the used effect when true
  78131. */
  78132. dispose(forceDisposeEffect?: boolean): void;
  78133. clone(name: string): GridMaterial;
  78134. serialize(): any;
  78135. getClassName(): string;
  78136. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78137. }
  78138. }
  78139. declare module BABYLON {
  78140. /** @hidden */
  78141. export var lavaPixelShader: {
  78142. name: string;
  78143. shader: string;
  78144. };
  78145. }
  78146. declare module BABYLON {
  78147. /** @hidden */
  78148. export var lavaVertexShader: {
  78149. name: string;
  78150. shader: string;
  78151. };
  78152. }
  78153. declare module BABYLON {
  78154. export class LavaMaterial extends BABYLON.PushMaterial {
  78155. private _diffuseTexture;
  78156. diffuseTexture: BABYLON.BaseTexture;
  78157. noiseTexture: BABYLON.BaseTexture;
  78158. fogColor: BABYLON.Color3;
  78159. speed: number;
  78160. movingSpeed: number;
  78161. lowFrequencySpeed: number;
  78162. fogDensity: number;
  78163. private _lastTime;
  78164. diffuseColor: BABYLON.Color3;
  78165. private _disableLighting;
  78166. disableLighting: boolean;
  78167. private _unlit;
  78168. unlit: boolean;
  78169. private _maxSimultaneousLights;
  78170. maxSimultaneousLights: number;
  78171. private _scaledDiffuse;
  78172. private _renderId;
  78173. constructor(name: string, scene: BABYLON.Scene);
  78174. needAlphaBlending(): boolean;
  78175. needAlphaTesting(): boolean;
  78176. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78177. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78178. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78179. getAnimatables(): BABYLON.IAnimatable[];
  78180. getActiveTextures(): BABYLON.BaseTexture[];
  78181. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78182. dispose(forceDisposeEffect?: boolean): void;
  78183. clone(name: string): LavaMaterial;
  78184. serialize(): any;
  78185. getClassName(): string;
  78186. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78187. }
  78188. }
  78189. declare module BABYLON {
  78190. /** @hidden */
  78191. export var mixPixelShader: {
  78192. name: string;
  78193. shader: string;
  78194. };
  78195. }
  78196. declare module BABYLON {
  78197. /** @hidden */
  78198. export var mixVertexShader: {
  78199. name: string;
  78200. shader: string;
  78201. };
  78202. }
  78203. declare module BABYLON {
  78204. export class MixMaterial extends BABYLON.PushMaterial {
  78205. /**
  78206. * Mix textures
  78207. */
  78208. private _mixTexture1;
  78209. mixTexture1: BABYLON.BaseTexture;
  78210. private _mixTexture2;
  78211. mixTexture2: BABYLON.BaseTexture;
  78212. /**
  78213. * Diffuse textures
  78214. */
  78215. private _diffuseTexture1;
  78216. diffuseTexture1: BABYLON.Texture;
  78217. private _diffuseTexture2;
  78218. diffuseTexture2: BABYLON.Texture;
  78219. private _diffuseTexture3;
  78220. diffuseTexture3: BABYLON.Texture;
  78221. private _diffuseTexture4;
  78222. diffuseTexture4: BABYLON.Texture;
  78223. private _diffuseTexture5;
  78224. diffuseTexture5: BABYLON.Texture;
  78225. private _diffuseTexture6;
  78226. diffuseTexture6: BABYLON.Texture;
  78227. private _diffuseTexture7;
  78228. diffuseTexture7: BABYLON.Texture;
  78229. private _diffuseTexture8;
  78230. diffuseTexture8: BABYLON.Texture;
  78231. /**
  78232. * Uniforms
  78233. */
  78234. diffuseColor: BABYLON.Color3;
  78235. specularColor: BABYLON.Color3;
  78236. specularPower: number;
  78237. private _disableLighting;
  78238. disableLighting: boolean;
  78239. private _maxSimultaneousLights;
  78240. maxSimultaneousLights: number;
  78241. private _renderId;
  78242. constructor(name: string, scene: BABYLON.Scene);
  78243. needAlphaBlending(): boolean;
  78244. needAlphaTesting(): boolean;
  78245. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78246. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78247. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78248. getAnimatables(): BABYLON.IAnimatable[];
  78249. getActiveTextures(): BABYLON.BaseTexture[];
  78250. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78251. dispose(forceDisposeEffect?: boolean): void;
  78252. clone(name: string): MixMaterial;
  78253. serialize(): any;
  78254. getClassName(): string;
  78255. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78256. }
  78257. }
  78258. declare module BABYLON {
  78259. /** @hidden */
  78260. export var normalPixelShader: {
  78261. name: string;
  78262. shader: string;
  78263. };
  78264. }
  78265. declare module BABYLON {
  78266. /** @hidden */
  78267. export var normalVertexShader: {
  78268. name: string;
  78269. shader: string;
  78270. };
  78271. }
  78272. declare module BABYLON {
  78273. export class NormalMaterial extends BABYLON.PushMaterial {
  78274. private _diffuseTexture;
  78275. diffuseTexture: BABYLON.BaseTexture;
  78276. diffuseColor: BABYLON.Color3;
  78277. private _disableLighting;
  78278. disableLighting: boolean;
  78279. private _maxSimultaneousLights;
  78280. maxSimultaneousLights: number;
  78281. private _renderId;
  78282. constructor(name: string, scene: BABYLON.Scene);
  78283. needAlphaBlending(): boolean;
  78284. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78285. needAlphaTesting(): boolean;
  78286. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78287. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78288. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78289. getAnimatables(): BABYLON.IAnimatable[];
  78290. getActiveTextures(): BABYLON.BaseTexture[];
  78291. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78292. dispose(forceDisposeEffect?: boolean): void;
  78293. clone(name: string): NormalMaterial;
  78294. serialize(): any;
  78295. getClassName(): string;
  78296. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78297. }
  78298. }
  78299. declare module BABYLON {
  78300. /** @hidden */
  78301. export var shadowOnlyPixelShader: {
  78302. name: string;
  78303. shader: string;
  78304. };
  78305. }
  78306. declare module BABYLON {
  78307. /** @hidden */
  78308. export var shadowOnlyVertexShader: {
  78309. name: string;
  78310. shader: string;
  78311. };
  78312. }
  78313. declare module BABYLON {
  78314. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78315. private _renderId;
  78316. private _activeLight;
  78317. constructor(name: string, scene: BABYLON.Scene);
  78318. shadowColor: BABYLON.Color3;
  78319. needAlphaBlending(): boolean;
  78320. needAlphaTesting(): boolean;
  78321. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78322. get activeLight(): BABYLON.IShadowLight;
  78323. set activeLight(light: BABYLON.IShadowLight);
  78324. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78325. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78326. clone(name: string): ShadowOnlyMaterial;
  78327. serialize(): any;
  78328. getClassName(): string;
  78329. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78330. }
  78331. }
  78332. declare module BABYLON {
  78333. /** @hidden */
  78334. export var simplePixelShader: {
  78335. name: string;
  78336. shader: string;
  78337. };
  78338. }
  78339. declare module BABYLON {
  78340. /** @hidden */
  78341. export var simpleVertexShader: {
  78342. name: string;
  78343. shader: string;
  78344. };
  78345. }
  78346. declare module BABYLON {
  78347. export class SimpleMaterial extends BABYLON.PushMaterial {
  78348. private _diffuseTexture;
  78349. diffuseTexture: BABYLON.BaseTexture;
  78350. diffuseColor: BABYLON.Color3;
  78351. private _disableLighting;
  78352. disableLighting: boolean;
  78353. private _maxSimultaneousLights;
  78354. maxSimultaneousLights: number;
  78355. private _renderId;
  78356. constructor(name: string, scene: BABYLON.Scene);
  78357. needAlphaBlending(): boolean;
  78358. needAlphaTesting(): boolean;
  78359. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78360. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78361. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78362. getAnimatables(): BABYLON.IAnimatable[];
  78363. getActiveTextures(): BABYLON.BaseTexture[];
  78364. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78365. dispose(forceDisposeEffect?: boolean): void;
  78366. clone(name: string): SimpleMaterial;
  78367. serialize(): any;
  78368. getClassName(): string;
  78369. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78370. }
  78371. }
  78372. declare module BABYLON {
  78373. /** @hidden */
  78374. export var skyPixelShader: {
  78375. name: string;
  78376. shader: string;
  78377. };
  78378. }
  78379. declare module BABYLON {
  78380. /** @hidden */
  78381. export var skyVertexShader: {
  78382. name: string;
  78383. shader: string;
  78384. };
  78385. }
  78386. declare module BABYLON {
  78387. /**
  78388. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  78389. * @see https://doc.babylonjs.com/extensions/sky
  78390. */
  78391. export class SkyMaterial extends BABYLON.PushMaterial {
  78392. /**
  78393. * Defines the overall luminance of sky in interval ]0, 1[.
  78394. */
  78395. luminance: number;
  78396. /**
  78397. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  78398. */
  78399. turbidity: number;
  78400. /**
  78401. * Defines the sky appearance (light intensity).
  78402. */
  78403. rayleigh: number;
  78404. /**
  78405. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  78406. */
  78407. mieCoefficient: number;
  78408. /**
  78409. * Defines the amount of haze particles following the Mie scattering theory.
  78410. */
  78411. mieDirectionalG: number;
  78412. /**
  78413. * Defines the distance of the sun according to the active scene camera.
  78414. */
  78415. distance: number;
  78416. /**
  78417. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  78418. * "inclined".
  78419. */
  78420. inclination: number;
  78421. /**
  78422. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  78423. * an object direction and a reference direction.
  78424. */
  78425. azimuth: number;
  78426. /**
  78427. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  78428. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  78429. */
  78430. sunPosition: BABYLON.Vector3;
  78431. /**
  78432. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  78433. * .sunPosition property.
  78434. */
  78435. useSunPosition: boolean;
  78436. /**
  78437. * Defines an offset vector used to get a horizon offset.
  78438. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  78439. */
  78440. cameraOffset: BABYLON.Vector3;
  78441. private _cameraPosition;
  78442. private _renderId;
  78443. /**
  78444. * Instantiates a new sky material.
  78445. * This material allows to create dynamic and texture free
  78446. * effects for skyboxes by taking care of the atmosphere state.
  78447. * @see https://doc.babylonjs.com/extensions/sky
  78448. * @param name Define the name of the material in the scene
  78449. * @param scene Define the scene the material belong to
  78450. */
  78451. constructor(name: string, scene: BABYLON.Scene);
  78452. /**
  78453. * Specifies if the material will require alpha blending
  78454. * @returns a boolean specifying if alpha blending is needed
  78455. */
  78456. needAlphaBlending(): boolean;
  78457. /**
  78458. * Specifies if this material should be rendered in alpha test mode
  78459. * @returns false as the sky material doesn't need alpha testing.
  78460. */
  78461. needAlphaTesting(): boolean;
  78462. /**
  78463. * Get the texture used for alpha test purpose.
  78464. * @returns null as the sky material has no texture.
  78465. */
  78466. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78467. /**
  78468. * Get if the submesh is ready to be used and all its information available.
  78469. * Child classes can use it to update shaders
  78470. * @param mesh defines the mesh to check
  78471. * @param subMesh defines which submesh to check
  78472. * @param useInstances specifies that instances should be used
  78473. * @returns a boolean indicating that the submesh is ready or not
  78474. */
  78475. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78476. /**
  78477. * Binds the submesh to this material by preparing the effect and shader to draw
  78478. * @param world defines the world transformation matrix
  78479. * @param mesh defines the mesh containing the submesh
  78480. * @param subMesh defines the submesh to bind the material to
  78481. */
  78482. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78483. /**
  78484. * Get the list of animatables in the material.
  78485. * @returns the list of animatables object used in the material
  78486. */
  78487. getAnimatables(): BABYLON.IAnimatable[];
  78488. /**
  78489. * Disposes the material
  78490. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78491. */
  78492. dispose(forceDisposeEffect?: boolean): void;
  78493. /**
  78494. * Makes a duplicate of the material, and gives it a new name
  78495. * @param name defines the new name for the duplicated material
  78496. * @returns the cloned material
  78497. */
  78498. clone(name: string): SkyMaterial;
  78499. /**
  78500. * Serializes this material in a JSON representation
  78501. * @returns the serialized material object
  78502. */
  78503. serialize(): any;
  78504. /**
  78505. * Gets the current class name of the material e.g. "SkyMaterial"
  78506. * Mainly use in serialization.
  78507. * @returns the class name
  78508. */
  78509. getClassName(): string;
  78510. /**
  78511. * Creates a sky material from parsed material data
  78512. * @param source defines the JSON representation of the material
  78513. * @param scene defines the hosting scene
  78514. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  78515. * @returns a new sky material
  78516. */
  78517. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  78518. }
  78519. }
  78520. declare module BABYLON {
  78521. /** @hidden */
  78522. export var terrainPixelShader: {
  78523. name: string;
  78524. shader: string;
  78525. };
  78526. }
  78527. declare module BABYLON {
  78528. /** @hidden */
  78529. export var terrainVertexShader: {
  78530. name: string;
  78531. shader: string;
  78532. };
  78533. }
  78534. declare module BABYLON {
  78535. export class TerrainMaterial extends BABYLON.PushMaterial {
  78536. private _mixTexture;
  78537. mixTexture: BABYLON.BaseTexture;
  78538. private _diffuseTexture1;
  78539. diffuseTexture1: BABYLON.Texture;
  78540. private _diffuseTexture2;
  78541. diffuseTexture2: BABYLON.Texture;
  78542. private _diffuseTexture3;
  78543. diffuseTexture3: BABYLON.Texture;
  78544. private _bumpTexture1;
  78545. bumpTexture1: BABYLON.Texture;
  78546. private _bumpTexture2;
  78547. bumpTexture2: BABYLON.Texture;
  78548. private _bumpTexture3;
  78549. bumpTexture3: BABYLON.Texture;
  78550. diffuseColor: BABYLON.Color3;
  78551. specularColor: BABYLON.Color3;
  78552. specularPower: number;
  78553. private _disableLighting;
  78554. disableLighting: boolean;
  78555. private _maxSimultaneousLights;
  78556. maxSimultaneousLights: number;
  78557. private _renderId;
  78558. constructor(name: string, scene: BABYLON.Scene);
  78559. needAlphaBlending(): boolean;
  78560. needAlphaTesting(): boolean;
  78561. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78564. getAnimatables(): BABYLON.IAnimatable[];
  78565. getActiveTextures(): BABYLON.BaseTexture[];
  78566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78567. dispose(forceDisposeEffect?: boolean): void;
  78568. clone(name: string): TerrainMaterial;
  78569. serialize(): any;
  78570. getClassName(): string;
  78571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  78572. }
  78573. }
  78574. declare module BABYLON {
  78575. /** @hidden */
  78576. export var triplanarPixelShader: {
  78577. name: string;
  78578. shader: string;
  78579. };
  78580. }
  78581. declare module BABYLON {
  78582. /** @hidden */
  78583. export var triplanarVertexShader: {
  78584. name: string;
  78585. shader: string;
  78586. };
  78587. }
  78588. declare module BABYLON {
  78589. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  78590. mixTexture: BABYLON.BaseTexture;
  78591. private _diffuseTextureX;
  78592. diffuseTextureX: BABYLON.BaseTexture;
  78593. private _diffuseTextureY;
  78594. diffuseTextureY: BABYLON.BaseTexture;
  78595. private _diffuseTextureZ;
  78596. diffuseTextureZ: BABYLON.BaseTexture;
  78597. private _normalTextureX;
  78598. normalTextureX: BABYLON.BaseTexture;
  78599. private _normalTextureY;
  78600. normalTextureY: BABYLON.BaseTexture;
  78601. private _normalTextureZ;
  78602. normalTextureZ: BABYLON.BaseTexture;
  78603. tileSize: number;
  78604. diffuseColor: BABYLON.Color3;
  78605. specularColor: BABYLON.Color3;
  78606. specularPower: number;
  78607. private _disableLighting;
  78608. disableLighting: boolean;
  78609. private _maxSimultaneousLights;
  78610. maxSimultaneousLights: number;
  78611. private _renderId;
  78612. constructor(name: string, scene: BABYLON.Scene);
  78613. needAlphaBlending(): boolean;
  78614. needAlphaTesting(): boolean;
  78615. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78616. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78617. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78618. getAnimatables(): BABYLON.IAnimatable[];
  78619. getActiveTextures(): BABYLON.BaseTexture[];
  78620. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78621. dispose(forceDisposeEffect?: boolean): void;
  78622. clone(name: string): TriPlanarMaterial;
  78623. serialize(): any;
  78624. getClassName(): string;
  78625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  78626. }
  78627. }
  78628. declare module BABYLON {
  78629. /** @hidden */
  78630. export var waterPixelShader: {
  78631. name: string;
  78632. shader: string;
  78633. };
  78634. }
  78635. declare module BABYLON {
  78636. /** @hidden */
  78637. export var waterVertexShader: {
  78638. name: string;
  78639. shader: string;
  78640. };
  78641. }
  78642. declare module BABYLON {
  78643. export class WaterMaterial extends BABYLON.PushMaterial {
  78644. renderTargetSize: BABYLON.Vector2;
  78645. private _bumpTexture;
  78646. bumpTexture: BABYLON.BaseTexture;
  78647. diffuseColor: BABYLON.Color3;
  78648. specularColor: BABYLON.Color3;
  78649. specularPower: number;
  78650. private _disableLighting;
  78651. disableLighting: boolean;
  78652. private _maxSimultaneousLights;
  78653. maxSimultaneousLights: number;
  78654. /**
  78655. * @param {number}: Represents the wind force
  78656. */
  78657. windForce: number;
  78658. /**
  78659. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  78660. */
  78661. windDirection: BABYLON.Vector2;
  78662. /**
  78663. * @param {number}: Wave height, represents the height of the waves
  78664. */
  78665. waveHeight: number;
  78666. /**
  78667. * @param {number}: Bump height, represents the bump height related to the bump map
  78668. */
  78669. bumpHeight: number;
  78670. /**
  78671. * @param {boolean}: Add a smaller moving bump to less steady waves.
  78672. */
  78673. private _bumpSuperimpose;
  78674. bumpSuperimpose: boolean;
  78675. /**
  78676. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  78677. */
  78678. private _fresnelSeparate;
  78679. fresnelSeparate: boolean;
  78680. /**
  78681. * @param {boolean}: bump Waves modify the reflection.
  78682. */
  78683. private _bumpAffectsReflection;
  78684. bumpAffectsReflection: boolean;
  78685. /**
  78686. * @param {number}: The water color blended with the refraction (near)
  78687. */
  78688. waterColor: BABYLON.Color3;
  78689. /**
  78690. * @param {number}: The blend factor related to the water color
  78691. */
  78692. colorBlendFactor: number;
  78693. /**
  78694. * @param {number}: The water color blended with the reflection (far)
  78695. */
  78696. waterColor2: BABYLON.Color3;
  78697. /**
  78698. * @param {number}: The blend factor related to the water color (reflection, far)
  78699. */
  78700. colorBlendFactor2: number;
  78701. /**
  78702. * @param {number}: Represents the maximum length of a wave
  78703. */
  78704. waveLength: number;
  78705. /**
  78706. * @param {number}: Defines the waves speed
  78707. */
  78708. waveSpeed: number;
  78709. /**
  78710. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  78711. * will avoid calculating useless pixels in the pixel shader of the water material.
  78712. */
  78713. disableClipPlane: boolean;
  78714. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  78715. private _mesh;
  78716. private _refractionRTT;
  78717. private _reflectionRTT;
  78718. private _reflectionTransform;
  78719. private _lastTime;
  78720. private _lastDeltaTime;
  78721. private _renderId;
  78722. private _useLogarithmicDepth;
  78723. private _waitingRenderList;
  78724. private _imageProcessingConfiguration;
  78725. private _imageProcessingObserver;
  78726. /**
  78727. * Gets a boolean indicating that current material needs to register RTT
  78728. */
  78729. get hasRenderTargetTextures(): boolean;
  78730. /**
  78731. * Constructor
  78732. */
  78733. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  78734. get useLogarithmicDepth(): boolean;
  78735. set useLogarithmicDepth(value: boolean);
  78736. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78737. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78738. addToRenderList(node: any): void;
  78739. enableRenderTargets(enable: boolean): void;
  78740. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  78741. get renderTargetsEnabled(): boolean;
  78742. needAlphaBlending(): boolean;
  78743. needAlphaTesting(): boolean;
  78744. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78745. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78746. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78747. private _createRenderTargets;
  78748. getAnimatables(): BABYLON.IAnimatable[];
  78749. getActiveTextures(): BABYLON.BaseTexture[];
  78750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78751. dispose(forceDisposeEffect?: boolean): void;
  78752. clone(name: string): WaterMaterial;
  78753. serialize(): any;
  78754. getClassName(): string;
  78755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  78756. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  78757. }
  78758. }
  78759. declare module BABYLON {
  78760. /** @hidden */
  78761. export var asciiartPixelShader: {
  78762. name: string;
  78763. shader: string;
  78764. };
  78765. }
  78766. declare module BABYLON {
  78767. /**
  78768. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  78769. *
  78770. * It basically takes care rendering the font front the given font size to a texture.
  78771. * This is used later on in the postprocess.
  78772. */
  78773. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  78774. private _font;
  78775. private _text;
  78776. private _charSize;
  78777. /**
  78778. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78779. */
  78780. get charSize(): number;
  78781. /**
  78782. * Create a new instance of the Ascii Art FontTexture class
  78783. * @param name the name of the texture
  78784. * @param font the font to use, use the W3C CSS notation
  78785. * @param text the caracter set to use in the rendering.
  78786. * @param scene the scene that owns the texture
  78787. */
  78788. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78789. /**
  78790. * Gets the max char width of a font.
  78791. * @param font the font to use, use the W3C CSS notation
  78792. * @return the max char width
  78793. */
  78794. private getFontWidth;
  78795. /**
  78796. * Gets the max char height of a font.
  78797. * @param font the font to use, use the W3C CSS notation
  78798. * @return the max char height
  78799. */
  78800. private getFontHeight;
  78801. /**
  78802. * Clones the current AsciiArtTexture.
  78803. * @return the clone of the texture.
  78804. */
  78805. clone(): AsciiArtFontTexture;
  78806. /**
  78807. * Parses a json object representing the texture and returns an instance of it.
  78808. * @param source the source JSON representation
  78809. * @param scene the scene to create the texture for
  78810. * @return the parsed texture
  78811. */
  78812. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  78813. }
  78814. /**
  78815. * Option available in the Ascii Art Post Process.
  78816. */
  78817. export interface IAsciiArtPostProcessOptions {
  78818. /**
  78819. * The font to use following the w3c font definition.
  78820. */
  78821. font?: string;
  78822. /**
  78823. * The character set to use in the postprocess.
  78824. */
  78825. characterSet?: string;
  78826. /**
  78827. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78828. * This number is defined between 0 and 1;
  78829. */
  78830. mixToTile?: number;
  78831. /**
  78832. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78833. * This number is defined between 0 and 1;
  78834. */
  78835. mixToNormal?: number;
  78836. }
  78837. /**
  78838. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  78839. *
  78840. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78841. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  78842. */
  78843. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  78844. /**
  78845. * The font texture used to render the char in the post process.
  78846. */
  78847. private _asciiArtFontTexture;
  78848. /**
  78849. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78850. * This number is defined between 0 and 1;
  78851. */
  78852. mixToTile: number;
  78853. /**
  78854. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78855. * This number is defined between 0 and 1;
  78856. */
  78857. mixToNormal: number;
  78858. /**
  78859. * Instantiates a new Ascii Art Post Process.
  78860. * @param name the name to give to the postprocess
  78861. * @camera the camera to apply the post process to.
  78862. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  78863. */
  78864. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  78865. }
  78866. }
  78867. declare module BABYLON {
  78868. /** @hidden */
  78869. export var digitalrainPixelShader: {
  78870. name: string;
  78871. shader: string;
  78872. };
  78873. }
  78874. declare module BABYLON {
  78875. /**
  78876. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  78877. *
  78878. * It basically takes care rendering the font front the given font size to a texture.
  78879. * This is used later on in the postprocess.
  78880. */
  78881. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  78882. private _font;
  78883. private _text;
  78884. private _charSize;
  78885. /**
  78886. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78887. */
  78888. get charSize(): number;
  78889. /**
  78890. * Create a new instance of the Digital Rain FontTexture class
  78891. * @param name the name of the texture
  78892. * @param font the font to use, use the W3C CSS notation
  78893. * @param text the caracter set to use in the rendering.
  78894. * @param scene the scene that owns the texture
  78895. */
  78896. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78897. /**
  78898. * Gets the max char width of a font.
  78899. * @param font the font to use, use the W3C CSS notation
  78900. * @return the max char width
  78901. */
  78902. private getFontWidth;
  78903. /**
  78904. * Gets the max char height of a font.
  78905. * @param font the font to use, use the W3C CSS notation
  78906. * @return the max char height
  78907. */
  78908. private getFontHeight;
  78909. /**
  78910. * Clones the current DigitalRainFontTexture.
  78911. * @return the clone of the texture.
  78912. */
  78913. clone(): DigitalRainFontTexture;
  78914. /**
  78915. * Parses a json object representing the texture and returns an instance of it.
  78916. * @param source the source JSON representation
  78917. * @param scene the scene to create the texture for
  78918. * @return the parsed texture
  78919. */
  78920. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  78921. }
  78922. /**
  78923. * Option available in the Digital Rain Post Process.
  78924. */
  78925. export interface IDigitalRainPostProcessOptions {
  78926. /**
  78927. * The font to use following the w3c font definition.
  78928. */
  78929. font?: string;
  78930. /**
  78931. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78932. * This number is defined between 0 and 1;
  78933. */
  78934. mixToTile?: number;
  78935. /**
  78936. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78937. * This number is defined between 0 and 1;
  78938. */
  78939. mixToNormal?: number;
  78940. }
  78941. /**
  78942. * DigitalRainPostProcess helps rendering everithing in digital rain.
  78943. *
  78944. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78945. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  78946. */
  78947. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  78948. /**
  78949. * The font texture used to render the char in the post process.
  78950. */
  78951. private _digitalRainFontTexture;
  78952. /**
  78953. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78954. * This number is defined between 0 and 1;
  78955. */
  78956. mixToTile: number;
  78957. /**
  78958. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78959. * This number is defined between 0 and 1;
  78960. */
  78961. mixToNormal: number;
  78962. /**
  78963. * Instantiates a new Digital Rain Post Process.
  78964. * @param name the name to give to the postprocess
  78965. * @camera the camera to apply the post process to.
  78966. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  78967. */
  78968. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  78969. }
  78970. }
  78971. declare module BABYLON {
  78972. /** @hidden */
  78973. export var oceanPostProcessPixelShader: {
  78974. name: string;
  78975. shader: string;
  78976. };
  78977. }
  78978. declare module BABYLON {
  78979. /**
  78980. * Option available in the Ocean Post Process.
  78981. */
  78982. export interface IOceanPostProcessOptions {
  78983. /**
  78984. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  78985. */
  78986. reflectionSize?: number | {
  78987. width: number;
  78988. height: number;
  78989. } | {
  78990. ratio: number;
  78991. };
  78992. /**
  78993. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  78994. */
  78995. refractionSize?: number | {
  78996. width: number;
  78997. height: number;
  78998. } | {
  78999. ratio: number;
  79000. };
  79001. }
  79002. /**
  79003. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  79004. *
  79005. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79006. * Example usage:
  79007. * var pp = new OceanPostProcess("myOcean", camera);
  79008. * pp.reflectionEnabled = true;
  79009. * pp.refractionEnabled = true;
  79010. */
  79011. export class OceanPostProcess extends BABYLON.PostProcess {
  79012. /**
  79013. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  79014. */
  79015. get reflectionEnabled(): boolean;
  79016. /**
  79017. * Sets weither or not the real-time reflection is enabled on the ocean.
  79018. * Is set to true, the reflection mirror texture will be used as reflection texture.
  79019. */
  79020. set reflectionEnabled(enabled: boolean);
  79021. /**
  79022. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  79023. */
  79024. get refractionEnabled(): boolean;
  79025. /**
  79026. * Sets weither or not the real-time refraction is enabled on the ocean.
  79027. * Is set to true, the refraction render target texture will be used as refraction texture.
  79028. */
  79029. set refractionEnabled(enabled: boolean);
  79030. /**
  79031. * Gets wether or not the post-processes is supported by the running hardware.
  79032. * This requires draw buffer supports.
  79033. */
  79034. get isSupported(): boolean;
  79035. /**
  79036. * This is the reflection mirror texture used to display reflections on the ocean.
  79037. * By default, render list is empty.
  79038. */
  79039. reflectionTexture: BABYLON.MirrorTexture;
  79040. /**
  79041. * This is the refraction render target texture used to display refraction on the ocean.
  79042. * By default, render list is empty.
  79043. */
  79044. refractionTexture: BABYLON.RenderTargetTexture;
  79045. private _time;
  79046. private _cameraRotation;
  79047. private _cameraViewMatrix;
  79048. private _reflectionEnabled;
  79049. private _refractionEnabled;
  79050. private _geometryRenderer;
  79051. /**
  79052. * Instantiates a new Ocean Post Process.
  79053. * @param name the name to give to the postprocess.
  79054. * @camera the camera to apply the post process to.
  79055. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  79056. */
  79057. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  79058. /**
  79059. * Returns the appropriate defines according to the current configuration.
  79060. */
  79061. private _getDefines;
  79062. /**
  79063. * Computes the current camera rotation as the shader requires a camera rotation.
  79064. */
  79065. private _computeCameraRotation;
  79066. }
  79067. }
  79068. declare module BABYLON {
  79069. /** @hidden */
  79070. export var brickProceduralTexturePixelShader: {
  79071. name: string;
  79072. shader: string;
  79073. };
  79074. }
  79075. declare module BABYLON {
  79076. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79077. private _numberOfBricksHeight;
  79078. private _numberOfBricksWidth;
  79079. private _jointColor;
  79080. private _brickColor;
  79081. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79082. updateShaderUniforms(): void;
  79083. get numberOfBricksHeight(): number;
  79084. set numberOfBricksHeight(value: number);
  79085. get numberOfBricksWidth(): number;
  79086. set numberOfBricksWidth(value: number);
  79087. get jointColor(): BABYLON.Color3;
  79088. set jointColor(value: BABYLON.Color3);
  79089. get brickColor(): BABYLON.Color3;
  79090. set brickColor(value: BABYLON.Color3);
  79091. /**
  79092. * Serializes this brick procedural texture
  79093. * @returns a serialized brick procedural texture object
  79094. */
  79095. serialize(): any;
  79096. /**
  79097. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79098. * @param parsedTexture defines parsed texture data
  79099. * @param scene defines the current scene
  79100. * @param rootUrl defines the root URL containing brick procedural texture information
  79101. * @returns a parsed Brick Procedural BABYLON.Texture
  79102. */
  79103. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79104. }
  79105. }
  79106. declare module BABYLON {
  79107. /** @hidden */
  79108. export var cloudProceduralTexturePixelShader: {
  79109. name: string;
  79110. shader: string;
  79111. };
  79112. }
  79113. declare module BABYLON {
  79114. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79115. private _skyColor;
  79116. private _cloudColor;
  79117. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79118. updateShaderUniforms(): void;
  79119. get skyColor(): BABYLON.Color4;
  79120. set skyColor(value: BABYLON.Color4);
  79121. get cloudColor(): BABYLON.Color4;
  79122. set cloudColor(value: BABYLON.Color4);
  79123. /**
  79124. * Serializes this cloud procedural texture
  79125. * @returns a serialized cloud procedural texture object
  79126. */
  79127. serialize(): any;
  79128. /**
  79129. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79130. * @param parsedTexture defines parsed texture data
  79131. * @param scene defines the current scene
  79132. * @param rootUrl defines the root URL containing cloud procedural texture information
  79133. * @returns a parsed Cloud Procedural BABYLON.Texture
  79134. */
  79135. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79136. }
  79137. }
  79138. declare module BABYLON {
  79139. /** @hidden */
  79140. export var fireProceduralTexturePixelShader: {
  79141. name: string;
  79142. shader: string;
  79143. };
  79144. }
  79145. declare module BABYLON {
  79146. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79147. private _time;
  79148. private _speed;
  79149. private _autoGenerateTime;
  79150. private _fireColors;
  79151. private _alphaThreshold;
  79152. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79153. updateShaderUniforms(): void;
  79154. render(useCameraPostProcess?: boolean): void;
  79155. static get PurpleFireColors(): BABYLON.Color3[];
  79156. static get GreenFireColors(): BABYLON.Color3[];
  79157. static get RedFireColors(): BABYLON.Color3[];
  79158. static get BlueFireColors(): BABYLON.Color3[];
  79159. get autoGenerateTime(): boolean;
  79160. set autoGenerateTime(value: boolean);
  79161. get fireColors(): BABYLON.Color3[];
  79162. set fireColors(value: BABYLON.Color3[]);
  79163. get time(): number;
  79164. set time(value: number);
  79165. get speed(): BABYLON.Vector2;
  79166. set speed(value: BABYLON.Vector2);
  79167. get alphaThreshold(): number;
  79168. set alphaThreshold(value: number);
  79169. /**
  79170. * Serializes this fire procedural texture
  79171. * @returns a serialized fire procedural texture object
  79172. */
  79173. serialize(): any;
  79174. /**
  79175. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79176. * @param parsedTexture defines parsed texture data
  79177. * @param scene defines the current scene
  79178. * @param rootUrl defines the root URL containing fire procedural texture information
  79179. * @returns a parsed Fire Procedural BABYLON.Texture
  79180. */
  79181. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79182. }
  79183. }
  79184. declare module BABYLON {
  79185. /** @hidden */
  79186. export var grassProceduralTexturePixelShader: {
  79187. name: string;
  79188. shader: string;
  79189. };
  79190. }
  79191. declare module BABYLON {
  79192. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79193. private _grassColors;
  79194. private _groundColor;
  79195. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79196. updateShaderUniforms(): void;
  79197. get grassColors(): BABYLON.Color3[];
  79198. set grassColors(value: BABYLON.Color3[]);
  79199. get groundColor(): BABYLON.Color3;
  79200. set groundColor(value: BABYLON.Color3);
  79201. /**
  79202. * Serializes this grass procedural texture
  79203. * @returns a serialized grass procedural texture object
  79204. */
  79205. serialize(): any;
  79206. /**
  79207. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79208. * @param parsedTexture defines parsed texture data
  79209. * @param scene defines the current scene
  79210. * @param rootUrl defines the root URL containing grass procedural texture information
  79211. * @returns a parsed Grass Procedural BABYLON.Texture
  79212. */
  79213. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79214. }
  79215. }
  79216. declare module BABYLON {
  79217. /** @hidden */
  79218. export var marbleProceduralTexturePixelShader: {
  79219. name: string;
  79220. shader: string;
  79221. };
  79222. }
  79223. declare module BABYLON {
  79224. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79225. private _numberOfTilesHeight;
  79226. private _numberOfTilesWidth;
  79227. private _amplitude;
  79228. private _jointColor;
  79229. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79230. updateShaderUniforms(): void;
  79231. get numberOfTilesHeight(): number;
  79232. set numberOfTilesHeight(value: number);
  79233. get amplitude(): number;
  79234. set amplitude(value: number);
  79235. get numberOfTilesWidth(): number;
  79236. set numberOfTilesWidth(value: number);
  79237. get jointColor(): BABYLON.Color3;
  79238. set jointColor(value: BABYLON.Color3);
  79239. /**
  79240. * Serializes this marble procedural texture
  79241. * @returns a serialized marble procedural texture object
  79242. */
  79243. serialize(): any;
  79244. /**
  79245. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79246. * @param parsedTexture defines parsed texture data
  79247. * @param scene defines the current scene
  79248. * @param rootUrl defines the root URL containing marble procedural texture information
  79249. * @returns a parsed Marble Procedural BABYLON.Texture
  79250. */
  79251. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79252. }
  79253. }
  79254. declare module BABYLON {
  79255. /** @hidden */
  79256. export var normalMapProceduralTexturePixelShader: {
  79257. name: string;
  79258. shader: string;
  79259. };
  79260. }
  79261. declare module BABYLON {
  79262. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79263. private _baseTexture;
  79264. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79265. updateShaderUniforms(): void;
  79266. render(useCameraPostProcess?: boolean): void;
  79267. resize(size: any, generateMipMaps: any): void;
  79268. get baseTexture(): BABYLON.Texture;
  79269. set baseTexture(texture: BABYLON.Texture);
  79270. /**
  79271. * Serializes this normal map procedural texture
  79272. * @returns a serialized normal map procedural texture object
  79273. */
  79274. serialize(): any;
  79275. /**
  79276. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79277. * @param parsedTexture defines parsed texture data
  79278. * @param scene defines the current scene
  79279. * @param rootUrl defines the root URL containing normal map procedural texture information
  79280. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79281. */
  79282. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79283. }
  79284. }
  79285. declare module BABYLON {
  79286. /** @hidden */
  79287. export var perlinNoiseProceduralTexturePixelShader: {
  79288. name: string;
  79289. shader: string;
  79290. };
  79291. }
  79292. declare module BABYLON {
  79293. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79294. time: number;
  79295. timeScale: number;
  79296. translationSpeed: number;
  79297. private _currentTranslation;
  79298. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79299. updateShaderUniforms(): void;
  79300. render(useCameraPostProcess?: boolean): void;
  79301. resize(size: any, generateMipMaps: any): void;
  79302. /**
  79303. * Serializes this perlin noise procedural texture
  79304. * @returns a serialized perlin noise procedural texture object
  79305. */
  79306. serialize(): any;
  79307. /**
  79308. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79309. * @param parsedTexture defines parsed texture data
  79310. * @param scene defines the current scene
  79311. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79312. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79313. */
  79314. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79315. }
  79316. }
  79317. declare module BABYLON {
  79318. /** @hidden */
  79319. export var roadProceduralTexturePixelShader: {
  79320. name: string;
  79321. shader: string;
  79322. };
  79323. }
  79324. declare module BABYLON {
  79325. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79326. private _roadColor;
  79327. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79328. updateShaderUniforms(): void;
  79329. get roadColor(): BABYLON.Color3;
  79330. set roadColor(value: BABYLON.Color3);
  79331. /**
  79332. * Serializes this road procedural texture
  79333. * @returns a serialized road procedural texture object
  79334. */
  79335. serialize(): any;
  79336. /**
  79337. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79338. * @param parsedTexture defines parsed texture data
  79339. * @param scene defines the current scene
  79340. * @param rootUrl defines the root URL containing road procedural texture information
  79341. * @returns a parsed Road Procedural BABYLON.Texture
  79342. */
  79343. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79344. }
  79345. }
  79346. declare module BABYLON {
  79347. /** @hidden */
  79348. export var starfieldProceduralTexturePixelShader: {
  79349. name: string;
  79350. shader: string;
  79351. };
  79352. }
  79353. declare module BABYLON {
  79354. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79355. private _time;
  79356. private _alpha;
  79357. private _beta;
  79358. private _zoom;
  79359. private _formuparam;
  79360. private _stepsize;
  79361. private _tile;
  79362. private _brightness;
  79363. private _darkmatter;
  79364. private _distfading;
  79365. private _saturation;
  79366. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79367. updateShaderUniforms(): void;
  79368. get time(): number;
  79369. set time(value: number);
  79370. get alpha(): number;
  79371. set alpha(value: number);
  79372. get beta(): number;
  79373. set beta(value: number);
  79374. get formuparam(): number;
  79375. set formuparam(value: number);
  79376. get stepsize(): number;
  79377. set stepsize(value: number);
  79378. get zoom(): number;
  79379. set zoom(value: number);
  79380. get tile(): number;
  79381. set tile(value: number);
  79382. get brightness(): number;
  79383. set brightness(value: number);
  79384. get darkmatter(): number;
  79385. set darkmatter(value: number);
  79386. get distfading(): number;
  79387. set distfading(value: number);
  79388. get saturation(): number;
  79389. set saturation(value: number);
  79390. /**
  79391. * Serializes this starfield procedural texture
  79392. * @returns a serialized starfield procedural texture object
  79393. */
  79394. serialize(): any;
  79395. /**
  79396. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79397. * @param parsedTexture defines parsed texture data
  79398. * @param scene defines the current scene
  79399. * @param rootUrl defines the root URL containing startfield procedural texture information
  79400. * @returns a parsed Starfield Procedural BABYLON.Texture
  79401. */
  79402. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79403. }
  79404. }
  79405. declare module BABYLON {
  79406. /** @hidden */
  79407. export var woodProceduralTexturePixelShader: {
  79408. name: string;
  79409. shader: string;
  79410. };
  79411. }
  79412. declare module BABYLON {
  79413. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79414. private _ampScale;
  79415. private _woodColor;
  79416. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79417. updateShaderUniforms(): void;
  79418. get ampScale(): number;
  79419. set ampScale(value: number);
  79420. get woodColor(): BABYLON.Color3;
  79421. set woodColor(value: BABYLON.Color3);
  79422. /**
  79423. * Serializes this wood procedural texture
  79424. * @returns a serialized wood procedural texture object
  79425. */
  79426. serialize(): any;
  79427. /**
  79428. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79429. * @param parsedTexture defines parsed texture data
  79430. * @param scene defines the current scene
  79431. * @param rootUrl defines the root URL containing wood procedural texture information
  79432. * @returns a parsed Wood Procedural BABYLON.Texture
  79433. */
  79434. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79435. }
  79436. }